mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-30 08:51:04 +02:00
CComponents: Rework some buggy paint methodes
Origin commit data
------------------
Branch: ni/coolstream
Commit: 9090e41d5b
Author: Thilo Graf <dbt@novatux.de>
Date: 2012-08-18 (Sat, 18 Aug 2012)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -193,31 +193,35 @@ class CComponentsInfoBox : public CComponentsContainer
|
|||||||
private:
|
private:
|
||||||
const char* text;
|
const char* text;
|
||||||
int text_mode; //see textbox.h for possible modes
|
int text_mode; //see textbox.h for possible modes
|
||||||
int x_text;
|
int x_text, x_offset;
|
||||||
Font* font;
|
Font* font;
|
||||||
CBox * box;
|
CBox * box;
|
||||||
CTextBox * textbox;
|
CTextBox * textbox;
|
||||||
CComponentsPicture * pic;
|
CComponentsPicture * pic;
|
||||||
|
std::string pic_default_name;
|
||||||
|
|
||||||
void paintPicture();
|
void paintPicture();
|
||||||
void paintText();
|
void paintText();
|
||||||
void initVarInfobox();
|
void initVarInfobox();
|
||||||
std::string pic_name;
|
std::string pic_name;
|
||||||
|
fb_pixel_t col_text;
|
||||||
public:
|
public:
|
||||||
CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h,
|
CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h,
|
||||||
const char* info_text = NULL, const int mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, Font* font_text = NULL,
|
const char* info_text = NULL, const int mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, Font* font_text = NULL,
|
||||||
bool has_shadow = CC_SHADOW_OFF,
|
bool has_shadow = CC_SHADOW_OFF,
|
||||||
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
|
fb_pixel_t color_text = COL_MENUCONTENT, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
|
||||||
|
|
||||||
~CComponentsInfoBox();
|
~CComponentsInfoBox();
|
||||||
|
|
||||||
void setText(const char* info_text, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL){text = info_text; text_mode = mode, font = font_text;};
|
void setText(const char* info_text, const int mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, Font* font_text = NULL){text = info_text; text_mode = mode, font = font_text;};
|
||||||
void setText(const std::string& info_text, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL){text = info_text.c_str(); text_mode = mode, font = font_text;};
|
void setText(const std::string& info_text, const int mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, Font* font_text = NULL){text = info_text.c_str(); text_mode = mode, font = font_text;};
|
||||||
void setText(neutrino_locale_t locale_text, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL);
|
void setText(neutrino_locale_t locale_text, const int mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH, Font* font_text = NULL);
|
||||||
void setTextMode(const int mode){text_mode = mode;};
|
void setTextMode(const int mode){text_mode = mode;};//see textbox.h for possible modes
|
||||||
void setTextFont(Font* font_text){font = font_text;};
|
void setTextFont(Font* font_text){font = font_text;};
|
||||||
|
void setTextColor(fb_pixel_t color_text){ col_text = color_text;};
|
||||||
|
void setSpaceOffset(const int offset){x_offset = offset;};
|
||||||
void setPicture(const std::string& picture_name){pic_name = picture_name;};
|
void setPicture(const std::string& picture_name){pic_name = picture_name;};
|
||||||
|
|
||||||
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -263,12 +263,14 @@ void CComponentsContainer::syncSysColors()
|
|||||||
CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const int w, const int h,
|
CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const int w, const int h,
|
||||||
const char* info_text, const int mode, Font* font_text,
|
const char* info_text, const int mode, Font* font_text,
|
||||||
bool has_shadow,
|
bool has_shadow,
|
||||||
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
|
fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
|
||||||
{
|
{
|
||||||
//CComponentsInfoBox
|
//CComponentsInfoBox
|
||||||
|
initVarInfobox();
|
||||||
text = info_text;
|
text = info_text;
|
||||||
text_mode = mode;
|
text_mode = mode;
|
||||||
font = font_text;
|
font = font_text;
|
||||||
|
col_text = color_text;
|
||||||
|
|
||||||
//CComponents
|
//CComponents
|
||||||
x = x_pos;
|
x = x_pos;
|
||||||
@@ -280,7 +282,7 @@ CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const i
|
|||||||
col_body = color_body;
|
col_body = color_body;
|
||||||
col_shadow = color_shadow;
|
col_shadow = color_shadow;
|
||||||
|
|
||||||
initVarInfobox();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CComponentsInfoBox::~CComponentsInfoBox()
|
CComponentsInfoBox::~CComponentsInfoBox()
|
||||||
@@ -313,6 +315,7 @@ void CComponentsInfoBox::initVarInfobox()
|
|||||||
pic = NULL;
|
pic = NULL;
|
||||||
pic_name = "";
|
pic_name = "";
|
||||||
x_text = x;
|
x_text = x;
|
||||||
|
x_offset = 10;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,31 +328,63 @@ void CComponentsInfoBox::setText(neutrino_locale_t locale_text, int mode, Font*
|
|||||||
|
|
||||||
void CComponentsInfoBox::paintPicture()
|
void CComponentsInfoBox::paintPicture()
|
||||||
{
|
{
|
||||||
|
//init and set icon paint position
|
||||||
if (pic == NULL)
|
if (pic == NULL)
|
||||||
pic = new CComponentsPicture(x+fr_thickness+corner_rad, y+fr_thickness+corner_rad, "");
|
pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness/*+y_offset*/, "");
|
||||||
|
pic->setXPos(x+fr_thickness+x_offset);
|
||||||
|
pic->setYPos(y+fr_thickness);
|
||||||
|
|
||||||
|
//define icon
|
||||||
pic->setPicture(pic_name);
|
pic->setPicture(pic_name);
|
||||||
int pic_w = pic->getWidth();
|
|
||||||
pic->setHeight(height-2*fr_thickness-2*corner_rad);
|
//fit icon into infobox
|
||||||
|
pic->setHeight(height-2*fr_thickness);
|
||||||
pic->setColorBody(col_body);
|
pic->setColorBody(col_body);
|
||||||
|
|
||||||
pic->paint();
|
pic->paint();
|
||||||
if (pic->isPainted())
|
|
||||||
x_text = x+fr_thickness+pic_w+corner_rad;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsInfoBox::paintText()
|
void CComponentsInfoBox::paintText()
|
||||||
{
|
{
|
||||||
box = new CBox( x_text+fr_thickness, y+fr_thickness, width-2*fr_thickness-(x_text-x), height-2*fr_thickness);
|
if (box == NULL)
|
||||||
textbox = new CTextBox(text, font, text_mode, box, col_body);
|
box = new CBox();
|
||||||
|
|
||||||
|
//define text x position
|
||||||
|
x_text = x+fr_thickness+x_offset;
|
||||||
|
if (pic->isPainted()){
|
||||||
|
int pic_w = pic->getWidth();
|
||||||
|
x_text += pic_w+x_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
box->iX = x_text;
|
||||||
|
box->iY = y+fr_thickness;
|
||||||
|
|
||||||
|
//text width and height
|
||||||
|
box->iWidth = width-2*fr_thickness-(x_text-x);
|
||||||
|
box->iHeight = height-2*fr_thickness;
|
||||||
|
|
||||||
|
//init textbox
|
||||||
|
if (textbox == NULL)
|
||||||
|
textbox = new CTextBox(text, font, text_mode, box, col_body);
|
||||||
|
|
||||||
|
//set properties
|
||||||
|
textbox->movePosition(box->iX, box->iY);
|
||||||
|
textbox->setTextColor(col_text);
|
||||||
textbox->enableBackgroundPaint(false);
|
textbox->enableBackgroundPaint(false);
|
||||||
textbox->paint();
|
|
||||||
|
//set text
|
||||||
|
string new_text = static_cast <string> (text);
|
||||||
|
if (textbox->setText(&new_text))
|
||||||
|
textbox->paint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsInfoBox::paint(bool do_save_bg)
|
void CComponentsInfoBox::paint(bool do_save_bg)
|
||||||
{
|
{
|
||||||
paintInit(do_save_bg);
|
paintInit(do_save_bg);
|
||||||
paintPicture();
|
paintPicture();
|
||||||
if (text != NULL)
|
if (text)
|
||||||
paintText();
|
paintText();
|
||||||
|
text = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------
|
||||||
@@ -632,14 +667,15 @@ void CComponentsPicture::setPictureAlign(const int alignment)
|
|||||||
|
|
||||||
void CComponentsPicture::initDimensions()
|
void CComponentsPicture::initDimensions()
|
||||||
{
|
{
|
||||||
if (pic_name.empty()){
|
pic_width = pic_height = 0;
|
||||||
printf("CComponentsPicture: %s no picture file defined !\n", __FUNCTION__);
|
pic_painted = false;
|
||||||
pic_width = pic_height = 0;
|
do_paint = false;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
frameBuffer->getIconSize(pic_name.c_str(), &pic_width, &pic_height);
|
frameBuffer->getIconSize(pic_name.c_str(), &pic_width, &pic_height);
|
||||||
|
|
||||||
|
if (pic_width == 0 || pic_height == 0)
|
||||||
|
printf("CComponentsPicture: %s file: %s, no icon dimensions found! width = %d, height = %d\n", __FUNCTION__, pic_name.c_str(), pic_width, pic_height);
|
||||||
|
|
||||||
pic_x += fr_thickness;
|
pic_x += fr_thickness;
|
||||||
pic_y += fr_thickness;
|
pic_y += fr_thickness;
|
||||||
|
|
||||||
@@ -660,17 +696,17 @@ void CComponentsPicture::initDimensions()
|
|||||||
do_paint = true;
|
do_paint = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
width = max(pic_width, width);
|
int sw = (shadow ? shadow_w :0);
|
||||||
height = max(pic_height, height);
|
width = max(pic_width, width) + sw ;
|
||||||
|
height = max(pic_height, height) + sw ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsPicture::paint(bool do_save_bg)
|
void CComponentsPicture::paint(bool do_save_bg)
|
||||||
{
|
{
|
||||||
pic_painted = false;
|
|
||||||
initDimensions();
|
initDimensions();
|
||||||
|
paintInit(do_save_bg);
|
||||||
|
|
||||||
if (do_paint){
|
if (do_paint){
|
||||||
paintInit(do_save_bg);
|
|
||||||
pic_painted = frameBuffer->paintIcon(pic_name, pic_x, pic_y, 0, pic_offset, pic_paint, pic_paintBg, col_body);
|
pic_painted = frameBuffer->paintIcon(pic_name, pic_x, pic_y, 0, pic_offset, pic_paint, pic_paintBg, col_body);
|
||||||
do_paint = false;
|
do_paint = false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user