From 483bd5dc4e3ecafee54ff608674eb7e6361622b3 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 30 Jul 2011 22:20:59 +0000 Subject: Added UI tiny font, have ui::Bitmap respect its color settings, corrected focus jumping to the next visible sibling when hiding widgets, changed ui::ListItem border appereance. --- src/ui/widget.cc | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/ui/widget.cc') diff --git a/src/ui/widget.cc b/src/ui/widget.cc index 540fd6c..9ae2f32 100644 --- a/src/ui/widget.cc +++ b/src/ui/widget.cc @@ -10,6 +10,8 @@ #include "ui/ui.h" #include "ui/widget.h" +#include + namespace ui { @@ -146,6 +148,18 @@ void Widget::show() void Widget::hide() { widget_visible = false; + + if (parent() && focus()) { + + Widget *sibling = next_sibling(); + + while (sibling && ((sibling == this) || !sibling->visible())) { + sibling = sibling->next_sibling(); + } + if (sibling) + sibling->set_focus(); + } + /* if (parent() && focus()) { Widget::Children::reverse_iterator it = parent()->children().rbegin(); @@ -160,6 +174,7 @@ void Widget::hide() } } } + */ } @@ -268,6 +283,33 @@ void Widget::set_height(const float h) widget_size[1] = h; } +Widget *Widget::next_sibling() +{ + if (!parent() || (parent()->children().size() < 2)) { + return 0; + } + + // find this widget in the parent's children + Children::iterator it = parent()->children().begin(); + while (it != parent()->children().end() && (*it) != this) { + it++; + } + + // assert this widget is a child of its parent + assert (it != parent()->children().end()); + + // next sibling + it++; + if (it == parent()->children().end()) { + it = parent()->children().begin(); + } + if ((*it) == this) { + return 0; + } else { + return (*it); + } +} + Widget::Children::iterator Widget::find_child(Widget *child) { Children::iterator it; -- cgit v1.2.3