summaryrefslogtreecommitdiff
path: root/meme
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2014-09-12 01:04:28 -0300
committerWerner Almesberger <werner@almesberger.net>2014-09-12 01:04:28 -0300
commit6f5fe859d085a68d12deb5b1d4d9310dab81dd19 (patch)
tree4846b34946f12caa38f21609c9fb4a49569881a8 /meme
parent1c6b75e49abd8cb77d28935f07d25de162bd46be (diff)
downloadmisc-6f5fe859d085a68d12deb5b1d4d9310dab81dd19.tar.gz
misc-6f5fe859d085a68d12deb5b1d4d9310dab81dd19.tar.bz2
misc-6f5fe859d085a68d12deb5b1d4d9310dab81dd19.zip
meme/gui.c (button_event): move coordinate transform to separate functions
... for future sharing.
Diffstat (limited to 'meme')
-rw-r--r--meme/gui.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/meme/gui.c b/meme/gui.c
index b78a3ff..40c7432 100644
--- a/meme/gui.c
+++ b/meme/gui.c
@@ -109,12 +109,22 @@ static void draw(SDL_Surface *s)
}
-static void button_event(SDL_MouseButtonEvent *button)
+static inline int x_screen2model(int x)
{
- int x, y; /* model coordinates */
+ return ((x - (XRES >> 1)) << zoom)+x_orig;
+}
+
- x = ((button->x - (XRES >> 1)) << zoom)+x_orig;
- y = ((button->y - (YRES >> 1)) << zoom)+y_orig;
+static inline int y_screen2model(int y)
+{
+ return ((y - (YRES >> 1)) << zoom)+y_orig;
+}
+
+
+static void button_event(SDL_MouseButtonEvent *button)
+{
+ int x = x_screen2model(button->x);
+ int y = y_screen2model(button->y);
switch (button->button) {
case 4: