diff options
author | Stijn Buys <ingar@osirion.org> | 2011-03-30 13:35:11 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2011-03-30 13:35:11 +0000 |
commit | 61a69153eec93f50acdc322a5f52406ac79fcb85 (patch) | |
tree | 505d438f6fb60c36b4fbd0802b591078e3223f51 /src/ui | |
parent | 0936e6722a8a651a85343d42fa2fb802cfc567ef (diff) |
Have ui::ListItem respect the disabled() state.
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/listitem.cc | 4 | ||||
-rw-r--r-- | src/ui/widget.cc | 22 |
2 files changed, 18 insertions, 8 deletions
diff --git a/src/ui/listitem.cc b/src/ui/listitem.cc index 8f445f1..c5cee32 100644 --- a/src/ui/listitem.cc +++ b/src/ui/listitem.cc @@ -43,7 +43,9 @@ void ListItem::draw() if (!text().size()) return; - if ( has_mouse_focus() || ((static_cast<ListView *>(parent()))->selected() == this)) { + if (disabled()) { + Paint::set_color(palette()->disabled()); + } else if (has_mouse_focus() || ((static_cast<ListView *>(parent()))->selected() == this)) { Paint::set_color(palette()->highlight()); } else { Paint::set_color(palette()->foreground()); diff --git a/src/ui/widget.cc b/src/ui/widget.cc index 37bde99..de18e6b 100644 --- a/src/ui/widget.cc +++ b/src/ui/widget.cc @@ -305,7 +305,7 @@ Widget *Widget::find_input_focus() for (Children::reverse_iterator rit = widget_children.rbegin(); rit != widget_children.rend(); ++rit) { Widget *w = (*rit); - if (w->visible() && w->widget_focus) { + if (w->visible() && w->enabled() && w->widget_focus) { Widget *f = w->find_input_focus(); if (f) return f; @@ -325,7 +325,7 @@ Widget *Widget::find_mouse_focus(const math::Vector2f & pos) // reverse-iterate children for (Children::reverse_iterator rit = widget_children.rbegin(); rit != widget_children.rend(); ++rit) { Widget *w = (*rit); - if (w->visible()) { + if (w->visible() && w->enabled()) { Widget *f = w->find_mouse_focus(pos - w->location()); if (f) return f; @@ -352,6 +352,9 @@ bool Widget::has_input_focus() const bool Widget::event_emit(Widget *sender, const Event event, void *data) // Unhandled events are sent to the parent widget { + if (disabled()) + return false; + if (on_emit(sender, event, data)) { return true; } else if (parent()) { @@ -367,12 +370,14 @@ bool Widget::event_key(const bool pressed, const int key, const unsigned int mod { bool handled = false; - if (pressed) { - handled = on_keypress(key, modifier); - } else { - handled = on_keyrelease(key, modifier); + if (enabled()) { + if (pressed) { + handled = on_keypress(key, modifier); + } else { + handled = on_keyrelease(key, modifier); + } } - + if (!handled && parent()) handled = parent()->event_key(pressed, key, modifier); @@ -381,6 +386,9 @@ bool Widget::event_key(const bool pressed, const int key, const unsigned int mod bool Widget::event_mouse(const math::Vector2f &cursor) { + if (disabled()) + return false; + math::Vector2f local_cursor = to_local_coords(cursor); bool handled = false; |