diff options
-rw-r--r-- | src/ui/bitmap.cc | 3 | ||||
-rw-r--r-- | src/ui/listitem.cc | 7 | ||||
-rw-r--r-- | src/ui/ui.cc | 1 | ||||
-rw-r--r-- | src/ui/ui.h | 8 | ||||
-rw-r--r-- | src/ui/widget.cc | 42 | ||||
-rw-r--r-- | src/ui/widget.h | 3 | ||||
-rw-r--r-- | src/ui/window.cc | 2 |
7 files changed, 60 insertions, 6 deletions
diff --git a/src/ui/bitmap.cc b/src/ui/bitmap.cc index 5e19435..03d7166 100644 --- a/src/ui/bitmap.cc +++ b/src/ui/bitmap.cc @@ -51,8 +51,7 @@ void Bitmap::set_color(const math::Color & color) void Bitmap::draw_background() { if (bitmap_texture.size()) { - Paint::set_color(bitmap_color); - Paint::draw_bitmap(global_location(), size(), bitmap_texture); + Paint::draw_bitmap(global_location(), size(),bitmap_color, bitmap_texture); } } diff --git a/src/ui/listitem.cc b/src/ui/listitem.cc index 5e58560..dfe0c0e 100644 --- a/src/ui/listitem.cc +++ b/src/ui/listitem.cc @@ -16,6 +16,8 @@ ListItem::ListItem(ListView *parent, const char * text) : Label(parent, text) { listitem_info = 0; listitem_item = 0; + + set_alignment(ui::AlignLeft); } ListItem::~ListItem() { @@ -33,9 +35,11 @@ void ListItem::draw_border() Paint::set_color(color); Paint::draw_border(global_location(), size()); } else if ((static_cast<ListView *>(parent()))->selected() == this) { + Paint::set_color(palette()->foreground()); + } else { Paint::set_color(palette()->border()); - Paint::draw_border(global_location(), size()); } + Paint::draw_border(global_location(), size()); } void ListItem::draw() @@ -48,7 +52,6 @@ void ListItem::draw() } else if (disabled()) { Paint::set_color(palette()->disabled()); - } else { Paint::set_color(palette()->foreground()); } diff --git a/src/ui/ui.cc b/src/ui/ui.cc index 252faa6..91eacd3 100644 --- a/src/ui/ui.cc +++ b/src/ui/ui.cc @@ -77,6 +77,7 @@ UI::UI() : Window(0) set_palette(ui_palette); // default fonts + ui_font_tiny = new Font("gui", 10, 18); ui_font_small = new Font("gui", 12, 18); ui_font_large = new Font("gui", 14, 24); set_font(ui_font_small); diff --git a/src/ui/ui.h b/src/ui/ui.h index fc0ce56..855d6ee 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -76,7 +76,12 @@ public: void load_settings(); /* -- fonts ------------------------------------------------ */ - + + /// default tiny font + inline const Font *font_tiny() const { + return ui_font_tiny; + } + /// default small font inline const Font *font_small() const { return ui_font_small; @@ -117,6 +122,7 @@ private: void draw_pointer(); Palette *ui_palette; + Font *ui_font_tiny; Font *ui_font_small; Font *ui_font_large; 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; diff --git a/src/ui/widget.h b/src/ui/widget.h index bd1cba5..e98d4c5 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -280,6 +280,9 @@ protected: return widget_children; } + /// return the next sibling + Widget *next_sibling(); + /// find the widget that has input focus virtual Widget *find_input_focus(); diff --git a/src/ui/window.cc b/src/ui/window.cc index b687f21..97792bc 100644 --- a/src/ui/window.cc +++ b/src/ui/window.cc @@ -40,6 +40,7 @@ void Window::hide() { Widget::hide(); emit(EventWindowHide); + } void Window::set_previous(Window *previous) @@ -61,7 +62,6 @@ void Window::draw_border() { Paint::set_color(palette()->foreground()); Paint::draw_border(global_location(), size()); - } } |