Merge branch 'ni/tuxbox' into ni/mp/tuxbox

Origin commit data
------------------
Commit: 6e4c63f289
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-01-13 (Fri, 13 Jan 2017)
This commit is contained in:
vanhofen
2017-01-13 13:27:49 +01:00
37 changed files with 177 additions and 107 deletions

View File

@@ -120,7 +120,7 @@ void CComponentsButton::initVarButton( const int& x_pos, const int& y_pos, const
cc_btn_icon_obj = NULL;
cc_btn_text_obj = NULL;
cc_btn_dy_font = CNeutrinoFonts::getInstance();
cc_btn_font = g_Font[SNeutrinoSettings::FONT_TYPE_BUTTON_TEXT];
cc_btn_font = NULL;
cc_btn_icon = icon_name;
cc_btn_text = caption;
cc_directKey = CRCInput::RC_nokey;
@@ -188,6 +188,7 @@ void CComponentsButton::initCaption()
//set basic properties
int w_frame = fr_thickness;
int reduce = 2*w_frame;
if (cc_btn_text_obj){
//position and size
int x_cap = w_frame;
@@ -197,8 +198,8 @@ void CComponentsButton::initCaption()
if (cc_btn_font == NULL)
cc_btn_font = g_Font[SNeutrinoSettings::FONT_TYPE_BUTTON_TEXT];
int w_cap = width - w_frame - append_x_offset - x_cap - w_frame;
int h_cap = min(height - 2*w_frame, cc_btn_font->getHeight());
int w_cap = min(width - append_x_offset - x_cap - reduce, cc_btn_font->getRenderWidth(cc_btn_text));
int h_cap = min(height - reduce, cc_btn_font->getHeight());
/*NOTE:
paint of centered text in y direction without y_offset
looks unlovely displaced in y direction especially besides small icons and inside small areas,
@@ -210,13 +211,17 @@ void CComponentsButton::initCaption()
cc_btn_text_obj->setDimensionsAll(x_cap, y_cap, w_cap, h_cap);
//text and font
Font* def_font = *cc_btn_dy_font->getDynFont(w_cap, h_cap, cc_btn_text);
/* If button dimension too small, use dynamic font, this ignores possible defined font
* Otherwise definied font will be used. Button dimensions are calculated from parent container (e.g. footer...).
* These dimensions must be enough to display complete content like possible icon and without truncated text.
*/
if ((cc_btn_font->getHeight()- 2*w_frame) > h_cap && (cc_btn_font->getRenderWidth(cc_btn_text)- 2*w_frame) > w_cap)
cc_btn_font = def_font;
Font *tmp_font = cc_btn_font;
if ((tmp_font->getHeight()-reduce) > (height-reduce) && (tmp_font->getRenderWidth(cc_btn_text)-reduce) > width-reduce)
tmp_font = *cc_btn_dy_font->getDynFont(w_cap, h_cap, cc_btn_text);
if ((cc_btn_font->getHeight()-reduce) > (height-reduce))
tmp_font = *cc_btn_dy_font->getDynFont(w_cap, h_cap, cc_btn_text);
cc_btn_font = tmp_font;
cc_btn_text_obj->setText(cc_btn_text, CTextBox::NO_AUTO_LINEBREAK, cc_btn_font);
cc_btn_text_obj->forceTextPaint(); //here required;

View File

@@ -75,11 +75,8 @@ CComponentsFrmClock::CComponentsFrmClock( const int& x_pos,
//init default font
cl_font = font;
cl_font_style = font_style;
if (cl_font == NULL){
int dx = 0;
int dy = 30;
setClockFont(*CNeutrinoFonts::getInstance()->getDynFont(dx, dy, cl_format_str, cl_font_style));
}
if (cl_font == NULL)
initClockFont(0, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight());
//init general clock dimensions
height = cl_font->getHeight();
@@ -114,6 +111,11 @@ CComponentsFrmClock::~CComponentsFrmClock()
delete cl_timer;
}
void CComponentsFrmClock::initClockFont(int dx, int dy)
{
setClockFont(*CNeutrinoFonts::getInstance()->getDynFont(dx, dy, cl_format_str, cl_font_style));
}
void CComponentsFrmClock::initTimeString()
{
@@ -260,12 +262,12 @@ void CComponentsFrmClock::initCCLockItems()
lbl->doPaintTextBoxBg(paint_bg);
bool save_txt_screen = cc_txt_save_screen || (!paint_bg || cc_body_gradient_enable);
lbl->enableTboxSaveScreen(save_txt_screen);
#if 0
//use matching height for digits for better vertical centerring into form
CTextBox* ctb = lbl->getCTextBoxObject();
if (ctb)
ctb->setFontUseDigitHeight();
#if 0
//ensure paint of text and label bg on changed text or painted form background
bool force_txt_and_bg = (lbl->textChanged() || this->paint_bg);
lbl->forceTextPaint(force_txt_and_bg);
@@ -380,14 +382,12 @@ void CComponentsFrmClock::paint(bool do_save_bg)
void CComponentsFrmClock::setClockFont(Font *font, const int& style)
{
if (cl_font != font)
cl_font = font;
if (style != -1)
cl_font_style = style;
// setHeight(cl_font->getHeight());
// setWidth(cl_font->getRenderWidth(cl_format_str));
if (cl_font != font || (cl_font != font)){
if (cl_font != font)
cl_font = font;
if (style != -1)
cl_font_style = style;
}
initCCLockItems();
}

View File

@@ -88,9 +88,8 @@ class CComponentsFrmClock : public CComponentsForm, public CCTextScreen
bool stopClock();
///switch between primary and secondary format
void toggleFormat();
///return pointer of font object
Font* getClockFont();
///init internal font
void initClockFont(int dx, int dy);
public:
@@ -121,6 +120,9 @@ class CComponentsFrmClock : public CComponentsForm, public CCTextScreen
*/
void setClockFont(Font * font, const int& style = -1);
///return pointer of font object
Font* getClockFont();
///set text color
virtual void setTextColor(fb_pixel_t color_text){ cl_col_text = color_text;}
@@ -132,6 +134,8 @@ class CComponentsFrmClock : public CComponentsForm, public CCTextScreen
///use string expession: "%H:%M" = 12:22, "%H:%M:%S" = 12:22:12
///set current time format string, 1st parameter set the default format, 2nd parameter sets an alternatively format for use as blink effect
virtual void setClockFormat(const char* prformat_str, const char* secformat_str = NULL);
///get current time format string,
std::string getClockFormat(){return cl_format;}
///start and paint ticking clock
virtual bool Start();

View File

@@ -137,11 +137,14 @@ void CComponentsFooter::setButtonLabels(const struct button_label_s * const cont
* With this container we can work inside footer as primary container (in this context '=this') and the parent for the button label container (chain object).
* Button label container (chain object) itself is concurrent to the parent object for button objects.
*/
int dist = height/2-cch_offset;
int h_chain = ccf_btn_font->getHeight() > height+dist ? height-dist : ccf_btn_font->getHeight()+dist;
int x_chain = width/2 - w_chain/2;
int y_chain = height/2 - h_chain/2;
if (cch_icon_obj)
x_chain = cch_offset+cch_icon_obj->getWidth()+cch_offset;
if (chain == NULL){
chain = new CComponentsFrmChain(x_chain, 0, w_chain, height, 0, CC_DIR_X, this, CC_SHADOW_OFF, COL_MENUCONTENT_PLUS_6, col_body);
chain = new CComponentsFrmChain(x_chain, y_chain, w_chain, h_chain, 0, CC_DIR_X, this, CC_SHADOW_OFF, COL_MENUCONTENT_PLUS_6, col_body);
chain->setAppendOffset(0, 0);
chain->setCorner(this->corner_rad, this->corner_type);
chain->doPaintBg(false);
@@ -172,7 +175,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label_s * const cont
* with default width to chain object.
*/
vector<CComponentsItem*> v_btns;
int h_btn = /*(ccf_enable_button_bg ? */(height*85/100)-2*fr_thickness-OFFSET_INNER_SMALL/* : height)*/-ccf_button_shadow_width;
int h_btn = /*(ccf_enable_button_bg ? */chain->getHeight()-2*fr_thickness/*-OFFSET_INNER_SMALL*//* : height)*/-ccf_button_shadow_width;
for (size_t i= 0; i< label_count; i++){
string txt = content[i].text;
string icon_name = string(content[i].button);
@@ -426,7 +429,8 @@ void CComponentsFooter::enableButtonShadow(int mode, const int& shadow_width, bo
if (chain){
for(size_t i=0; i<chain->size(); i++){
chain->getCCItem(i)->enableShadow(ccf_enable_button_shadow, ccf_button_shadow_width, ccf_button_shadow_force_paint);
int y_btn = ccf_enable_button_shadow == CC_SHADOW_OFF ? CC_CENTERED : chain->getHeight()/2 - chain->getCCItem(i)->getHeight()/2 - ccf_button_shadow_width;
//int y_btn = ccf_enable_button_shadow == CC_SHADOW_OFF ? CC_CENTERED : chain->getHeight()/2 - chain->getCCItem(i)->getHeight()/2 - ccf_button_shadow_width;
int y_btn = chain->getHeight()/2 - chain->getCCItem(i)->getHeight()/2;
chain->getCCItem(i)->setYPos(y_btn);
}
}

View File

@@ -204,7 +204,7 @@ class CComponentsFooter : public CComponentsHeader
const struct button_label * const content,
const int& label_width = 0,
const int& context_buttons = 0,
Font* font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT],
Font* font = g_Font[SNeutrinoSettings::FONT_TYPE_BUTTON_TEXT],
bool do_save_bg = CC_SAVE_SCREEN_NO
);