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>2011-07-30 22:20:59 +0000
committerStijn Buys <ingar@osirion.org>2011-07-30 22:20:59 +0000
commit483bd5dc4e3ecafee54ff608674eb7e6361622b3 (patch)
tree2bb413e0f67fae1ce076a2c18783c7df568cbb84 /src/ui/widget.cc
parent9651df184a3fb433411fe233d9e1cfe3a1960c48 (diff)
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.
Diffstat (limited to 'src/ui/widget.cc')
-rw-r--r--src/ui/widget.cc42
1 files changed, 42 insertions, 0 deletions
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 <cassert>
+
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;