mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 17:01:15 +02:00
Merge branch 'master' into pu/mp
This commit is contained in:
@@ -35,8 +35,8 @@ CCDraw::CCDraw() : COSDFader(g_settings.theme.menu_Content_alpha)
|
||||
{
|
||||
frameBuffer = CFrameBuffer::getInstance();
|
||||
|
||||
x = cc_xr = x_old = 0;
|
||||
y = cc_yr = y_old = 0;
|
||||
x = cc_xr = cc_xr_old = x_old = 0;
|
||||
y = cc_yr = cc_yr_old = y_old = 0;
|
||||
height = height_old = CC_HEIGHT_MIN;
|
||||
width = width_old = CC_WIDTH_MIN;
|
||||
|
||||
@@ -95,14 +95,16 @@ CCDraw::~CCDraw()
|
||||
inline bool CCDraw::applyPosChanges()
|
||||
{
|
||||
bool ret = false;
|
||||
if (x != x_old){
|
||||
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], Pos changes x %d != x_old %d...\033[0m\n", __func__, __LINE__, x, x_old);
|
||||
if (x != x_old || cc_xr != cc_xr_old){
|
||||
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], Pos changes x %d != x_old %d... [cc_xr = %d cc_xr_old = %d]\033[0m\n", __func__, __LINE__, x, x_old, cc_xr, cc_xr_old);
|
||||
x_old = x;
|
||||
cc_xr_old = cc_xr;
|
||||
ret = true;
|
||||
}
|
||||
if (y != y_old){
|
||||
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], Pos changes y %d != y_old %d...\033[0m\n", __func__, __LINE__, y, y_old);
|
||||
if (y != y_old || cc_yr != cc_yr_old){
|
||||
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], Pos changes y %d != y_old %d... [cc_yr = %d cc_yr_old = %d]\033[0m\n", __func__, __LINE__, y, y_old, cc_yr, cc_yr_old);
|
||||
y_old = y;
|
||||
cc_yr_old = cc_yr;
|
||||
ret = true;
|
||||
}
|
||||
|
||||
|
@@ -62,9 +62,9 @@ class CCDraw : public COSDFader, public CComponentsSignals
|
||||
///property: y-position on screen, to alter setPos() or setDimensionsAll(), see also defines CC_APPEND, CC_CENTERED
|
||||
int y, y_old;
|
||||
///property: contains real x-position on screen
|
||||
int cc_xr;
|
||||
int cc_xr, cc_xr_old;
|
||||
///property: contains real y-position on screen
|
||||
int cc_yr;
|
||||
int cc_yr, cc_yr_old;
|
||||
///property: height-dimension on screen, to alter with setHeight() or setDimensionsAll()
|
||||
int height, height_old;
|
||||
///property: width-dimension on screen, to alter with setWidth() or setDimensionsAll()
|
||||
@@ -184,17 +184,6 @@ class CCDraw : public COSDFader, public CComponentsSignals
|
||||
///to set the real screen position, look at setRealPos()
|
||||
virtual void setPos(const int& xpos, const int& ypos){setXPos(xpos); setYPos(ypos);}
|
||||
|
||||
///sets real x position on screen. Use this, if item is added to a parent form
|
||||
virtual void setRealXPos(const int& xr){cc_xr = xr;}
|
||||
///sets real y position on screen. Use this, if item is added to a parent form
|
||||
virtual void setRealYPos(const int& yr){cc_yr = yr;}
|
||||
///sets real x and y position on screen at once. Use this, if item is added to a parent form
|
||||
virtual void setRealPos(const int& xr, const int& yr){cc_xr = xr; cc_yr = yr;}
|
||||
///get real x-position on screen. Use this, if item contains own render methods and item is bound to a form
|
||||
virtual int getRealXPos(){return cc_xr;}
|
||||
///get real y-position on screen. Use this, if item contains own render methods and item is bound to a form
|
||||
virtual int getRealYPos(){return cc_yr;}
|
||||
|
||||
///set height of component on screen
|
||||
virtual void setHeight(const int& h);
|
||||
///set width of component on screen
|
||||
|
@@ -257,6 +257,16 @@ CComponentsItem* CComponentsForm::getCCItem(const uint& cc_item_id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CComponentsItem* CComponentsForm::getPrevCCItem(CComponentsItem* current_cc_item)
|
||||
{
|
||||
return getCCItem(getCCItemId(current_cc_item) - 1);
|
||||
}
|
||||
|
||||
CComponentsItem* CComponentsForm::getNextCCItem(CComponentsItem* current_cc_item)
|
||||
{
|
||||
return getCCItem(getCCItemId(current_cc_item) + 1);
|
||||
}
|
||||
|
||||
void CComponentsForm::replaceCCItem(const uint& cc_item_id, CComponentsItem* new_cc_Item)
|
||||
{
|
||||
if (!v_cc_items.empty()){
|
||||
@@ -685,3 +695,21 @@ bool CComponentsForm::enableColBodyGradient(const int& enable_mode, const fb_pix
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int CComponentsForm::getUsedDY()
|
||||
{
|
||||
int y_res = 0;
|
||||
for (size_t i= 0; i< v_cc_items.size(); i++)
|
||||
y_res = max(v_cc_items[i]->getYPos() + v_cc_items[i]->getHeight(), y_res);
|
||||
|
||||
return y_res;
|
||||
}
|
||||
|
||||
int CComponentsForm::getUsedDX()
|
||||
{
|
||||
int x_res = 0;
|
||||
for (size_t i= 0; i< v_cc_items.size(); i++)
|
||||
x_res = max(v_cc_items[i]->getXPos() + v_cc_items[i]->getWidth(), x_res);
|
||||
|
||||
return x_res;
|
||||
}
|
||||
|
@@ -106,8 +106,39 @@ class CComponentsForm : public CComponentsItem
|
||||
virtual void replaceCCItem(CComponentsItem* old_cc_Item, CComponentsItem* new_cc_Item);
|
||||
virtual void exchangeCCItem(const uint& item_id_a, const uint& item_id_b);
|
||||
virtual void exchangeCCItem(CComponentsItem* item_a, CComponentsItem* item_b);
|
||||
virtual int getCCItemId(CComponentsItem* cc_Item);
|
||||
virtual CComponentsItem* getCCItem(const uint& cc_item_id);
|
||||
|
||||
/**Function to get current item id from passed item.
|
||||
* @param[in] cc_Item
|
||||
* @li CComponentsItem*
|
||||
* @return
|
||||
* int, in case of not found item returns -1
|
||||
*/
|
||||
int getCCItemId(CComponentsItem* cc_Item);
|
||||
|
||||
/**Function to get current item from item collection.
|
||||
* @param[in] cc_item_id
|
||||
* @li item id as unsigned int
|
||||
* @return
|
||||
* CComponentsItem*, in case of not found item returns NULL
|
||||
*/
|
||||
CComponentsItem* getCCItem(const uint& cc_item_id);
|
||||
|
||||
/**Function to get previous item from item collection.
|
||||
* @param[in] current_cc_item
|
||||
* @li CComponentsItem*
|
||||
* @return
|
||||
* CComponentsItem*, in case of not found item returns NULL
|
||||
*/
|
||||
CComponentsItem* getPrevCCItem(CComponentsItem* current_cc_item);
|
||||
|
||||
/**Function to get next item from item collection.
|
||||
* @param[in] current_cc_item
|
||||
* @li CComponentsItem*
|
||||
* @return
|
||||
* CComponentsItem*, in case of not found item returns NULL
|
||||
*/
|
||||
CComponentsItem* getNextCCItem(CComponentsItem* current_cc_item);
|
||||
|
||||
virtual void paintCCItems();
|
||||
|
||||
///clean up and deallocate existant items from v_cc_items at once
|
||||
@@ -152,6 +183,31 @@ class CComponentsForm : public CComponentsItem
|
||||
virtual void setScrollBarWidth(const int& scrollbar_width){w_sb = scrollbar_width;};
|
||||
///returns id of selected item, return value as int, returns -1: if is nothing selected
|
||||
virtual int getSelectedItem();
|
||||
|
||||
/**Function to get consumed space of items inside form in y direction.
|
||||
* @return
|
||||
* int, used lines
|
||||
*/
|
||||
int getUsedDY();
|
||||
|
||||
/**Function to get consumed space of items inside form in x direction.
|
||||
* @return
|
||||
* int, used lines
|
||||
*/
|
||||
int getUsedDX();
|
||||
|
||||
/**Function to get free usable space of items inside form in y direction.
|
||||
* @return
|
||||
* int, free lines
|
||||
*/
|
||||
int getFreeDY(){return height - getUsedDY();}
|
||||
|
||||
/**Function to get free usable space of items inside form in x direction.
|
||||
* @return
|
||||
* int, free lines
|
||||
*/
|
||||
int getFreeDX(){return width - getUsedDX();}
|
||||
|
||||
///returns pointer to selected item, return value as CComponentsItem*, returns NULL: if is nothing selected
|
||||
virtual CComponentsItem* getSelectedItemObject();
|
||||
///select a definied item, parameter1 as size_t
|
||||
|
@@ -273,6 +273,7 @@ void CComponentsHeader::initIcon()
|
||||
|
||||
void CComponentsHeader::initLogo()
|
||||
{
|
||||
// init logo with required height and logo
|
||||
int h_logo = cch_logo.dy_max == -1 ? height - 2*OFFSET_INNER_MIN : cch_logo.dy_max;
|
||||
|
||||
if(!cch_logo_obj)
|
||||
@@ -291,70 +292,71 @@ void CComponentsHeader::initLogo()
|
||||
h_logo = dy_orig;
|
||||
}
|
||||
|
||||
//cch_logo_obj->setWidth(1, true);
|
||||
// manage logo position
|
||||
if (cch_logo_obj->hasLogo()){
|
||||
cch_logo_obj->setHeight(h_logo, true);
|
||||
|
||||
// set id of logo item depends of neighbor items
|
||||
/* Detect next and previous items,
|
||||
* current item is logo item.
|
||||
*/
|
||||
int logo_id = getCCItemId(cch_logo_obj);
|
||||
int prev_id = logo_id - 1;
|
||||
CComponentsItem *prev_item = getCCItem((cch_caption_align & CC_TITLE_RIGHT) ? logo_id - 2 : logo_id - 1);
|
||||
CComponentsItem *next_item = getCCItem((cch_caption_align & CC_TITLE_RIGHT) ? logo_id - 1 : logo_id + 1);
|
||||
|
||||
//right end
|
||||
int x_logo_right = width - cch_logo_obj->getWidth();
|
||||
if (!(cch_caption_align & CC_TITLE_RIGHT)){
|
||||
if (cch_btn_obj)
|
||||
x_logo_right -= cch_btn_obj->getWidth();
|
||||
if (cch_cl_obj)
|
||||
x_logo_right -= cch_cl_obj->getWidth();
|
||||
}else{
|
||||
if (cch_icon_obj)
|
||||
x_logo_right += cch_icon_obj->getWidth();
|
||||
/*
|
||||
* FIXME: Workaround to fix next item in case of wrong order of items.
|
||||
*/
|
||||
if (next_item){
|
||||
if (next_item->getItemType() == CC_ITEMTYPE_FRM_ICONFORM)
|
||||
next_item = cch_cl_obj;
|
||||
}
|
||||
|
||||
//left end
|
||||
int x_logo_left = cch_offset;
|
||||
if (!(cch_caption_align & CC_TITLE_RIGHT))
|
||||
x_logo_left = getCCItem(prev_id) ? getCCItem(prev_id)->getXPos() + getCCItem(prev_id)->getWidth() : 0;
|
||||
else
|
||||
if (cch_icon_obj)
|
||||
x_logo_left += cch_icon_obj->getWidth();
|
||||
/*
|
||||
* Adjust usable space for logo.
|
||||
*/
|
||||
int x_logo_left = prev_item ? prev_item->getXPos() + prev_item->getWidth() : cch_offset;
|
||||
int x_logo_right = next_item ? next_item->getXPos() : width - cch_offset;
|
||||
int logo_space = x_logo_right - x_logo_left;
|
||||
|
||||
//calculate available space
|
||||
int logo_space = x_logo_right + cch_logo_obj->getWidth() - x_logo_left;
|
||||
|
||||
//reduce logo width if logo space too small
|
||||
/*
|
||||
* Reduce logo width if logo space too small
|
||||
* and adjust logo new width if required.
|
||||
*/
|
||||
int w_logo = min(cch_logo_obj->getWidth(), logo_space);
|
||||
cch_logo_obj->setWidth(w_logo, true);
|
||||
|
||||
//set final logo position
|
||||
int x_logo = 0;
|
||||
if (cch_logo.Align & CC_LOGO_RIGHT){
|
||||
if (cch_caption_align & CC_TITLE_RIGHT){
|
||||
if (cch_text_obj)
|
||||
x_logo = cch_text_obj->getXPos() - cch_logo_obj->getWidth();
|
||||
}else
|
||||
x_logo = x_logo_right;
|
||||
}
|
||||
/*
|
||||
* Adjust logo x position depends of align parameters.
|
||||
*/
|
||||
int x_logo = x_logo_left;
|
||||
if (cch_logo.Align & CC_LOGO_RIGHT)
|
||||
x_logo = x_logo_right - w_logo;
|
||||
|
||||
if (cch_logo.Align & CC_LOGO_LEFT)
|
||||
x_logo = x_logo_left;
|
||||
|
||||
if (cch_logo.Align & CC_LOGO_CENTER){
|
||||
x_logo = width/2 - cch_logo_obj->getWidth()/2;
|
||||
//fallback if adjacent item and logo are overlapping
|
||||
if (!(cch_caption_align & CC_TITLE_RIGHT)){
|
||||
if (getCCItem(prev_id)){
|
||||
int x_tmp = x_logo_left + logo_space/2 - cch_logo_obj->getWidth()/2;
|
||||
if (x_logo <= x_logo_left)
|
||||
x_logo = x_tmp;
|
||||
}
|
||||
}else{
|
||||
if (cch_text_obj){
|
||||
if (x_logo + cch_logo_obj->getWidth() >= cch_text_obj->getXPos()){
|
||||
x_logo = (x_logo_left + cch_text_obj->getXPos())/2 - cch_logo_obj->getWidth()/2;
|
||||
}
|
||||
}
|
||||
x_logo = logo_space/2 - w_logo/2;
|
||||
/*
|
||||
* We are using centered mode as default,
|
||||
* but we must notice possible overlapp
|
||||
* with previous or next item.
|
||||
*/
|
||||
if (cch_caption_align & CC_TITLE_LEFT){
|
||||
int left_tag = prev_item->getXPos() + prev_item->getWidth();
|
||||
if (x_logo <= left_tag)
|
||||
x_logo = left_tag + logo_space/2 - w_logo/2;
|
||||
}
|
||||
|
||||
if (cch_caption_align & CC_TITLE_RIGHT){
|
||||
if (x_logo + w_logo >= next_item->getXPos())
|
||||
x_logo = next_item->getXPos() - logo_space/2 - w_logo/2;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Finally set logo x position
|
||||
*/
|
||||
cch_logo_obj->setXPos(x_logo);
|
||||
cch_logo_obj->setYPos(height/2 - cch_logo_obj->getHeight()/2);
|
||||
}
|
||||
@@ -505,6 +507,7 @@ void CComponentsHeader::initClock()
|
||||
if (cch_cl_obj == NULL){
|
||||
dprintf(DEBUG_DEBUG, "[CComponentsHeader]\n [%s - %d] init clock...\n", __func__, __LINE__);
|
||||
cch_cl_obj = new CComponentsFrmClock(0, cch_items_y, cch_font, cch_cl_format, NULL, false, 1, this);
|
||||
cch_cl_obj->disableForceSegmentPaint();
|
||||
cch_cl_obj->doPaintBg(false);
|
||||
}
|
||||
|
||||
@@ -547,7 +550,7 @@ void CComponentsHeader::initCaption()
|
||||
}
|
||||
|
||||
//calc width of text object in header
|
||||
cc_text_w = width-cch_text_x-cch_offset;
|
||||
cc_text_w = width-cch_text_x/*-cch_offset*/;
|
||||
|
||||
//context buttons
|
||||
int buttons_w = 0;
|
||||
@@ -601,15 +604,15 @@ void CComponentsHeader::initCaption()
|
||||
int w_free = cc_text_w;
|
||||
|
||||
//recalc caption width
|
||||
cc_text_w = min(cc_text_w, cch_font->getRenderWidth(cch_text)+ OFFSET_INNER_MID);
|
||||
cc_text_w = min(cc_text_w, cch_font->getRenderWidth(cch_text)) + cch_offset;
|
||||
|
||||
//set alignment of text item in dependency from text alignment
|
||||
if (cch_caption_align & CC_TITLE_CENTER)
|
||||
cch_text_x = width/2 - cc_text_w/2;
|
||||
|
||||
if (cch_caption_align & CC_TITLE_RIGHT){
|
||||
if (cch_caption_align & CC_TITLE_RIGHT){ //FIXME: does not work correct with some conditions, but still not used at the moment
|
||||
cch_text_x += w_free;
|
||||
cch_text_x -= max(cc_text_w, cch_font->getRenderWidth(cch_text)+ OFFSET_INNER_MID);
|
||||
cch_text_x -= max(cc_text_w, cch_font->getRenderWidth(cch_text));
|
||||
}
|
||||
|
||||
//assign general properties
|
||||
|
@@ -32,7 +32,7 @@
|
||||
#include "cc_frm_clock.h"
|
||||
#include <driver/colorgradient.h>
|
||||
|
||||
#define DEFAULT_LOGO_ALIGN CCHeaderTypes::CC_LOGO_CENTER
|
||||
#define DEFAULT_LOGO_ALIGN CCHeaderTypes::CC_LOGO_RIGHT
|
||||
#define DEFAULT_TITLE_ALIGN CCHeaderTypes::CC_TITLE_LEFT
|
||||
|
||||
class CCHeaderTypes
|
||||
|
@@ -153,7 +153,7 @@ void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const
|
||||
ccw_align_mode = DEFAULT_TITLE_ALIGN;
|
||||
ccw_show_l_sideber = false;
|
||||
ccw_show_r_sideber = false;
|
||||
ccw_w_sidebar = 40;
|
||||
ccw_w_sidebar = SIDEBAR_WIDTH;
|
||||
ccw_col_head = COL_MENUHEAD_PLUS_0;
|
||||
ccw_col_head_text = COL_MENUHEAD_TEXT;
|
||||
ccw_col_footer = COL_MENUFOOT_PLUS_0;
|
||||
|
@@ -265,14 +265,14 @@ void CComponentsItem::setXPos(const int& xpos)
|
||||
{
|
||||
CCDraw::setXPos(xpos);
|
||||
if (cc_parent)
|
||||
cc_xr = cc_parent->getXPos() + x;
|
||||
cc_xr = cc_parent->getRealXPos() + x;
|
||||
}
|
||||
|
||||
void CComponentsItem::setYPos(const int& ypos)
|
||||
{
|
||||
CCDraw::setYPos(ypos);
|
||||
if (cc_parent)
|
||||
cc_yr = cc_parent->getYPos() + y;
|
||||
cc_yr = cc_parent->getRealYPos() + y;
|
||||
}
|
||||
|
||||
void CComponentsItem::setXPosP(const uint8_t& xpos_percent)
|
||||
|
@@ -146,6 +146,17 @@ class CComponentsItem : public CComponents
|
||||
///set x and y position as percent value related to current parent form or screen dimensions at once
|
||||
virtual void setPosP(const uint8_t& xpos_percent, const uint8_t& ypos_percent);
|
||||
|
||||
///sets real x position on screen. Use this, if item is added to a parent form
|
||||
virtual void setRealXPos(const int& xr){cc_xr = xr;}
|
||||
///sets real y position on screen. Use this, if item is added to a parent form
|
||||
virtual void setRealYPos(const int& yr){cc_yr = yr;}
|
||||
///sets real x and y position on screen at once. Use this, if item is added to a parent form
|
||||
virtual void setRealPos(const int& xr, const int& yr){cc_xr = xr; cc_yr = yr;}
|
||||
///get real x-position on screen. Use this, if item contains own render methods and item is bound to a form
|
||||
virtual int getRealXPos(){return cc_parent ? cc_xr : x;}
|
||||
///get real y-position on screen. Use this, if item contains own render methods and item is bound to a form
|
||||
virtual int getRealYPos(){return cc_parent ? cc_yr : y;}
|
||||
|
||||
///do center item on screen or within a parent form, parameter along_mode assigns direction of centering
|
||||
virtual void setCenterPos(int along_mode = CC_ALONG_X | CC_ALONG_Y);
|
||||
|
||||
|
Reference in New Issue
Block a user