Merge remote-tracking branch 'uncool/cst-next'

This need buildfixes and some functional updates...
This commit is contained in:
Stefan Seyfried
2015-12-13 17:41:55 +01:00
320 changed files with 21291 additions and 13199 deletions

View File

@@ -65,8 +65,11 @@ CComponents::CComponents() : COSDFader(g_settings.theme.menu_Content_alpha)
frameBuffer = CFrameBuffer::getInstance();
v_fbdata.clear();
saved_screen.pixbuf = NULL;
cc_body_gradientBuf = NULL;
col_body_gradient = false;
cc_body_gradient_c2c = true;
cc_body_gradient_2nd_col= COL_MENUCONTENT_PLUS_0;
cc_gradientData.gradientBuf = NULL;
cc_gradientData.boxBuf = NULL;
}
CComponents::~CComponents()
@@ -74,8 +77,10 @@ CComponents::~CComponents()
hide();
clearSavedScreen();
clearFbData();
if (cc_body_gradientBuf)
free(cc_body_gradientBuf);
if (cc_gradientData.gradientBuf)
free(cc_gradientData.gradientBuf);
if (cc_gradientData.boxBuf)
cs_free_uncached(cc_gradientData.boxBuf);
}
void CComponents::clearSavedScreen()
@@ -195,7 +200,7 @@ void CComponents::paintFbItems(bool do_save_bg)
//calculate current shadow width depends of current corner_rad
sw_cur = max(2*v_fbdata[i].r, sw);
}
if (cc_allow_paint){
if (cc_allow_paint && !is_painted){
// shadow right
frameBuffer->paintBoxRel(x_sh, v_fbdata[i].y, sw_cur, v_fbdata[i].dy-sw_cur, v_fbdata[i].color, v_fbdata[i].r, corner_type & CORNER_TOP_RIGHT);
// shadow bottom
@@ -293,11 +298,13 @@ void CComponents::clearFbData()
if (v_fbdata[i].pixbuf)
delete[] v_fbdata[i].pixbuf;
#if 0
if (v_fbdata[i].data && (v_fbdata[i].fbdata_type == CC_FBDATA_TYPE_BOX)) {
gradientData_t *gradientData = static_cast<gradientData_t*> (v_fbdata[i].data);
if (gradientData->boxBuf)
cs_free_uncached(gradientData->boxBuf);
}
#endif
}
v_fbdata.clear();
}
@@ -323,5 +330,5 @@ void CComponents::setFrameThickness(const int& thickness, const int& thickness_s
void CComponents::enableColBodyGradient(bool do_paint_gradient)
{
col_body_gradient = g_settings.gradiant ? do_paint_gradient : false;
col_body_gradient = do_paint_gradient;
}

View File

@@ -72,6 +72,8 @@ class CComponents : public CComponentsSignals, public COSDFader
void *cc_tag;
///property: color of body
fb_pixel_t col_body;
fb_pixel_t old_gradient_color;
int old_gradient_c2c;
///property: color of shadow
fb_pixel_t col_shadow;
///property: color of frame
@@ -81,8 +83,6 @@ class CComponents : public CComponentsSignals, public COSDFader
///property: contains data for gradiant handling
gradientData_t cc_gradientData;
///gradiant pixel buffer
fb_pixel_t *cc_body_gradientBuf;
///property: true component can paint gradient, see also enableColBodyGradient()
bool col_body_gradient;
///property: background gradient mode
@@ -97,6 +97,10 @@ class CComponents : public CComponentsSignals, public COSDFader
uint8_t cc_body_gradient_saturation;
///property: background gradient direction
int cc_body_gradient_direction;
///property: background gradient mode
bool cc_body_gradient_c2c;
///property: background gradient 2nd color
fb_pixel_t cc_body_gradient_2nd_col;
///property: true=component has shadow
bool shadow;
@@ -211,6 +215,8 @@ class CComponents : public CComponentsSignals, public COSDFader
cc_body_gradient_intensity_v_max=v_max;
cc_body_gradient_saturation=s; };
virtual void set2ndColor(fb_pixel_t col_2nd){ cc_body_gradient_c2c = true; cc_body_gradient_2nd_col = col_2nd;};
///get frame color
inline virtual fb_pixel_t getColorFrame(){return col_frame;};
///get body color
@@ -251,7 +257,7 @@ class CComponents : public CComponentsSignals, public COSDFader
///allow/disalows paint of item and its contents, but initialize of other properties are not touched
///this can be understood as a counterpart to isPainted(), but before paint and value of is_painted is modified temporarily till next paint of item //TODO: is this sufficiently?
virtual void allowPaint(bool allow){cc_allow_paint = allow; is_painted = cc_allow_paint ? false : true;};
void allowPaint(bool allow){cc_allow_paint = allow; is_painted = cc_allow_paint ? false : true;};
///returns visibility mode
virtual bool paintAllowed(){return cc_allow_paint;};
@@ -346,6 +352,10 @@ class CComponentsItem : public CComponents
///returns current number of page location of current item, see: cc_page_number
virtual u_int8_t getPageNumber(){return cc_page_number;};
///set screen x-position, parameter as int
virtual void setXPos(const int& xpos);
///set screen y-position, parameter as int
virtual void setYPos(const int& ypos);
///set screen x-position, parameter as uint8_t, percent x value related to current width of parent form or screen
virtual void setXPosP(const uint8_t& xpos_percent);
///set screen y-position, parameter as uint8_t, percent y value related to current height of parent form or screen

View File

