]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/root.cpp
Support loading Buttons from datafiles
[libs/gltk.git] / source / root.cpp
index 83042a63f3c8a62339d40b7ae5708306fef398da..32cd87940fe22e71abcef2769f2c3b6516181005 100644 (file)
@@ -18,18 +18,27 @@ Root::Root(Resources &r, Window &w):
 
 void Root::button_press_event(int x, int y, unsigned btn, unsigned)
 {
+       translate_coords(x, y);
        button_press(x, y, btn);
 }
 
 void Root::button_release_event(int x, int y, unsigned btn, unsigned)
 {
+       translate_coords(x, y);
        button_release(x, y, btn);
 }
 
 void Root::pointer_motion_event(int x, int y)
 {
+       translate_coords(x, y);
        pointer_motion(x, y);
 }
 
+void Root::translate_coords(int &x, int &y)
+{
+       x=x*geom.w/window.get_width();
+       y=geom.h-1-y*geom.h/window.get_height();
+}
+
 } // namespace GLtk
 } // namespace Msp