X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpanel.cpp;h=c97cd6d7212da9c648cbed683edf23dad4250701;hb=7286d604956ddffcbfa2df6567de866f3d5df3a2;hp=dc2808ed4bf5a237d97aad9cd1ec75e068ac7580;hpb=10c448468c4e225fab701e69bdc296422bb3f509;p=libs%2Fgltk.git diff --git a/source/panel.cpp b/source/panel.cpp index dc2808e..c97cd6d 100644 --- a/source/panel.cpp +++ b/source/panel.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include "button.h" @@ -24,6 +24,9 @@ using namespace std; namespace Msp { namespace GLtk { +DataFile::LoadableTypeRegistry Panel::widget_registry; +bool Panel::widget_registry_init_done = false; + Panel::Panel(): layout(0) { @@ -84,6 +87,9 @@ bool Panel::navigate(Navigation nav) origin_dim = abs(nav_x)*geom.h+abs(nav_y)*geom.w; } + if(pointer_grabbed && pointer_focus==input_focus) + return false; + Widget *sibling = find_next_child(origin_x, origin_y, origin_dim, nav_x, nav_y); if(!sibling && input_focus) { @@ -101,6 +107,28 @@ bool Panel::navigate(Navigation nav) return true; } } + else if(nav==NAV_NEXT || nav==NAV_PREVIOUS) + { + vector::iterator i = find(nav_order, input_focus); + + if(nav==NAV_NEXT) + { + if(i!=nav_order.end()) + ++i; + if(i==nav_order.end()) + i = nav_order.begin(); + } + else + { + if(i==nav_order.begin()) + i = nav_order.end(); + --i; + } + + set_input_focus(*i); + + return true; + } return false; } @@ -148,7 +176,7 @@ int Panel::compute_delta(int pos, int dim, int origin_pos, int origin_dim, int n return 0; } -void Panel::on_geometry_change() +void Panel::on_size_change() { if(layout) layout->update(); @@ -156,6 +184,9 @@ void Panel::on_geometry_change() void Panel::on_child_added(Widget &wdg) { + if(wdg.get_input_type()!=INPUT_NONE) + nav_order.push_back(&wdg); + if(layout) { layout->add_widget(wdg); @@ -165,6 +196,10 @@ void Panel::on_child_added(Widget &wdg) void Panel::on_child_removed(Widget &wdg) { + vector::iterator i = std::remove(nav_order.begin(), nav_order.end(), &wdg); + if(i!=nav_order.end()) + nav_order.erase(i, nav_order.end()); + if(layout) { layout->remove_widget(wdg); @@ -178,27 +213,33 @@ Panel::Loader::Loader(Panel &p, map &m): wdg_map(m), last_widget(0) { - add("button", &Loader::child