X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flist.cpp;h=10c5af84ab100ef8591a1215b6113868657c8f60;hb=22e2888b01b7b9d0a8df568f25dbe06addd51710;hp=14c779f0f579dc236eae5049e5c4720e94760591;hpb=c2664a6da9ee4a9fc3cb1adb42442412b45c7333;p=libs%2Fgltk.git diff --git a/source/list.cpp b/source/list.cpp index 14c779f..10c5af8 100644 --- a/source/list.cpp +++ b/source/list.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -39,6 +40,7 @@ void List::init() first = 0; max_scroll = 0; view_size = 5; + ignore_slider_change = false; observer = new DataObserver(*this); @@ -116,11 +118,13 @@ void List::items_changed() List::Item *List::create_item(unsigned index) { - Item *item = 0; + Item *item = 0; if(item_factory) item = item_factory->create_item(index); else item = new BasicItem(data->get_string(index)); + if(static_cast(index)==sel_index) + item->set_active(true); add(*item); item->autosize(); item->signal_autosize_changed.connect(sigc::bind(sigc::mem_fun(this, &List::item_autosize_changed), item)); @@ -164,6 +168,9 @@ void List::rebuild_special(const Part &part) reposition_child(slider, part); else if(part.get_name()=="items") { + SetFlag flag(ignore_slider_change); + check_view_range(); + const Sides &margin = part.get_margin(); unsigned w = geom.w-min(geom.w, margin.left+margin.right); unsigned y = geom.h-min(geom.h, margin.top); @@ -190,8 +197,6 @@ void List::rebuild_special(const Part &part) } } } - - check_view_range(); } Widget::rebuild_special(part); @@ -261,7 +266,7 @@ void List::check_view_range() void List::slider_value_changed(double value) { - if(max_scroll>0) + if(max_scroll>0 && !ignore_slider_change) { first = max_scroll-static_cast(value); rebuild(); @@ -410,8 +415,8 @@ void List::MultiColumnItem::on_style_change() if(MultiColumnItem *mci = dynamic_cast(*i)) mci->set_widths(self_widths); } - else - set_widths(self_widths); + + set_widths(self_widths); }