@@ -250,6 +250,11 @@ int CComponentsForm::genIndex()
CComponentsItem* CComponentsForm::getCCItem(const uint& cc_item_id)
{
if (cc_item_id >= size()){
dprintf(DEBUG_NORMAL, "[CComponentsForm] [%s - %d] Error: parameter cc_item_id = %u, out of range (size = %u)...\n", __func__, __LINE__, cc_item_id, size());
return NULL;
}
if (v_cc_items[cc_item_id])
return v_cc_items[cc_item_id];
return NULL;
@@ -363,6 +368,7 @@ void CComponentsForm::paintCCItems()
//using of real x/y values to paint items if this text object is bound in a parent form
int this_x = x, auto_x = x, this_y = y, auto_y = y, this_w = width;
int w_parent_frame = 0;
if (cc_parent){
this_x = auto_x = cc_xr;
this_y = auto_y = cc_yr;
@@ -404,16 +410,16 @@ void CComponentsForm::paintCCItems()
//assign item object
CComponentsItem *cc_item = v_cc_items[i];
dprintf(DEBUG_INFO, "[CComponentsForm] %s: page_count = %u, item_page = %u, cur_page = %u\n", __func__, getPageCount(), cc_item->getPageNumber(), this->cur_page);
//get current dimension of item
int w_item = cc_item->getWidth();
int h_item = cc_item->getHeight();
dprintf(DEBUG_DEBUG, "[CComponentsForm] %s: page_count = %u, item_page = %u, cur_page = %u\n", __func__, getPageCount(), cc_item->getPageNumber(), this->cur_page);
//get current position of item
int xpos = cc_item->getXPos();
int ypos = cc_item->getYPos();
//get current dimension of item
int w_item = cc_item->getWidth() - (xpos <= fr_thickness ? fr_thickness : 0);
int h_item = cc_item->getHeight() - (ypos <= fr_thickness ? fr_thickness : 0);
//check item for corrupt position, skip current item if found problems
if (ypos > height || xpos > this_w){
dprintf(DEBUG_INFO, "[CComponentsForm] %s: [form: %d] [item-index %d] [type=%d] WARNING: item position is out of form size:\ndefinied x=%d, defined this_w=%d \ndefinied y=%d, defined height=%d \n",
@@ -422,40 +428,53 @@ void CComponentsForm::paintCCItems()
continue;
}
//move item x-position, if we have a frame on parent, TODO: other constellations not considered at the moment
w_parent_frame = xpos <= fr_thickness ? fr_thickness : 0;
//set required x-position to item:
//append vertical
if (xpos == CC_APPEND){
auto_x += append_x_offset;
cc_item->setRealXPos(auto_x + xpos);
cc_item->setRealXPos(auto_x + xpos + w_parent_frame);
auto_x += w_item;
}
//positionize vertical centered
else if (xpos == CC_CENTERED){
auto_x = this_w/2 - w_item/2;
cc_item->setRealXPos(this_x + auto_x);
cc_item->setRealXPos(this_x + auto_x + w_parent_frame);
}
else{
cc_item->setRealXPos(this_x + xpos);
cc_item->setRealXPos(this_x + xpos + w_parent_frame);
auto_x = (cc_item->getRealXPos() + w_item);
}
//move item y-position, if we have a frame on parent, TODO: other constellations not considered at the moment
w_parent_frame = ypos <= fr_thickness ? fr_thickness : 0;
//set required y-position to item
//append hor
if (ypos == CC_APPEND){
auto_y += append_y_offset;
cc_item->setRealYPos(auto_y + ypos);
cc_item->setRealYPos(auto_y + ypos + w_parent_frame);
auto_y += h_item;
}
//positionize hor centered
else if (ypos == CC_CENTERED){
auto_y = height/2 - h_item/2;
cc_item->setRealYPos(this_y + auto_y);
cc_item->setRealYPos(this_y + auto_y + w_parent_frame);
}
else{
cc_item->setRealYPos(this_y + ypos);
cc_item->setRealYPos(this_y + ypos + w_parent_frame);
auto_y = (cc_item->getRealYPos() + h_item);
}
//reduce corner radius, if we have a frame around parent item, ensure matching corners inside of embedded item, this avoids ugly unpainted spaces between frame and item border
//TODO: other constellations not considered at the moment
if (w_parent_frame){
if(xpos <= fr_thickness || ypos <= fr_thickness)
cc_item->setCorner(max(0, cc_item->getCornerRadius()-w_parent_frame), cc_item->getCornerType());
}
//These steps check whether the element can be painted into the container.
//Is it too wide or too high, it will be shortened and displayed in the log.
//This should be avoid!
@@ -535,14 +554,14 @@ void CComponentsForm::setPageCount(const u_int8_t& pageCount)
u_int8_t CComponentsForm::getPageCount()
{
u_int8_t num = 0;
u_int8_t num = 1;
for(size_t i=0; i<v_cc_items.size(); i++){
u_int8_t item_num = v_cc_items[i]->getPageNumber();
num = max(item_num, num);
}
//convert type, possible -Wconversion warnings!
page_count = static_cast<u_int8_t>(num + 1);
page_count = static_cast<u_int8_t>(num);
return page_count;
}
@@ -608,9 +627,14 @@ CComponentsItem* CComponentsForm::getSelectedItemObject()
void CComponentsForm::ScrollPage(int direction, bool do_paint)
{
if (getPageCount() == 1){
cur_page = 0;
return;
}
OnBeforeScrollPage();
int target_page_id = (int)getPageCount() - 1;
int target_page_id = (int)page_count - 1;
int target_page = (int)cur_page;
if (direction == SCROLL_P_DOWN)

View File

@@ -101,21 +101,22 @@ void CComponentsButton::initVarButton( const int& x_pos, const int& y_pos, const
height = h;
shadow = has_shadow;
shadow_w = SHADOW_OFFSET;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
col_body_gradient = g_settings.gradiant;
setColBodyGradient(CColorGradient::gradientDark2Light2Dark, CFrameBuffer::gradientVertical, CColorGradient::light);
col_body_gradient = false/*g_settings.gradiant*/; //gradient is prepared for use but disabled at the moment till some other parts of gui parts are provide gradient
setColBodyGradient(CColorGradient::gradientLight2Dark, CFrameBuffer::gradientVertical, CColorGradient::light);
col_frame = color_frame;
col_body = col_body_gradient? COL_DARK_GRAY : color_body;
col_shadow = color_shadow;
cc_item_enabled = enabled;
cc_item_selected = selected;
fr_thickness = 3;
append_x_offset = 6;
append_y_offset = 0;
corner_rad = RADIUS_MID;
corner_rad = 0;
cc_btn_capt_col = COL_MENUCONTENT_TEXT;
cc_btn_capt_col = col_body_gradient ? COL_BUTTON_TEXT_ENABLED : COL_INFOBAR_SHADOW_TEXT;
cc_btn_capt_disable_col = col_body_gradient ? COL_BUTTON_TEXT_DISABLED : COL_MENUCONTENTINACTIVE_TEXT;
cc_btn_icon_obj = NULL;
cc_btn_capt_obj = NULL;
cc_btn_dy_font = CNeutrinoFonts::getInstance();
@@ -142,20 +143,26 @@ void CComponentsButton::initIcon()
//initialize icon object
if (cc_btn_icon_obj == NULL){
int w_icon = 0;
int h_icon = 0;
frameBuffer->getIconSize(cc_btn_icon.c_str(), &w_icon, &h_icon);
int y_icon = 0;
h_icon = min(height-2*fr_thickness, h_icon);
// if (h_icon != h_max){
// int ratio = h_icon/h_max;
// cc_btn_icon = frameBuffer->getIconBasePath() + cc_btn_icon;
// cc_btn_icon += ".png";
// w_icon = w_icon*ratio;
// }
int y_icon = height/2 - h_icon/2;
cc_btn_icon_obj = new CComponentsPicture(fr_thickness, y_icon, w_icon, h_icon, cc_btn_icon, this);
string::size_type pos = cc_btn_icon.find("/", 0);
if (pos == string::npos)
cc_btn_icon = frameBuffer->getIconBasePath() + "/" + cc_btn_icon + ".png";
cc_btn_icon_obj = new CComponentsPictureScalable(fr_thickness, y_icon, cc_btn_icon, this);
int h_icon = cc_btn_icon_obj->getHeight();
//get required icon height
int h_max = height-2*fr_thickness;
//get current icon dimensions
if (h_icon > h_max)
cc_btn_icon_obj->setHeight(h_max, true);
y_icon = height/2 - cc_btn_icon_obj->getHeight()/2;
cc_btn_icon_obj->setYPos(y_icon);
cc_btn_icon_obj->doPaintBg(false);
}
}
@@ -184,7 +191,7 @@ void CComponentsButton::initCaption()
x_cap += cc_btn_icon_obj ? cc_btn_icon_obj->getWidth() : 0;
int w_cap = width - fr_thickness - append_x_offset - x_cap - fr_thickness;
int h_cap = height - 2*fr_thickness;
int h_cap = height*80/100/* - 2*fr_thickness*/;
/*NOTE:
paint of centered text in y direction without y_offset
@@ -192,7 +199,7 @@ void CComponentsButton::initCaption()
but text render isn't wrong here, because capitalized chars or long chars like e. 'q', 'y' are considered!
Therefore we here need other icons or a hack, that considers some different height values.
*/
int y_cap = height/2 - h_cap/2 - fr_thickness;
int y_cap = height/2 - h_cap/2 + fr_thickness/2;
cc_btn_capt_obj->setDimensionsAll(x_cap, y_cap, w_cap, h_cap);
@@ -204,7 +211,7 @@ void CComponentsButton::initCaption()
cc_btn_capt_obj->forceTextPaint(); //here required;
//set color
cc_btn_capt_obj->setTextColor(this->cc_item_enabled ? COL_MENUCONTENT_TEXT : COL_MENUCONTENTINACTIVE_TEXT);
cc_btn_capt_obj->setTextColor(this->cc_item_enabled ? cc_btn_capt_col : cc_btn_capt_disable_col);
//corner of text item
cc_btn_capt_obj->setCorner(corner_rad-fr_thickness, corner_type);

View File

@@ -35,6 +35,10 @@
#include <driver/neutrinofonts.h>
#include <driver/rcinput.h>
#define COL_BUTTON_BODY COL_INFOBAR_SHADOW_PLUS_1
#define COL_BUTTON_TEXT_ENABLED COL_BLACK
#define COL_BUTTON_TEXT_DISABLED COL_LIGHT_GRAY
//! Sub class of CComponentsForm.
/*!
Shows a button box with caption and optional icon.
@@ -43,7 +47,7 @@ class CComponentsButton : public CComponentsFrmChain
{
protected:
///object: picture object
CComponentsPicture *cc_btn_icon_obj;
CComponentsPictureScalable *cc_btn_icon_obj;
///object: label object
CComponentsLabel *cc_btn_capt_obj;
@@ -74,6 +78,8 @@ class CComponentsButton : public CComponentsFrmChain
///property: text color
fb_pixel_t cc_btn_capt_col;
///property: text color for disabled button
fb_pixel_t cc_btn_capt_disable_col;
///object: text font
Font* cc_btn_font;
///object: dynamic font object handler
@@ -96,7 +102,7 @@ class CComponentsButton : public CComponentsFrmChain
bool selected = false,
bool enabled = true,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
CComponentsButton( const int& x_pos, const int& y_pos, const int& w, const int& h,
const neutrino_locale_t& caption_locale,
@@ -105,7 +111,7 @@ class CComponentsButton : public CComponentsFrmChain
bool selected = false,
bool enabled = true,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
CComponentsButton( const int& x_pos, const int& y_pos, const int& w, const int& h,
const neutrino_locale_t& caption_locale,
@@ -114,7 +120,7 @@ class CComponentsButton : public CComponentsFrmChain
bool selected = false,
bool enabled = true,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
CComponentsButton( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& caption,
@@ -123,10 +129,10 @@ class CComponentsButton : public CComponentsFrmChain
bool selected = false,
bool enabled = true,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
fb_pixel_t color_frame = COL_DARK_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
///set text color
virtual void setButtonTextColor(fb_pixel_t caption_color){cc_btn_capt_col = caption_color;};
virtual void setButtonTextColor(fb_pixel_t text_color, fb_pixel_t text_color_disabled = COL_MENUCONTENTINACTIVE_TEXT){cc_btn_capt_col = text_color; cc_btn_capt_disable_col = text_color_disabled;}
///set caption: parameter as string
virtual void setCaption(const std::string& text);
@@ -176,7 +182,7 @@ class CComponentsButtonRed : public CComponentsButton
bool selected = false,
bool enabled = true,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
:CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_RED, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_BUTTON_RED;
@@ -187,7 +193,7 @@ class CComponentsButtonRed : public CComponentsButton
bool selected = false,
bool enabled = true,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
:CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_RED, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_BUTTON_RED;
@@ -207,7 +213,7 @@ class CComponentsButtonGreen : public CComponentsButton
bool selected = false,
bool enabled = true,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
:CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_GREEN, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_BUTTON_GREEN;
@@ -218,7 +224,7 @@ class CComponentsButtonGreen : public CComponentsButton
bool selected = false,
bool enabled = true,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
:CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_GREEN, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_BUTTON_GREEN;
@@ -238,7 +244,7 @@ class CComponentsButtonYellow : public CComponentsButton
bool selected = false,
bool enabled = true,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
:CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_YELLOW, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_BUTTON_YELLOW;
@@ -249,7 +255,7 @@ class CComponentsButtonYellow : public CComponentsButton
bool selected = false,
bool enabled = true,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
:CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_YELLOW, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_BUTTON_YELLOW;
@@ -269,7 +275,7 @@ class CComponentsButtonBlue : public CComponentsButton
bool selected = false,
bool enabled = true,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
:CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_BLUE, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_BUTTON_BLUE;
@@ -280,7 +286,7 @@ class CComponentsButtonBlue : public CComponentsButton
bool selected = false,
bool enabled = true,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0)
:CComponentsButton(x_pos, y_pos, w, h, caption_locale, NEUTRINO_ICON_BUTTON_BLUE, parent, selected, enabled, has_shadow, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_BUTTON_BLUE;

View File

@@ -76,12 +76,15 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
col_body_gradient = false;
col_body_gradient = false; /*g_settings.theme.Foot_gradient*/; //TODO: not implemented at the moment
cc_body_gradient_direction = CFrameBuffer::gradientVertical;
cc_body_gradient_mode = CColorGradient::gradientDark2Light;
btn_auto_frame_col = false;
corner_rad = RADIUS_LARGE;
corner_type = CORNER_BOTTOM;
btn_contour = false;
btn_contour = false /*g_settings.theme.Button_gradient*/; //TODO: not implemented at the moment
ccf_btn_font = NULL;
chain = NULL;
@@ -139,21 +142,26 @@ void CComponentsFooter::setButtonLabels(const struct button_label_s * const cont
continue;
}
CComponentsButton *btn = new CComponentsButton(0, CC_CENTERED, w_btn_min, height-height/4, txt, btn_name);
CComponentsButton *btn = new CComponentsButton(0, CC_CENTERED, w_btn_min, height-height/(btn_contour ? 4 : 3), txt, btn_name);
btn->setButtonFont(ccf_btn_font);
btn->doPaintBg(btn_contour);
btn->setButtonEventMsg(content[i].btn_msg);
btn->setButtonResult(content[i].btn_result);
btn->setButtonAlias(content[i].btn_alias);
if (btn_name == NEUTRINO_ICON_BUTTON_RED)
btn->setColorFrame(COL_DARK_RED);
if (btn_name == NEUTRINO_ICON_BUTTON_GREEN)
btn->setColorFrame(COL_DARK_GREEN);
if (btn_name == NEUTRINO_ICON_BUTTON_YELLOW)
btn->setColorFrame(COL_OLIVE);
if (btn_name == NEUTRINO_ICON_BUTTON_BLUE)
btn->setColorFrame(COL_DARK_BLUE);
//set button frames to icon color, predefined for available color buttons
if (btn_auto_frame_col){
fb_pixel_t f_col = btn->getColorFrame();
if (btn_name == NEUTRINO_ICON_BUTTON_RED)
f_col = COL_DARK_RED;
if (btn_name == NEUTRINO_ICON_BUTTON_GREEN)
f_col = COL_DARK_GREEN;
if (btn_name == NEUTRINO_ICON_BUTTON_YELLOW)
f_col = COL_OLIVE;
if (btn_name == NEUTRINO_ICON_BUTTON_BLUE)
f_col = COL_DARK_BLUE;
btn->setColorFrame(f_col);
}
chain->addCCItem(btn);
@@ -215,7 +223,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label * const conten
setButtonLabels(buttons, label_count, chain_width, label_width);
}
void CComponentsFooter::setButtonLabels(const vector<button_label_l>v_content, const int& chain_width, const int& label_width)
void CComponentsFooter::setButtonLabels(const vector<button_label_l> &v_content, const int& chain_width, const int& label_width)
{
size_t label_count = v_content.size();
button_label_l buttons[label_count];
@@ -231,7 +239,7 @@ void CComponentsFooter::setButtonLabels(const vector<button_label_l>v_content, c
setButtonLabels(buttons, label_count, chain_width, label_width);
}
void CComponentsFooter::setButtonLabels(const vector<button_label_s>v_content, const int& chain_width, const int& label_width)
void CComponentsFooter::setButtonLabels(const vector<button_label_s> &v_content, const int& chain_width, const int& label_width)
{
size_t label_count = v_content.size();
button_label_s buttons[label_count];

View File

@@ -69,6 +69,8 @@ class CComponentsFooter : public CComponentsHeader
///show button frame and background, default false
bool btn_contour;
///enable/disable button frame in icon color, predefined for red, green, yellow and blue, default disabled
bool btn_auto_frame_col;
///property: set font for label caption, see also setButtonFont()
Font* ccf_btn_font;
@@ -91,9 +93,12 @@ class CComponentsFooter : public CComponentsHeader
///add button labels with locale label type as content, count as size_t, chain_width as int, label width as int
void setButtonLabels(const struct button_label_l * const content, const size_t& label_count, const int& chain_width = 0, const int& label_width = 0);
///add button labels with locale label type as content, parameter 1 as vector, chain_width as int, label width as int
void setButtonLabels(const std::vector<button_label_l>v_content, const int& chain_width, const int& label_width);
void setButtonLabels(const std::vector<button_label_l> &v_content, const int& chain_width, const int& label_width);
///add button labels with string label type as content, parameter 1 as vector, chain_width as int, label width as int
void setButtonLabels(const std::vector<button_label_s>v_content, const int& chain_width, const int& label_width);
void setButtonLabels(const std::vector<button_label_s> &v_content, const int& chain_width, const int& label_width);
///enable/disable button frame in icon color, predefined for red, green, yellow and blue
inline void enableButtonFrameColor(bool enable = true){btn_auto_frame_col = enable;}
///add button labels with old label type, count as size_t, chain_width as int, label width as int
///NOTE: for compatibility with older button handler find in gui/widget/buttons.h, if possible, don't use this
@@ -133,6 +138,14 @@ class CComponentsFooter : public CComponentsHeader
Font* font = NULL,
bool do_save_bg = CC_SAVE_SCREEN_NO
);
enum
{
CC_FOOTER_SIZE_LARGE = 0,
CC_FOOTER_SIZE_SMALL = 1
};
///set size of footer, possible values are CC_FOOTER_SIZE_LARGE, CC_FOOTER_SIZE_SMALL
virtual void setSizeMode(const int& size_mode){cch_size_mode = size_mode; initCCItems();};
};
#endif

View File

@@ -98,8 +98,9 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const
col_body = color_body;
col_shadow = color_shadow;
col_body = COL_MENUHEAD_PLUS_0;
col_body_gradient = g_settings.gradiant;
cc_body_gradient_direction = CFrameBuffer::gradientVertical;
col_body_gradient = g_settings.theme.menu_Head_gradient;
cc_body_gradient_direction = CFrameBuffer::gradientVertical;
cc_body_gradient_mode = CColorGradient::gradientLight2Dark;
cch_text = caption;
cch_icon_name = icon_name;
@@ -205,7 +206,7 @@ void CComponentsHeader::initIcon()
//get dimensions of header icon
int iw = 0;
int ih = 0;
cch_icon_obj->getImageSize(&iw, &ih);
cch_icon_obj->getSize(&iw, &ih);
dprintf(DEBUG_INFO, "[CComponentsHeader]\n [%s - %d] init icon size: iw = %d, ih = %d\n", __func__, __LINE__, iw, ih);
cch_icon_obj->setWidth(iw);
cch_icon_obj->setHeight(ih);

View File

@@ -81,8 +81,8 @@ void CComponentsScrollBar::initVarSbForm(const int& count)
sb_segments_obj = NULL;
string ftype = ".png";
sb_up_icon = frameBuffer->getIconBasePath() + NEUTRINO_ICON_BUTTON_TOP + ftype;
sb_down_icon = frameBuffer->getIconBasePath() + NEUTRINO_ICON_BUTTON_DOWN + ftype;
sb_up_icon = frameBuffer->getIconBasePath() + "/" + NEUTRINO_ICON_BUTTON_TOP + ftype;
sb_down_icon = frameBuffer->getIconBasePath() + "/" + NEUTRINO_ICON_BUTTON_DOWN + ftype;
sb_segments_count = count;
sb_mark_id = 0;

View File

@@ -33,6 +33,7 @@
#include "cc_base.h"
#include <driver/screen_max.h>
#include <system/debug.h>
#include <cs_api.h>
using namespace std;
// y
@@ -98,8 +99,7 @@ void CComponentsItem::paintInit(bool do_save_bg)
ix = cc_xr;
iy = cc_yr;
}
cc_gradientData.boxBuf = NULL;
cc_gradientData.mode = CFrameBuffer::pbrg_noFree;
void* gradientData = (cc_gradientData.gradientBuf == NULL) ? NULL : &cc_gradientData;
comp_fbdata_t fbdata[] =
@@ -194,16 +194,30 @@ bool CComponentsItem::isAdded()
return false;
}
inline void CComponentsItem::setXPos(const int& xpos)
{
x = xpos;
if (cc_parent)
setRealXPos(cc_parent->getRealXPos() + x);
}
inline void CComponentsItem::setYPos(const int& ypos)
{
y = ypos;
if (cc_parent)
setRealYPos(cc_parent->getRealYPos() + y);
}
void CComponentsItem::setXPosP(const uint8_t& xpos_percent)
{
int x_tmp = cc_parent ? xpos_percent*cc_parent->getWidth() : xpos_percent*frameBuffer->getScreenWidth();
x = x_tmp/100;
setXPos(x_tmp/100);
}
void CComponentsItem::setYPosP(const uint8_t& ypos_percent)
{
int y_tmp = cc_parent ? ypos_percent*cc_parent->getHeight() : ypos_percent*frameBuffer->getScreenHeight();
x = y_tmp/100;
setYPos(y_tmp/100);
}
void CComponentsItem::setPosP(const uint8_t& xpos_percent, const uint8_t& ypos_percent)
@@ -243,12 +257,25 @@ void CComponentsItem::setFocus(bool focus)
void CComponentsItem::initBodyGradient()
{
if (cc_body_gradientBuf == NULL) {
if (col_body_gradient && cc_gradientData.gradientBuf && (old_gradient_color != col_body || old_gradient_c2c != g_settings.theme.gradient_c2c)) {
free(cc_gradientData.gradientBuf);
cc_gradientData.gradientBuf = NULL;
if (cc_gradientData.boxBuf) {
cs_free_uncached(cc_gradientData.boxBuf);
cc_gradientData.boxBuf = NULL;
}
}
if (cc_gradientData.gradientBuf == NULL) {
CColorGradient ccGradient;
int gsize = cc_body_gradient_direction == CFrameBuffer::gradientVertical ? height : width;
cc_body_gradientBuf = ccGradient.gradientOneColor(col_body, NULL, gsize, cc_body_gradient_mode, cc_body_gradient_intensity, cc_body_gradient_intensity_v_min, cc_body_gradient_intensity_v_max, cc_body_gradient_saturation);
if (g_settings.theme.gradient_c2c)
cc_gradientData.gradientBuf = ccGradient.gradientColorToColor(col_body, cc_body_gradient_2nd_col, NULL, gsize, cc_body_gradient_mode, cc_body_gradient_intensity);
else
cc_gradientData.gradientBuf = ccGradient.gradientOneColor(col_body, NULL, gsize, cc_body_gradient_mode, cc_body_gradient_intensity, cc_body_gradient_intensity_v_min, cc_body_gradient_intensity_v_max, cc_body_gradient_saturation);
old_gradient_color = col_body;
old_gradient_c2c = g_settings.theme.gradient_c2c;
}
cc_gradientData.gradientBuf = cc_body_gradientBuf;
cc_gradientData.direction = cc_body_gradient_direction;
cc_gradientData.mode = CFrameBuffer::pbrg_noOption;
}

View File

@@ -95,24 +95,27 @@ void CComponentsInfoBox::setPicture(const char* picture_name)
void CComponentsInfoBox::paintPicture()
{
//ensure empty pic object
if (pic)
if (pic){
delete pic;
pic = NULL;
pic = NULL;
}
//exit if no image definied
if (pic_name.empty())
return;
//init pic object and set icon paint position
pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness, "");
//define icon
pic->setPicture(pic_name);
pic = new CComponentsPicture(x+fr_thickness+x_offset, y+fr_thickness, 0, min(48, height-2*fr_thickness), pic_name); //NOTE: icons do not scale!
//fit icon into infobox
pic->setHeight(height-2*fr_thickness);
pic->setColorBody(col_body);
//set gradient behavior of pic object
if (col_body_gradient)
pic->doPaintBg(false);
//fit icon into frame
pic->setYPos(y+(height/2-pic->getHeight()/2));
//paint, but set visibility mode
pic->allowPaint(cc_allow_paint);
pic->paint(CC_SAVE_SCREEN_NO);
@@ -137,22 +140,25 @@ void CComponentsInfoBox::paint(bool do_save_bg)
if (!ct_text.empty()){
if (cctext)
delete cctext;
cctext = new CComponentsText();
cctext->setText(ct_text, ct_text_mode, ct_font);
cctext->doPaintTextBoxBg(ct_paint_textbg);
cctext->doPaintBg(false);
cctext->setTextColor(ct_col_text);
cctext->enableTboxSaveScreen(save_tbox_screen);
//calculate vars for x-position and dimensions
int tx = x_offset + x_text + pic_w;
int tw = width - x_offset - pic_w - 2*fr_thickness;
int th = height-2*fr_thickness;
cctext->setDimensionsAll(tx, y_text, tw, th);
//paint, but set visibility mode
cctext->allowPaint(cc_allow_paint);
cctext->paint(CC_SAVE_SCREEN_NO);
cctext = NULL;
}
if (cctext == NULL)
cctext = new CComponentsText();
cctext->setText(ct_text, ct_text_mode, ct_font);
cctext->doPaintTextBoxBg(ct_paint_textbg);
cctext->doPaintBg(false);
cctext->setTextColor(ct_col_text);
cctext->enableTboxSaveScreen(save_tbox_screen);
//calculate vars for x-position and dimensions
int tx = x_offset + x_text + pic_w;
int tw = width - x_offset - pic_w - 2*fr_thickness;
int th = height-2*fr_thickness;
cctext->setDimensionsAll(tx, y_text, tw, th);
//paint, but set visibility mode
cctext->allowPaint(cc_allow_paint);
cctext->paint(CC_SAVE_SCREEN_NO);
}

View File

@@ -57,9 +57,6 @@ class CComponentsInfoBox : public CComponentsText
///property: path or name of displayed image
std::string pic_name;
///set scale mode of image
bool scale_image;
public:
///object: internal used CTextBox object
CComponentsText * cctext;
@@ -86,7 +83,8 @@ class CComponentsInfoBox : public CComponentsText
void setPicture(const std::string& picture_name);
///set property: path or name of displayed image, parameter as const char*
void setPicture(const char* picture_name);
///set property: gradient behavior
void enableGradient(bool enable) { col_body_gradient = enable; }
///paint item
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};

