diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h index fa7c455b7..dee9a91d3 100644 --- a/src/gui/components/cc.h +++ b/src/gui/components/cc.h @@ -51,17 +51,17 @@ class CComponents ///container: for frambuffer properties and pixel buffer std::vector v_fbdata; - ///property: x-position on screen + ///property: x-position on screen, to alter with setPos() or setDimensionsAll(), see also defines CC_APPEND, CC_CENTERED int x; - ///property: y-position on screen + ///property: y-position on screen, to alter setPos() or setDimensionsAll(), see also defines CC_APPEND, CC_CENTERED int y; ///property: contains real x-position on screen int cc_xr; ///property: contains real y-position on screen int cc_yr; - ///property: height-dimension on screen + ///property: height-dimension on screen, to alter with setHeight() or setDimensionsAll() int height; - ///property: width-dimension on screen + ///property: width-dimension on screen, to alter with setWidth() or setDimensionsAll() int width; ///property: has corners with definied type, types are defined in /driver/frambuffer.h, without effect, if corner_radius=0 int corner_type; diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index 16f9eb423..bb652a41e 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -309,23 +309,35 @@ void CComponentsForm::paintCCItems() int xpos = cc_item->getXPos(); int ypos = cc_item->getYPos(); - //set required x-position to item + //set required x-position to item: + //append vertical if (xpos == CC_APPEND){ auto_x += append_h_offset; cc_item->setRealXPos(auto_x + xpos + 1); auto_x += w_item; } + //positionize vertical centered + else if (xpos == CC_CENTERED){ + auto_x = width/2 - cc_item->getWidth()/2; + cc_item->setRealXPos(this_x + auto_x); + } else{ cc_item->setRealXPos(this_x + xpos); auto_x = (cc_item->getRealXPos() + w_item); } //set required y-position to item + //append hor if (ypos == CC_APPEND){ auto_y += append_v_offset; cc_item->setRealYPos(auto_y + ypos + 1); auto_y += h_item; } + //positionize hor centered + else if (ypos == CC_CENTERED){ + auto_y = height/2 - cc_item->getHeight()/2; + cc_item->setRealYPos(this_y + auto_y); + } else{ cc_item->setRealYPos(this_y + ypos); auto_y = (cc_item->getRealYPos() + h_item); diff --git a/src/gui/components/cc_types.h b/src/gui/components/cc_types.h index 76c4b12b6..55011123c 100644 --- a/src/gui/components/cc_types.h +++ b/src/gui/components/cc_types.h @@ -134,7 +134,12 @@ typedef struct comp_element_data_t #define CC_SAVE_SCREEN_NO false #define CC_NO_INDEX -1 + +///predefined parameters for auto positionizing of embedded items inside a parent form +///CC_APPEND used for x or y position or booth. An item with this parameter will paint automatically arranged side by side #define CC_APPEND -1 +///CC CENTERED used for x or y position or booth. An item with this parameter will paint automatically centered +#define CC_CENTERED -2