-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from clojerl/15-looping-functions
[#15] looping functions
- Loading branch information
Showing
7 changed files
with
154 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
(ns doodler.events) | ||
|
||
(def event-names | ||
[:set_focus ;; focus-gained | ||
:kill_focus ;; focus-lost | ||
:enter_window ;; mouse-entered | ||
:leave_window ;; mouse-exited | ||
:left_down ;; mouse-pressed | ||
:middle_down ;; mouse-pressed | ||
:right_down ;; mouse-pressed | ||
:left_up ;; mouse-released | ||
:middle_up ;; mouse-released | ||
:right_up ;; mouse-released | ||
:motion ;; mouse-moved | ||
:left_dclick ;; mouse-clicked (twice) | ||
:middle_dclick ;; mouse-clicked (twice) | ||
:right_dclick ;; mouse-clicked (twice) | ||
:mousewheel ;; mouse-wheel | ||
;; Listen to all key events | ||
:key_down ;; key-pressed | ||
:key_up ;; key-released | ||
:char ;; key-typed (?) | ||
]) | ||
|
||
(defn* event-type->mouse-event | ||
([:enter_window] :mouse-entered) | ||
([:leave_window] :mouse-exited) | ||
([:left_down] :mouse-pressed) | ||
([:middle_down] :mouse-pressed) | ||
([:right_down] :mouse-pressed) | ||
([:left_up] :mouse-released) | ||
([:middle_up] :mouse-released) | ||
([:right_up] :mouse-released) | ||
([:left_dclick] :mouse-clicked) | ||
([:middle_dclick] :mouse-clicked) | ||
([:right_dclick] :mouse-clicked) | ||
([:motion] :mouse-moved) | ||
([:mousewheel] :mouse-wheel)) | ||
|
||
(defn* event-type->mouse-clicks | ||
([:left_dclick] 2) | ||
([:middle_dclick] 2) | ||
([:right_dclick] 2) | ||
([:left_up] 1) | ||
([:middle_up] 1) | ||
([:right_up] 1) | ||
([_] 0)) | ||
|
||
(defn* event-type->key-event | ||
([:key_down] :key-pressed) | ||
([:key_up] :key-released) | ||
([:char] :key-typed)) | ||
|
||
(defn* event->map | ||
([#erl[:wxClose :close_window]] | ||
#erl{:event :on-close}) | ||
|
||
([#erl[:wxSize :size size rect]] | ||
#erl{:event :on-resize | ||
:size size}) | ||
|
||
([#erl[:wxFocus :set_focus window]] | ||
#erl{:event :focus-gained | ||
:window window}) | ||
([#erl[:wxFocus :kill_focus window]] | ||
#erl{:event :focus-lost | ||
:window window}) | ||
|
||
([#erl[:wxMouse type | ||
x y | ||
left middle right | ||
control shift alt meta | ||
wheel-rotation wheel-delta lines-per-action]] | ||
#erl{:event (event-type->mouse-event type) | ||
:clicks (event-type->mouse-clicks type) | ||
:x x :y y | ||
:left left :middle middle :right right | ||
:control control :shift shift :alt alt :meta meta | ||
:wheel-rotation wheel-rotation :wheel-delta wheel-delta | ||
:lines-per-action lines-per-action}) | ||
|
||
([#erl[:wxKey type | ||
x y | ||
key-code control shift alt meta | ||
scan-code uni-char raw-code raw-flags]] | ||
#erl{:event (event-type->key-event type) | ||
:x x :y y | ||
:key-code key-code | ||
:control control :shift shift :alt alt :meta meta | ||
:scan-code scan-code :uni-char uni-char | ||
:raw-code raw-code :raw-flags raw-flags})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.