mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
CComponents: add sub class CComponentsContainer and clean up some members
- add virtual members to set colors - remove parameters from CComponents constructor and set default values in constructor - v_fbdata becomes a protected member, because old members like v_screen_val and v_infobox_val not needed in sub classes - using sizeof() to get size of fbdata structs in paint() members, so we don't need explizit defines for struct size - new class CComponentsContainer is a basic class for CComponentsInfoBox and other similar coming sub classes - use enums for fbdata types - add function setShadowOnOff() - also add defines for plausible usage of setShadowOnOff(CC_SHADOW_ON/OFF)
This commit is contained in:
@@ -30,81 +30,119 @@
|
|||||||
#include <gui/color.h>
|
#include <gui/color.h>
|
||||||
#include <gui/customcolor.h>
|
#include <gui/customcolor.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
//required typedefs
|
//required typedefs
|
||||||
typedef struct comp_fbdata_t
|
typedef struct comp_fbdata_t
|
||||||
{
|
{
|
||||||
|
int fbdata_type;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int dx;
|
int dx;
|
||||||
int dy;
|
int dy;
|
||||||
fb_pixel_t color;
|
fb_pixel_t color;
|
||||||
int r;
|
int r;
|
||||||
void * data;
|
|
||||||
fb_pixel_t* pixbuf;
|
|
||||||
bool is_frame;
|
|
||||||
int frame_thickness;
|
int frame_thickness;
|
||||||
|
fb_pixel_t* pixbuf;
|
||||||
|
void * data;
|
||||||
} comp_fbdata_struct_t;
|
} comp_fbdata_struct_t;
|
||||||
|
|
||||||
|
//fb data object types
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CC_FBDATA_TYPE_BGSCREEN,
|
||||||
|
CC_FBDATA_TYPE_SHADOW,
|
||||||
|
CC_FBDATA_TYPE_BOX,
|
||||||
|
CC_FBDATA_TYPE_FRAME,
|
||||||
|
CC_FBDATA_TYPE_LINE
|
||||||
|
}
|
||||||
|
FBDATA_TYPES;
|
||||||
|
|
||||||
|
#define CC_WIDTH_MIN 16
|
||||||
|
#define CC_HEIGHT_MIN 16
|
||||||
|
#define CC_SHADOW_ON true
|
||||||
|
#define CC_SHADOW_OFF false
|
||||||
|
#define CC_SAVE_SCREEN_YES true
|
||||||
|
#define CC_SAVE_SCREEN_NO false
|
||||||
|
|
||||||
class CComponents
|
class CComponents
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
int x, y, height, width, sw;
|
int x, y, height, width, corner_type, shadow_w;
|
||||||
CFrameBuffer * frameBuffer;
|
CFrameBuffer * frameBuffer;
|
||||||
std::vector<comp_fbdata_t> v_screen_val;
|
std::vector<comp_fbdata_t> v_fbdata;
|
||||||
|
fb_pixel_t col_body, col_shadow, col_frame;
|
||||||
|
bool firstPaint, shadow;
|
||||||
|
|
||||||
void paintFbItems(struct comp_fbdata_t * fbdata, const int items_count, bool do_save_bg = true);
|
void paintFbItems(struct comp_fbdata_t * fbdata, const int items_count, bool do_save_bg = true);
|
||||||
fb_pixel_t* saveScreen(int ax, int ay, int dx, int dy);
|
fb_pixel_t* getScreen(int ax, int ay, int dx, int dy);
|
||||||
|
fb_pixel_t* saved_screen;
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CComponents(const int x_pos = 0, const int y_pos = 0, const int h = 0, const int w = 0);
|
CComponents();
|
||||||
virtual~CComponents();
|
virtual~CComponents();
|
||||||
|
|
||||||
virtual void setXPos(const int& xpos){x = xpos;};
|
virtual void setXPos(const int& xpos){x = xpos;};
|
||||||
virtual void setYPos(const int& ypos){y = ypos;};
|
virtual void setYPos(const int& ypos){y = ypos;};
|
||||||
virtual void setHeight(const int& h){height = h;};
|
virtual void setHeight(const int& h){height = h;};
|
||||||
virtual void setWidth(const int& w){width = w;};
|
virtual void setWidth(const int& w){width = w;};
|
||||||
virtual void restore();
|
|
||||||
|
/// set colors: Possible color values are defined in "gui/color.h" and "gui/customcolor.h"
|
||||||
|
virtual void setColorFrame(fb_pixel_t color){col_frame = color;};
|
||||||
|
virtual void setColorBody(fb_pixel_t color){col_body = color;};
|
||||||
|
virtual void setColorShadow(fb_pixel_t color){col_shadow = color;};
|
||||||
|
virtual void setColorAll(fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow){col_frame = color_frame; col_body = color_body; col_shadow = color_shadow;};
|
||||||
|
|
||||||
|
virtual void hide();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CComponentsContainer : public CComponents
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
int corner_rad, fr_thickness;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CComponentsContainer();
|
||||||
|
|
||||||
|
/// set corner types: Possible corner types are defined in CFrameBuffer (see: driver/framebuffer.h).
|
||||||
|
virtual void setCornerType(const int& type){corner_type = type;};
|
||||||
|
virtual void setCornerRadius(const int& radius){corner_rad = radius;};
|
||||||
|
|
||||||
|
virtual void setFrameThickness(const int& thickness){fr_thickness = thickness;};
|
||||||
|
virtual void setShadowOnOff(bool has_shadow){shadow = has_shadow;};
|
||||||
|
|
||||||
|
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||||
|
virtual void hide(bool no_restore = false);
|
||||||
|
virtual void paintBackground();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define INFO_BOX_Y_OFFSET 2
|
||||||
|
class CComponentsInfoBox : public CComponentsContainer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h, bool has_shadow = CC_SHADOW_ON,
|
||||||
|
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENTDARK_PLUS_0,fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class CComponentsDetailLine : public CComponents
|
class CComponentsDetailLine : public CComponents
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int thickness, y_down, h_mark_top, h_mark_down;
|
int thickness, y_down, h_mark_top, h_mark_down;
|
||||||
fb_pixel_t col_line, col_shadow;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CComponentsDetailLine( const int x_pos,const int y_pos_top, const int y_pos_down,
|
CComponentsDetailLine( const int x_pos,const int y_pos_top, const int y_pos_down,
|
||||||
const int h_mark_up =16 , const int h_mark_down = 16,
|
const int h_mark_up =16 , const int h_mark_down = 16,
|
||||||
fb_pixel_t color_line = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
|
fb_pixel_t color_line = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
|
||||||
~CComponentsDetailLine();
|
~CComponentsDetailLine();
|
||||||
|
|
||||||
void paint(bool do_save_bg = false);
|
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||||
void hide();
|
void paintBackground();
|
||||||
void setColor(fb_pixel_t color_line, fb_pixel_t color_shadow){col_line = color_line; col_shadow = color_shadow;};
|
void setColors(fb_pixel_t color_line, fb_pixel_t color_shadow){col_body = color_line; col_shadow = color_shadow;};
|
||||||
void setYPosDown(const int& y_pos_down){y_down = y_pos_down;};
|
void setYPosDown(const int& y_pos_down){y_down = y_pos_down;};
|
||||||
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_;};
|
||||||
};
|
};
|
||||||
|
|
||||||
#define INFO_BOX_Y_OFFSET 2
|
|
||||||
class CComponentsInfoBox : public CComponents
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
int rad,fr_thickness;
|
|
||||||
bool shadow;
|
|
||||||
fb_pixel_t col_frame, col_body, col_shadow;
|
|
||||||
bool firstPaint;
|
|
||||||
std::vector<comp_fbdata_t> v_infobox_val;
|
|
||||||
|
|
||||||
public:
|
|
||||||
CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h, bool has_shadow = true,
|
|
||||||
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENTDARK_PLUS_0,fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
|
|
||||||
|
|
||||||
void paint(bool do_save_bg = false, bool fullPaint = false);
|
|
||||||
void hide();
|
|
||||||
void restore(bool clear_ = true);
|
|
||||||
void setColor(fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow){col_frame = color_frame; col_body = color_body; col_shadow = color_shadow;};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -33,19 +33,26 @@
|
|||||||
#include "cc.h"
|
#include "cc.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
//abstract basic class CComponents
|
||||||
|
CComponents::CComponents()
|
||||||
//basic class CComponents
|
|
||||||
CComponents::CComponents(const int x_pos, const int y_pos, const int h, const int w)
|
|
||||||
{
|
{
|
||||||
x = x_pos;
|
//basic CComponents
|
||||||
y = y_pos;
|
x = 0;
|
||||||
height = h;
|
y = 0;
|
||||||
width = w;
|
height = CC_HEIGHT_MIN;
|
||||||
sw = 0; //shadow width
|
width = CC_WIDTH_MIN;
|
||||||
|
col_body = COL_MENUCONTENT;
|
||||||
|
col_shadow = COL_MENUCONTENTDARK_PLUS_0;
|
||||||
|
col_frame = COL_MENUCONTENT_PLUS_6;
|
||||||
|
corner_type = CORNER_ALL;
|
||||||
|
shadow = CC_SHADOW_OFF;
|
||||||
|
shadow_w = SHADOW_OFFSET;
|
||||||
|
firstPaint = true;
|
||||||
frameBuffer = CFrameBuffer::getInstance();
|
frameBuffer = CFrameBuffer::getInstance();
|
||||||
v_screen_val.clear();
|
v_fbdata.clear();
|
||||||
|
saved_screen = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CComponents::~CComponents()
|
CComponents::~CComponents()
|
||||||
@@ -56,64 +63,189 @@ CComponents::~CComponents()
|
|||||||
//paint framebuffer stuff and fill buffer
|
//paint framebuffer stuff and fill buffer
|
||||||
void CComponents::paintFbItems(struct comp_fbdata_t * fbdata, const int items_count, bool do_save_bg)
|
void CComponents::paintFbItems(struct comp_fbdata_t * fbdata, const int items_count, bool do_save_bg)
|
||||||
{
|
{
|
||||||
int i;
|
for(int i=0; i< items_count ;i++){
|
||||||
for(i=0; i< items_count ;i++){
|
int fbtype = fbdata[i].fbdata_type;
|
||||||
if (do_save_bg)
|
|
||||||
fbdata[i].pixbuf = saveScreen(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy);
|
if (firstPaint){
|
||||||
v_screen_val.push_back(fbdata[i]);
|
|
||||||
}
|
if (do_save_bg && fbtype == CC_FBDATA_TYPE_LINE)
|
||||||
|
fbdata[i].pixbuf = saved_screen = getScreen(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy);
|
||||||
for(i=0; i< items_count ;i++){
|
v_fbdata.push_back(fbdata[i]);
|
||||||
if (fbdata[i].is_frame)
|
|
||||||
frameBuffer->paintBoxFrame(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy, fbdata[i].frame_thickness, fbdata[i].color, fbdata[i].r);
|
//ensure painting of all line fb items with saved screens
|
||||||
else
|
if (fbtype == CC_FBDATA_TYPE_LINE)
|
||||||
frameBuffer->paintBoxRel(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy, fbdata[i].color, fbdata[i].r);
|
firstPaint = true;
|
||||||
|
else
|
||||||
|
firstPaint = false;
|
||||||
|
}
|
||||||
|
if (fbtype != CC_FBDATA_TYPE_BGSCREEN){
|
||||||
|
if (fbtype == CC_FBDATA_TYPE_FRAME && fbdata[i].frame_thickness > 0)
|
||||||
|
frameBuffer->paintBoxFrame(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy, fbdata[i].frame_thickness, fbdata[i].color, fbdata[i].r);
|
||||||
|
else
|
||||||
|
frameBuffer->paintBoxRel(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy, fbdata[i].color, fbdata[i].r, corner_type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//screen area save
|
//screen area save
|
||||||
inline fb_pixel_t* CComponents::saveScreen(int ax, int ay, int dx, int dy)
|
inline fb_pixel_t* CComponents::getScreen(int ax, int ay, int dx, int dy)
|
||||||
{
|
{
|
||||||
fb_pixel_t* pixbuf = new fb_pixel_t[dx * dy];
|
fb_pixel_t* pixbuf = new fb_pixel_t[dx * dy];
|
||||||
frameBuffer->SaveScreen(ax, ay, dx, dy, pixbuf);
|
frameBuffer->SaveScreen(ax, ay, dx, dy, pixbuf);
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
//restore screen
|
//restore screen from buffer
|
||||||
inline void CComponents::restore()
|
inline void CComponents::hide()
|
||||||
{
|
{
|
||||||
for(size_t i =0; i< v_screen_val.size() ;i++) {
|
for(size_t i =0; i< v_fbdata.size() ;i++) {
|
||||||
if (v_screen_val[i].pixbuf != NULL){
|
if (v_fbdata[i].pixbuf != NULL){
|
||||||
frameBuffer->RestoreScreen(v_screen_val[i].x, v_screen_val[i].y, v_screen_val[i].dx, v_screen_val[i].dy, v_screen_val[i].pixbuf);
|
frameBuffer->RestoreScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].pixbuf);
|
||||||
delete[] v_screen_val[i].pixbuf;
|
delete[] v_fbdata[i].pixbuf;
|
||||||
|
v_fbdata[i].pixbuf = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
v_screen_val.clear();
|
v_fbdata.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//clean old screen buffer
|
//clean old screen buffer
|
||||||
inline void CComponents::clear()
|
inline void CComponents::clear()
|
||||||
{
|
{
|
||||||
for(size_t i =0; i< v_screen_val.size() ;i++)
|
for(size_t i =0; i< v_fbdata.size() ;i++)
|
||||||
if (v_screen_val[i].pixbuf != NULL)
|
if (v_fbdata[i].pixbuf != NULL)
|
||||||
delete[] v_screen_val[i].pixbuf;
|
delete[] v_fbdata[i].pixbuf;
|
||||||
v_screen_val.clear();
|
v_fbdata.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------
|
||||||
|
//abstract sub class CComponentsContainer from CComponents
|
||||||
|
CComponentsContainer::CComponentsContainer()
|
||||||
|
{
|
||||||
|
//CComponentsContainer
|
||||||
|
corner_rad = 0;
|
||||||
|
fr_thickness = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// y
|
||||||
|
// x+------f-r-a-m-e-------+
|
||||||
|
// | |
|
||||||
|
// height body |
|
||||||
|
// | |
|
||||||
|
// +--------width---------+
|
||||||
|
|
||||||
|
|
||||||
|
void CComponentsContainer::paint(bool do_save_bg)
|
||||||
|
{
|
||||||
|
int items_cnt = 0;
|
||||||
|
clear();
|
||||||
|
|
||||||
|
int sw = shadow ? shadow_w : 0;
|
||||||
|
int th = fr_thickness;
|
||||||
|
|
||||||
|
comp_fbdata_t fbdata[] =
|
||||||
|
{
|
||||||
|
{CC_FBDATA_TYPE_BGSCREEN, x, y, width+sw, height+sw, 0, 0, 0, NULL, NULL},
|
||||||
|
{CC_FBDATA_TYPE_SHADOW, x+sw, y+sw, width, height, col_shadow, corner_rad, 0, NULL, NULL},
|
||||||
|
{CC_FBDATA_TYPE_FRAME, x, y, width, height, col_frame, corner_rad, th, NULL, NULL},
|
||||||
|
{CC_FBDATA_TYPE_BOX, x+th, y+th, width-2*th, height-2*th, col_body, corner_rad-th, 0, NULL, NULL},
|
||||||
|
};
|
||||||
|
|
||||||
|
items_cnt = sizeof(fbdata) / sizeof(fbdata[0]);
|
||||||
|
|
||||||
|
if (firstPaint && do_save_bg) {
|
||||||
|
for(int i=0; i<items_cnt; i++){
|
||||||
|
if (fbdata[i].fbdata_type == CC_FBDATA_TYPE_BGSCREEN){
|
||||||
|
fbdata[i].pixbuf = getScreen(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
paintFbItems(fbdata, items_cnt, do_save_bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//restore last saved screen behind form box,
|
||||||
|
//Do use parameter 'no restore' to override temporarly the restore funtionality.
|
||||||
|
//This could help to avoid ugly flicker efffects if it is necessary e.g. on often repaints, without changed contents.
|
||||||
|
void CComponentsContainer::hide(bool no_restore)
|
||||||
|
{
|
||||||
|
if (no_restore)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(size_t i =0; i< v_fbdata.size() ;i++) {
|
||||||
|
if (v_fbdata[i].pixbuf != NULL && v_fbdata[i].fbdata_type == CC_FBDATA_TYPE_BGSCREEN)
|
||||||
|
frameBuffer->RestoreScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].pixbuf);
|
||||||
|
delete[] v_fbdata[i].pixbuf;
|
||||||
|
}
|
||||||
|
v_fbdata.clear();
|
||||||
|
firstPaint = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//hide rendered objects
|
||||||
|
void CComponentsContainer::paintBackground()
|
||||||
|
{
|
||||||
|
//save current colors
|
||||||
|
fb_pixel_t c_tmp1, c_tmp2, c_tmp3;
|
||||||
|
c_tmp1 = col_body;
|
||||||
|
c_tmp2 = col_shadow;
|
||||||
|
c_tmp3 = col_frame;
|
||||||
|
|
||||||
|
//set background color
|
||||||
|
col_body = col_frame = col_shadow = COL_BACKGROUND;
|
||||||
|
|
||||||
|
//paint with background and restore last used colors
|
||||||
|
paint(CC_SAVE_SCREEN_NO);
|
||||||
|
col_body = c_tmp1;
|
||||||
|
col_shadow = c_tmp2;
|
||||||
|
col_frame = c_tmp3;
|
||||||
|
firstPaint = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------
|
||||||
//sub class CComponentsDetailLine
|
//sub class CComponentsInfoBox from CComponentsContainer
|
||||||
|
CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const int w, const int h, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
|
||||||
|
{
|
||||||
|
//CComponents
|
||||||
|
x = x_pos;
|
||||||
|
y = y_pos;
|
||||||
|
width = w;
|
||||||
|
height = h;
|
||||||
|
shadow = has_shadow;
|
||||||
|
shadow_w = SHADOW_OFFSET;
|
||||||
|
col_frame = color_frame;
|
||||||
|
col_body = color_body;
|
||||||
|
col_shadow = color_shadow;
|
||||||
|
firstPaint = true;
|
||||||
|
v_fbdata.clear();
|
||||||
|
|
||||||
|
//CComponentsContainer
|
||||||
|
corner_rad = RADIUS_LARGE;
|
||||||
|
fr_thickness = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------
|
||||||
|
//sub class CComponentsDetailLine from CComponents
|
||||||
CComponentsDetailLine::CComponentsDetailLine(const int x_pos, const int y_pos_top, const int y_pos_down, const int h_mark_top_, const int h_mark_down_, fb_pixel_t color_line, fb_pixel_t color_shadow)
|
CComponentsDetailLine::CComponentsDetailLine(const int x_pos, const int y_pos_top, const int y_pos_down, const int h_mark_top_, const int h_mark_down_, fb_pixel_t color_line, fb_pixel_t color_shadow)
|
||||||
{
|
{
|
||||||
|
//CComponents
|
||||||
x = x_pos;
|
x = x_pos;
|
||||||
width = 16;
|
|
||||||
thickness = 4;
|
|
||||||
sw = 1; //shadow width
|
|
||||||
y = y_pos_top;
|
y = y_pos_top;
|
||||||
|
width = CC_WIDTH_MIN;
|
||||||
|
col_shadow = color_shadow;
|
||||||
|
col_body = color_line;
|
||||||
|
// col_frame = COL_BACKGROUND; // not used in this class
|
||||||
|
// shadow = CC_SHADOW_OFF; // not used in this class
|
||||||
|
shadow_w = 1;
|
||||||
|
firstPaint = true;
|
||||||
|
v_fbdata.clear();
|
||||||
|
|
||||||
|
//CComponentsDetailLine
|
||||||
y_down = y_pos_down;
|
y_down = y_pos_down;
|
||||||
h_mark_top = h_mark_top_;
|
h_mark_top = h_mark_top_;
|
||||||
h_mark_down = h_mark_down_;
|
h_mark_down = h_mark_down_;
|
||||||
col_line = color_line;
|
thickness = 4;
|
||||||
col_shadow = color_shadow;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CComponentsDetailLine::~CComponentsDetailLine()
|
CComponentsDetailLine::~CComponentsDetailLine()
|
||||||
@@ -136,148 +268,65 @@ CComponentsDetailLine::~CComponentsDetailLine()
|
|||||||
// y_down
|
// y_down
|
||||||
|
|
||||||
|
|
||||||
#define DLINE_ITEMS_COUNT 12
|
//paint details line with current parameters
|
||||||
//paint details line with current parameters
|
|
||||||
void CComponentsDetailLine::paint(bool do_save_bg)
|
void CComponentsDetailLine::paint(bool do_save_bg)
|
||||||
{
|
{
|
||||||
|
int items_cnt = 0;
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
int y_mark_top = y-h_mark_top/2+thickness/2;
|
int y_mark_top = y-h_mark_top/2+thickness/2;
|
||||||
int y_mark_down = y_down-h_mark_down/2+thickness/2;
|
int y_mark_down = y_down-h_mark_down/2+thickness/2;
|
||||||
|
|
||||||
|
int sw = shadow_w;
|
||||||
|
|
||||||
comp_fbdata_t fbdata[DLINE_ITEMS_COUNT] =
|
comp_fbdata_t fbdata[] =
|
||||||
{
|
{
|
||||||
/* vertical item mark | */
|
/* vertical item mark | */
|
||||||
{x+width-thickness-sw, y_mark_top, thickness, h_mark_top, col_line, 0, NULL, NULL, false, 0},
|
{CC_FBDATA_TYPE_LINE, x+width-thickness-sw, y_mark_top, thickness, h_mark_top, col_body, 0, 0, NULL, NULL},
|
||||||
{x+width-sw, y_mark_top, sw, h_mark_top, col_shadow, 0, NULL, NULL, false, 0},
|
{CC_FBDATA_TYPE_LINE, x+width-sw, y_mark_top, sw, h_mark_top, col_shadow, 0, 0, NULL, NULL},
|
||||||
{x+width-thickness-sw, y_mark_top+h_mark_top, thickness+sw, sw , col_shadow, 0, NULL, NULL, false, 0},
|
{CC_FBDATA_TYPE_LINE, x+width-thickness-sw, y_mark_top+h_mark_top, thickness+sw, sw , col_shadow, 0, 0, NULL, NULL},
|
||||||
|
|
||||||
/* horizontal item line - */
|
/* horizontal item line - */
|
||||||
{x, y, width-thickness-sw, thickness, col_line, 0, NULL, NULL, false, 0},
|
{CC_FBDATA_TYPE_LINE, x, y, width-thickness-sw, thickness, col_body, 0, 0, NULL, NULL},
|
||||||
{x+thickness, y+thickness, width-2*thickness-sw, sw, col_shadow, 0, NULL, NULL, false, 0},
|
{CC_FBDATA_TYPE_LINE, x+thickness, y+thickness, width-2*thickness-sw, sw, col_shadow, 0, 0, NULL, NULL},
|
||||||
|
|
||||||
/* vertical connect line [ */
|
/* vertical connect line [ */
|
||||||
{x, y+thickness, thickness, y_down-y-thickness, col_line, 0, NULL, NULL, false, 0},
|
{CC_FBDATA_TYPE_LINE, x, y+thickness, thickness, y_down-y-thickness, col_body, 0, 0, NULL, NULL},
|
||||||
{x+thickness, y+thickness+sw, sw, y_down-y-thickness-sw, col_shadow, 0, NULL, NULL, false, 0},
|
{CC_FBDATA_TYPE_LINE, x+thickness, y+thickness+sw, sw, y_down-y-thickness-sw, col_shadow, 0, 0, NULL, NULL},
|
||||||
|
|
||||||
/* horizontal info line - */
|
/* horizontal info line - */
|
||||||
{x, y_down, width-thickness-sw, thickness, col_line, 0, NULL, NULL, false, 0},
|
{CC_FBDATA_TYPE_LINE, x, y_down, width-thickness-sw, thickness, col_body, 0, 0, NULL, NULL},
|
||||||
{x, y_down+thickness, width-thickness-sw, sw, col_shadow, 0, NULL, NULL, false, 0},
|
{CC_FBDATA_TYPE_LINE, x, y_down+thickness, width-thickness-sw, sw, col_shadow, 0, 0, NULL, NULL},
|
||||||
|
|
||||||
/* vertical info mark | */
|
/* vertical info mark | */
|
||||||
{x+width-thickness-sw, y_mark_down, thickness, h_mark_down, col_line, 0, NULL, NULL, false, 0},
|
{CC_FBDATA_TYPE_LINE, x+width-thickness-sw, y_mark_down, thickness, h_mark_down, col_body, 0, 0, NULL, NULL},
|
||||||
{x+width-sw, y_mark_down, sw, h_mark_down, col_shadow, 0, NULL, NULL, false, 0},
|
{CC_FBDATA_TYPE_LINE, x+width-sw, y_mark_down, sw, h_mark_down, col_shadow, 0, 0, NULL, NULL},
|
||||||
{x+width-thickness-sw, y_mark_down+h_mark_down,thickness+sw, sw, col_shadow, 0, NULL, NULL, false, 0},
|
{CC_FBDATA_TYPE_LINE, x+width-thickness-sw, y_mark_down+h_mark_down,thickness+sw, sw, col_shadow, 0, 0, NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
paintFbItems(fbdata, DLINE_ITEMS_COUNT, do_save_bg);
|
items_cnt = sizeof(fbdata) / sizeof(fbdata[0]);
|
||||||
|
|
||||||
|
paintFbItems(fbdata, items_cnt, do_save_bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove painted lines from screen
|
//remove painted fb items from screen
|
||||||
void CComponentsDetailLine::hide()
|
void CComponentsDetailLine::paintBackground()
|
||||||
{
|
{
|
||||||
//caching current colors
|
//save current colors
|
||||||
fb_pixel_t c_tmp1, c_tmp2;
|
fb_pixel_t c_tmp1, c_tmp2;
|
||||||
c_tmp1 = col_line;
|
|
||||||
c_tmp2 = col_shadow;
|
|
||||||
|
|
||||||
//set background color
|
|
||||||
col_line = col_shadow = COL_BACKGROUND;
|
|
||||||
|
|
||||||
//paint with background and restore, set last used colors
|
|
||||||
paint(false);
|
|
||||||
col_line = c_tmp1;
|
|
||||||
col_shadow = c_tmp2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------
|
|
||||||
//sub class CComponentsInfoBox
|
|
||||||
CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const int w, const int h, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
|
|
||||||
{
|
|
||||||
x = x_pos;
|
|
||||||
y = y_pos;
|
|
||||||
width = w;
|
|
||||||
height = h;
|
|
||||||
rad = 0;
|
|
||||||
shadow = has_shadow;
|
|
||||||
col_frame = color_frame;
|
|
||||||
col_body = color_body;
|
|
||||||
col_shadow = color_shadow;
|
|
||||||
fr_thickness = 2;
|
|
||||||
firstPaint = true;
|
|
||||||
v_infobox_val.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
#define INFOBOX_ITEMS_COUNT 3
|
|
||||||
void CComponentsInfoBox::paint(bool do_save_bg, bool fullPaint)
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
rad = RADIUS_LARGE;
|
|
||||||
|
|
||||||
comp_fbdata_t fbdata[INFOBOX_ITEMS_COUNT] =
|
|
||||||
{
|
|
||||||
{x+SHADOW_OFFSET, y+SHADOW_OFFSET, width, height, col_shadow, rad, NULL, NULL, false, 0},
|
|
||||||
{x, y, width, height, col_frame, rad, NULL, NULL, false, 0},
|
|
||||||
{x+fr_thickness, y+fr_thickness, width-2*fr_thickness, height-2*fr_thickness, col_body, rad, NULL, NULL, false, 0},
|
|
||||||
};
|
|
||||||
|
|
||||||
int start = (shadow) ? 0 : 1;
|
|
||||||
if (firstPaint) {
|
|
||||||
if (do_save_bg) {
|
|
||||||
v_infobox_val.clear();
|
|
||||||
for(int i = start; i < INFOBOX_ITEMS_COUNT; i++) {
|
|
||||||
fbdata[i].pixbuf = saveScreen(fbdata[i].x, fbdata[i].y, fbdata[i].dx, fbdata[i].dy);
|
|
||||||
v_infobox_val.push_back(fbdata[i]);
|
|
||||||
fbdata[i].pixbuf = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// paint infobox full
|
|
||||||
paintFbItems((comp_fbdata_t*)&fbdata[start], INFOBOX_ITEMS_COUNT - start, false);
|
|
||||||
firstPaint = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (fullPaint)
|
|
||||||
// paint infobox full
|
|
||||||
paintFbItems((comp_fbdata_t*)&fbdata[start], INFOBOX_ITEMS_COUNT - start, false);
|
|
||||||
else
|
|
||||||
// paint body only
|
|
||||||
paintFbItems((comp_fbdata_t*)&fbdata[INFOBOX_ITEMS_COUNT - 1], 1, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//restore infobox
|
|
||||||
void CComponentsInfoBox::restore(bool clear_)
|
|
||||||
{
|
|
||||||
if (!v_infobox_val.empty()) {
|
|
||||||
for(size_t i =0; i< v_infobox_val.size() ;i++) {
|
|
||||||
if (v_infobox_val[i].pixbuf != NULL) {
|
|
||||||
frameBuffer->RestoreScreen(v_infobox_val[i].x, v_infobox_val[i].y, v_infobox_val[i].dx, v_infobox_val[i].dy, v_infobox_val[i].pixbuf);
|
|
||||||
if (clear_)
|
|
||||||
delete[] v_infobox_val[i].pixbuf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (clear_) {
|
|
||||||
v_infobox_val.clear();
|
|
||||||
firstPaint = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CComponentsInfoBox::hide()
|
|
||||||
{
|
|
||||||
//caching current colors
|
|
||||||
fb_pixel_t c_tmp1, c_tmp2, c_tmp3;
|
|
||||||
c_tmp1 = col_body;
|
c_tmp1 = col_body;
|
||||||
c_tmp2 = col_shadow;
|
c_tmp2 = col_shadow;
|
||||||
c_tmp3 = col_frame;
|
|
||||||
|
|
||||||
//set background color
|
//set background color
|
||||||
col_body = col_frame = col_shadow = COL_BACKGROUND;
|
col_body = col_shadow = COL_BACKGROUND;
|
||||||
|
|
||||||
//paint with background and restore, set last used colors
|
//paint with background and restore, set last used colors
|
||||||
paint(false, true);
|
paint(CC_SAVE_SCREEN_NO);
|
||||||
col_body = c_tmp1;
|
col_body = c_tmp1;
|
||||||
col_shadow = c_tmp2;
|
col_shadow = c_tmp2;
|
||||||
col_frame = c_tmp3;
|
firstPaint = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user