Last active
September 5, 2019 12:39
-
-
Save toomasv/6734701334ac1e9e8c8e8714167e6ed9 to your computer and use it in GitHub Desktop.
Zooming and moving different faces
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
Red [ | |
Date: 5-Sep-2019 | |
Description: {Example of zooming and moving with different faces} | |
Author: "Toomas Vooglaid" | |
Licence: "Public domain" | |
] | |
context [ | |
ofs: just-down: none | |
moving: function [face event][ | |
mx: face/draw/matrix | |
df: event/offset - ofs | |
face/draw/matrix/5: mx/5 + df/x | |
face/draw/matrix/6: mx/6 + df/y | |
self/ofs: event/offset | |
face/draw: face/draw | |
] | |
zooming: function [face event][ | |
mx: face/draw/matrix | |
ev: event/offset | |
op: get pick [/ *] 0 > event/picked | |
face/draw/matrix: reduce [ | |
sc: mx/1 op 1.1 0 0 sc | |
mx/5 - ev/x op 1.1 + ev/x | |
mx/6 - ev/y op 1.1 + ev/y | |
] | |
] | |
view/tight [ | |
title "Zoom-and-move" | |
style zoom: box 500x300 all-over | |
on-wheel [ | |
unless find face/draw "zooming" [ | |
change find face/draw string! "zooming" | |
] | |
zooming face event | |
] | |
on-down [ | |
change find face/draw string! "ready.." | |
move find face/parent/pane face tail face/parent/pane | |
ofs: event/offset | |
just-down: yes | |
] | |
on-over [ | |
either event/down? [ | |
unless find face/draw "moving" [ | |
either just-down [just-down: no][ | |
change find face/draw string! "moving" | |
] | |
] | |
moving face event | |
][ | |
unless find face/draw "waiting" [ | |
change find face/draw string! "waiting" | |
] | |
] | |
] | |
on-up [change find face/draw string! "waiting"] | |
zoom draw [ | |
matrix [1 0 0 1 0 0] | |
fill-pen linen | |
box 100x100 200x130 5 | |
text 125x105 "waiting" | |
] | |
at 0x0 zoom draw [ | |
matrix [1 0 0 1 0 0] | |
fill-pen beige | |
ellipse 10x10 120x40 | |
text 50x20 "waiting" | |
] | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment