X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flist.cpp;h=5d765008765c9ccbece8c28e77c9a62da5a4cecb;hb=9faf932be00ba7ec7ed8c81f1e7971dcfa2b2085;hp=5a9f749fd0363b974ee1bfab98c37f37264a4354;hpb=7b555d7c7bd9d3236e251039be950358bf318393;p=libs%2Fgltk.git diff --git a/source/list.cpp b/source/list.cpp index 5a9f749..5d76500 100644 --- a/source/list.cpp +++ b/source/list.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "graphic.h" #include "list.h" #include "part.h" @@ -43,6 +44,7 @@ void List::init() first = 0; max_scroll = 0; view_size = 5; + items_part = 0; ignore_slider_change = false; dragging = false; drag_start_x = 0; @@ -70,18 +72,16 @@ void List::autosize_special(const Part &part, Geometry &ageom) const const Sides &margin = part.get_margin(); unsigned max_w = 0; - unsigned total_h = 0; + unsigned max_h = 0; for(unsigned i=0; iautosize(igeom); max_w = max(max_w, igeom.w); - if(view_size==0 || i=0 && items[focus_index]->is_visible()) set_input_focus(items[focus_index]); else @@ -327,22 +340,36 @@ void List::focus_in() bool List::navigate(Navigation nav) { - if(nav==NAV_UP && !items.empty()) + if((nav==NAV_UP || nav==NAV_DOWN) && !items.empty()) + move_focus(nav, true); + else if(nav==NAV_ACTIVATE) + set_selected_index(focus_index); + else + return false; + + return true; +} + +void List::on_style_change() +{ + items_part = (style ? style->get_part("items") : 0); +} + +void List::move_focus(Navigation nav, bool select) +{ + if(nav==NAV_UP) { if(focus_index>0) set_focus_index(focus_index-1); } - else if(nav==NAV_DOWN && !items.empty()) + else if(nav==NAV_DOWN) { if(static_cast(focus_index+1)get_part("items")) - { - const Sides &margin = items_part->get_margin(); - view_h -= margin.top+margin.bottom; - } + const Sides &margin = items_part->get_margin(); + unsigned view_h = geom.h-min(geom.h, margin.top+margin.bottom); unsigned items_h = 0; for(unsigned i=last; iwidget; + child->autosize(); + if(const Part *part = style->get_part("children")) + { + const Sides &margin = part->get_margin(); + child->set_position(margin.left, margin.bottom); + } +} + + void List::MultiColumnItem::check_widths(vector &widths) const { if(widths.size()get_part("children")) - { - const Sides &margin = part->get_margin(); - label.set_position(margin.left, margin.bottom); - } -} - List::Loader::Loader(List &l): DataFile::DerivedObjectLoader(l)