From 47105169e1c7f34122cd826856c82f78c92cb229 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Fri, 3 Aug 2018 22:34:14 +0200 Subject: [PATCH] - menu: add condition to enable/disable items in record mode (version 2) Signed-off-by: Thilo Graf Unused but useful if conditions are required to disable or enable items depends of record mode. --- src/gui/widget/menue.cpp | 36 ++++++++++++++++++++++++++++++++---- src/gui/widget/menue.h | 10 +++++++--- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 3aa29b1c8..f5c2aa07f 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -110,7 +111,7 @@ void CMenuItem::setActive(const bool Active) paint(); } -bool CMenuItem::initModeCondition(const int& stb_mode) +bool CMenuItem::initNeutrinoModeCondition(const int& stb_mode) { if (CNeutrinoApp::getInstance()->getMode() == stb_mode){ active = false; @@ -124,23 +125,50 @@ bool CMenuItem::initModeCondition(const int& stb_mode) return false; } +bool CMenuItem::initRecordModeCondition(const int& rec_mode) +{ + if (CRecordManager::getInstance()->GetRecordMode() & rec_mode){ + active = false; + marked = false; + if (parent_widget) + if (!isSelectable()) + parent_widget->initSelectable(); + return true; + } + printf("\033[33m[CMenuItem] [%s - %d] missmatching rec mode condition %d\033[0m\n", __func__, __LINE__, rec_mode); + return false; +} + void CMenuItem::disableByCondition(const menu_item_disable_cond_t& condition) { int stb_mode = CNeutrinoApp::getInstance()->getMode(); + int rec_mode = CRecordManager::getInstance()->GetRecordMode(); + // Neutrino modes if (condition & DCOND_MODE_TS){ if (stb_mode == NeutrinoModes::mode_ts) - if (initModeCondition(stb_mode)) + if (initNeutrinoModeCondition(stb_mode)) return; } if (condition & DCOND_MODE_RADIO){ if (stb_mode == NeutrinoModes::mode_radio) - if (initModeCondition(stb_mode)) + if (initNeutrinoModeCondition(stb_mode)) return; } if (condition & DCOND_MODE_TV){ if (stb_mode == NeutrinoModes::mode_tv) - if (initModeCondition(stb_mode)) + if (initNeutrinoModeCondition(stb_mode)) + return; + } + // record modes + if (condition & DCOND_MODE_REC){ + if (rec_mode & CRecordManager::RECMODE_REC) + if (initRecordModeCondition(CRecordManager::RECMODE_REC)) + return; + } + if (condition & DCOND_MODE_TSHIFT){ + if (rec_mode & CRecordManager::RECMODE_TSHIFT) + if (initRecordModeCondition(CRecordManager::RECMODE_TSHIFT)) return; } diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index f2aa0bada..e21292597 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -75,10 +75,13 @@ struct menu_return enum { DCOND_MODE_NONE = 1, - + // Neutrino modes DCOND_MODE_TV = 2, DCOND_MODE_RADIO = 4, - DCOND_MODE_TS = 8 + DCOND_MODE_TS = 8, + // record modes + DCOND_MODE_REC = 16, + DCOND_MODE_TSHIFT = 32 }/*menu_item_disable_cond_t*/; class CChangeObserver @@ -116,7 +119,8 @@ class CMenuItem : public CComponentsSignals int x, y, dx, offx, name_start_x; bool used; fb_pixel_t item_color, item_bgcolor; - bool initModeCondition(const int& stb_mode); + bool initNeutrinoModeCondition(const int& stb_mode); + bool initRecordModeCondition(const int& rec_mode); void initItemColors(const bool select_mode); lua_State *luaState; std::string luaAction;