mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-30 17:01:08 +02:00
CComponents: add class to place and paint icons and pictures
Origin commit data
------------------
Branch: ni/coolstream
Commit: faca582807
Author: Thilo Graf <dbt@novatux.de>
Date: 2012-08-13 (Mon, 13 Aug 2012)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -58,8 +58,7 @@ typedef enum
|
|||||||
CC_FBDATA_TYPE_BACKGROUND,
|
CC_FBDATA_TYPE_BACKGROUND,
|
||||||
|
|
||||||
CC_FBDATA_TYPES
|
CC_FBDATA_TYPES
|
||||||
}
|
}FBDATA_TYPES;
|
||||||
FBDATA_TYPES;
|
|
||||||
|
|
||||||
typedef struct comp_screen_data_t
|
typedef struct comp_screen_data_t
|
||||||
{
|
{
|
||||||
@@ -76,8 +75,18 @@ typedef enum
|
|||||||
CC_BGMODE_PERMANENT,
|
CC_BGMODE_PERMANENT,
|
||||||
|
|
||||||
CC_BGMODE_TYPES
|
CC_BGMODE_TYPES
|
||||||
}
|
}BGMODE_TYPES;
|
||||||
BGMODE_TYPES;
|
|
||||||
|
//align types
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
CC_ALIGN_RIGHT = 0,
|
||||||
|
CC_ALIGN_LEFT = 1,
|
||||||
|
CC_ALIGN_TOP = 2,
|
||||||
|
CC_ALIGN_BOTTOM = 4,
|
||||||
|
CC_ALIGN_HOR_CENTER = 8,
|
||||||
|
CC_ALIGN_VER_CENTER = 16
|
||||||
|
};
|
||||||
|
|
||||||
#define CC_WIDTH_MIN 16
|
#define CC_WIDTH_MIN 16
|
||||||
#define CC_HEIGHT_MIN 16
|
#define CC_HEIGHT_MIN 16
|
||||||
@@ -116,6 +125,7 @@ class CComponents
|
|||||||
inline virtual int getYPos(){return y;};
|
inline virtual int getYPos(){return y;};
|
||||||
inline virtual int getHeight(){return height;};
|
inline virtual int getHeight(){return height;};
|
||||||
inline virtual int getWidth(){return width;};
|
inline virtual int getWidth(){return width;};
|
||||||
|
inline virtual void getDimensions(int* xpos, int* ypos, int* w, int* h){*xpos=x; *ypos=y; *w=width; *h=height;};
|
||||||
|
|
||||||
/// set colors: Possible color values are defined in "gui/color.h" and "gui/customcolor.h"
|
/// set colors: Possible color values are defined in "gui/color.h" and "gui/customcolor.h"
|
||||||
inline virtual void setColorFrame(fb_pixel_t color){col_frame = color;};
|
inline virtual void setColorFrame(fb_pixel_t color){col_frame = color;};
|
||||||
@@ -210,4 +220,29 @@ class CComponentsDetailLine : public CComponents
|
|||||||
void setHMarkDown(const int& h_mark_down_){h_mark_down = h_mark_down_;};
|
void setHMarkDown(const int& h_mark_down_){h_mark_down = h_mark_down_;};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CComponentsPicture : public CComponentsContainer
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::string pic_name;
|
||||||
|
unsigned char pic_offset;
|
||||||
|
bool pic_paint, pic_paintBg, pic_painted, do_paint;
|
||||||
|
int pic_align, pic_x, pic_y, pic_width, pic_height;
|
||||||
|
|
||||||
|
void initDimensions();
|
||||||
|
|
||||||
|
public:
|
||||||
|
CComponentsPicture( const int x_pos, const int y_pos, const std::string& picture_name, const int alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, bool has_shadow = CC_SHADOW_OFF,
|
||||||
|
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_background = 0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
|
||||||
|
void setPictureOffset(const unsigned char offset){pic_offset = offset;};
|
||||||
|
void setPicturePaint(bool paint_p){pic_paint = paint_p;};
|
||||||
|
void setPicturePaintBackground(bool paintBg){pic_paintBg = paintBg;};
|
||||||
|
void setPicture(const std::string& picture_name);
|
||||||
|
void setPictureAlign(const int alignment);
|
||||||
|
|
||||||
|
bool isPainted(){return pic_painted;};
|
||||||
|
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||||
|
void getPictureSize(int *pwidth, int *pheight){*pwidth=pic_width; *pheight=pic_height;};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -506,3 +506,102 @@ void CComponentsPIP::hide(bool no_restore)
|
|||||||
videoDecoder->Pig(-1, -1, -1, -1);
|
videoDecoder->Pig(-1, -1, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------
|
||||||
|
//sub class CComponentsPicture from CComponentsContainer
|
||||||
|
CComponentsPicture::CComponentsPicture( int x_pos, int y_pos, const string& picture_name, const int alignment, bool has_shadow,
|
||||||
|
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
|
||||||
|
{
|
||||||
|
//CComponentsPicture
|
||||||
|
pic_name = picture_name;
|
||||||
|
pic_align = alignment;
|
||||||
|
pic_offset = 1;
|
||||||
|
pic_paint = true;
|
||||||
|
pic_paintBg = false;
|
||||||
|
pic_painted = false;
|
||||||
|
do_paint = false;
|
||||||
|
if (pic_name.empty())
|
||||||
|
pic_width = pic_height = 0;
|
||||||
|
|
||||||
|
//CComponents
|
||||||
|
x = pic_x = x_pos;
|
||||||
|
y = pic_y = y_pos;
|
||||||
|
height = 0;
|
||||||
|
width = 0;
|
||||||
|
shadow = has_shadow;
|
||||||
|
shadow_w = SHADOW_OFFSET;
|
||||||
|
col_frame = color_frame;
|
||||||
|
col_body = color_background;
|
||||||
|
col_shadow = color_shadow;
|
||||||
|
firstPaint = true;
|
||||||
|
v_fbdata.clear();
|
||||||
|
bgMode = CC_BGMODE_PERMANENT;
|
||||||
|
|
||||||
|
//CComponentsContainer
|
||||||
|
corner_rad = 0;
|
||||||
|
fr_thickness = 0;
|
||||||
|
|
||||||
|
initDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CComponentsPicture::setPicture(const std::string& picture_name)
|
||||||
|
{
|
||||||
|
pic_name = picture_name;
|
||||||
|
initDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CComponentsPicture::setPictureAlign(const int alignment)
|
||||||
|
{
|
||||||
|
pic_align = alignment;
|
||||||
|
initDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CComponentsPicture::initDimensions()
|
||||||
|
{
|
||||||
|
if (pic_name.empty()){
|
||||||
|
printf("CComponentsPicture: %s no picture file defined !\n", __FUNCTION__);
|
||||||
|
pic_width = pic_height = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
frameBuffer->getIconSize(pic_name.c_str(), &pic_width, &pic_height);
|
||||||
|
|
||||||
|
pic_x += fr_thickness;
|
||||||
|
pic_y += fr_thickness;
|
||||||
|
|
||||||
|
if (pic_height>0 && pic_width>0){
|
||||||
|
if (pic_align & CC_ALIGN_LEFT)
|
||||||
|
pic_x = x+fr_thickness;
|
||||||
|
if (pic_align & CC_ALIGN_RIGHT)
|
||||||
|
pic_x = x+width-pic_width-fr_thickness;
|
||||||
|
if (pic_align & CC_ALIGN_TOP)
|
||||||
|
pic_y = y+fr_thickness;
|
||||||
|
if (pic_align & CC_ALIGN_BOTTOM)
|
||||||
|
pic_y = y+height-pic_height-fr_thickness;
|
||||||
|
if (pic_align & CC_ALIGN_HOR_CENTER)
|
||||||
|
pic_x = x+width/2-pic_width/2;
|
||||||
|
if (pic_align & CC_ALIGN_VER_CENTER)
|
||||||
|
pic_y = y+height/2-pic_height/2;
|
||||||
|
|
||||||
|
do_paint = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
width = max(pic_width, width);
|
||||||
|
height = max(pic_height, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CComponentsPicture::paint(bool do_save_bg)
|
||||||
|
{
|
||||||
|
pic_painted = false;
|
||||||
|
initDimensions();
|
||||||
|
|
||||||
|
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);
|
||||||
|
do_paint = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user