From 5449be27c13bcd2e64d881c99b440f7fc536aa55 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 27 Mar 2022 21:46:44 +0200 Subject: [PATCH] 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: https://github.com/neutrino-images/ni-neutrino/commit/8174f094e6ee9341ea5eb55ed247ec34cef58c92 Author: Thilo Graf Date: 2022-03-27 (Sun, 27 Mar 2022) ------------------ This commit was generated by Migit --- src/gui/test_menu.cpp | 1 + src/gui/widget/menue.cpp | 21 +++++++++++++++------ src/gui/widget/menue.h | 3 ++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index afeb1f16c..49eba8b2f 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -1380,6 +1380,7 @@ int CTestMenu::showTestMenu() w_test.addItem(new CMenuForwarder("Shell Window Test", true, NULL, this, "shellwindow")); // 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)); showHWTests(w_hw); diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 844535206..1d1ced8cb 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -642,7 +642,7 @@ void CMenuWidget::Init(const std::string &NameString, const std::string &Icon, c //pos x = y = 0; height = 0; - w_pos_mode = MENU_POS_PRESET; + w_pos_mode = g_settings.menu_pos; //caption and icon nameString = NameString; @@ -718,6 +718,13 @@ void CMenuWidget::move(int xoff, int yoff) offy = yoff; } +void CMenuWidget::setPos(int X, int Y) +{ + x = X; + y = Y; + w_pos_mode = MENU_POS_CUSTOM; +} + CMenuWidget::~CMenuWidget() { resetWidget(true); @@ -1489,32 +1496,34 @@ void CMenuWidget::setMenuPos(const int& menu_width) int y_old = y; //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) { + case MENU_POS_CUSTOM: + x += DETAILSLINE_WIDTH; + break; case MENU_POS_CENTER: x = offx + scr_x + ((scr_w - menu_width ) >> 1 ); y = offy + scr_y + ((scr_h - real_h) >> 1 ); //x += DETAILSLINE_WIDTH; break; - case MENU_POS_TOP_LEFT: y = offy + scr_y + OFFSET_INNER_MID; x = offx + scr_x + OFFSET_INNER_MID; x += g_settings.show_menu_hints_line ? DETAILSLINE_WIDTH : 0; //NI break; - case MENU_POS_TOP_RIGHT: y = offy + scr_y + OFFSET_INNER_MID; x = /*offx +*/ scr_x + scr_w - menu_width - OFFSET_INNER_MID; break; - case MENU_POS_BOTTOM_LEFT: y = /*offy +*/ scr_y + scr_h - real_h - OFFSET_INNER_MID; x = offx + scr_x + OFFSET_INNER_MID; x += g_settings.show_menu_hints_line ? DETAILSLINE_WIDTH : 0; //NI break; - case MENU_POS_BOTTOM_RIGHT: y = /*offy +*/ scr_y + scr_h - real_h - OFFSET_INNER_MID; x = /*offx +*/ scr_x + scr_w - menu_width - OFFSET_INNER_MID; diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index cecb53a96..f8810ebd2 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -652,6 +652,7 @@ class CMenuWidget : public CMenuTarget, public CComponentsSignals void initSelectable(); int getSelected()const { return selected; }; void move(int xoff, int yoff); + void setPos(int X, int Y); int getHeight() {calcSize(); return full_height;} int getFullWidth() {calcSize(); return full_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_RIGHT , - MENU_POS_PRESET + MENU_POS_CUSTOM }; 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);