CComponentsScrollBar: add missing attributes for different visual modes

This commit is contained in:
2017-04-21 22:47:23 +02:00
parent 89bda2d14f
commit 324ba258a0
2 changed files with 102 additions and 47 deletions

View File

@@ -32,29 +32,39 @@
using namespace std;
/* base schema
x,y
+-----------------+
|+---------------+|
||sb_up_obj ||
|| ||
|+---------------+|
|+---------------+|
||sb_segments_obj||
||+-------------+||
||| segment |||
||| id 0 |||
||| |||
||+-------------+||
||| segment |||
||| id 1 |||
||| |||
||+-------------+||
|+---------------+|
|+---------------+|
||sb_up_obj ||
|| ||
|+---------------+|
+-----------------+
x,y width (w)
/(x_pos, y_pos) ^
+---------------------+
| +-----------------+ |
| | sb_up_obj (icon)| |/color_frame
| | /\ | |
| +-----------------+ | |/color_shadow
| col_body | |
| |
| +-sb_segments_obj+ |
| | | |
| | +---segment---+ | |
| | | id 0 | | |
| | | active | | |
| | | color_select| | |
| | +-------------+ | |
| | append_y_offset | |
| | +---segment---+ | |
| | | id 1 | | |
| | | passive | | |
| | |color_passive| | |
| | +-------------+ | |
| | (count = 2) | |
| | other segments | |
| | are possible | |
| +-----------------+ |
| |
| +-----------------+ |
| | sb_up_obj (icon)| |
| | \/ | |
| +-----------------+ |
+---------------------+-> height (h)
*/
//sub class CComponentsScrollBar inherit from CComponentsFrmChain
@@ -64,13 +74,15 @@ CComponentsScrollBar::CComponentsScrollBar( const int &x_pos, const int &y_pos,
int shadow_mode,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow)
fb_pixel_t color_shadow,
fb_pixel_t color_select,
fb_pixel_t color_passive)
:CComponentsFrmChain(x_pos, y_pos, w, h, NULL, CC_DIR_Y, parent, shadow_mode, color_frame, color_body, color_shadow)
{
initVarSbForm(count);
initVarSbForm(count, color_select, color_passive);
}
void CComponentsScrollBar::initVarSbForm(const int& count)
void CComponentsScrollBar::initVarSbForm(const int& count, const fb_pixel_t& color_select, const fb_pixel_t& color_passive)
{
cc_item_type = CC_ITEMTYPE_FRM_SCROLLBAR;
fr_thickness = 0;
@@ -90,6 +102,10 @@ void CComponentsScrollBar::initVarSbForm(const int& count)
sb_segments_count = count;
sb_mark_id = 0;
sb_visual_enable = false;
sb_segment_col_sel = color_select;
sb_segment_col = color_passive;
initCCItems();
}
@@ -159,6 +175,8 @@ void CComponentsScrollBar::initSegments()
if (h_seg < 0)
h_seg = 0;
fb_pixel_t passive_col = sb_visual_enable ? sb_segment_col : col_body;
//create and add segments to segment container
for(u_int8_t i=0; i<sb_segments_count; i++){
CComponentsShapeSquare *item = new CComponentsShapeSquare(0, y_seg, w_seg, h_seg, sb_segments_obj, false);
@@ -168,26 +186,37 @@ void CComponentsScrollBar::initSegments()
//set color for marked id
if (sb_mark_id == id){
item->setColorBody(COL_SCROLLBAR_ACTIVE);
item->setColorBody(sb_segment_col_sel);
#if 0
item->enableColBodyGradient(CC_COLGRAD_COL_A_2_COL_B);
item->setColBodyGradient(CColorGradient::gradientDark2Light2Dark, CFrameBuffer::gradientHorizontal);
#endif
}
else{
item->setColorBody(COL_SCROLLBAR_PASSIVE);
item->setColorBody(passive_col);
#if 0
item->disableColBodyGradient();
#endif
}
}
//set corner types
if (sb_segments_obj->size() == 1){
sb_segments_obj->front()->setCorner(RADIUS_MIN, CORNER_ALL);
}else{
sb_segments_obj->front()->setCorner(RADIUS_MIN, CORNER_TOP);
sb_segments_obj->back()->setCorner(RADIUS_MIN, CORNER_BOTTOM);
//set different corner types for segments with possible conditions
if (passive_col == col_body){
item->setCorner(RADIUS_MIN, CORNER_ALL);
continue;
}else if (sb_segments_count == 1){
item->setCorner(RADIUS_MIN, CORNER_ALL);
break;
}else if(i == 0){
item->setCorner(RADIUS_MIN, CORNER_TOP);
continue;
}else if(i == sb_segments_count - 1){
item->setCorner(RADIUS_MIN, CORNER_BOTTOM);
break;
}else if((i > 0 && i < sb_segments_count - 1)){
item->setCorner(RADIUS_MIN, CORNER_NONE);
}else{
item->setCorner(RADIUS_MIN, CORNER_NONE);
}
}
}
@@ -201,9 +230,11 @@ void paintScrollBar( const int &x_pos,
int shadow_mode,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow)
fb_pixel_t color_shadow,
fb_pixel_t color_select,
fb_pixel_t color_passive)
{
CComponentsScrollBar scrollbar(x_pos, y_pos, w, h, count, NULL, shadow_mode, color_frame, color_body, color_shadow);
CComponentsScrollBar scrollbar(x_pos, y_pos, w, h, count, NULL, shadow_mode, color_frame, color_body, color_shadow, color_select, color_passive);
scrollbar.setMarkID(current_num);
scrollbar.paint0();
}

