Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2015-01-06 18:51:37 +0000
committerStijn Buys <ingar@osirion.org>2015-01-06 18:51:37 +0000
commit72ee43e9470c6fdbc6ed7ff92b85dfa5062c5762 (patch)
tree6474fa59066d5212dcd40e3d76652dce35565280 /src/ui/widget.cc
parent57d958d40af061e83aa99ca12e375e5345836ecd (diff)
Added separate event handlers for mouse button clicks and mouse wheel movement.
Diffstat (limited to 'src/ui/widget.cc')
-rw-r--r--src/ui/widget.cc56
1 files changed, 52 insertions, 4 deletions
diff --git a/src/ui/widget.cc b/src/ui/widget.cc
index e931147..982b792 100644
--- a/src/ui/widget.cc
+++ b/src/ui/widget.cc
@@ -438,7 +438,8 @@ bool Widget::event_key(const bool pressed, const int key, const unsigned int mod
{
bool handled = false;
- if (enabled()) {
+ if (enabled())
+ {
if (pressed) {
handled = on_keypress(key, modifier);
} else {
@@ -452,19 +453,51 @@ bool Widget::event_key(const bool pressed, const int key, const unsigned int mod
return handled;
}
-bool Widget::event_mouse(const math::Vector2f &cursor)
+void Widget::event_mouse(const math::Vector2f & cursor)
{
if (disabled())
- return false;
+ return;
math::Vector2f local_cursor = to_local_coords(cursor);
- bool handled = false;
if (root()->mouse_focus() != this) {
on_mouseover(local_cursor);
}
on_mousemove(local_cursor);
+}
+
+bool Widget::event_mouse_button(const bool pressed, const unsigned int button)
+{
+ bool handled = false;
+
+ if (enabled())
+ {
+ if (pressed) {
+ handled = on_mousepress(button);
+ } else {
+ handled = on_mouserelease(button);
+ }
+ }
+
+ if (!handled && parent())
+ handled = parent()->event_mouse_button(pressed, button);
+
+ return handled;
+}
+
+bool Widget::event_mouse_wheel(const math::Vector2f & direction)
+{
+ bool handled = false;
+
+ if (enabled())
+ {
+ handled = on_mousewheel(direction);
+ }
+
+ if (!handled && parent())
+ handled = parent()->event_mouse_wheel(direction);
+
return handled;
}
@@ -512,6 +545,21 @@ void Widget::on_mousemove(const math::Vector2f &cursor)
return;
}
+bool Widget::on_mousepress(const unsigned int button)
+{
+ return false;
+}
+
+bool Widget::on_mouserelease(const unsigned int button)
+{
+ return false;
+}
+
+bool Widget::on_mousewheel(const math::Vector2f & direction)
+{
+ return false;
+}
+
bool Widget::on_keypress(const int key, const unsigned int modifier)
{
return false;