]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/mouse.cpp
Add EventSource abstraction layer below Window
[libs/gui.git] / source / input / mouse.cpp
index 0fbc940f144b23537495cf99825db4b3e09fbc8b..6717427535b4190f49f3720cef2e29dcc4f6e4b1 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of libmspgbase
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2008, 2010  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
@@ -11,17 +11,17 @@ Distributed under the LGPL
 namespace Msp {
 namespace Input {
 
-Mouse::Mouse(Graphics::Window &w):
-       window(w)
+Mouse::Mouse(Graphics::EventSource &s):
+       source(s)
 {
        name="Mouse";
 
        buttons.resize(3);
        axes.resize(2);
 
-       window.signal_button_press.connect(sigc::mem_fun(this, &Mouse::button_press));
-       window.signal_button_release.connect(sigc::mem_fun(this, &Mouse::button_release));
-       window.signal_pointer_motion.connect(sigc::mem_fun(this, &Mouse::pointer_motion));
+       source.signal_button_press.connect(sigc::mem_fun(this, &Mouse::button_press));
+       source.signal_button_release.connect(sigc::mem_fun(this, &Mouse::button_release));
+       source.signal_pointer_motion.connect(sigc::mem_fun(this, &Mouse::pointer_motion));
 }
 
 std::string Mouse::get_button_name(unsigned btn) const
@@ -68,8 +68,8 @@ void Mouse::button_release(int, int, unsigned btn, unsigned)
 
 void Mouse::pointer_motion(int x, int y)
 {
-       set_axis_value(0, x*2.0f/window.get_width()-1.0f, true);
-       set_axis_value(1, 1.0f-y*2.0f/window.get_height(), true);
+       set_axis_value(0, x*2.0f/source.get_width()-1.0f, true);
+       set_axis_value(1, 1.0f-y*2.0f/source.get_height(), true);
 }
 
 } // namespace Input