mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
CComponentsForm: add predefine CC_CENTERED for auto positions
This saves explicit position calculations to arrange items centered
This commit is contained in:
@@ -51,17 +51,17 @@ class CComponents
|
|||||||
///container: for frambuffer properties and pixel buffer
|
///container: for frambuffer properties and pixel buffer
|
||||||
std::vector<comp_fbdata_t> v_fbdata;
|
std::vector<comp_fbdata_t> 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;
|
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;
|
int y;
|
||||||
///property: contains real x-position on screen
|
///property: contains real x-position on screen
|
||||||
int cc_xr;
|
int cc_xr;
|
||||||
///property: contains real y-position on screen
|
///property: contains real y-position on screen
|
||||||
int cc_yr;
|
int cc_yr;
|
||||||
///property: height-dimension on screen
|
///property: height-dimension on screen, to alter with setHeight() or setDimensionsAll()
|
||||||
int height;
|
int height;
|
||||||
///property: width-dimension on screen
|
///property: width-dimension on screen, to alter with setWidth() or setDimensionsAll()
|
||||||
int width;
|
int width;
|
||||||
///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;
|
int corner_type;
|
||||||
|
@@ -309,23 +309,35 @@ void CComponentsForm::paintCCItems()
|
|||||||
int xpos = cc_item->getXPos();
|
int xpos = cc_item->getXPos();
|
||||||
int ypos = cc_item->getYPos();
|
int ypos = cc_item->getYPos();
|
||||||
|
|
||||||
//set required x-position to item
|
//set required x-position to item:
|
||||||
|
//append vertical
|
||||||
if (xpos == CC_APPEND){
|
if (xpos == CC_APPEND){
|
||||||
auto_x += append_h_offset;
|
auto_x += append_h_offset;
|
||||||
cc_item->setRealXPos(auto_x + xpos + 1);
|
cc_item->setRealXPos(auto_x + xpos + 1);
|
||||||
auto_x += w_item;
|
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{
|
else{
|
||||||
cc_item->setRealXPos(this_x + xpos);
|
cc_item->setRealXPos(this_x + xpos);
|
||||||
auto_x = (cc_item->getRealXPos() + w_item);
|
auto_x = (cc_item->getRealXPos() + w_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
//set required y-position to item
|
//set required y-position to item
|
||||||
|
//append hor
|
||||||
if (ypos == CC_APPEND){
|
if (ypos == CC_APPEND){
|
||||||
auto_y += append_v_offset;
|
auto_y += append_v_offset;
|
||||||
cc_item->setRealYPos(auto_y + ypos + 1);
|
cc_item->setRealYPos(auto_y + ypos + 1);
|
||||||
auto_y += h_item;
|
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{
|
else{
|
||||||
cc_item->setRealYPos(this_y + ypos);
|
cc_item->setRealYPos(this_y + ypos);
|
||||||
auto_y = (cc_item->getRealYPos() + h_item);
|
auto_y = (cc_item->getRealYPos() + h_item);
|
||||||
|
@@ -134,7 +134,12 @@ typedef struct comp_element_data_t
|
|||||||
#define CC_SAVE_SCREEN_NO false
|
#define CC_SAVE_SCREEN_NO false
|
||||||
|
|
||||||
#define CC_NO_INDEX -1
|
#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
|
#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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user