View File

@@ -42,6 +42,12 @@ class CComponentsScrollBar : public CComponentsFrmChain
///names of navi icons
std::string sb_up_icon, sb_down_icon;
///visualize count mode
bool sb_visual_enable;
///segment colors
fb_pixel_t sb_segment_col, sb_segment_col_sel;
///count of segments
int sb_segments_count;
@@ -55,11 +61,11 @@ class CComponentsScrollBar : public CComponentsFrmChain
///init segements
void initSegments();
///init all items
void initCCItems();
void initVarSbForm( const int& count);
void initVarSbForm( const int& count, const fb_pixel_t& color_select, const fb_pixel_t& color_passive);
public:
/**Class constructor to generate individual scrollbar objects
@@ -73,9 +79,11 @@ class CComponentsScrollBar : public CComponentsFrmChain
* usual paraemters:
* @param[in] parent optional, exepts type pointer to a parent CComponentsForm object, default NULL
* @param[in] shadow_mode optional, exepts type int defined by shadow mode enums, default CC_SHADOW_OFF
* @param[in] color_frame optional, exepts type fb_pixel_t, default COL_SCROLLBAR_ACTIVE_PLUS_0
* @param[in] color_body optional, exepts type fb_pixel_t, default COL_SCROLLBAR_PASSIVE_PLUS_0
* @param[in] color_frame optional, exepts type fb_pixel_t, default COL_SCROLLBAR
* @param[in] color_body optional, exepts type fb_pixel_t, default COL_SCROLLBAR
* @param[in] color_shadow optional, exepts type fb_pixel_t, default COL_SHADOW_PLUS_0
* @param[in] color_select optional, exepts type fb_pixel_t, default COL_SCROLLBAR_ACTIVE
* @param[in] color_passive optional, exepts type fb_pixel_t, default COL_SCROLLBAR_PASSIVE
*/
CComponentsScrollBar( const int &x_pos,
const int &y_pos,
@@ -84,9 +92,11 @@ class CComponentsScrollBar : public CComponentsFrmChain
const int& count = 1,
CComponentsForm *parent = NULL,
int shadow_mode = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_SCROLLBAR_ACTIVE_PLUS_0,
fb_pixel_t color_body = COL_SCROLLBAR_PASSIVE_PLUS_0,
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
fb_pixel_t color_frame = COL_SCROLLBAR,
fb_pixel_t color_body = COL_SCROLLBAR,
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0,
fb_pixel_t color_select = COL_SCROLLBAR_ACTIVE,
fb_pixel_t color_passive = COL_SCROLLBAR_PASSIVE);
// ~CComponentsScrollBar(); //inherited from CComponentsForm
/**Set current page number
@@ -123,6 +133,16 @@ class CComponentsScrollBar : public CComponentsFrmChain
* @see setSegmentCount()
*/
int getSegmentCount(){return sb_segments_count;}
/**Enable/disable vizualized count of possible scroll items
* @param[in] enable optional, exepts type bool.
* @note Default mode is disabled.
*/
void enableVisualize(bool enable = true){sb_visual_enable = enable;}
/**Disable vizualized count of possible scroll items
*/
void disableVisualize(){enableVisualize(false);}
};
/**Small and easy to apply scrollbar paint methode without expilcit object declaration
@@ -141,6 +161,8 @@ class CComponentsScrollBar : public CComponentsFrmChain
* @param[in] color_frame optional, exepts type fb_pixel_t, default COL_SCROLLBAR_ACTIVE_PLUS_0
* @param[in] color_body optional, exepts type fb_pixel_t, default COL_SCROLLBAR_PASSIVE_PLUS_0
* @param[in] color_shadow optional, exepts type fb_pixel_t, default COL_SHADOW_PLUS_0
* @param[in] color_select optional, exepts type fb_pixel_t, default COL_SCROLLBAR_ACTIVE
* @param[in] color_passive optional, exepts type fb_pixel_t, default COL_SCROLLBAR_PASSIVE
*/
void paintScrollBar( const int &x_pos,
const int &y_pos,
@@ -149,8 +171,10 @@ void paintScrollBar( const int &x_pos,
const int& count,
const int& current_num,
int shadow_mode = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_SCROLLBAR_ACTIVE_PLUS_0,
fb_pixel_t color_body = COL_SCROLLBAR_PASSIVE_PLUS_0,
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
fb_pixel_t color_frame = COL_SCROLLBAR,
fb_pixel_t color_body = COL_SCROLLBAR,
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0,
fb_pixel_t color_select = COL_SCROLLBAR_ACTIVE,
fb_pixel_t color_passive = COL_SCROLLBAR_PASSIVE);
#endif