mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
header/footer: add overloaded versions of header class with size mode option
Size mode didn't really work. It is easier to implement headers with with separate class constructor and other size mode Footer works also with this additional parameter but without additional overloaded constructors.
This commit is contained in:
@@ -38,7 +38,7 @@ using namespace std;
|
|||||||
CComponentsFooter::CComponentsFooter(CComponentsForm* parent):CCButtonSelect()
|
CComponentsFooter::CComponentsFooter(CComponentsForm* parent):CCButtonSelect()
|
||||||
{
|
{
|
||||||
//CComponentsFooter
|
//CComponentsFooter
|
||||||
initVarFooter(1, 1, 0, 0, 0, parent, CC_SHADOW_OFF, COL_FRAME_PLUS_0, COL_MENUFOOT_PLUS_0, COL_SHADOW_PLUS_0);
|
initVarFooter(1, 1, 0, 0, 0, parent, CC_SHADOW_OFF, COL_FRAME_PLUS_0, COL_MENUFOOT_PLUS_0, COL_SHADOW_PLUS_0, CC_HEADER_SIZE_LARGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
CComponentsFooter::CComponentsFooter( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
CComponentsFooter::CComponentsFooter( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||||
@@ -47,10 +47,11 @@ CComponentsFooter::CComponentsFooter( const int& x_pos, const int& y_pos, const
|
|||||||
int shadow_mode,
|
int shadow_mode,
|
||||||
fb_pixel_t color_frame,
|
fb_pixel_t color_frame,
|
||||||
fb_pixel_t color_body,
|
fb_pixel_t color_body,
|
||||||
fb_pixel_t color_shadow ):CCButtonSelect()
|
fb_pixel_t color_shadow,
|
||||||
|
int sizeMode):CCButtonSelect()
|
||||||
{
|
{
|
||||||
//CComponentsFooter
|
//CComponentsFooter
|
||||||
initVarFooter(x_pos, y_pos, w, h, buttons, parent, shadow_mode, color_frame, color_body, color_shadow);
|
initVarFooter(x_pos, y_pos, w, h, buttons, parent, shadow_mode, color_frame, color_body, color_shadow, sizeMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||||
@@ -59,7 +60,8 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
|
|||||||
int shadow_mode,
|
int shadow_mode,
|
||||||
fb_pixel_t color_frame,
|
fb_pixel_t color_frame,
|
||||||
fb_pixel_t color_body,
|
fb_pixel_t color_body,
|
||||||
fb_pixel_t color_shadow )
|
fb_pixel_t color_shadow,
|
||||||
|
int sizeMode)
|
||||||
{
|
{
|
||||||
cc_item_type.id = CC_ITEMTYPE_FOOTER;
|
cc_item_type.id = CC_ITEMTYPE_FOOTER;
|
||||||
cc_item_type.name = "cc_footer";
|
cc_item_type.name = "cc_footer";
|
||||||
@@ -70,16 +72,17 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
|
|||||||
//init footer width
|
//init footer width
|
||||||
width = width_old = w == 0 ? frameBuffer->getScreenWidth(true) : w;
|
width = width_old = w == 0 ? frameBuffer->getScreenWidth(true) : w;
|
||||||
|
|
||||||
//init default fonts
|
cch_font = NULL;
|
||||||
initDefaultFonts();
|
cch_size_mode = sizeMode;
|
||||||
|
|
||||||
|
//init font and height
|
||||||
|
initSizeMode();
|
||||||
|
if (h)
|
||||||
|
setHeight(h);
|
||||||
|
|
||||||
//init default button text font
|
//init default button text font
|
||||||
ccf_btn_font = g_Font[SNeutrinoSettings::FONT_TYPE_BUTTON_TEXT];
|
ccf_btn_font = g_Font[SNeutrinoSettings::FONT_TYPE_BUTTON_TEXT];
|
||||||
|
|
||||||
//init footer height
|
|
||||||
initCaptionFont();
|
|
||||||
height = height_old = max(h, cch_font->getHeight());
|
|
||||||
|
|
||||||
shadow = shadow_mode;
|
shadow = shadow_mode;
|
||||||
ccf_enable_button_shadow = false ;
|
ccf_enable_button_shadow = false ;
|
||||||
ccf_button_shadow_width = shadow ? OFFSET_SHADOW/2 : 0;
|
ccf_button_shadow_width = shadow ? OFFSET_SHADOW/2 : 0;
|
||||||
|
@@ -50,7 +50,9 @@ class CComponentsFooter : public CComponentsHeader, public CCButtonSelect
|
|||||||
int shadow_mode,
|
int shadow_mode,
|
||||||
fb_pixel_t color_frame,
|
fb_pixel_t color_frame,
|
||||||
fb_pixel_t color_body,
|
fb_pixel_t color_body,
|
||||||
fb_pixel_t color_shadow );
|
fb_pixel_t color_shadow,
|
||||||
|
int sizeMode
|
||||||
|
);
|
||||||
|
|
||||||
///show button with background, default false
|
///show button with background, default false
|
||||||
bool ccf_enable_button_bg;
|
bool ccf_enable_button_bg;
|
||||||
@@ -77,7 +79,8 @@ class CComponentsFooter : public CComponentsHeader, public CCButtonSelect
|
|||||||
int shadow_mode = CC_SHADOW_OFF,
|
int shadow_mode = CC_SHADOW_OFF,
|
||||||
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
|
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
|
||||||
fb_pixel_t color_body = COL_MENUFOOT_PLUS_0,
|
fb_pixel_t color_body = COL_MENUFOOT_PLUS_0,
|
||||||
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
|
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0,
|
||||||
|
int sizeMode = CC_HEADER_SIZE_LARGE);
|
||||||
|
|
||||||
///add button labels with string label type as content, count as size_t, chain_width as int, label width as int
|
///add button labels with string label type as content, count as size_t, chain_width as int, label width as int
|
||||||
void setButtonLabels(const struct button_label_cc * const content, const size_t& label_count, const int& chain_width = 0, const int& label_width = 0);
|
void setButtonLabels(const struct button_label_cc * const content, const size_t& label_count, const int& chain_width = 0, const int& label_width = 0);
|
||||||
|
@@ -49,7 +49,25 @@ using namespace std;
|
|||||||
CComponentsHeader::CComponentsHeader(CComponentsForm* parent)
|
CComponentsHeader::CComponentsHeader(CComponentsForm* parent)
|
||||||
{
|
{
|
||||||
//CComponentsHeader
|
//CComponentsHeader
|
||||||
initVarHeader(1, 1, 0, 0, "", "", 0, parent, CC_SHADOW_OFF, COL_FRAME_PLUS_0, COL_MENUHEAD_PLUS_0, COL_SHADOW_PLUS_0);
|
initVarHeader(1, 1, 0, 0, "", "", 0, parent, CC_SHADOW_OFF, COL_FRAME_PLUS_0, COL_MENUHEAD_PLUS_0, COL_SHADOW_PLUS_0, CC_HEADER_SIZE_LARGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
CComponentsHeader::CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||||
|
int sizeMode,
|
||||||
|
neutrino_locale_t caption_locale,
|
||||||
|
CComponentsForm* parent
|
||||||
|
)
|
||||||
|
{
|
||||||
|
initVarHeader(x_pos, y_pos, w, h, g_Locale->getText(caption_locale), "", 0, parent, CC_SHADOW_OFF, COL_FRAME_PLUS_0, COL_MENUHEAD_PLUS_0, COL_SHADOW_PLUS_0, sizeMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
CComponentsHeader::CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||||
|
int sizeMode,
|
||||||
|
const std::string& caption,
|
||||||
|
CComponentsForm* parent
|
||||||
|
)
|
||||||
|
{
|
||||||
|
initVarHeader(x_pos, y_pos, w, h, caption, "", 0, parent, CC_SHADOW_OFF, COL_FRAME_PLUS_0, COL_MENUHEAD_PLUS_0, COL_SHADOW_PLUS_0, sizeMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
CComponentsHeader::CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
CComponentsHeader::CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||||
@@ -60,9 +78,11 @@ CComponentsHeader::CComponentsHeader( const int& x_pos, const int& y_pos, const
|
|||||||
int shadow_mode,
|
int shadow_mode,
|
||||||
fb_pixel_t color_frame,
|
fb_pixel_t color_frame,
|
||||||
fb_pixel_t color_body,
|
fb_pixel_t color_body,
|
||||||
fb_pixel_t color_shadow)
|
fb_pixel_t color_shadow,
|
||||||
|
int sizeMode
|
||||||
|
)
|
||||||
{
|
{
|
||||||
initVarHeader(x_pos, y_pos, w, h, caption, icon_name, buttons, parent, shadow_mode, color_frame, color_body, color_shadow);
|
initVarHeader(x_pos, y_pos, w, h, caption, icon_name, buttons, parent, shadow_mode, color_frame, color_body, color_shadow, sizeMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
CComponentsHeader::CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
CComponentsHeader::CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||||
@@ -73,9 +93,11 @@ CComponentsHeader::CComponentsHeader( const int& x_pos, const int& y_pos, const
|
|||||||
int shadow_mode,
|
int shadow_mode,
|
||||||
fb_pixel_t color_frame,
|
fb_pixel_t color_frame,
|
||||||
fb_pixel_t color_body,
|
fb_pixel_t color_body,
|
||||||
fb_pixel_t color_shadow)
|
fb_pixel_t color_shadow,
|
||||||
|
int sizeMode
|
||||||
|
)
|
||||||
{
|
{
|
||||||
initVarHeader(x_pos, y_pos, w, h, g_Locale->getText(caption_locale), icon_name, buttons, parent, shadow_mode, color_frame, color_body, color_shadow);
|
initVarHeader(x_pos, y_pos, w, h, g_Locale->getText(caption_locale), icon_name, buttons, parent, shadow_mode, color_frame, color_body, color_shadow, sizeMode);
|
||||||
};
|
};
|
||||||
|
|
||||||
void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||||
@@ -86,7 +108,9 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const
|
|||||||
int shadow_mode,
|
int shadow_mode,
|
||||||
fb_pixel_t color_frame,
|
fb_pixel_t color_frame,
|
||||||
fb_pixel_t color_body,
|
fb_pixel_t color_body,
|
||||||
fb_pixel_t color_shadow)
|
fb_pixel_t color_shadow,
|
||||||
|
int sizeMode
|
||||||
|
)
|
||||||
{
|
{
|
||||||
cc_item_type.id = CC_ITEMTYPE_FRM_HEADER;
|
cc_item_type.id = CC_ITEMTYPE_FRM_HEADER;
|
||||||
cc_item_type.name = "cc_header";
|
cc_item_type.name = "cc_header";
|
||||||
@@ -97,11 +121,15 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const
|
|||||||
|
|
||||||
//init header width
|
//init header width
|
||||||
width = width_old = w == 0 ? frameBuffer->getScreenWidth(true) : w;
|
width = width_old = w == 0 ? frameBuffer->getScreenWidth(true) : w;
|
||||||
height = height_old = h;
|
|
||||||
|
|
||||||
cch_font = NULL;
|
cch_font = NULL;
|
||||||
initDefaultFonts();
|
cch_size_mode = sizeMode;
|
||||||
cch_size_mode = CC_HEADER_SIZE_LARGE;
|
|
||||||
|
//init font and height
|
||||||
|
initSizeMode();
|
||||||
|
if (h)
|
||||||
|
setHeight(h);
|
||||||
|
|
||||||
CNeutrinoApp::getInstance()->OnAfterSetupFonts.connect(sigc::mem_fun(this, &CComponentsHeader::resetFont));
|
CNeutrinoApp::getInstance()->OnAfterSetupFonts.connect(sigc::mem_fun(this, &CComponentsHeader::resetFont));
|
||||||
|
|
||||||
shadow = shadow_mode;
|
shadow = shadow_mode;
|
||||||
@@ -197,16 +225,16 @@ void CComponentsHeader::initDefaultFonts()
|
|||||||
|
|
||||||
void CComponentsHeader::initCaptionFont()
|
void CComponentsHeader::initCaptionFont()
|
||||||
{
|
{
|
||||||
if (cch_font == NULL){
|
initDefaultFonts();
|
||||||
cch_font = (cch_size_mode == CC_HEADER_SIZE_LARGE? l_font : s_font);
|
if (!cch_font)
|
||||||
//select matching height
|
cch_font = (cch_size_mode == CC_HEADER_SIZE_LARGE ? l_font : s_font);
|
||||||
if (cch_size_mode == CC_HEADER_SIZE_LARGE)
|
}
|
||||||
height = std::max(height, l_font->getHeight());
|
|
||||||
else
|
void CComponentsHeader::initSizeMode()
|
||||||
height = std::min(height, s_font->getHeight());
|
{
|
||||||
}
|
initCaptionFont();
|
||||||
else
|
int h_new = cch_font->getHeight();
|
||||||
height = std::max(height, cch_font->getHeight());
|
setHeight(h_new);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsHeader::setIcon(const char* icon_name)
|
void CComponentsHeader::setIcon(const char* icon_name)
|
||||||
|
@@ -84,7 +84,9 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
|
|||||||
int shadow_mode,
|
int shadow_mode,
|
||||||
fb_pixel_t color_frame,
|
fb_pixel_t color_frame,
|
||||||
fb_pixel_t color_body,
|
fb_pixel_t color_body,
|
||||||
fb_pixel_t color_shadow);
|
fb_pixel_t color_shadow,
|
||||||
|
int sizeMode
|
||||||
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///object: icon object, see also setIcon()
|
///object: icon object, see also setIcon()
|
||||||
@@ -145,6 +147,8 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
|
|||||||
void initCaptionFont();
|
void initCaptionFont();
|
||||||
///init default fonts for size modes
|
///init default fonts for size modes
|
||||||
void initDefaultFonts();
|
void initDefaultFonts();
|
||||||
|
///init large or small mode considered assigned height
|
||||||
|
void initSizeMode();
|
||||||
///sub: init icon object
|
///sub: init icon object
|
||||||
void initIcon();
|
void initIcon();
|
||||||
///sub: init caption object
|
///sub: init caption object
|
||||||
@@ -167,7 +171,26 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
|
|||||||
CC_HEADER_ITEM_BUTTONS = 2
|
CC_HEADER_ITEM_BUTTONS = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
CC_HEADER_SIZE_LARGE = 0,
|
||||||
|
CC_HEADER_SIZE_SMALL = 1
|
||||||
|
};
|
||||||
|
|
||||||
CComponentsHeader(CComponentsForm *parent = NULL);
|
CComponentsHeader(CComponentsForm *parent = NULL);
|
||||||
|
|
||||||
|
CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h = 0,
|
||||||
|
int sizeMode = CC_HEADER_SIZE_LARGE,
|
||||||
|
const std::string& caption = std::string(),
|
||||||
|
CComponentsForm *parent = NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h = 0,
|
||||||
|
int sizeMode = CC_HEADER_SIZE_LARGE,
|
||||||
|
neutrino_locale_t caption_locale = NONEXISTANT_LOCALE,
|
||||||
|
CComponentsForm *parent = NULL
|
||||||
|
);
|
||||||
|
|
||||||
CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h = 0,
|
CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h = 0,
|
||||||
const std::string& caption = std::string(),
|
const std::string& caption = std::string(),
|
||||||
const std::string& icon_name = std::string(),
|
const std::string& icon_name = std::string(),
|
||||||
@@ -176,7 +199,9 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
|
|||||||
int shadow_mode = CC_SHADOW_OFF,
|
int shadow_mode = CC_SHADOW_OFF,
|
||||||
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
|
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
|
||||||
fb_pixel_t color_body = COL_MENUHEAD_PLUS_0,
|
fb_pixel_t color_body = COL_MENUHEAD_PLUS_0,
|
||||||
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
|
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0,
|
||||||
|
int sizeMode = CC_HEADER_SIZE_LARGE
|
||||||
|
);
|
||||||
|
|
||||||
CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h = 0,
|
CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h = 0,
|
||||||
neutrino_locale_t caption_locale = NONEXISTANT_LOCALE,
|
neutrino_locale_t caption_locale = NONEXISTANT_LOCALE,
|
||||||
@@ -186,7 +211,9 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
|
|||||||
int shadow_mode = CC_SHADOW_OFF,
|
int shadow_mode = CC_SHADOW_OFF,
|
||||||
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
|
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
|
||||||
fb_pixel_t color_body = COL_MENUHEAD_PLUS_0,
|
fb_pixel_t color_body = COL_MENUHEAD_PLUS_0,
|
||||||
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
|
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0,
|
||||||
|
int sizeMode = CC_HEADER_SIZE_LARGE
|
||||||
|
);
|
||||||
|
|
||||||
virtual ~CComponentsHeader();
|
virtual ~CComponentsHeader();
|
||||||
|
|
||||||
@@ -216,25 +243,6 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
|
|||||||
///set text color for caption
|
///set text color for caption
|
||||||
void setCaptionColor(fb_pixel_t text_color){cch_col_text = text_color;}
|
void setCaptionColor(fb_pixel_t text_color){cch_col_text = text_color;}
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
CC_HEADER_SIZE_LARGE = 0,
|
|
||||||
CC_HEADER_SIZE_SMALL = 1
|
|
||||||
};
|
|
||||||
/**Set size mode of header.
|
|
||||||
* These modes are using fonts SNeutrinoSettings::FONT_TYPE_MENU_TITLE for large mode (default)
|
|
||||||
* and SNeutrinoSettings::FONT_TYPE_MENU for small mode to set required height.
|
|
||||||
* If other size wanted then use set setCaptionFont() and setHeight()
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @param[in] size_mode expects type int (enums)
|
|
||||||
* possible modes are:
|
|
||||||
* CC_HEADER_SIZE_LARGE
|
|
||||||
* CC_HEADER_SIZE_SMALL
|
|
||||||
* @see setCaption(), setHeight()
|
|
||||||
*/
|
|
||||||
void setSizeMode(const int& size_mode){cch_size_mode = size_mode; initCCItems();}
|
|
||||||
|
|
||||||
///set offset between items
|
///set offset between items
|
||||||
void setOffset(const int offset){cch_offset = offset;};
|
void setOffset(const int offset){cch_offset = offset;};
|
||||||
///set name of icon
|
///set name of icon
|
||||||
|
Reference in New Issue
Block a user