diff options
Diffstat (limited to 'src/ui/widget.cc')
-rw-r--r-- | src/ui/widget.cc | 56 |
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; |