CComponentsItem: fix changeing color on select switching of frames

expand select mode methodes with paremters for frame properties
This should make variables col_frame_sel and fr_thickness_sel superfluous.
This commit is contained in:
2016-08-20 20:42:40 +02:00
parent 1888189fb3
commit 3477e28cd7
8 changed files with 38 additions and 39 deletions

View File

@@ -40,10 +40,8 @@ CCDraw::CCDraw() : COSDFader(g_settings.theme.menu_Content_alpha)
col_body = col_body_old = COL_MENUCONTENT_PLUS_0;
col_shadow = col_shadow_old = COL_SHADOW_PLUS_0;
col_frame = col_frame_old = COL_FRAME_PLUS_0;
col_frame_sel = col_frame_sel_old = COL_MENUCONTENTSELECTED_PLUS_0;
fr_thickness = fr_thickness_old = 0;
fr_thickness_sel = fr_thickness_sel_old = 3;
corner_type = corner_type_old = CORNER_ALL;
corner_rad = corner_rad_old = 0;
@@ -116,11 +114,6 @@ inline bool CCDraw::applyDimChanges()
fr_thickness_old = fr_thickness;
ret = true;
}
if (fr_thickness_sel != fr_thickness_sel_old){
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], dim changes fr_thickness_sel %d != fr_thickness_sel_old %d...\033[0m\n", __func__, __LINE__, fr_thickness_sel, fr_thickness_sel_old);
fr_thickness_old = fr_thickness;
ret = true;
}
if (shadow_w != shadow_w_old){
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], dim changes shadow_w_sel %d != shadow_w_old %d...\033[0m\n", __func__, __LINE__, shadow_w, shadow_w_old);
shadow_w_old = shadow_w;
@@ -158,11 +151,6 @@ inline bool CCDraw::applyColChanges()
col_frame_old = col_frame;
ret = true;
}
if (col_frame_sel != col_frame_sel_old){
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], col changes col_frame_sel %d != col_frame_sel_old %d...\033[0m\n", __func__, __LINE__, col_frame_sel, col_frame_sel_old);
col_frame_old = col_frame;
ret = true;
}
if (cc_body_gradient_enable != cc_body_gradient_enable_old){
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], col changes cc_body_gradient_enable %d != cc_body_gradient_enable_old %d...\033[0m\n", __func__, __LINE__, cc_body_gradient_enable, cc_body_gradient_enable_old);
cc_body_gradient_enable_old = cc_body_gradient_enable;
@@ -218,13 +206,10 @@ inline void CCDraw::setWidth(const int& w)
width = w;
}
void CCDraw::setFrameThickness(const int& thickness, const int& thickness_sel)
void CCDraw::setFrameThickness(const int& thickness)
{
fr_thickness = thickness;
if (fr_thickness_sel != thickness_sel)
fr_thickness_sel = thickness_sel;
//ensure enabled frame if frame width > 0
cc_enable_frame = false;
if (fr_thickness)

View File

@@ -67,13 +67,9 @@ class CCDraw : public COSDFader, public CComponentsSignals
fb_pixel_t col_shadow, col_shadow_old;
///property: color of frame
fb_pixel_t col_frame, col_frame_old;
///property: color of frame if component is selected, Note: fr_thickness_sel must be set
fb_pixel_t col_frame_sel, col_frame_sel_old;
///property: frame thickness, see also setFrameThickness()
int fr_thickness, fr_thickness_old;
///property: frame thickness of selected component, see also setFrameThickness()
int fr_thickness_sel, fr_thickness_sel_old;
///property: has corners with definied type, types are defined in /driver/frambuffer.h, without effect, if corner_radius=0
int corner_type, corner_type_old;
@@ -210,13 +206,12 @@ class CCDraw : public COSDFader, public CComponentsSignals
virtual void getDimensions(int* xpos, int* ypos, int* w, int* h){*xpos=x; *ypos=y; *w=width; *h=height;}
///set frame thickness
virtual void setFrameThickness(const int& thickness, const int& thickness_sel = 3);
virtual void setFrameThickness(const int& thickness);
///return of frame thickness
virtual int getFrameThickness(){return fr_thickness;}
///set frame color
virtual void setColorFrame(fb_pixel_t color){col_frame = color;}
///set selected frame color
virtual void setColorFrameSel(fb_pixel_t color){col_frame_sel = color;}
virtual void set2ndColor(fb_pixel_t col_2nd){cc_body_gradient_2nd_col = col_2nd;}
///get frame color

View File

@@ -188,7 +188,7 @@ void CComponentsButton::initCaption()
}
//set basic properties
int w_frame = max(fr_thickness, fr_thickness_sel);
int w_frame = fr_thickness;
if (cc_btn_capt_obj){
//position and size
int x_cap = w_frame;

View File

@@ -140,7 +140,7 @@ void CComponentsScrollBar::initSegments()
//init segment container
if (sb_segments_obj == NULL){
sb_segments_obj = new CComponentsFrmChain(CC_CENTERED, CC_APPEND, w_seg, h_seg_obj, NULL, CC_DIR_Y, this, false);
sb_segments_obj->setFrameThickness(0,0);
sb_segments_obj->setFrameThickness(0/*,0*/);
sb_segments_obj->setAppendOffset(0, 3);
}else
sb_segments_obj->setDimensionsAll(CC_CENTERED, CC_APPEND, w_seg, h_seg_obj);

View File

@@ -72,16 +72,11 @@ void CComponentsItem::paintInit(bool do_save_bg)
is_painted = false; //force repaint if required
}
//calculate current needed frame thickeness and color, if item selected or not
fb_pixel_t col_frame_cur = col_frame;
int th = fr_thickness;
if (v_fbdata.empty()){
int th = fr_thickness;
fb_pixel_t col_frame_cur = col_frame;
//calculate current needed frame thickeness and color, if item selected or not
if (cc_item_selected){
col_frame_cur = col_frame_sel;
th = max(fr_thickness_sel, fr_thickness);
}
//calculate current needed corner radius for body box, depends of frame thickness
int rad = (corner_rad>th) ? corner_rad-th : corner_rad;
int sw = (shadow) ? shadow_w : 0;
@@ -136,6 +131,7 @@ void CComponentsItem::paintInit(bool do_save_bg)
//body box
{true, CC_FBDATA_TYPE_BOX, ix+th, iy+th, width-2*th, height-2*th, col_body, rad, corner_type, 0, NULL, NULL, NULL, false},
//body frame
{true, CC_FBDATA_TYPE_FRAME, ix, iy, width, height, col_frame_cur, corner_rad, corner_type, th, NULL, NULL, NULL, false}
};
@@ -145,9 +141,18 @@ void CComponentsItem::paintInit(bool do_save_bg)
continue;
v_fbdata.push_back(fbdata[i]);
}
dprintf(DEBUG_DEBUG, "[CComponentsItem] %s:\ncc_item_type: %d\ncc_item_index = %d\nheight = %d\nwidth = %d\n", __func__, cc_item_type, cc_item_index, height, width);
}
//handle frame color for slected/not selected item
if (fr_thickness) {
for(size_t j =0; j< v_fbdata.size() ;j++) {
if ((v_fbdata[j].fbdata_type == CC_FBDATA_TYPE_FRAME)){
v_fbdata[j].color = col_frame_cur;
v_fbdata[j].frame_thickness = th;
}
}
}
paintFbItems(do_save_bg);
}
@@ -242,3 +247,11 @@ void CComponentsItem::setFocus(bool focus)
}
cc_has_focus = focus;
}
void CComponentsItem::setSelected(bool selected, const fb_pixel_t& sel_frame_col, const fb_pixel_t& frame_col, const fb_pixel_t& sel_body_col, const fb_pixel_t& body_col, const int& frame_w, const int& sel_frame_w)
{
cc_item_selected = selected;
fr_thickness = cc_item_selected ? sel_frame_w : frame_w;
col_body = cc_item_selected ? sel_body_col : body_col;
col_frame = cc_item_selected ? sel_frame_col : frame_col;
}

