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

Origin commit data
------------------
Commit: 87fe81b890
Author: vanhofen <vanhofen@gmx.de>
Date: 2016-12-02 (Fri, 02 Dec 2016)
This commit is contained in:
vanhofen
2016-12-02 23:39:21 +01:00
41 changed files with 345 additions and 205 deletions

View File

@@ -34,6 +34,13 @@
using namespace std;
CComponentsExtTextForm::CComponentsExtTextForm(CComponentsForm* parent)
{
Font* t_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO];
initVarExtTextForm(0, 0, 300, t_font->getHeight(), "", "", t_font, parent, CC_SHADOW_OFF, COL_MENUCONTENTINACTIVE_TEXT, COL_MENUCONTENT_TEXT, COL_FRAME_PLUS_0, COL_MENUCONTENT_PLUS_0, COL_SHADOW_PLUS_0);
initCCTextItems();
}
CComponentsExtTextForm::CComponentsExtTextForm( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& label_text, const std::string& text,
Font* font_text,
@@ -47,20 +54,19 @@ CComponentsExtTextForm::CComponentsExtTextForm( const int& x_pos, const int& y_p
initCCTextItems();
}
CComponentsExtTextFormLocalized::CComponentsExtTextFormLocalized(const int& x_pos, const int& y_pos, const int& w, const int& h,
const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text,
Font* font_text,
CComponentsForm* parent,
int shadow_mode,
fb_pixel_t label_color,
fb_pixel_t text_color,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
: CComponentsExtTextForm( x_pos, y_pos, w, h,
g_Locale->getText(locale_label_text), g_Locale->getText(locale_text),
font_text,
parent,
shadow_mode,
label_color, text_color, color_frame, color_body, color_shadow){};
CComponentsExtTextForm::CComponentsExtTextForm( const int& x_pos, const int& y_pos, const int& w, const int& h,
neutrino_locale_t l_text, const std::string& text,
Font* font_text,
CComponentsForm* parent,
int shadow_mode,
fb_pixel_t label_color,
fb_pixel_t text_color,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
initVarExtTextForm(x_pos, y_pos, w, h, (string)g_Locale->getText(l_text), text, font_text, parent, shadow_mode, label_color, text_color, color_frame, color_body, color_shadow);
initCCTextItems();
}
void CComponentsExtTextForm::initVarExtTextForm(const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& label_text, const std::string& text,
@@ -81,9 +87,13 @@ void CComponentsExtTextForm::initVarExtTextForm(const int& x_pos, const int& y_p
ccx_percent_label_w = DEF_LABEL_WIDTH_PERCENT;
ccx_label_width = ccx_percent_label_w * width/100;
ccx_text_width = width-ccx_label_width;
height = h;
if (height == 0)
height = DEF_HEIGHT;
y_text = 0;
ccx_label_text = label_text;
ccx_text = text;
shadow = shadow_mode;
@@ -95,8 +105,11 @@ void CComponentsExtTextForm::initVarExtTextForm(const int& x_pos, const int& y_p
ccx_label_obj = NULL;
ccx_text_obj = NULL;
corner_type = 0;
int dx = 0, dy = DEF_HEIGHT;
ccx_font = font_text == NULL ? *(CNeutrinoFonts::getInstance()->getDynFont(dx, dy)) : g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO];
ccx_font = font_text;
if (ccx_font == NULL){
int dx = 0, dy = height;
ccx_font = *(CNeutrinoFonts::getInstance()->getDynFont(dx, dy));
}
ccx_label_align = ccx_text_align = CTextBox::NO_AUTO_LINEBREAK;
initParent(parent);
@@ -120,9 +133,10 @@ void CComponentsExtTextForm::initLabel()
//set properties
if (ccx_label_obj){
ccx_label_width = (ccx_percent_label_w * width/100);
y_text = height/2 - height-2*fr_thickness;
ccx_label_obj->setText(ccx_label_text, ccx_label_align, ccx_font);
ccx_label_obj->setTextColor(ccx_label_color);
ccx_label_obj->setDimensionsAll(0, 0, ccx_label_width-2*fr_thickness, height-2*fr_thickness);
ccx_label_obj->setDimensionsAll(0, y_text, ccx_label_width-2*fr_thickness, height-2*fr_thickness);
ccx_label_obj->setCorner(this->corner_rad, CORNER_LEFT);
}
}
@@ -146,7 +160,7 @@ void CComponentsExtTextForm::initText()
ccx_text_width = width-ccx_label_obj->getWidth();
ccx_text_obj->setText(ccx_text, ccx_text_align, ccx_font);
ccx_text_obj->setTextColor(ccx_text_color);
ccx_text_obj->setDimensionsAll(CC_APPEND, 0, ccx_text_width-2*fr_thickness, height-2*fr_thickness);
ccx_text_obj->setDimensionsAll(ccx_label_obj->getWidth(), y_text, ccx_text_width-2*fr_thickness, height-2*fr_thickness);
ccx_text_obj->setCorner(this->corner_rad, CORNER_RIGHT);
}
}

View File

@@ -51,6 +51,8 @@ class CComponentsExtTextForm : public CComponentsForm, public CCTextScreen
Font* ccx_font;
///property: percentage val of label width related to full width, causes fit of text automatically into the available remaining size of item, see also setLabelWidthPercent()
uint8_t ccx_percent_label_w;
///centered y position of label and text
int y_text;
///object: label object
CComponentsLabel *ccx_label_obj;
@@ -79,7 +81,9 @@ class CComponentsExtTextForm : public CComponentsForm, public CCTextScreen
public:
///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as string
CComponentsExtTextForm( const int& x_pos = 1, const int& y_pos = 1, const int& w = 300, const int& h = 48,
CComponentsExtTextForm(CComponentsForm* parent = NULL);
CComponentsExtTextForm( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& label_text = "", const std::string& text = "",
Font* font_text = NULL,
CComponentsForm *parent = NULL,
@@ -89,6 +93,17 @@ class CComponentsExtTextForm : public CComponentsForm, public CCTextScreen
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
CComponentsExtTextForm( const int& x_pos, const int& y_pos, const int& w, const int& h,
neutrino_locale_t l_text = NONEXISTANT_LOCALE, const std::string& text = "",
Font* font_text = NULL,
CComponentsForm *parent = NULL,
int shadow_mode = CC_SHADOW_OFF,
fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT,
fb_pixel_t text_color = COL_MENUCONTENT_TEXT,
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
// ~CComponentsExtTextForm(); //inherited from CComponentsForm
///assigns texts for label and text, parameter as string, parameter Font is optional for required font type, default font is dependently from defined item height
@@ -142,20 +157,4 @@ class CComponentsExtTextForm : public CComponentsForm, public CCTextScreen
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
class CComponentsExtTextFormLocalized : public CComponentsExtTextForm
{
public:
///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as locales
CComponentsExtTextFormLocalized(const int& x_pos = 1, const int& y_pos = 1, const int& w = 300, const int& h = 48,
const neutrino_locale_t& locale_label_text = NONEXISTANT_LOCALE, const neutrino_locale_t& locale_text = NONEXISTANT_LOCALE,
Font* font_text = NULL,
CComponentsForm *parent = NULL,
int shadow_mode = CC_SHADOW_OFF,
fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT,
fb_pixel_t text_color = COL_MENUCONTENT_TEXT,
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
};
#endif

View File

@@ -79,7 +79,7 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
cc_body_gradient_enable = cc_body_gradient_enable_old = g_settings.theme.menu_ButtonBar_gradient; //TODO: not complete implemented at the moment
cc_body_gradient_enable = cc_body_gradient_enable_old = CC_COLGRAD_OFF/*g_settings.theme.menu_ButtonBar_gradient*/; //TODO: not complete implemented at the moment
cc_body_gradient_direction = CFrameBuffer::gradientVertical;
cc_body_gradient_mode = CColorGradient::gradientDark2Light;
btn_auto_frame_col = false;
@@ -362,8 +362,7 @@ void CComponentsFooter::setSelectedButton(size_t item_id,
sel_col = sel_fr_col; //TODO: make it configurable
chain->setSelectedItem(item_id, sel_col, fr_col, sel_bg_col, bg_col, frame_width, sel_frame_width);
if (chain->size() > 1)
getSelectedButtonObject()->setButtonTextColor(sel_text_col);
getSelectedButtonObject()->setButtonTextColor(sel_text_col);
}
}

View File

@@ -158,8 +158,8 @@ class CComponentsFooter : public CComponentsHeader
* @li optional: exepts type int, default = 2
*/
void setSelectedButton(size_t item_id,
const fb_pixel_t& fr_col = COL_MENUCONTENTSELECTED_PLUS_2,
const fb_pixel_t& sel_fr_col = COL_MENUCONTENTSELECTED_PLUS_0,
const fb_pixel_t& fr_col = COL_SHADOW_PLUS_0, //NI
const fb_pixel_t& sel_fr_col = COL_SHADOW_PLUS_0, //NI
const fb_pixel_t& bg_col = COL_MENUCONTENT_PLUS_0,
const fb_pixel_t& sel_bg_col = COL_MENUCONTENTSELECTED_PLUS_0,
const fb_pixel_t& text_col = COL_MENUCONTENT_TEXT,

View File

@@ -59,7 +59,7 @@ using namespace std;
//sub class CComponentsWindow inherit from CComponentsForm
CComponentsWindow::CComponentsWindow(CComponentsForm *parent)
{
initVarWindow(0, 0, 800, 600, "", "", parent);
initVarWindow(0, 0, 800, 600, "", "", parent, CC_SHADOW_OFF, COL_FRAME_PLUS_0, COL_MENUCONTENT_PLUS_0, COL_SHADOW_PLUS_0);
}
CComponentsWindow::CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h,
@@ -297,6 +297,7 @@ void CComponentsWindow::initBody()
ccw_body->setDimensionsAll(x_body, h_header, w_body, h_body);
ccw_body->doPaintBg(true);
ccw_body->setColorBody(col_body);
//handle corner behavior
if (!ccw_show_header)

View File

@@ -107,14 +107,14 @@ class CComponentsWindow : public CComponentsForm
///initialze all window objects at once
void initCCWItems();
///initialize all attributes
void initVarWindow( const int& x_pos = CC_CENTERED, const int& y_pos = CC_CENTERED, const int& w = 0, const int& h = 0,
const std::string& caption = "",
const std::string& iconname = "",
CComponentsForm *parent = NULL,
int shadow_mode = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
void initVarWindow( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& caption,
const std::string& iconname,
CComponentsForm *parent,
int shadow_mode,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow);
///initialize width and height
void initWindowSize();
///initialize position

View File

@@ -86,7 +86,7 @@ void CComponentsItem::paintInit(bool do_save_bg)
sw = max(0, sw);
//set current needed corner main box radius
int box_rad = corner_rad;
int box_rad = corner_type ? corner_rad : 0;
//and ensure max main box radius < dimensions
if (2*box_rad > dy)
@@ -186,7 +186,7 @@ void CComponentsItem::paintInit(bool do_save_bg)
{sh_ctr, CC_FBDATA_TYPE_SHADOW_BOX, sh_ctr_x-sw, sh_ctr_y-sw+th, sh_cdx, sh_cdy-sh_cdy_size_offset+sw, col_shadow_clean, box_rad, corner_type & CORNER_TOP_RIGHT, 0, NULL, NULL, NULL, false},
//main box
{true, CC_FBDATA_TYPE_BOX, ix+th, iy+th, dx-2*th, dy-2*th, col_body, box_rad-th, corner_type, 0, NULL, NULL, NULL, false},
{true, CC_FBDATA_TYPE_BOX, ix+th, iy+th, dx-2*th, dy-2*th, col_body, max(0,box_rad-th), corner_type, 0, NULL, NULL, NULL, false},
//frame
{true, CC_FBDATA_TYPE_FRAME, ix, iy, dx, dy, col_frame_cur, box_rad, corner_type, th, NULL, NULL, NULL, false}

View File

@@ -86,10 +86,11 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w
ct_text_mode = mode;
ct_text_style = font_style;
iX = x = x_old = x_pos; //TODO: equalize inhertited member names
iY = y = y_old = y_pos;
iWidth = width_old = width = w;
iHeight = height_old = height = h;
fr_thickness = 0;
x = x_old = x_pos;
y = y_old = y_pos;
width = width_old = w;
height = height_old = h;
/* we need a minimal borderwith of 1px because the edge-smoothing
(or fontrenderer?) otherwise will paint single pixels outside the
@@ -103,7 +104,7 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
fr_thickness = 0;
ct_text_sent = false;
ct_paint_textbg = false;
ct_force_text_paint = false;
@@ -114,6 +115,27 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w
}
void CComponentsText::initCBox()
{
x = max(0, x);
y = max(0, y);
int x_box = x + fr_thickness;
int y_box = y + fr_thickness;
if (cc_parent){
ct_box.iX = cc_xr;
ct_box.iY = cc_yr;
}else{
ct_box.iX = x_box;
ct_box.iY = y_box;
}
ct_box.iWidth = width - 2*fr_thickness;
ct_box.iHeight = height - 2*fr_thickness;
}
void CComponentsText::initCCText()
{
//set default font, if is no font definied
@@ -121,41 +143,32 @@ void CComponentsText::initCCText()
ct_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO];
//define height from font size
height = max(height, ct_font->getHeight());
//init CBox dimensions
iWidth = width-2*fr_thickness;
iHeight = height-2*fr_thickness;
//using of real x/y values to paint textbox if this text object is bound in a parent form
if (cc_parent){
int th_parent_fr = cc_parent->getFrameThickness();
iX = cc_xr + (x <= th_parent_fr ? th_parent_fr : 0);
iY = cc_yr - (y <= th_parent_fr ? th_parent_fr : 0);
}else{
iX = x;
iY = y;
}
iX += fr_thickness;
iY += fr_thickness;
int h_tmp = ct_font->getHeight();
height = max(height, h_tmp-2*fr_thickness);
if (width == 0)
width = max(width, CTextBox::getMaxLineWidth(ct_text, ct_font)-2*fr_thickness);
//init textbox
initCBox();
if (ct_textbox == NULL)
ct_textbox = new CTextBox();
//set text box properties
//set text properties
ct_textbox->setTextFont(ct_font);
ct_textbox->setTextMode(ct_text_mode);
ct_textbox->setWindowPos(this);
ct_textbox->setTextColor(ct_col_text);
ct_textbox->enableUTF8(ct_utf8_encoded);
//set text box properties
ct_textbox->setWindowPos(&ct_box);
ct_textbox->setWindowMaxDimensions(ct_box.iWidth, ct_box.iHeight);
ct_textbox->setWindowMinDimensions(ct_box.iWidth, ct_box.iHeight);
ct_textbox->setTextBorderWidth(ct_text_Hborder, ct_text_Vborder);
ct_textbox->enableBackgroundPaint(ct_paint_textbg && !cc_txt_save_screen);
ct_textbox->setBackGroundColor(col_body);
ct_textbox->setBackGroundRadius(corner_rad-fr_thickness, corner_type);
ct_textbox->setTextColor(ct_col_text);
ct_textbox->setWindowMaxDimensions(iWidth, iHeight);
ct_textbox->setWindowMinDimensions(iWidth, iHeight);
ct_textbox->setBackGroundRadius(0/*(corner_type ? corner_rad-fr_thickness : 0), corner_type*/);
ct_textbox->enableSaveScreen(cc_txt_save_screen && !ct_paint_textbg);
ct_textbox->enableUTF8(ct_utf8_encoded);
//observe behavior of parent form if available
bool force_text_paint = ct_force_text_paint;
@@ -169,7 +182,7 @@ void CComponentsText::initCCText()
#endif
//send text to CTextBox object, but force text paint text if force_text_paint option is enabled
//this is managed by CTextBox object itself
ct_text_sent = ct_textbox->setText(&ct_text, this->iWidth, force_text_paint);
ct_text_sent = ct_textbox->setText(&ct_text, ct_box.iWidth, force_text_paint);
//set current text status, needed by textChanged()
if (ct_text_sent){
@@ -180,7 +193,7 @@ void CComponentsText::initCCText()
//ensure clean font rendering on transparency background
ct_textbox->setTextRenderModeFullBG(!paint_bg);
// dprintf(DEBUG_NORMAL, "[CComponentsText] [%s - %d] init text: %s [x %d x_old %d, y %d y_old %d, w %d, h %d]\n", __func__, __LINE__, ct_text.c_str(), this->x, x_old, this->y, y_old, this->iWidth, this->iHeight);
// dprintf(DEBUG_NORMAL, "[CComponentsText] [%s - %d] ct_text = %s, x = %d , x_old = %d , y = %d , y_old = %d , \nct_box.iWidth = %d , ct_box.iHeight = %d , width = %d , height = %d, corner_rad = %d\n", __func__, __LINE__, ct_text.c_str(), x, x_old, y, y_old, ct_box.iWidth, ct_box.iHeight, width, height, corner_rad);
}
void CComponentsText::clearCCText()
@@ -287,25 +300,25 @@ void CComponentsText::hide()
void CComponentsText::setXPos(const int& xpos)
{
CCDraw::setXPos(xpos);
iX = x;
initCBox();
}
void CComponentsText::setYPos(const int& ypos)
{
CCDraw::setYPos(ypos);
iY = y;
initCBox();
}
void CComponentsText::setHeight(const int& h)
{
CCDraw::setHeight(h);
iHeight = height;
initCBox();
}
void CComponentsText::setWidth(const int& w)
{
CCDraw::setWidth(w);
iWidth = width;
initCBox();
}
//small helper to remove excessiv linbreaks

View File

@@ -40,11 +40,12 @@ Handling of text parts based up CTextBox attributes and methodes.
CComponentsText provides a interface to the embedded CTextBox object.
*/
class CComponentsText : public CCTextScreen, public CComponentsItem, public CBox
class CComponentsText : public CCTextScreen, public CComponentsItem
{
protected:
///object: CTextBox object
CTextBox * ct_textbox;
CBox ct_box;
///object: Fontrenderer object
Font * ct_font;
///property: font style
@@ -96,6 +97,9 @@ class CComponentsText : public CCTextScreen, public CComponentsItem, public CBox
///initialize all required attributes for text and send to the CTextBox object
void initCCText();
///init internal CBox object required by CTextBox object
void initCBox();
///paint CCItem backckrond (if paint_bg=true), apply initCCText() and send paint() to the CTextBox object
void paintText(bool do_save_bg = CC_SAVE_SCREEN_YES);
public:
@@ -105,7 +109,7 @@ class CComponentsText : public CCTextScreen, public CComponentsItem, public CBox
FONT_STYLE_ITALIC = 2
};
CComponentsText( const int x_pos = 10, const int y_pos = 10, const int w = 150, const int h = 50,
CComponentsText( const int x_pos = 10, const int y_pos = 10, const int w = 0, const int h = 0,
std::string text = "",
const int mode = CTextBox::AUTO_WIDTH,
Font* font_text = NULL,