menue.cpp/h: modify move behavior of menu window for custom position

MENU_POS_PRESET is replaced with MENU_POS_CUSTOM. This allows
with methode setPos() to any position on screen without preset offset.
Old behavior is untouched.


Origin commit data
------------------
Branch: ni/coolstream
Commit: 8174f094e6
Author: Thilo Graf <dbt@novatux.de>
Date: 2022-03-27 (Sun, 27 Mar 2022)



------------------
This commit was generated by Migit
This commit is contained in:
2022-03-27 21:46:44 +02:00
committed by vanhofen
parent d4c9d4fbc7
commit 5449be27c1
3 changed files with 18 additions and 7 deletions

View File

@@ -1380,6 +1380,7 @@ int CTestMenu::showTestMenu()
w_test.addItem(new CMenuForwarder("Shell Window Test", true, NULL, this, "shellwindow")); w_test.addItem(new CMenuForwarder("Shell Window Test", true, NULL, this, "shellwindow"));
// hardware // hardware
CMenuWidget *w_hw = new CMenuWidget("Hardware Test", NEUTRINO_ICON_INFO, width, MN_WIDGET_ID_TESTMENU_HARDWARE); CMenuWidget *w_hw = new CMenuWidget("Hardware Test", NEUTRINO_ICON_INFO, width, MN_WIDGET_ID_TESTMENU_HARDWARE);
w_hw->setPos(20, 50);
w_test.addItem(new CMenuForwarder(w_hw->getName(), true, NULL, w_hw)); w_test.addItem(new CMenuForwarder(w_hw->getName(), true, NULL, w_hw));
showHWTests(w_hw); showHWTests(w_hw);

View File

@@ -642,7 +642,7 @@ void CMenuWidget::Init(const std::string &NameString, const std::string &Icon, c
//pos //pos
x = y = 0; x = y = 0;
height = 0; height = 0;
w_pos_mode = MENU_POS_PRESET; w_pos_mode = g_settings.menu_pos;
//caption and icon //caption and icon
nameString = NameString; nameString = NameString;
@@ -718,6 +718,13 @@ void CMenuWidget::move(int xoff, int yoff)
offy = yoff; offy = yoff;
} }
void CMenuWidget::setPos(int X, int Y)
{
x = X;
y = Y;
w_pos_mode = MENU_POS_CUSTOM;
}
CMenuWidget::~CMenuWidget() CMenuWidget::~CMenuWidget()
{ {
resetWidget(true); resetWidget(true);
@@ -1489,32 +1496,34 @@ void CMenuWidget::setMenuPos(const int& menu_width)
int y_old = y; int y_old = y;
//configured/custom positions //configured/custom positions
int menu_pos = w_pos_mode == MENU_POS_PRESET ? g_settings.menu_pos : w_pos_mode; int menu_pos = g_settings.menu_pos;
if (w_pos_mode == MENU_POS_CUSTOM)
menu_pos = MENU_POS_CUSTOM;
switch(menu_pos) switch(menu_pos)
{ {
case MENU_POS_CUSTOM:
x += DETAILSLINE_WIDTH;
break;
case MENU_POS_CENTER: case MENU_POS_CENTER:
x = offx + scr_x + ((scr_w - menu_width ) >> 1 ); x = offx + scr_x + ((scr_w - menu_width ) >> 1 );
y = offy + scr_y + ((scr_h - real_h) >> 1 ); y = offy + scr_y + ((scr_h - real_h) >> 1 );
//x += DETAILSLINE_WIDTH; //x += DETAILSLINE_WIDTH;
break; break;
case MENU_POS_TOP_LEFT: case MENU_POS_TOP_LEFT:
y = offy + scr_y + OFFSET_INNER_MID; y = offy + scr_y + OFFSET_INNER_MID;
x = offx + scr_x + OFFSET_INNER_MID; x = offx + scr_x + OFFSET_INNER_MID;
x += g_settings.show_menu_hints_line ? DETAILSLINE_WIDTH : 0; //NI x += g_settings.show_menu_hints_line ? DETAILSLINE_WIDTH : 0; //NI
break; break;
case MENU_POS_TOP_RIGHT: case MENU_POS_TOP_RIGHT:
y = offy + scr_y + OFFSET_INNER_MID; y = offy + scr_y + OFFSET_INNER_MID;
x = /*offx +*/ scr_x + scr_w - menu_width - OFFSET_INNER_MID; x = /*offx +*/ scr_x + scr_w - menu_width - OFFSET_INNER_MID;
break; break;
case MENU_POS_BOTTOM_LEFT: case MENU_POS_BOTTOM_LEFT:
y = /*offy +*/ scr_y + scr_h - real_h - OFFSET_INNER_MID; y = /*offy +*/ scr_y + scr_h - real_h - OFFSET_INNER_MID;
x = offx + scr_x + OFFSET_INNER_MID; x = offx + scr_x + OFFSET_INNER_MID;
x += g_settings.show_menu_hints_line ? DETAILSLINE_WIDTH : 0; //NI x += g_settings.show_menu_hints_line ? DETAILSLINE_WIDTH : 0; //NI
break; break;
case MENU_POS_BOTTOM_RIGHT: case MENU_POS_BOTTOM_RIGHT:
y = /*offy +*/ scr_y + scr_h - real_h - OFFSET_INNER_MID; y = /*offy +*/ scr_y + scr_h - real_h - OFFSET_INNER_MID;
x = /*offx +*/ scr_x + scr_w - menu_width - OFFSET_INNER_MID; x = /*offx +*/ scr_x + scr_w - menu_width - OFFSET_INNER_MID;

View File

@@ -652,6 +652,7 @@ class CMenuWidget : public CMenuTarget, public CComponentsSignals
void initSelectable(); void initSelectable();
int getSelected()const { return selected; }; int getSelected()const { return selected; };
void move(int xoff, int yoff); void move(int xoff, int yoff);
void setPos(int X, int Y);
int getHeight() {calcSize(); return full_height;} int getHeight() {calcSize(); return full_height;}
int getFullWidth() {calcSize(); return full_width;} int getFullWidth() {calcSize(); return full_width;}
int getWidth() {calcSize(); return full_width - DETAILSLINE_WIDTH;} int getWidth() {calcSize(); return full_width - DETAILSLINE_WIDTH;}
@@ -670,7 +671,7 @@ class CMenuWidget : public CMenuTarget, public CComponentsSignals
MENU_POS_BOTTOM_LEFT , MENU_POS_BOTTOM_LEFT ,
MENU_POS_BOTTOM_RIGHT , MENU_POS_BOTTOM_RIGHT ,
MENU_POS_PRESET MENU_POS_CUSTOM
}; };
void addKey(neutrino_msg_t key, CMenuTarget *menue, const std::string &action); void addKey(neutrino_msg_t key, CMenuTarget *menue, const std::string &action);
void setFooter(const struct button_label *_fbutton_label, const int _fbutton_count, bool repaint = false); void setFooter(const struct button_label *_fbutton_label, const int _fbutton_count, bool repaint = false);