+ else if(dy<0 && first>0)
+ {
+ int item_h = items[first-1]->get_geometry().h;
+ if(-dy>item_h)
+ {
+ drag_start_y -= item_h;
+ slider.set_value(max_scroll-(first-1));
+ }
+ }
+ }
+}
+
+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 || 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::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)
+ {
+ if(static_cast<unsigned>(focus_index+1)<items.size())
+ set_focus_index(focus_index+1);
+ }
+
+ if(select)
+ set_selected_index(focus_index);
+}
+
+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]);