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

View File

@@ -42,6 +42,12 @@ class CComponentsScrollBar : public CComponentsFrmChain
///names of navi icons ///names of navi icons
std::string sb_up_icon, sb_down_icon; 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 ///count of segments
int sb_segments_count; int sb_segments_count;
@@ -59,7 +65,7 @@ class CComponentsScrollBar : public CComponentsFrmChain
///init all items ///init all items
void initCCItems(); 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: public:
/**Class constructor to generate individual scrollbar objects /**Class constructor to generate individual scrollbar objects
@@ -73,9 +79,11 @@ class CComponentsScrollBar : public CComponentsFrmChain
* usual paraemters: * usual paraemters:
* @param[in] parent optional, exepts type pointer to a parent CComponentsForm object, default NULL * @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] 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_frame optional, exepts type fb_pixel_t, default COL_SCROLLBAR
* @param[in] color_body optional, exepts type fb_pixel_t, default COL_SCROLLBAR_PASSIVE_PLUS_0 * @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_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, CComponentsScrollBar( const int &x_pos,
const int &y_pos, const int &y_pos,
@@ -84,9 +92,11 @@ class CComponentsScrollBar : public CComponentsFrmChain
const int& count = 1, const int& count = 1,
CComponentsForm *parent = NULL, CComponentsForm *parent = NULL,
int shadow_mode = CC_SHADOW_OFF, int shadow_mode = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_SCROLLBAR_ACTIVE_PLUS_0, fb_pixel_t color_frame = COL_SCROLLBAR,
fb_pixel_t color_body = COL_SCROLLBAR_PASSIVE_PLUS_0, fb_pixel_t color_body = COL_SCROLLBAR,
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); 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 // ~CComponentsScrollBar(); //inherited from CComponentsForm
/**Set current page number /**Set current page number
@@ -123,6 +133,16 @@ class CComponentsScrollBar : public CComponentsFrmChain
* @see setSegmentCount() * @see setSegmentCount()
*/ */
int getSegmentCount(){return sb_segments_count;} 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 /**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_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_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_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, void paintScrollBar( const int &x_pos,
const int &y_pos, const int &y_pos,
@@ -149,8 +171,10 @@ void paintScrollBar( const int &x_pos,
const int& count, const int& count,
const int& current_num, const int& current_num,
int shadow_mode = CC_SHADOW_OFF, int shadow_mode = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_SCROLLBAR_ACTIVE_PLUS_0, fb_pixel_t color_frame = COL_SCROLLBAR,
fb_pixel_t color_body = COL_SCROLLBAR_PASSIVE_PLUS_0, fb_pixel_t color_body = COL_SCROLLBAR,
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); 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 #endif