mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
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:
@@ -40,10 +40,8 @@ CCDraw::CCDraw() : COSDFader(g_settings.theme.menu_Content_alpha)
|
|||||||
col_body = col_body_old = COL_MENUCONTENT_PLUS_0;
|
col_body = col_body_old = COL_MENUCONTENT_PLUS_0;
|
||||||
col_shadow = col_shadow_old = COL_SHADOW_PLUS_0;
|
col_shadow = col_shadow_old = COL_SHADOW_PLUS_0;
|
||||||
col_frame = col_frame_old = COL_FRAME_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 = fr_thickness_old = 0;
|
||||||
fr_thickness_sel = fr_thickness_sel_old = 3;
|
|
||||||
|
|
||||||
corner_type = corner_type_old = CORNER_ALL;
|
corner_type = corner_type_old = CORNER_ALL;
|
||||||
corner_rad = corner_rad_old = 0;
|
corner_rad = corner_rad_old = 0;
|
||||||
@@ -116,11 +114,6 @@ inline bool CCDraw::applyDimChanges()
|
|||||||
fr_thickness_old = fr_thickness;
|
fr_thickness_old = fr_thickness;
|
||||||
ret = true;
|
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){
|
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);
|
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;
|
shadow_w_old = shadow_w;
|
||||||
@@ -158,11 +151,6 @@ inline bool CCDraw::applyColChanges()
|
|||||||
col_frame_old = col_frame;
|
col_frame_old = col_frame;
|
||||||
ret = true;
|
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){
|
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);
|
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;
|
cc_body_gradient_enable_old = cc_body_gradient_enable;
|
||||||
@@ -218,13 +206,10 @@ inline void CCDraw::setWidth(const int& w)
|
|||||||
width = w;
|
width = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCDraw::setFrameThickness(const int& thickness, const int& thickness_sel)
|
void CCDraw::setFrameThickness(const int& thickness)
|
||||||
{
|
{
|
||||||
fr_thickness = thickness;
|
fr_thickness = thickness;
|
||||||
|
|
||||||
if (fr_thickness_sel != thickness_sel)
|
|
||||||
fr_thickness_sel = thickness_sel;
|
|
||||||
|
|
||||||
//ensure enabled frame if frame width > 0
|
//ensure enabled frame if frame width > 0
|
||||||
cc_enable_frame = false;
|
cc_enable_frame = false;
|
||||||
if (fr_thickness)
|
if (fr_thickness)
|
||||||
|
@@ -67,13 +67,9 @@ class CCDraw : public COSDFader, public CComponentsSignals
|
|||||||
fb_pixel_t col_shadow, col_shadow_old;
|
fb_pixel_t col_shadow, col_shadow_old;
|
||||||
///property: color of frame
|
///property: color of frame
|
||||||
fb_pixel_t col_frame, col_frame_old;
|
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()
|
///property: frame thickness, see also setFrameThickness()
|
||||||
int fr_thickness, fr_thickness_old;
|
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
|
///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;
|
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;}
|
virtual void getDimensions(int* xpos, int* ypos, int* w, int* h){*xpos=x; *ypos=y; *w=width; *h=height;}
|
||||||
|
|
||||||
///set frame thickness
|
///set frame thickness
|
||||||
virtual void setFrameThickness(const int& thickness, const int& thickness_sel = 3);
|
virtual void setFrameThickness(const int& thickness);
|
||||||
///return of frame thickness
|
///return of frame thickness
|
||||||
virtual int getFrameThickness(){return fr_thickness;}
|
virtual int getFrameThickness(){return fr_thickness;}
|
||||||
///set frame color
|
///set frame color
|
||||||
virtual void setColorFrame(fb_pixel_t color){col_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;}
|
virtual void set2ndColor(fb_pixel_t col_2nd){cc_body_gradient_2nd_col = col_2nd;}
|
||||||
|
|
||||||
///get frame color
|
///get frame color
|
||||||
|
@@ -188,7 +188,7 @@ void CComponentsButton::initCaption()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//set basic properties
|
//set basic properties
|
||||||
int w_frame = max(fr_thickness, fr_thickness_sel);
|
int w_frame = fr_thickness;
|
||||||
if (cc_btn_capt_obj){
|
if (cc_btn_capt_obj){
|
||||||
//position and size
|
//position and size
|
||||||
int x_cap = w_frame;
|
int x_cap = w_frame;
|
||||||
|
@@ -140,7 +140,7 @@ void CComponentsScrollBar::initSegments()
|
|||||||
//init segment container
|
//init segment container
|
||||||
if (sb_segments_obj == NULL){
|
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 = 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);
|
sb_segments_obj->setAppendOffset(0, 3);
|
||||||
}else
|
}else
|
||||||
sb_segments_obj->setDimensionsAll(CC_CENTERED, CC_APPEND, w_seg, h_seg_obj);
|
sb_segments_obj->setDimensionsAll(CC_CENTERED, CC_APPEND, w_seg, h_seg_obj);
|
||||||
|
@@ -72,16 +72,11 @@ void CComponentsItem::paintInit(bool do_save_bg)
|
|||||||
is_painted = false; //force repaint if required
|
is_painted = false; //force repaint if required
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
//calculate current needed frame thickeness and color, if item selected or not
|
||||||
if (cc_item_selected){
|
fb_pixel_t col_frame_cur = col_frame;
|
||||||
col_frame_cur = col_frame_sel;
|
int th = fr_thickness;
|
||||||
th = max(fr_thickness_sel, fr_thickness);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (v_fbdata.empty()){
|
||||||
//calculate current needed corner radius for body box, depends of frame thickness
|
//calculate current needed corner radius for body box, depends of frame thickness
|
||||||
int rad = (corner_rad>th) ? corner_rad-th : corner_rad;
|
int rad = (corner_rad>th) ? corner_rad-th : corner_rad;
|
||||||
int sw = (shadow) ? shadow_w : 0;
|
int sw = (shadow) ? shadow_w : 0;
|
||||||
@@ -136,6 +131,7 @@ void CComponentsItem::paintInit(bool do_save_bg)
|
|||||||
|
|
||||||
//body box
|
//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},
|
{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
|
//body frame
|
||||||
{true, CC_FBDATA_TYPE_FRAME, ix, iy, width, height, col_frame_cur, corner_rad, corner_type, th, NULL, NULL, NULL, false}
|
{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;
|
continue;
|
||||||
v_fbdata.push_back(fbdata[i]);
|
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);
|
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);
|
paintFbItems(do_save_bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,3 +247,11 @@ void CComponentsItem::setFocus(bool focus)
|
|||||||
}
|
}
|
||||||
cc_has_focus = 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;
|
||||||
|
}
|
||||||
|
@@ -105,8 +105,14 @@ class CComponentsItem : public CComponents
|
|||||||
///syncronizes item colors with current color settings if required, NOTE: overwrites internal values!
|
///syncronizes item colors with current color settings if required, NOTE: overwrites internal values!
|
||||||
virtual void syncSysColors();
|
virtual void syncSysColors();
|
||||||
|
|
||||||
///set select mode, see also col_frame_sel
|
///set select mode
|
||||||
virtual void setSelected(bool selected){cc_item_selected = selected;};
|
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
|
///set enable mode, see also cc_item_enabled
|
||||||
virtual void setEnable(bool enabled){cc_item_enabled = enabled;};
|
virtual void setEnable(bool enabled){cc_item_enabled = enabled;};
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
#include <system/localize.h>
|
#include <system/localize.h>
|
||||||
#include <driver/fontrenderer.h>
|
#include <driver/fontrenderer.h>
|
||||||
#include <driver/rcinput.h>
|
#include <driver/rcinput.h>
|
||||||
|
#include <gui/color_custom.h>
|
||||||
|
|
||||||
class CComponentsForm;
|
class CComponentsForm;
|
||||||
class CComponentsScrollBar;
|
class CComponentsScrollBar;
|
||||||
|
@@ -39,7 +39,7 @@
|
|||||||
//frame around hint container as indent
|
//frame around hint container as indent
|
||||||
#define W_FRAME 15
|
#define W_FRAME 15
|
||||||
//frame color around hint/message box
|
//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.
|
//! Sub class of CComponentsWindow. Shows a window as a hintbox with text and optional icon beside of text.
|
||||||
/*!
|
/*!
|
||||||
|
Reference in New Issue
Block a user