View File

@@ -42,12 +42,12 @@ using namespace std;
//-------------------------------------------------------------------------------------------------------
//sub class CComponentsPicture from CComponentsItem
CComponentsPicture::CComponentsPicture( const int &x_pos, const int &y_pos, const int &w, const int &h,
const std::string& image_path,
const std::string& image_name,
CComponentsForm *parent,
bool has_shadow,
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow, int transparent)
{
init(x_pos, y_pos, w, h, image_path, parent, has_shadow, color_frame, color_background, color_shadow, transparent, SCALE);
init(x_pos, y_pos, w, h, image_name, parent, has_shadow, color_frame, color_background, color_shadow, transparent, SCALE);
}
CComponentsPicture::CComponentsPicture( const int &x_pos, const int &y_pos,
@@ -59,6 +59,7 @@ CComponentsPicture::CComponentsPicture( const int &x_pos, const int &y_pos,
init(x_pos, y_pos, 0, 0, image_name, parent, has_shadow, color_frame, color_background, color_shadow, transparent, NO_SCALE);
}
void CComponentsPicture::init( const int &x_pos, const int &y_pos, const int &w, const int &h,
const string& image_name,
CComponentsForm *parent,
@@ -72,25 +73,22 @@ void CComponentsPicture::init( const int &x_pos, const int &y_pos, const int &w,
//CComponents
x = x_pos;
y = y_pos;
height = h;
width = w;
width = dx = w;
height = dy = h;
pic_name = image_name;
shadow = has_shadow;
shadow_w = SHADOW_OFFSET;
col_frame = color_frame;
col_body = color_background;
col_shadow = color_shadow;
//CComponentsPicture
pic_name = image_name;
do_scale = allow_scale;
is_image_painted= false;
do_paint = true;
image_transparent = transparent;
do_scale = allow_scale;
keep_dx_aspect = false;
keep_dy_aspect = false;
g_PicViewer->getSupportedImageFormats(v_ext);
v_ext.resize(unique(v_ext.begin(), v_ext.end()) - v_ext.begin());
initCCItem();
initParent(parent);
}
@@ -109,67 +107,105 @@ void CComponentsPicture::setPicture(const char* picture_name)
setPicture(s_tmp);
}
void CComponentsPicture::setWidth(const int& w, bool keep_aspect)
{
CComponentsItem::setWidth(w),
do_scale = true;
keep_dy_aspect = keep_aspect;
initCCItem();
}
void CComponentsPicture::setHeight(const int& h, bool keep_aspect)
{
CComponentsItem::setHeight(h),
do_scale = true;
keep_dx_aspect = keep_aspect;
initCCItem();
}
void CComponentsPicture::initCCItem()
{
//handle size
int w_pic = width;
int h_pic = height;
if (pic_name.empty())
if (pic_name.empty()){
dprintf(DEBUG_INFO, "[CComponentsPicture] %s - %d : no image file assigned...\n", __func__, __LINE__);
return;
}
//check for path or name, set icon or image with full path
//check for path or name, set icon or image with full path, has no path, then use as icon and disble scale mode
string::size_type pos = pic_name.find("/", 0);
if (pos == string::npos)
do_scale = false;
dprintf(DEBUG_INFO, "[CComponentsPicture] %s: detected image file: do_scale: %d (pos= %zd), pic_name=%s\n", __func__, do_scale, pos, pic_name.c_str());
//get current image size
getImageSize(&w_pic, &h_pic);
//for icons (names without explicit path) set dimensions of "this" to current image...//TODO: centering image/icon
//initial internal size
if (!do_scale){
width = max(w_pic, width);
height = max(h_pic, height);
//use image/icon size as object dimension values
frameBuffer->getIconSize(pic_name.c_str(), &width, &height);
return;
}
else{ //defined values in constructor or defined via setters defined, have priority, value 0 is not allowed
if (width == 0)
width = w_pic;
if (height == 0)
height = h_pic;
else{ //initialized scaled size
//first get real image dimensions
if ((dx != width || dy != height) || (dx == 0 || dy == 0))
g_PicViewer->getSize(pic_name.c_str(), &dx, &dy);
}
//resize/scale image if required, if no icon mode detected, use real image size
if (do_scale){
if (width != w_pic || height != h_pic) {
g_PicViewer->rescaleImageDimensions(&w_pic, &h_pic, width, height);
width = w_pic;
height = h_pic;
}
//ensure filled inital values
if (width == 0)
width = dx;
if (height == 0)
height = dy;
//check dimensions, leave if dimensions are equal
if (width == dx && height == dy)
return;
//temporarily vars
int w_2scale = width;
int h_2scale = height;
//resize image and set current dimensions
g_PicViewer->rescaleImageDimensions(&width, &height, w_2scale, h_2scale);
//handle aspect ratio
if (keep_dx_aspect){
float h_ratio = float(height)*100/(float)dy;
width = int(h_ratio*(float)dx/100);
}
if (keep_dy_aspect){
float w_ratio = float(width)*100/(float)dx;
height = int(w_ratio*(float)dy/100);
}
}
void CComponentsPicture::initPosition(int *x_position, int *y_position)
{
//using of real x/y values to paint images if this picture object is bound in a parent form
*x_position = x;
*y_position = y;
if (cc_parent){
if (cc_parent){ //using of real x/y values to paint images if this picture object is bound in a parent form
*x_position = cc_xr;
*y_position = cc_yr;
}
}
void CComponentsPicture::getImageSize(int* width_image, int *height_image)
void CComponentsPicture::getSize(int* width_image, int *height_image)
{
if (do_scale)
g_PicViewer->getSize(pic_name.c_str(), width_image, height_image);
else
frameBuffer->getIconSize(pic_name.c_str(), width_image, height_image);
initCCItem();
*width_image = width;
*height_image = height;
}
int CComponentsPicture::getWidth()
{
int w, h;
getSize(&w, &h);
return w;
}
int CComponentsPicture::getHeight()
{
int w, h;
getSize(&w, &h);
return h;
}
void CComponentsPicture::paintPicture()
@@ -179,12 +215,13 @@ void CComponentsPicture::paintPicture()
int x_pic = x;
int y_pic = y;
initPosition(&x_pic, &y_pic);
initCCItem();
if (pic_name.empty())
return;
dprintf(DEBUG_INFO, "[CComponentsPicture] %s: paint image file: pic_name=%s\n", __func__, pic_name.c_str());
if (cc_allow_paint){
dprintf(DEBUG_INFO, "[CComponentsPicture] %s: paint image file: pic_name=%s\n", __func__, pic_name.c_str());
frameBuffer->SetTransparent(image_transparent);
if (do_scale)
is_image_painted = g_PicViewer->DisplayImage(pic_name, x_pic, y_pic, width, height);
@@ -196,6 +233,8 @@ void CComponentsPicture::paintPicture()
void CComponentsPicture::paint(bool do_save_bg)
{
if (pic_name.empty())
return;
paintInit(do_save_bg);
paintPicture();
}
@@ -217,8 +256,7 @@ CComponentsChannelLogo::CComponentsChannelLogo( const int &x_pos, const int &y_p
"", parent, has_shadow,
color_frame, color_background, color_shadow, transparent)
{
setChannel(channelId, channelName);
alt_pic_name = "";
init(channelId, channelName, SCALE);
}
CComponentsChannelLogo::CComponentsChannelLogo( const int &x_pos, const int &y_pos,
@@ -231,18 +269,23 @@ CComponentsChannelLogo::CComponentsChannelLogo( const int &x_pos, const int &y_p
"", parent, has_shadow,
color_frame, color_background, color_shadow, transparent)
{
setChannel(channelId, channelName);
alt_pic_name = "";
init(channelId, channelName, NO_SCALE);
}
void CComponentsChannelLogo::init(const uint64_t& channelId, const std::string& channelName, bool allow_scale)
{
alt_pic_name = "";
setChannel(channelId, channelName);
do_scale = allow_scale;
}
void CComponentsChannelLogo::setAltLogo(const std::string& picture_name)
{
alt_pic_name = picture_name;
channel_id = 0;
channel_name = "";
has_logo = true;
initCCItem();
has_logo = !alt_pic_name.empty();
if (has_logo)
initCCItem();
}
void CComponentsChannelLogo::setAltLogo(const char* picture_name)
@@ -261,9 +304,18 @@ void CComponentsChannelLogo::setChannel(const uint64_t& channelId, const std::st
has_logo = g_PicViewer->GetLogoName(channel_id, channel_name, pic_name, &dummy, &dummy);
if (!has_logo)
if (!has_logo)//no logo was found, use altrenate icon or logo
pic_name = alt_pic_name;
//if logo or alternate image still not available, set has logo to false
has_logo = !pic_name.empty();
//refresh object
initCCItem();
//set has_logo to false if no dimensions were detected
if (width && height)
has_logo = true;
doPaintBg(false);
}

View File

@@ -49,6 +49,9 @@ class CComponentsPicture : public CComponentsItem
///possible image formats
std::vector<std::string> v_ext;
///current original image dimensions
int dx, dy;
///property: name of image (without extensionn) full path to image (with extension), icon names to find in /widget/icons.h, icons will paint never scaled
std::string pic_name;
@@ -63,6 +66,9 @@ class CComponentsPicture : public CComponentsItem
///set internel paint mode to allow/disallow scale an image, value is assigned with constructor, if defined dimensions w and h = 0, then image scale is enabled
bool do_scale;
///sets internal option for keeping aspect, see also setHeight(), setWidth(), default value = false
bool keep_dx_aspect;
bool keep_dy_aspect;
void init( const int &x_pos, const int &y_pos, const int &w, const int &h,
const std::string& image_name,
@@ -86,7 +92,15 @@ class CComponentsPicture : public CComponentsItem
void SetTransparent(int t){ image_transparent = t; }
public:
///constructor for image objects, use this for scaled images, scaling dimensions are defined with parameters w (width) and h (height)
/*!
Constructor for image objects: use this for scaled images.
Dimensions are defined with parameters w (width) and h (height).
Note: only dimension values >0 causes scaling of image!
Note: See also class CComponentsPictureScalable(). That does the same like this, but uses internal value 0 for parameters w (width) and h (height).
If scaling is not required, you should use overloaded version that comes without dimension parameters.
If no dimensions are defined (in constructor or e.g. with setWidth() or setHeight(),
width and height are defined by image itself and are retrievable e.g. with getWidth() or getHeight().
*/
CComponentsPicture( const int &x_pos, const int &y_pos, const int &w, const int &h,
const std::string& image_name,
CComponentsForm *parent = NULL,
@@ -96,7 +110,13 @@ class CComponentsPicture : public CComponentsItem
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0,
int transparent = CFrameBuffer::TM_NONE);
///constructor for image objects, use this for non scaled images, dimensions are defined by image size
/*!
Constructor for image objects, use this for non scaled images. This is similar with known method paintIcon() from framebuffer class.
Dimensions are defined by image itself.
Note: you can use the dimension setters setWidth() or setHeight() too, but this has only effects for item body, not for image!
If scaling is required, you should use overloaded version above, that comes with dimension parameters or use
class CComponentsPictureScalable().
*/
CComponentsPicture( const int &x_pos, const int &y_pos,
const std::string& image_name,
CComponentsForm *parent = NULL,
@@ -111,18 +131,49 @@ class CComponentsPicture : public CComponentsItem
///sets an image name (unscaled icons only), full image path or url to an image file
virtual void setPicture(const char* picture_name);
///handle image size
virtual void getSize(int* width_image, int *height_image);
///return width of component
virtual int getWidth();
///return height of component
virtual int getHeight();
///set width of object and image, value >0 causes scale of image, parameter keep_aspect = true causes scaling of height with same aspect, default = false
virtual void setWidth(const int& w, bool keep_aspect = false);
///set height of object and image, value >0 causes scale of image, parameter keep_aspect = true causes scaling of width with same aspect, , default = false
virtual void setHeight(const int& h, bool keep_aspect = false);
///set width of object and image related to current screen size, see also CComponentsItem::setWidthP(), parameter as uint8_t
virtual void setWidthP(const uint8_t& w_percent){CComponentsItem::setWidthP(w_percent), do_scale = true; initCCItem();}
///set height of object and image related to current screen size, see also CComponentsItem::setHeightP(), parameter as uint8_t
virtual void setHeightP(const uint8_t& h_percent){CComponentsItem::setHeightP(h_percent), do_scale = true; initCCItem();}
///return paint mode of internal image, true=image was painted, please do not to confuse with isPainted()! isPainted() is related to item itself.
virtual inline bool isPicPainted(){return is_image_painted;};
///handle image size
void getImageSize(int* width_image, int *height_image);
///paint item
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
///hide item
virtual void hide(bool no_restore = false);
};
class CComponentsPictureScalable : public CComponentsPicture
{
public:
/*!
Constructor for image objects: use this for scaled images.
Does the same like class CComponentsPicture() with assigned value 0 for parameters w (width) and h (height).
*/
CComponentsPictureScalable( const int &x_pos, const int &y_pos,
const std::string& image_name,
CComponentsForm *parent = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_background = 0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0,
int transparent = CFrameBuffer::TM_NONE)
: CComponentsPicture(x_pos, y_pos, 0, 0, image_name, parent, has_shadow, color_frame, color_background, color_shadow, transparent){};
};
class CComponentsChannelLogo : public CComponentsPicture
{
private:
@@ -137,7 +188,15 @@ class CComponentsChannelLogo : public CComponentsPicture
///indicates that logo is available, after paint or new instance, value = false
bool has_logo;
void init(const uint64_t& channelId, const std::string& channelName, bool allow_scale);
public:
/*!
Constructor for channel image objects: use this for scaled channel logos.
Does the same like class CComponentsPicture() with parameters w (width) and h (height), see above!
Requires parameter channel_name or channelId instead image filename
NOTE: channel name string is prefered!
*/
CComponentsChannelLogo( const int &x_pos, const int &y_pos, const int &w, const int &h,
const std::string& channelName = "",
const uint64_t& channelId =0,
@@ -147,7 +206,13 @@ class CComponentsChannelLogo : public CComponentsPicture
fb_pixel_t color_background = 0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0,
int transparent = CFrameBuffer::TM_BLACK);
/*!
Constructor for channel image objects: use this for non scaled channel logos.
Does the same like class CComponentsPicture() without parameters w (width) and h (height), see above!
Requires parameter channel_name or channelId instead image filename
NOTE: channel name string is prefered!
*/
CComponentsChannelLogo( const int &x_pos, const int &y_pos,
const std::string& channelName = "",
const uint64_t& channelId =0,
@@ -171,4 +236,25 @@ class CComponentsChannelLogo : public CComponentsPicture
};
class CComponentsChannelLogoScalable : public CComponentsChannelLogo
{
public:
/*!
Constructor for channel image objects: use this for scaled channel logos.
Does the same like class CComponentsPictureScalable(), see above!
Requires parameter channel_name or channelId instead image filename.
NOTE: channel name string is prefered!
*/
CComponentsChannelLogoScalable( const int &x_pos, const int &y_pos,
const std::string& channelName = "",
const uint64_t& channelId =0,
CComponentsForm *parent = NULL,
bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6,
fb_pixel_t color_background = 0,
fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0,
int transparent = CFrameBuffer::TM_BLACK)
: CComponentsChannelLogo(x_pos, y_pos, 0, 0, channelName, channelId, parent, has_shadow, color_frame, color_background, color_shadow, transparent){};
};
#endif

View File

@@ -32,7 +32,6 @@
#include <neutrino.h>
#include "cc_item_progressbar.h"
#include "cc_item_shapes.h"
#define ITEMW 4
#define POINT 2
@@ -380,9 +379,9 @@ void CProgressBarCache::applyGradient(fb_pixel_t *b)
if (v != last_old) {
last_old = v;
double s = sin((y + .5) * M_PI / pb_height) * .8 + .2;
float fr = ((last_old >> 16) & 0xff) * s + 0.5;
float fg = ((last_old >> 8) & 0xff) * s + 0.5;
float fb = ((last_old ) & 0xff) * s + 0.5;
float fr = float(((last_old >> 16) & 0xff) * s + 0.5);
float fg = float(((last_old >> 8) & 0xff) * s + 0.5);
float fb = float(((last_old ) & 0xff) * s + 0.5);
last_new = (last_old & 0xFF000000)
| ((unsigned int)fr << 16)
| ((unsigned int)fg << 8)
@@ -423,11 +422,14 @@ void CProgressBar::paintProgress(bool do_save_bg)
//progress
bool pb_invert = (pb_type == PB_REDRIGHT) || ((pb_type == PB_TIMESCALE) && g_settings.progressbar_timescale_invert);
if (pb_active_width != pb_last_width) {
CProgressBarCache *pbc = CProgressBarCache::lookup(pb_height, pb_max_width, pb_active_col, pb_passive_col, *pb_design, pb_invert, *pb_gradient, pb_red, pb_yellow, pb_green);
if (pbc)
pbc->paint(pb_x, pb_y, pb_active_width, pb_passive_width);
is_painted = true;
if (cc_allow_paint){
if (pb_active_width != pb_last_width) {
CProgressBarCache *pbc = CProgressBarCache::lookup(pb_height, pb_max_width, pb_active_col, pb_passive_col, *pb_design, pb_invert, *pb_gradient, pb_red, pb_yellow, pb_green);
if (pbc)
pbc->paint(pb_x, pb_y, pb_active_width, pb_passive_width);
is_painted = true;
}
}
if (is_painted)

View File

@@ -55,9 +55,6 @@
class CProgressBar : public CComponentsItem
{
protected:
void initVarProgressbar();
private:
///colors of active and passive bar area, active means the displayed value, passive the neutral area
fb_pixel_t pb_active_col, pb_passive_col;

View File

@@ -81,6 +81,7 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w
ct_text = text;
ct_old_text = ct_text;
ct_text_mode = mode;
ct_text_style = FONT_STYLE_REGULAR;
iX = x = x_pos;
iY = y = y_pos;
@@ -103,6 +104,7 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w
ct_text_sent = false;
ct_paint_textbg = false;
ct_force_text_paint = false;
ct_utf8_encoded = true;
initCCText();
initParent(parent);
@@ -147,6 +149,7 @@ void CComponentsText::initCCText()
ct_textbox->setWindowMaxDimensions(iWidth, iHeight);
ct_textbox->setWindowMinDimensions(iWidth, iHeight);
ct_textbox->enableSaveScreen(save_tbox_screen);
ct_textbox->enableUTF8(ct_utf8_encoded);
//observe behavior of parent form if available
bool force_text_paint = ct_force_text_paint;
@@ -180,33 +183,37 @@ void CComponentsText::clearCCText()
ct_textbox = NULL;
}
void CComponentsText::setText(const std::string& stext, const int mode, Font* font_text, const fb_pixel_t& color_text)
void CComponentsText::setText(const std::string& stext, const int mode, Font* font_text, const fb_pixel_t& color_text, const int& style)
{
ct_old_text = ct_text;
ct_text = stext;
ct_text_mode = mode;
ct_font = font_text;
if (mode != ~CTextBox::AUTO_WIDTH)
ct_text_mode = mode;
if (font_text)
ct_font = font_text;
if (color_text != 0)
ct_col_text = color_text;
setTextColor(color_text);
if (style != FONT_STYLE_REGULAR)
ct_text_style = style;
dprintf(DEBUG_DEBUG, "[CComponentsText] [%s - %d] ct_text: %s \n", __func__, __LINE__, ct_text.c_str());
}
void CComponentsText::setText(neutrino_locale_t locale_text, int mode, Font* font_text, const fb_pixel_t& color_text)
void CComponentsText::setText(neutrino_locale_t locale_text, int mode, Font* font_text, const fb_pixel_t& color_text, const int& style)
{
string stext = g_Locale->getText(locale_text);
setText(stext, mode, font_text, color_text);
setText(stext, mode, font_text, color_text, style);
}
void CComponentsText::setText(const char* ctext, const int mode, Font* font_text, const fb_pixel_t& color_text)
void CComponentsText::setText(const char* ctext, const int mode, Font* font_text, const fb_pixel_t& color_text, const int& style)
{
setText((string)ctext, mode, font_text, color_text);
setText((string)ctext, mode, font_text, color_text, style);
}
void CComponentsText::setText(const int digit, const int mode, Font* font_text, const fb_pixel_t& color_text)
void CComponentsText::setText(const int digit, const int mode, Font* font_text, const fb_pixel_t& color_text, const int& style)
{
string s_digit = iToString(digit);
setText(s_digit, mode, font_text, color_text);
setText(s_digit, mode, font_text, color_text, style);
}
string CComponentsText::getTextFromFile(const string& path_to_textfile)
@@ -230,14 +237,14 @@ string CComponentsText::getTextFromFile(const string& path_to_textfile)
}
//set text lines directly from a file, returns true on succsess
bool CComponentsText::setTextFromFile(const string& path_to_textfile, const int mode, Font* font_text, const fb_pixel_t& color_text)
bool CComponentsText::setTextFromFile(const string& path_to_textfile, const int mode, Font* font_text, const fb_pixel_t& color_text, const int& style)
{
string txt = getTextFromFile(path_to_textfile);
if (txt.empty())
return false;
setText(txt, mode, font_text, color_text);
setText(txt, mode, font_text, color_text, style);
return true;
}
@@ -298,3 +305,10 @@ int CComponentsText::getTextLinesAutoHeight(const int& textMaxHeight, const int&
return ret;
}
void CComponentsText::setTextColor(const fb_pixel_t& color_text)
{
ct_col_text = color_text;
if (ct_textbox)
ct_textbox->setTextColor(ct_col_text);
}

View File

@@ -45,6 +45,8 @@ class CComponentsText : public CComponentsItem, public CBox
CTextBox * ct_textbox;
///object: Fontrenderer object
Font * ct_font;
///property: font style
int ct_text_style;
///property: text color
fb_pixel_t ct_col_text;
@@ -61,6 +63,8 @@ class CComponentsText : public CComponentsItem, public CBox
///status: cached text string, mainly required to compare with current text
std::string ct_old_text;
bool ct_utf8_encoded;
///status: current text string is sent to CTextBox object
bool ct_text_sent;
///property: send to CTextBox object enableBackgroundPaint(true)
@@ -89,6 +93,12 @@ class CComponentsText : public CComponentsItem, public CBox
///paint CCItem backckrond (if paint_bg=true), apply initCCText() and send paint() to the CTextBox object
void paintText(bool do_save_bg = CC_SAVE_SCREEN_YES);
public:
enum {
FONT_STYLE_REGULAR = 0,
FONT_STYLE_BOLD = 1,
FONT_STYLE_ITALIC = 2
};
CComponentsText( const int x_pos = 10, const int y_pos = 10, const int w = 150, const int h = 50,
std::string text = "",
const int mode = CTextBox::AUTO_WIDTH,
@@ -116,7 +126,7 @@ class CComponentsText : public CComponentsItem, public CBox
///send options for text font (size and type), color and mode (allignment)
virtual inline void setTextFont(Font* font_text){ct_font = font_text;};
///set text color
virtual inline void setTextColor(fb_pixel_t color_text){ ct_col_text = color_text;};
virtual void setTextColor(const fb_pixel_t& color_text);
///get text color
virtual inline fb_pixel_t getTextColor(){return ct_col_text;};
///set text alignment, also see textbox.h for possible alignment modes
@@ -128,17 +138,17 @@ class CComponentsText : public CComponentsItem, public CBox
virtual inline void doPaintTextBoxBg(bool do_paintbox_bg){ ct_paint_textbg = do_paintbox_bg;};
///set text as string also possible with overloades members for loacales, const char and text file
virtual void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0);
virtual void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0, const int& style = FONT_STYLE_REGULAR);
///set text with const char*
virtual void setText(const char* ctext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0);
virtual void setText(const char* ctext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0, const int& style = FONT_STYLE_REGULAR);
///set text from locale
virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0);
virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0, const int& style = FONT_STYLE_REGULAR);
///set text from digit, digit is integer
virtual void setText(const int digit, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0);
virtual void setText(const int digit, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0, const int& style = FONT_STYLE_REGULAR);
///set text directly from a textfile, path as string is required
virtual bool setTextFromFile(const std::string& path_to_textfile, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0);
virtual bool setTextFromFile(const std::string& path_to_textfile, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL, const fb_pixel_t& color_text = 0, const int& style = FONT_STYLE_REGULAR);
///get text directly from a textfile, path as string is required
virtual std::string getTextFromFile(const std::string& path_to_textfile);
static std::string getTextFromFile(const std::string& path_to_textfile);
///returns current text content of text/label object as std::string
virtual std::string getText(){return ct_text;};
@@ -162,6 +172,9 @@ class CComponentsText : public CComponentsItem, public CBox
if (ct_textbox)
ct_textbox->enableSaveScreen(mode);
}
///enable/disable utf8 encoding
void enableUTF8(bool enable = true){ct_utf8_encoded = enable;}
void disableUTF8(bool enable = false){enableUTF8(enable);}
};

View File

@@ -51,8 +51,8 @@ CComponentsPIP::CComponentsPIP( const int x_pos, const int y_pos, const int perc
//CComponentsPIP
screen_w = frameBuffer->getScreenWidth(true);
screen_h = frameBuffer->getScreenHeight(true);
pic_name = DATADIR;
pic_name += "/neutrino/icons/start.jpg";
pic_name = ICONSDIR;
pic_name += "/start.jpg";
//CComponents
x = x_pos;
@@ -96,11 +96,15 @@ void CComponentsPIP::paint(bool do_save_bg)
return;
int mode = CNeutrinoApp::getInstance()->getMode();
if(mode == NeutrinoMessages::mode_tv || mode == NeutrinoMessages::mode_webtv) {
if(mode == NeutrinoMessages::mode_tv || mode == NeutrinoMessages::mode_webtv || mode == NeutrinoMessages::mode_ts) {
videoDecoder->Pig(pig_x, pig_y, pig_w, pig_h, screen_w, screen_h);
}
else{ //paint an alternate image if no tv mode available
CComponentsPicture pic = CComponentsPicture (pig_x, pig_y, pig_w, pig_h, pic_name, NULL, false, col_frame, col_frame);
pic.doPaintBg(false);
int w, h;
pic.getSize(&w, &h);
pic.setPos(pig_x + pig_w/2-w/2, pig_y + pig_h/2-h/2);
pic.setCorner(corner_rad, corner_type);
pic.paint(CC_SAVE_SCREEN_NO);
}

View File

@@ -111,9 +111,16 @@ class CComponentsSignals : public sigc::trackable
///signal on leave CComponentsForm::ScrollPage()
sigc::signal<void> OnAfterScrollPage;
///signal on before paint()
sigc::signal<void> OnBeforePaint;
///signal on after paint()
sigc::signal<void> OnAfterPaint;
///signal on before execute hide()
sigc::signal<void> OnBeforeHide;
///signal on after execute hide()
sigc::signal<void> OnAfterHide;
///signal on CComponentsForm::setSelectedItem() is completed
sigc::signal<void> OnSelect;
};

View File

@@ -40,7 +40,10 @@ CComponentsTimer::CComponentsTimer( const int& interval)
{
tm_thread = 0;
tm_interval = interval;
startTimer();
sl = sigc::mem_fun(*this, &CComponentsTimer::stopTimer);
if (interval > 0)
startTimer();
}
CComponentsTimer::~CComponentsTimer()
@@ -52,17 +55,14 @@ CComponentsTimer::~CComponentsTimer()
//thread handle
void* CComponentsTimer::initTimerThread(void *arg)
{
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0);
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS,0);
CComponentsTimer *timer = static_cast<CComponentsTimer*>(arg);
//start loop
while(timer) {
timer->mutex.lock();
timer->OnTimer();
timer->mutex.unlock();
mySleep(timer->tm_interval);
timer->mutex.unlock();
}
return 0;
@@ -73,14 +73,20 @@ bool CComponentsTimer::startTimer()
{
void *ptr = static_cast<void*>(this);
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0);
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS,0);
if(!tm_thread) {
int res = pthread_create (&tm_thread, NULL, initTimerThread, ptr) ;
if (res != 0){
dprintf(DEBUG_NORMAL,"[CComponentsTimer] [%s] pthread_create %s\n", __func__, strerror(errno));
return false;
}
dprintf(DEBUG_INFO,"[CComponentsTimer] [%s] timer thread [%lu] created with interval = %d\n", __func__, tm_thread, tm_interval);
}
dprintf(DEBUG_INFO,"[CComponentsTimer] [%s] timer thread [%lu] created with interval = %d\n", __func__, tm_thread, tm_interval);
//ensure kill of thread on any restart of neutrino
CNeutrinoApp::getInstance()->OnBeforeRestart.connect(sl);
return true;
}
@@ -99,6 +105,8 @@ bool CComponentsTimer::stopTimer()
}
if (thres == 0){
tm_thread = 0;
//ensure disconnect of unused slot
sl.disconnect();
return true;
}

View File

@@ -50,6 +50,8 @@ class CComponentsTimer : public sigc::trackable
static void* initTimerThread(void *arg);
///mutex for timer
OpenThreads::Mutex mutex;
///slot for signals
sigc::slot0<bool> sl;
public:
///class constructor, parameter interval sets the interval in seconds, default value=1 (1 sec)
@@ -62,7 +64,7 @@ class CComponentsTimer : public sigc::trackable
bool stopTimer();
///returns true, if timer is running in thread
bool isRun() const {return tm_thread == 0 ? false:true;};
bool isRun() const {return tm_thread;};
///set another interval in seconds
void setTimerIntervall(const int& seconds){tm_interval = seconds;};