mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 07:51:19 +02:00
gui/widget/menu: CMenuOptionNumberChooser: add option to show units
This commit is contained in:
@@ -1158,6 +1158,7 @@ CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name,
|
|||||||
localized_value_name = special_value_name;
|
localized_value_name = special_value_name;
|
||||||
|
|
||||||
optionString = non_localized_name;
|
optionString = non_localized_name;
|
||||||
|
numberFormat = "%d";
|
||||||
observ = Observ;
|
observ = Observ;
|
||||||
slider_on = sliderOn;
|
slider_on = sliderOn;
|
||||||
}
|
}
|
||||||
@@ -1190,7 +1191,7 @@ int CMenuOptionNumberChooser::paint(bool selected)
|
|||||||
|
|
||||||
if ((localized_value_name == NONEXISTANT_LOCALE) || ((*optionValue) != localized_value))
|
if ((localized_value_name == NONEXISTANT_LOCALE) || ((*optionValue) != localized_value))
|
||||||
{
|
{
|
||||||
sprintf(option_value, "%d", ((*optionValue) + display_offset));
|
sprintf(option_value, numberFormat.c_str(), ((*optionValue) + display_offset));
|
||||||
l_option = option_value;
|
l_option = option_value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1242,6 +1243,12 @@ int CMenuOptionNumberChooser::getWidth(void)
|
|||||||
|
|
||||||
width += (w1 > w2) ? w1 : w2;
|
width += (w1 > w2) ? w1 : w2;
|
||||||
|
|
||||||
|
if (numberFormat != "%d") {
|
||||||
|
char format[numberFormat.length()];
|
||||||
|
snprintf(format, numberFormat.length(), numberFormat.c_str(), 0);
|
||||||
|
width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(format, true) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0", true);
|
||||||
|
}
|
||||||
|
|
||||||
return width + 10; /* min 10 pixels between option name and value. enough? */
|
return width + 10; /* min 10 pixels between option name and value. enough? */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -298,6 +298,7 @@ private:
|
|||||||
neutrino_locale_t localized_value_name;
|
neutrino_locale_t localized_value_name;
|
||||||
bool slider_on;
|
bool slider_on;
|
||||||
CChangeObserver * observ;
|
CChangeObserver * observ;
|
||||||
|
std::string numberFormat;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ = NULL, const int print_offset = 0, const int special_value = 0, const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, const char * non_localized_name = NULL, bool sliderOn = false );
|
CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ = NULL, const int print_offset = 0, const int special_value = 0, const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, const char * non_localized_name = NULL, bool sliderOn = false );
|
||||||
@@ -307,6 +308,7 @@ private:
|
|||||||
int exec(CMenuTarget* parent);
|
int exec(CMenuTarget* parent);
|
||||||
int isMenueOptionChooser(void) const{return 1;}
|
int isMenueOptionChooser(void) const{return 1;}
|
||||||
int getWidth(void);
|
int getWidth(void);
|
||||||
|
void setNumberFormat(std::string format) { numberFormat = format; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMenuOptionChooser : public CAbstractMenuOptionChooser
|
class CMenuOptionChooser : public CAbstractMenuOptionChooser
|
||||||
|
Reference in New Issue
Block a user