Skip to content

Commit

Permalink
Merge pull request #29 from guzba/master
Browse files Browse the repository at this point in the history
mac progress
  • Loading branch information
treeform authored Oct 30, 2021
2 parents e6c36fd + 249e785 commit 352e9a2
Show file tree
Hide file tree
Showing 9 changed files with 656 additions and 311 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ Here are a few reasons that may be worth considering:

* Windy is written in Nim so it will be more natural to use than bindings to other libraries. For example, making a window fullscreen is as easy as `window.fullscreen = true`. Consider browsing some of the examples and consider if you would find this Nim-first API more pleasant to work with.

* Windy includes events for double, triple and quadruple clicks. Furthermore, Windy maintains the keyboard and mouse state in a way that makes reacting to input state easier each frame. (See `buttonPress[]`, `buttonDown[]`, `buttonRelease[]` and `buttonToggle[]` on `Window`.)
* Windy includes events for double, triple and quadruple clicks. Furthermore, Windy maintains the keyboard and mouse state in a way that makes reacting to input state easier each frame. (See `buttonPressed[]`, `buttonDown[]`, `buttonReleased[]` and `buttonToggle[]` on `Window`.)

* Windy has IME input support for Chinese, Japanese, Korean and other languages. Text input can also be enabled or disabled at any time (for example, to avoid opening the IME editor when a user just wants to use WASD in a game).
10 changes: 3 additions & 7 deletions examples/basic.nim
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import boxy, opengl, windy
import opengl, windy

let window = newWindow("Windy Basic", ivec2(1280, 800))

window.makeContextCurrent()
loadExtensions()

let bxy = newBoxy()

proc display() =
bxy.beginFrame(window.size)
bxy.drawRect(rect(vec2(0, 0), window.size.vec2), color(1, 1, 1, 1))
bxy.drawRect(rect(vec2(100, 100), vec2(200, 200)), color(1, 0, 1, 1))
bxy.endFrame()
glClear(GL_COLOR_BUFFER_BIT)
# Your OpenGL display code here
window.swapBuffers()

while not window.closeRequested:
Expand Down
10 changes: 3 additions & 7 deletions examples/callbacks.nim
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import boxy, opengl, os, windy
import opengl, os, windy

let window = newWindow("Windy Callbacks", ivec2(1280, 800))

window.makeContextCurrent()
loadExtensions()

let bxy = newBoxy()

proc display() =
bxy.beginFrame(window.size)
bxy.drawRect(rect(vec2(0, 0), window.size.vec2), color(1, 1, 1, 1))
bxy.drawRect(rect(vec2(100, 100), vec2(200, 200)), color(1, 0, 1, 1))
bxy.endFrame()
glClear(GL_COLOR_BUFFER_BIT)
# Your OpenGL display code here
window.swapBuffers()

window.onCloseRequest = proc() =
Expand Down
5 changes: 5 additions & 0 deletions src/windy/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,8 @@ type
NumpadMultiply # *
NumpadDivide # /
NumpadEqual # =

ButtonView* = distinct set[Button]

proc `[]`*(buttonView: ButtonView, button: Button): bool =
button in (set[Button])buttonView
18 changes: 17 additions & 1 deletion src/windy/internal.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
import vmath
import common, vmath

type
State* = object
title*: string
closeRequested*, closed*: bool
mousePos*: IVec2
buttonPressed*, buttonDown*, buttonReleased*, buttonToggle*: set[Button]
perFrame*: PerFrame

doubleClickTime*: float64
tripleClickTimes*: array[2, float64]
quadrupleClickTimes*: array[3, float64]
multiClickPositions*: array[3, IVec2]

runeInputEnabled*: bool
imeCursorIndex*: int
imeCompositionString*: string

PerFrame* = object
mousePrevPos*: IVec2
mouseDelta*: IVec2
Expand Down
5 changes: 0 additions & 5 deletions src/windy/platforms/linux/x11_2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ type
onRune*: RuneCallback
onImeChange*: Callback

ButtonView* = distinct set[Button]

proc title*(window: Window): string =
discard

Expand Down Expand Up @@ -159,9 +157,6 @@ proc buttonReleased*(window: Window): ButtonView =
proc buttonToggle*(window: Window): ButtonView =
discard

proc `[]`*(buttonView: ButtonView, button: Button): bool =
discard

proc getClipboardString*(): string =
discard

Expand Down
Loading

0 comments on commit 352e9a2

Please sign in to comment.