#include <msp/debug/demangle.h>
#include <msp/gl/matrix.h>
#include <msp/gl/meshbuilder.h>
+#include <msp/input/keys.h>
#include "graphic.h"
#include "list.h"
#include "part.h"
slider.render(renderer);
}
+bool List::key_press(unsigned key, unsigned mod)
+{
+ if(key==Input::KEY_UP && mod==MOD_CTRL)
+ move_focus(NAV_UP, false);
+ else if(key==Input::KEY_DOWN && mod==MOD_CTRL)
+ move_focus(NAV_DOWN, false);
+ else
+ return false;
+
+ return true;
+}
+
void List::button_press(int x, int y, unsigned btn)
{
if(btn==4 || btn==5)
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::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<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;
+ if(select)
+ set_selected_index(focus_index);
}
void List::set_focus_index(int i)
virtual void render_special(const Part &, GL::Renderer &) const;
public:
+ virtual bool key_press(unsigned, unsigned);
virtual void button_press(int, int, unsigned);
virtual void touch_press(int, int, unsigned);
virtual void touch_release(int, int, unsigned);
virtual void focus_in();
virtual bool navigate(Navigation);
private:
+ void move_focus(Navigation, bool);
void set_focus_index(int);
void item_autosize_changed(Item *);