gui/vfd_setup.cpp: modify brightness menu so vfd follow selected menu item on scroll

Origin commit data
------------------
Branch: ni/coolstream
Commit: 2edfa2655b
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2014-10-22 (Wed, 22 Oct 2014)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
[CST] Focus
2014-10-22 15:47:12 +04:00
parent 9c0617bb3c
commit c33860aecb
2 changed files with 65 additions and 34 deletions

View File

@@ -52,13 +52,11 @@
CVfdSetup::CVfdSetup()
{
width = w_max (40, 10);
dim_time = NULL;
vfd_enabled = (cs_get_revision() != 10) && (cs_get_revision() != 11);
}
CVfdSetup::~CVfdSetup()
{
delete dim_time;
}
@@ -67,8 +65,8 @@ int CVfdSetup::exec(CMenuTarget* parent, const std::string &actionKey)
dprintf(DEBUG_DEBUG, "init lcd setup\n");
if(parent != NULL)
parent->hide();
if(actionKey=="def")
{
if(actionKey=="def") {
brightness = DEFAULT_VFD_BRIGHTNESS;
brightnessstandby = DEFAULT_VFD_STANDBYBRIGHTNESS;
brightnessdeepstandby = DEFAULT_VFD_STANDBYBRIGHTNESS;
@@ -77,6 +75,8 @@ int CVfdSetup::exec(CMenuTarget* parent, const std::string &actionKey)
CVFD::getInstance()->setBrightnessStandby(brightnessstandby);
CVFD::getInstance()->setBrightnessDeepStandby(brightnessdeepstandby);
return menu_return::RETURN_REPAINT;
} else if (actionKey == "brightness") {
return showBrightnessSetup();
}
int res = showSetup();
@@ -114,9 +114,7 @@ int CVfdSetup::showSetup()
vfds->addIntroItems(LOCALE_LCDMENU_HEAD);
//vfd brightness menu
CMenuWidget lcd_sliders(LOCALE_LCDMENU_HEAD, NEUTRINO_ICON_LCD,width, MN_WIDGET_ID_VFDSETUP_LCD_SLIDERS);
showBrightnessSetup(&lcd_sliders);
CMenuForwarder * mf = new CMenuForwarder(LOCALE_LCDMENU_LCDCONTROLER, vfd_enabled, NULL, &lcd_sliders, NULL, CRCInput::RC_red);
CMenuForwarder * mf = new CMenuForwarder(LOCALE_LCDMENU_LCDCONTROLER, vfd_enabled, NULL, this, "brightness", CRCInput::RC_red);
mf->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESS_SETUP);
vfds->addItem(mf);
@@ -158,12 +156,22 @@ int CVfdSetup::showSetup()
return res;
}
void CVfdSetup::showBrightnessSetup(CMenuWidget *mn_widget)
int CVfdSetup::showBrightnessSetup()
{
CMenuOptionNumberChooser * nc;
CMenuForwarder * mf;
mn_widget->addIntroItems(LOCALE_LCDMENU_LCDCONTROLER);
CMenuWidget *mn_widget = new CMenuWidget(LOCALE_LCDMENU_HEAD, NEUTRINO_ICON_LCD,width, MN_WIDGET_ID_VFDSETUP_LCD_SLIDERS);
mn_widget->addItem(new CMenuSeparator(CMenuSeparator::ALIGN_LEFT | CMenuSeparator::SUB_HEAD | CMenuSeparator::STRING, LOCALE_LCDMENU_LCDCONTROLER));
mn_widget->addItem(GenericMenuSeparator);
mf = new CMenuForwarder(LOCALE_MENU_BACK, true);
mf->setItemButton(!g_settings.menu_left_exit ? NEUTRINO_ICON_BUTTON_HOME : NEUTRINO_ICON_BUTTON_LEFT);
mf->setActivateObserver(this);
mn_widget->addItem(mf);
mn_widget->addItem(GenericMenuSeparatorLine);
brightness = CVFD::getInstance()->getBrightness();
brightnessstandby = CVFD::getInstance()->getBrightnessStandby();
@@ -171,33 +179,45 @@ void CVfdSetup::showBrightnessSetup(CMenuWidget *mn_widget)
nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESS, &brightness, true, 0, 15, this, CRCInput::RC_nokey, NULL, 0, 0, NONEXISTANT_LOCALE, true);
nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESS);
nc->setActivateObserver(this);
mn_widget->addItem(nc);
nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, &brightnessstandby, true, 0, 15, this, CRCInput::RC_nokey, NULL, 0, 0, NONEXISTANT_LOCALE, true);
nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESSSTANDBY);
nc->setActivateObserver(this);
mn_widget->addItem(nc);
if(cs_get_revision() > 7) {
nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSDEEPSTANDBY, &brightnessdeepstandby, true, 0, 15, this, CRCInput::RC_nokey, NULL, 0, 0, NONEXISTANT_LOCALE, true);
nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESSDEEPSTANDBY);
nc->setActivateObserver(this);
mn_widget->addItem(nc);
}
nc = new CMenuOptionNumberChooser(LOCALE_LCDMENU_DIM_BRIGHTNESS, &g_settings.lcd_setting_dim_brightness, vfd_enabled, -1, 15, NULL, CRCInput::RC_nokey, NULL, 0, -1, LOCALE_OPTIONS_OFF, true);
nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESSDIM);
nc->setActivateObserver(this);
mn_widget->addItem(nc);
mn_widget->addItem(GenericMenuSeparatorLine);
if (dim_time == NULL)
dim_time = new CStringInput(LOCALE_LCDMENU_DIM_TIME, &g_settings.lcd_setting_dim_time, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE,"0123456789 ");
CStringInput *dim_time = new CStringInput(LOCALE_LCDMENU_DIM_TIME, &g_settings.lcd_setting_dim_time, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE,"0123456789 ");
mf = new CMenuForwarder(LOCALE_LCDMENU_DIM_TIME, vfd_enabled, g_settings.lcd_setting_dim_time,dim_time);
mf = new CMenuForwarder(LOCALE_LCDMENU_DIM_TIME, vfd_enabled, g_settings.lcd_setting_dim_time, dim_time);
mf->setHint("", LOCALE_MENU_HINT_VFD_DIMTIME);
mf->setActivateObserver(this);
mn_widget->addItem(mf);
mn_widget->addItem(GenericMenuSeparatorLine);
mf = new CMenuForwarder(LOCALE_OPTIONS_DEFAULT, true, NULL, this, "def", CRCInput::RC_red);
mf->setHint("", LOCALE_MENU_HINT_VFD_DEFAULTS);
mf->setActivateObserver(this);
mn_widget->addItem(mf);
int res = mn_widget->exec(this, "");
delete mn_widget;
g_settings.lcd_setting[SNeutrinoSettings::LCD_BRIGHTNESS] = brightness;
g_settings.lcd_setting[SNeutrinoSettings::LCD_STANDBY_BRIGHTNESS] = brightnessstandby;
return res;
}
void CVfdSetup::showLedSetup(CMenuWidget *mn_led_widget)
@@ -244,30 +264,42 @@ void CVfdSetup::showBacklightSetup(CMenuWidget *mn_led_widget)
mn_led_widget->addItem(mc);
}
bool CVfdSetup::changeNotify(const neutrino_locale_t OptionName, void */* data */)
bool CVfdSetup::changeNotify(const neutrino_locale_t OptionName, void * /* data */)
{
if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCDCONTROLER_BRIGHTNESS))
{
CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCDCONTROLER_BRIGHTNESS)) {
CVFD::getInstance()->setBrightness(brightness);
}
else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY))
{
CVFD::getInstance()->setMode(CVFD::MODE_STANDBY);
} else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY)) {
CVFD::getInstance()->setBrightnessStandby(brightnessstandby);
}
else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCDCONTROLER_BRIGHTNESSDEEPSTANDBY))
{
} else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCDCONTROLER_BRIGHTNESSDEEPSTANDBY)) {
CVFD::getInstance()->setBrightnessStandby(brightnessdeepstandby);
CVFD::getInstance()->setBrightnessDeepStandby(brightnessdeepstandby);
}
else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LEDCONTROLER_MODE_TV))
{
} else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCDMENU_DIM_BRIGHTNESS)) {
CVFD::getInstance()->setBrightness(g_settings.lcd_setting_dim_brightness);
} else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LEDCONTROLER_MODE_TV)) {
CVFD::getInstance()->setled();
}
else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LEDCONTROLER_BACKLIGHT_TV))
{
} else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LEDCONTROLER_BACKLIGHT_TV)) {
CVFD::getInstance()->setBacklight(g_settings.backlight_tv);
}
return false;
}
void CVfdSetup::activateNotify(const neutrino_locale_t OptionName)
{
if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY)) {
g_settings.lcd_setting[SNeutrinoSettings::LCD_STANDBY_BRIGHTNESS] = brightnessstandby;
CVFD::getInstance()->setMode(CVFD::MODE_STANDBY);
} else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCDCONTROLER_BRIGHTNESSDEEPSTANDBY)) {
g_settings.lcd_setting[SNeutrinoSettings::LCD_STANDBY_BRIGHTNESS] = brightnessdeepstandby;
CVFD::getInstance()->setMode(CVFD::MODE_STANDBY);
} else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCDCONTROLER_BRIGHTNESS)) {
g_settings.lcd_setting[SNeutrinoSettings::LCD_BRIGHTNESS] = brightness;
CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
} else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LCDMENU_DIM_BRIGHTNESS)) {
g_settings.lcd_setting[SNeutrinoSettings::LCD_BRIGHTNESS] = g_settings.lcd_setting_dim_brightness;
CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
} else {
g_settings.lcd_setting[SNeutrinoSettings::LCD_BRIGHTNESS] = brightness;
CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8);
}
}

View File

@@ -36,24 +36,23 @@
#include <string>
class CVfdSetup : public CMenuTarget, CChangeObserver
class CVfdSetup : public CMenuTarget, CChangeObserver, CActivateObserver
{
private:
int width;
int showSetup();
void showBrightnessSetup(CMenuWidget *mn_widget);
int showBrightnessSetup();
void showLedSetup(CMenuWidget *mn_led_widget);
void showBacklightSetup(CMenuWidget *mn_led_widget);
virtual bool changeNotify(const neutrino_locale_t OptionName, void *data);
virtual void activateNotify(const neutrino_locale_t OptionName);
int brightness;
int brightnessstandby;
int brightnessdeepstandby;
bool vfd_enabled;
CStringInput * dim_time;
public:
CVfdSetup();
~CVfdSetup();