menu: -add SliderItem to CMenuOptionNumberChooser

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1419 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
satbaby
2011-05-01 20:47:55 +00:00
parent a7b08b66bc
commit 22854c30a7
2 changed files with 35 additions and 5 deletions

View File

@@ -173,6 +173,31 @@ void CMenuItem::prepareItem(const bool select_mode, const int &item_height)
} }
void CMenuItem::paintItemSlider( const bool select_mode, const int &item_height, const int &optionvalue, const int &factor, const char * left_text, const char * right_text)
{
CFrameBuffer *frameBuffer = CFrameBuffer::getInstance();
int slider_lenght = 0, h = 0;
frameBuffer->getIconSize(NEUTRINO_ICON_VOLUMEBODY, &slider_lenght, &h);
if(slider_lenght == 0)
return;
int stringwidth = 0;
if (right_text != NULL) {
stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("U999", true) ;
}
int stringwidth2 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text, true);
int maxspace = dx - stringwidth - icon_frame_w - stringwidth2 - 10;
if(maxspace < slider_lenght){
return ;
}
int stringstartposOption = x + dx - stringwidth - slider_lenght;
int optionV = (optionvalue < 0) ? 0 : optionvalue;
frameBuffer->paintBoxRel(stringstartposOption, y, slider_lenght, item_height, item_bgcolor);
frameBuffer->paintIcon(NEUTRINO_ICON_VOLUMEBODY, stringstartposOption, y+2+item_height/4);
frameBuffer->paintIcon(select_mode ? NEUTRINO_ICON_VOLUMESLIDER2BLUE : NEUTRINO_ICON_VOLUMESLIDER2, (stringstartposOption + (optionV * 100 / factor)), y+item_height/4);
}
void CMenuItem::paintItemButton(const bool select_mode, const int &item_height, const std::string &icon_Name) void CMenuItem::paintItemButton(const bool select_mode, const int &item_height, const std::string &icon_Name)
{ {
CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); CFrameBuffer *frameBuffer = CFrameBuffer::getInstance();
@@ -864,7 +889,7 @@ void CMenuWidget::addIntroItems(neutrino_locale_t subhead_text, neutrino_locale_
} }
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, const char * non_localized_name) CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, const char * non_localized_name, bool sliderOn)
{ {
height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
optionName = name; optionName = name;
@@ -882,6 +907,7 @@ CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name,
optionString = non_localized_name; optionString = non_localized_name;
can_arrow = true; can_arrow = true;
observ = Observ; observ = Observ;
slider_on = sliderOn;
} }
int CMenuOptionNumberChooser::exec(CMenuTarget*) int CMenuOptionNumberChooser::exec(CMenuTarget*)
@@ -924,7 +950,8 @@ int CMenuOptionNumberChooser::paint(bool selected, bool /*last*/)
//paint item icon //paint item icon
paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY);
if(slider_on)
paintItemSlider( selected, height, *optionValue, (upper_bound - lower_bound) , l_optionName, l_option);
//paint text //paint text
paintItemCaption(selected, height , l_optionName, l_option); paintItemCaption(selected, height , l_optionName, l_option);

View File

@@ -129,6 +129,8 @@ class CMenuItem
virtual void setItemButton(const std::string& icon_Name, const bool is_select_button = false); virtual void setItemButton(const std::string& icon_Name, const bool is_select_button = false);
virtual void paintItemCaption(const bool select_mode, const int &item_height, const char * left_text=NULL, const char * right_text=NULL); virtual void paintItemCaption(const bool select_mode, const int &item_height, const char * left_text=NULL, const char * right_text=NULL);
virtual void paintItemSlider( const bool select_mode, const int &item_height, const int &optionvalue, const int &factor, const char * left_text=NULL, const char * right_text=NULL);
}; };
class CMenuSeparator : public CMenuItem class CMenuSeparator : public CMenuItem
@@ -238,6 +240,7 @@ class CAbstractMenuOptionChooser : public CMenuItem
class CMenuOptionNumberChooser : public CAbstractMenuOptionChooser class CMenuOptionNumberChooser : public CAbstractMenuOptionChooser
{ {
private:
const char * optionString; const char * optionString;
int lower_bound; int lower_bound;
@@ -247,11 +250,11 @@ class CMenuOptionNumberChooser : public CAbstractMenuOptionChooser
int localized_value; int localized_value;
neutrino_locale_t localized_value_name; neutrino_locale_t localized_value_name;
private: bool slider_on;
CChangeObserver * observ; CChangeObserver * observ;
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); 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 );
int paint(bool selected, bool last = false); int paint(bool selected, bool last = false);