listbox: use CListHelpers

This commit is contained in:
Stefan Seyfried
2016-01-16 18:30:32 +01:00
committed by svenhoefer
parent ed7eaafbcb
commit cfeaf6fc6d
2 changed files with 8 additions and 27 deletions

View File

@@ -188,33 +188,13 @@ int CListBox::exec(CMenuTarget* parent, const std::string & /*actionKey*/)
{ {
loop = false; loop = false;
} }
else if (msg == CRCInput::RC_up || (int) msg == g_settings.key_pageup) else if (msg == CRCInput::RC_up || (int) msg == g_settings.key_pageup ||
msg == CRCInput::RC_down || (int) msg == g_settings.key_pagedown)
{ {
if(getItemCount()!=0) { if (getItemCount() != 0) {
int step = (msg == (neutrino_msg_t)g_settings.key_pageup) ? listmaxshow : 1; // browse or step 1 int new_selected = UpDownKey((int)getItemCount(), msg, listmaxshow, selected);
int new_selected = selected - step; if (new_selected >= 0)
updateSelection(new_selected);
if (new_selected < 0) {
if (selected != 0 && step != 1)
new_selected = 0;
else
new_selected = getItemCount() - 1;
}
updateSelection(new_selected);
}
}
else if (msg == CRCInput::RC_down || (int) msg == g_settings.key_pagedown)
{
if(getItemCount()!=0) {
int step = ((int) msg == g_settings.key_pagedown) ? listmaxshow : 1; // browse or step 1
int new_selected = selected + step;
if (new_selected > (int) getItemCount() - 1) {
if ((selected != getItemCount() - 1))
new_selected = getItemCount() - 1;
else
new_selected = 0;
}
updateSelection(new_selected);
} }
} }
else if (msg == (neutrino_msg_t) g_settings.key_list_start || msg == (neutrino_msg_t) g_settings.key_list_end) { else if (msg == (neutrino_msg_t) g_settings.key_list_start || msg == (neutrino_msg_t) g_settings.key_list_end) {

View File

@@ -26,12 +26,13 @@
#define __listbox__ #define __listbox__
#include "menue.h" #include "menue.h"
#include "listhelpers.h"
#include <driver/framebuffer.h> #include <driver/framebuffer.h>
#include <string> #include <string>
class CListBox : public CMenuTarget class CListBox : public CMenuTarget, public CListHelpers
{ {
protected: protected:
CFrameBuffer* frameBuffer; CFrameBuffer* frameBuffer;