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.


Origin commit data
------------------
Branch: ni/coolstream
Commit: 5c2c8861f8
Author: Thilo Graf <dbt@novatux.de>
Date: 2019-04-02 (Tue, 02 Apr 2019)

Origin message was:
------------------
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 was generated by Migit
This commit is contained in:
2019-04-02 22:10:16 +02:00
committed by vanhofen
parent 1a373d8c4c
commit a56f49b70e
4 changed files with 95 additions and 53 deletions

View File

@@ -38,7 +38,7 @@ using namespace std;
CComponentsFooter::CComponentsFooter(CComponentsForm* parent):CCButtonSelect()
{
//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,
@@ -47,10 +47,11 @@ CComponentsFooter::CComponentsFooter( const int& x_pos, const int& y_pos, const
int shadow_mode,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow ):CCButtonSelect()
fb_pixel_t color_shadow,
int sizeMode):CCButtonSelect()
{
//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,
@@ -59,7 +60,8 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
int shadow_mode,
fb_pixel_t color_frame,
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.name = "cc_footer";
@@ -70,16 +72,17 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
//init footer width
width = width_old = w == 0 ? frameBuffer->getScreenWidth(true) : w;
//init default fonts
initDefaultFonts();
cch_font = NULL;
cch_size_mode = sizeMode;
//init font and height
initSizeMode();
if (h)
setHeight(h);
//init default button text font
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;
ccf_enable_button_shadow = false ;
ccf_button_shadow_width = shadow ? OFFSET_SHADOW/2 : 0;

View File

@@ -50,7 +50,9 @@ class CComponentsFooter : public CComponentsHeader, public CCButtonSelect
int shadow_mode,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow );
fb_pixel_t color_shadow,
int sizeMode
);
///show button with background, default false
bool ccf_enable_button_bg;
@@ -77,7 +79,8 @@ class CComponentsFooter : public CComponentsHeader, public CCButtonSelect
int shadow_mode = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_FRAME_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
void setButtonLabels(const struct button_label_cc * const content, const size_t& label_count, const int& chain_width = 0, const int& label_width = 0);

View File

@@ -49,7 +49,25 @@ using namespace std;
CComponentsHeader::CComponentsHeader(CComponentsForm* parent)
{
//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,
@@ -60,9 +78,11 @@ CComponentsHeader::CComponentsHeader( const int& x_pos, const int& y_pos, const
int shadow_mode,
fb_pixel_t color_frame,
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,
@@ -73,9 +93,11 @@ CComponentsHeader::CComponentsHeader( const int& x_pos, const int& y_pos, const
int shadow_mode,
fb_pixel_t color_frame,
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,
@@ -86,7 +108,9 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const
int shadow_mode,
fb_pixel_t color_frame,
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.name = "cc_header";
@@ -97,11 +121,15 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const
//init header width
width = width_old = w == 0 ? frameBuffer->getScreenWidth(true) : w;
height = height_old = h;
cch_font = NULL;
initDefaultFonts();
cch_size_mode = CC_HEADER_SIZE_LARGE;
cch_size_mode = sizeMode;
//init font and height
initSizeMode();
if (h)
setHeight(h);
CNeutrinoApp::getInstance()->OnAfterSetupFonts.connect(sigc::mem_fun(this, &CComponentsHeader::resetFont));
shadow = shadow_mode;
@@ -197,16 +225,16 @@ void CComponentsHeader::initDefaultFonts()
void CComponentsHeader::initCaptionFont()
{
if (cch_font == NULL){
cch_font = (cch_size_mode == CC_HEADER_SIZE_LARGE? l_font : s_font);
//select matching height
if (cch_size_mode == CC_HEADER_SIZE_LARGE)
height = std::max(height, l_font->getHeight());
else
height = std::min(height, s_font->getHeight());
}
else
height = std::max(height, cch_font->getHeight());
initDefaultFonts();
if (!cch_font)
cch_font = (cch_size_mode == CC_HEADER_SIZE_LARGE ? l_font : s_font);
}
void CComponentsHeader::initSizeMode()
{
initCaptionFont();
int h_new = cch_font->getHeight();
setHeight(h_new);
}
void CComponentsHeader::setIcon(const char* icon_name)

View File

@@ -84,7 +84,9 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
int shadow_mode,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow);
fb_pixel_t color_shadow,
int sizeMode
);
protected:
///object: icon object, see also setIcon()
@@ -145,6 +147,8 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
void initCaptionFont();
///init default fonts for size modes
void initDefaultFonts();
///init large or small mode considered assigned height
void initSizeMode();
///sub: init icon object
void initIcon();
///sub: init caption object
@@ -167,7 +171,26 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
CC_HEADER_ITEM_BUTTONS = 2
};
enum
{
CC_HEADER_SIZE_LARGE = 0,
CC_HEADER_SIZE_SMALL = 1
};
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,
const std::string& caption = 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,
fb_pixel_t color_frame = COL_FRAME_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,
neutrino_locale_t caption_locale = NONEXISTANT_LOCALE,
@@ -186,7 +211,9 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
int shadow_mode = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_FRAME_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();
@@ -216,25 +243,6 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderT
///set text color for caption
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
void setOffset(const int offset){cch_offset = offset;};
///set name of icon