Merge branch 'master' into pu/mp

This commit is contained in:
svenhoefer
2017-04-22 16:13:02 +02:00
9 changed files with 264 additions and 76 deletions

View File

@@ -31,6 +31,9 @@
#include "cc_frm_header.h"
#include <system/debug.h>
#include <driver/fontrenderer.h>
#include <driver/pictureviewer/pictureviewer.h>
extern CPictureViewer * g_PicViewer;
using namespace std;
@@ -91,8 +94,8 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const
cc_item_type = CC_ITEMTYPE_FRM_HEADER;
clear();
cc_txt_save_screen = false;
x = x_old = x_pos;
y = y_old = y_pos;
x = cc_xr = x_old = x_pos;
y = cc_yr = y_old = y_pos;
//init header width
width = width_old = w == 0 ? frameBuffer->getScreenWidth(true) : w;
@@ -121,6 +124,11 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const
cch_text_obj = NULL;
cch_btn_obj = NULL;
cch_cl_obj = NULL;
cch_logo_obj = NULL;
cch_logo.Id = 0;
cch_logo.Name = "";
cch_logo.dy_max = -1;
cch_logo.Align = CC_LOGO_RIGHT;
cch_col_text = COL_MENUHEAD_TEXT;
cch_caption_align = CTextBox::NO_AUTO_LINEBREAK;
cch_items_y = CC_CENTERED;
@@ -264,6 +272,49 @@ void CComponentsHeader::initIcon()
}
}
void CComponentsHeader::initLogo()
{
cch_logo.dy_max = cch_logo.dy_max == -1 ? height - 2*OFFSET_INNER_SMALL : cch_logo.dy_max;
if(!cch_logo_obj)
cch_logo_obj = new CComponentsChannelLogoScalable(width/2, height/2 - cch_logo.dy_max/2, cch_logo.Name, cch_logo.Id, this);
else
cch_logo_obj->setChannel(cch_logo.Id, cch_logo.Name);
if (cch_logo_obj->hasLogo()){
cch_logo_obj->setHeight(cch_logo.dy_max, true);
// set id of logo item depends of neighbor items
int logo_id = getCCItemId(cch_logo_obj);
int next_id = logo_id + 1;
int prev_id = logo_id - 1;
//right end
int x_logo_right = getCCItem(next_id) ? getCCItem(next_id)->getXPos() - cch_logo_obj->getWidth() : width - cch_logo_obj->getWidth()-OFFSET_INNER_MID;
//left end
int x_logo_left = getCCItem(prev_id) ? getCCItem(prev_id)->getXPos() + getCCItem(prev_id)->getWidth() : 0;
//calculate available space
int logo_space = x_logo_right + cch_logo_obj->getWidth() - x_logo_left;
//reduce logo width if logo space too small
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)
x_logo = x_logo_right;
if (cch_logo.Align == CC_LOGO_LEFT)
x_logo = x_logo_left;
if (cch_logo.Align == CC_LOGO_CENTER)
x_logo = x_logo_left + logo_space/2 - cch_logo_obj->getWidth()/2;
cch_logo_obj->setXPos(x_logo);
cch_logo_obj->setYPos(height/2 - cch_logo_obj->getHeight()/2);
}
}
void CComponentsHeader::addContextButton(const std::string& button_name)
{
v_cch_btn.push_back(button_name);
@@ -505,6 +556,9 @@ void CComponentsHeader::initCaption()
if (cch_caption_align == CTextBox::CENTER)
cch_text_x = CC_CENTERED;
//recalc caption width
cc_text_w = min(cc_text_w, cch_font->getRenderWidth(cch_text)+ OFFSET_INNER_MID);
//assign general properties
cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, cc_text_w, height);
cch_text_obj->setColorBody(col_body);
@@ -548,6 +602,9 @@ void CComponentsHeader::initCCItems()
//init text
initCaption();
//init logo
initLogo();
}
void CComponentsHeader::paint(bool do_save_bg)

View File

@@ -36,9 +36,29 @@
/*!
CComponentsHeader provides prepared items like icon, caption and context button icons, mostly for usage in menues or simple windows
*/
class CComponentsHeader : public CComponentsForm, public CCTextScreen
{
public:
///logo position options
typedef enum
{
CC_LOGO_RIGHT ,
CC_LOGO_LEFT ,
CC_LOGO_CENTER
}cc_logo_alignment_t;
private:
///required logo data type
typedef struct cch_logo_t
{
uint64_t Id;
std::string Name;
int32_t dx_max;
int32_t dy_max;
cc_logo_alignment_t Align;
} cch_logo_struct_t;
///member: init genaral variables, parameters for mostly used properties
void initVarHeader( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& caption,
@@ -59,6 +79,11 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen
CComponentsIconForm * cch_btn_obj;
///object: clock object
CComponentsFrmClock * cch_cl_obj;
///object: logo object
CComponentsChannelLogoScalable * cch_logo_obj;
///attributes for logos
cch_logo_t cch_logo;
///property: caption text, see also setCaption()
std::string cch_text;
@@ -112,6 +137,9 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen
void initButtons();
///sub: init clock object
void initClock();
///sub: init logo object
void initLogo();
///int repaint slot
void initRepaintSlot();
@@ -275,6 +303,30 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen
///set color gradient on/off, returns true if gradient mode was changed
virtual bool enableColBodyGradient(const int& enable_mode, const fb_pixel_t& sec_color = 255 /*=COL_BACKGROUND*/, const int& direction = -1);
/**Methode to set channel logo into header body via id and/or channel name
* @param[in] channelId
* @li required channel id as uint64_t
* @param[in] channelIName
* @li required channel name as std::string
* @param[in] alignment
* @li optional alingment parameter as cc_logo_alignment_t (enum)\n
* Possible values are:\n
* CC_LOGO_RIGHT \n
* CC_LOGO_CENTER (default)\n
* CC_LOGO_RIGHT \n
* @param[in] dy
* @li optional logo height, default = -1 (auto)
*/
void setChannelLogo( const uint64_t& channelId,
const std::string& channelName,
cc_logo_alignment_t alignment = CC_LOGO_CENTER,
const int& dy = -1)
{cch_logo.Id = channelId; cch_logo.Name = channelName, cch_logo.Align = alignment, cch_logo.dy_max = dy; initCCItems();}
/**Methode to get channel logo object for direct access to its properties and methodes
* @return CComponentsChannelLogoScalable*
*/
CComponentsChannelLogoScalable* getChannelLogoObject(){return cch_logo_obj;}
};
//! Sub class of CComponentsHeader.

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,23 +186,38 @@ 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
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);
}
}
}
@@ -197,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

View File

@@ -128,9 +128,9 @@ void CComponentsPicture::setPicture(const char* picture_name)
void CComponentsPicture::setWidth(const int& w, bool keep_aspect)
{
CComponentsItem::setWidth(w);
if (w == width && keep_aspect == keep_dy_aspect)
return;
CComponentsItem::setWidth(w);
need_init = true;
do_scale = true;
keep_dy_aspect = keep_aspect;
@@ -139,9 +139,9 @@ void CComponentsPicture::setWidth(const int& w, bool keep_aspect)
void CComponentsPicture::setHeight(const int& h, bool keep_aspect)
{
CComponentsItem::setHeight(h);
if (h == height && keep_aspect == keep_dx_aspect)
return;
CComponentsItem::setHeight(h);
need_init = true;
do_scale = true;
keep_dx_aspect = keep_aspect;