View File

@@ -105,8 +105,14 @@ class CComponentsItem : public CComponents
///syncronizes item colors with current color settings if required, NOTE: overwrites internal values!
virtual void syncSysColors();
///set select mode, see also col_frame_sel
virtual void setSelected(bool selected){cc_item_selected = selected;};
///set select mode
virtual void setSelected(bool selected,
const fb_pixel_t& sel_frame_col = COL_MENUCONTENTSELECTED_PLUS_0,
const fb_pixel_t& frame_col = COL_SHADOW_PLUS_0,
const fb_pixel_t& sel_body_col = COL_MENUCONTENT_PLUS_0,
const fb_pixel_t& body_col = COL_MENUCONTENT_PLUS_0,
const int& frame_w = 3,
const int& sel_frame_w = 3);
///set enable mode, see also cc_item_enabled
virtual void setEnable(bool enabled){cc_item_enabled = enabled;};

View File

@@ -30,7 +30,7 @@
#include <system/localize.h>
#include <driver/fontrenderer.h>
#include <driver/rcinput.h>
#include <gui/color_custom.h>
class CComponentsForm;
class CComponentsScrollBar;

View File

@@ -39,7 +39,7 @@
//frame around hint container as indent
#define W_FRAME 15
//frame color around hint/message box
#define HINTBOX_DEFAULT_FRAME_COLOR COL_MENUCONTENT_PLUS_6
#define HINTBOX_DEFAULT_FRAME_COLOR COL_FRAME
//! Sub class of CComponentsWindow. Shows a window as a hintbox with text and optional icon beside of text.
/*!