+void List::focus_in()
+{
+ Container::focus_in();
+ if(focus_index>=0 && items[focus_index]->is_visible())
+ set_input_focus(items[focus_index]);
+ else
+ {
+ if(sel_index>=0 && items[sel_index]->is_visible())
+ set_focus_index(sel_index);
+ else if(!items.empty())
+ set_focus_index(first);
+ }
+}
+
+bool List::navigate(Navigation nav)
+{
+ if(nav==NAV_UP && !items.empty())
+ {
+ if(focus_index>0)
+ set_focus_index(focus_index-1);
+ }
+ else if(nav==NAV_DOWN && !items.empty())
+ {
+ if(static_cast<unsigned>(focus_index+1)<items.size())
+ set_focus_index(focus_index+1);
+ }
+ else if(nav==NAV_ACTIVATE)
+ set_selected_index(focus_index);
+ else
+ return false;
+
+ return true;
+}
+
+void List::set_focus_index(int i)
+{
+ focus_index = i;
+ if(focus_index>=0)
+ {
+ scroll_to_focus();
+ if(state&FOCUS)
+ set_input_focus(items[focus_index]);
+ }
+}
+
+void List::item_autosize_changed(Item *item)
+{
+ item->autosize();
+ signal_autosize_changed.emit();
+ rebuild();
+}
+
+unsigned List::last_to_first(unsigned last) const
+{
+ if(!style)
+ return last;
+
+ unsigned view_h = geom.h;
+ if(const Part *items_part = style->get_part("items"))
+ {
+ const Sides &margin = items_part->get_margin();
+ view_h -= margin.top+margin.bottom;
+ }
+
+ unsigned items_h = 0;
+ for(unsigned i=last; i<items.size(); --i)
+ {
+ items_h += items[i]->get_geometry().h;
+ if(items_h>view_h)
+ return min(i+1, last);
+ }
+
+ return 0;
+}
+
+void List::check_view_range()
+{
+ if(!style)
+ return;
+
+ if(items.empty())
+ max_scroll = 0;
+ else
+ max_scroll = last_to_first(items.size()-1);
+
+ if(first>max_scroll)
+ first = max_scroll;
+
+ slider.set_range(0, max_scroll);
+ slider.set_value(max_scroll-first);
+}
+
+void List::scroll_to_focus()
+{
+ if(focus_index<0 || items[focus_index]->is_visible())
+ return;
+
+ if(static_cast<unsigned>(focus_index)<first)
+ slider.set_value(max_scroll-focus_index);
+ else
+ slider.set_value(max_scroll-last_to_first(focus_index));
+}
+
+void List::slider_value_changed(double value)
+{
+ if(max_scroll>0 && !ignore_slider_change)
+ {
+ first = max_scroll-static_cast<unsigned>(value);
+ rebuild();
+ }
+}
+
+void List::adjust_index(int &index, int pos, int change)