Merge remote-tracking branch 'tuxbox/master'

This commit is contained in:
Stefan Seyfried
2016-12-04 18:02:51 +01:00
135 changed files with 3933 additions and 3385 deletions

View File

@@ -32,6 +32,7 @@
CCDraw::CCDraw() : COSDFader(g_settings.theme.menu_Content_alpha)
{
frameBuffer = CFrameBuffer::getInstance();
x = cc_xr = x_old = 0;
y = cc_yr = y_old = 0;
height = height_old = CC_HEIGHT_MIN;
@@ -40,10 +41,9 @@ CCDraw::CCDraw() : COSDFader(g_settings.theme.menu_Content_alpha)
col_body = col_body_old = COL_MENUCONTENT_PLUS_0;
col_shadow = col_shadow_old = COL_SHADOW_PLUS_0;
col_frame = col_frame_old = COL_FRAME_PLUS_0;
col_frame_sel = col_frame_sel_old = COL_MENUCONTENTSELECTED_PLUS_0;
col_shadow_clean = 0;
fr_thickness = fr_thickness_old = 0;
fr_thickness_sel = fr_thickness_sel_old = 3;
corner_type = corner_type_old = CORNER_ALL;
corner_rad = corner_rad_old = 0;
@@ -71,6 +71,9 @@ CCDraw::CCDraw() : COSDFader(g_settings.theme.menu_Content_alpha)
cc_body_gradient_saturation = 0xC0;
cc_body_gradient_direction = cc_body_gradient_direction_old = CFrameBuffer::gradientVertical;
cc_draw_timer = NULL;
cc_draw_trigger_slot = sigc::mem_fun0(*this, &CCDraw::paintTrigger);
cc_gradient_bg_cleanup = true;
v_fbdata.clear();
@@ -78,6 +81,9 @@ CCDraw::CCDraw() : COSDFader(g_settings.theme.menu_Content_alpha)
CCDraw::~CCDraw()
{
if(cc_draw_timer){
delete cc_draw_timer; cc_draw_timer = NULL;
}
clearFbData();
}
@@ -116,11 +122,6 @@ inline bool CCDraw::applyDimChanges()
fr_thickness_old = fr_thickness;
ret = true;
}
if (fr_thickness_sel != fr_thickness_sel_old){
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], dim changes fr_thickness_sel %d != fr_thickness_sel_old %d...\033[0m\n", __func__, __LINE__, fr_thickness_sel, fr_thickness_sel_old);
fr_thickness_old = fr_thickness;
ret = true;
}
if (shadow_w != shadow_w_old){
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], dim changes shadow_w_sel %d != shadow_w_old %d...\033[0m\n", __func__, __LINE__, shadow_w, shadow_w_old);
shadow_w_old = shadow_w;
@@ -158,11 +159,6 @@ inline bool CCDraw::applyColChanges()
col_frame_old = col_frame;
ret = true;
}
if (col_frame_sel != col_frame_sel_old){
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], col changes col_frame_sel %d != col_frame_sel_old %d...\033[0m\n", __func__, __LINE__, col_frame_sel, col_frame_sel_old);
col_frame_old = col_frame;
ret = true;
}
if (cc_body_gradient_enable != cc_body_gradient_enable_old){
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], col changes cc_body_gradient_enable %d != cc_body_gradient_enable_old %d...\033[0m\n", __func__, __LINE__, cc_body_gradient_enable, cc_body_gradient_enable_old);
cc_body_gradient_enable_old = cc_body_gradient_enable;
@@ -218,13 +214,10 @@ inline void CCDraw::setWidth(const int& w)
width = w;
}
void CCDraw::setFrameThickness(const int& thickness, const int& thickness_sel)
void CCDraw::setFrameThickness(const int& thickness)
{
fr_thickness = thickness;
if (fr_thickness_sel != thickness_sel)
fr_thickness_sel = thickness_sel;
//ensure enabled frame if frame width > 0
cc_enable_frame = false;
if (fr_thickness)
@@ -647,6 +640,7 @@ void CCDraw::paintFbItems(bool do_save_bg)
void CCDraw::hide()
{
OnBeforeHide();
//restore saved screen background of item if available
for(size_t i =0; i< v_fbdata.size() ;i++) {
if (v_fbdata[i].fbdata_type == CC_FBDATA_TYPE_BGSCREEN){
@@ -660,6 +654,7 @@ void CCDraw::hide()
}
is_painted = false;
firstPaint = true;
OnAfterHide();
}
//erase or paint over rendered objects
@@ -730,3 +725,42 @@ void CCDraw::enableShadow(int mode, const int& shadow_width, bool force_paint)
shadow_force = force_paint;
}
void CCDraw::paintTrigger()
{
if (!is_painted)
paint1();
else
hide();
}
bool CCDraw::paintBlink(const int& interval, bool is_nano)
{
if (cc_draw_timer == NULL){
cc_draw_timer = new CComponentsTimer(interval, is_nano);
if (cc_draw_timer->OnTimer.empty()){
cc_draw_timer->OnTimer.connect(cc_draw_trigger_slot);
}
}
if (cc_draw_timer)
return cc_draw_timer->isRun();
return false;
}
bool CCDraw::cancelBlink(bool keep_on_screen)
{
bool res = false;
if (cc_draw_timer){
res = cc_draw_timer->stopTimer();
delete cc_draw_timer; cc_draw_timer = NULL;
}
if(keep_on_screen)
paint1();
else
hide();
return res;
}

View File

@@ -27,6 +27,7 @@
#include "cc_types.h"
#include "cc_signals.h"
#include "cc_timer.h"
#include <driver/colorgradient.h>
#include <driver/fade.h>
#include <gui/color.h>
@@ -47,7 +48,14 @@ class CCDraw : public COSDFader, public CComponentsSignals
///object: framebuffer object, usable in all sub classes
CFrameBuffer * frameBuffer;
///internal draw timer, used for effects
CComponentsTimer *cc_draw_timer;
///slot for timer event, reserved for cc_draw_timer
sigc::slot0<void> cc_draw_trigger_slot;
///paint item with trigger effect
virtual void paintTrigger();
///property: x-position on screen, to alter with setPos() or setDimensionsAll(), see also defines CC_APPEND, CC_CENTERED
int x, x_old;
///property: y-position on screen, to alter setPos() or setDimensionsAll(), see also defines CC_APPEND, CC_CENTERED
@@ -67,13 +75,11 @@ class CCDraw : public COSDFader, public CComponentsSignals
fb_pixel_t col_shadow, col_shadow_old;
///property: color of frame
fb_pixel_t col_frame, col_frame_old;
///property: color of frame if component is selected, Note: fr_thickness_sel must be set
fb_pixel_t col_frame_sel, col_frame_sel_old;
///internal property: color for shadow clean up
fb_pixel_t col_shadow_clean;
///property: frame thickness, see also setFrameThickness()
int fr_thickness, fr_thickness_old;
///property: frame thickness of selected component, see also setFrameThickness()
int fr_thickness_sel, fr_thickness_sel_old;
///property: has corners with definied type, types are defined in /driver/frambuffer.h, without effect, if corner_radius=0
int corner_type, corner_type_old;
@@ -210,13 +216,12 @@ class CCDraw : public COSDFader, public CComponentsSignals
virtual void getDimensions(int* xpos, int* ypos, int* w, int* h){*xpos=x; *ypos=y; *w=width; *h=height;}
///set frame thickness
virtual void setFrameThickness(const int& thickness, const int& thickness_sel = 3);
virtual void setFrameThickness(const int& thickness);
///return of frame thickness
virtual int getFrameThickness(){return fr_thickness;}
///set frame color
virtual void setColorFrame(fb_pixel_t color){col_frame = color;}
///set selected frame color
virtual void setColorFrameSel(fb_pixel_t color){col_frame_sel = color;}
virtual void set2ndColor(fb_pixel_t col_2nd){cc_body_gradient_2nd_col = col_2nd;}
///get frame color
@@ -277,7 +282,12 @@ class CCDraw : public COSDFader, public CComponentsSignals
///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?
void allowPaint(bool allow){cc_allow_paint = allow; is_painted = cc_allow_paint ? false : true;}
void allowPaint(bool allow) {
if (allow != cc_allow_paint)
cc_allow_paint = allow;
if (cc_allow_paint)
is_painted = false;
}
///returns visibility mode
virtual bool paintAllowed(){return cc_allow_paint;};
@@ -297,10 +307,40 @@ class CCDraw : public COSDFader, public CComponentsSignals
///abstract: paint item, arg: do_save_bg see paintInit() above
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES) = 0;
///paint item, same like paint(CC_SAVE_SCREEN_YES) but without any argument
virtual void paint1(){paint(CC_SAVE_SCREEN_YES);}
///paint item, same like paint(CC_SAVE_SCREEN_NO) but without any argument
virtual void paint0(){paint(CC_SAVE_SCREEN_NO);}
///paint item, same like paint(CC_SAVE_SCREEN_YES) but without any argument
virtual void paint1(){paint(CC_SAVE_SCREEN_YES);}
/**paint item with blink effect
* This should work with all cc item types.
*
* @return bool returns true if effect is successful started
*
* @param[in] interval optional, interval time as int, default = 1
* @param[in] is_nano optional, time mode as bool, default = false means as seconds, true means nano seconds.
*
* @see take a look into test menu class for examples.
* cancelBlink()
*
* NOTE: If you want to use enbedded items from a cc form (e.g. with gettCCItem(ID))
* you must cast into current item type. e.g.:
* CComponentsItemBla* item = static_cast<CComponentsItemBla*>(form->getCCItem(2));
* and it's possible you must remove from screen before e.g.:
* item->kill();
*/
virtual bool paintBlink(const int& interval = 1, bool is_nano = false);
/**Cancel blink effect
*
* @return bool returns true if effect was successful canceled
*
* @param[in] keep_on_screen optional, exepts bool, default = false. means: item is not repainted after canceled effect
*
* @see take a look into test menu class for examples
* NOTE: Effect must be started with paintBlink()
*/
bool cancelBlink(bool keep_on_screen = false);
///signal on before paint fb layers, called inside paintFbItems()
sigc::signal<void> OnBeforePaintLayers;

View File

@@ -57,6 +57,10 @@ CComponentsForm::CComponentsForm( const int x_pos, const int y_pos, const int w,
corner_type = CORNER_ALL;
cc_item_index = 0;
//add default exit keys for exec handler
v_exit_keys.push_back(CRCInput::RC_home);
v_exit_keys.push_back(CRCInput::RC_setup);
v_cc_items.clear();
append_x_offset = 0;
@@ -69,7 +73,7 @@ CComponentsForm::CComponentsForm( const int x_pos, const int y_pos, const int w,
page_scroll_mode = PG_SCROLL_M_UP_DOWN_KEY;
//connect page scroll slot
sigc::slot3<void, neutrino_msg_t&, neutrino_msg_data_t&, int&> sl = sigc::mem_fun(*this, &CComponentsForm::execPageScroll);
sigc::slot4<void, neutrino_msg_t&, neutrino_msg_data_t&, int&, bool&> sl = sigc::mem_fun(*this, &CComponentsForm::execPageScroll);
this->OnExec.connect(sl);
}
@@ -91,74 +95,65 @@ CComponentsForm::~CComponentsForm()
int CComponentsForm::exec()
{
dprintf(DEBUG_NORMAL, "[CComponentsForm] [%s - %d] \n", __func__, __LINE__);
OnBeforeExec();
//basic values
neutrino_msg_t msg;
neutrino_msg_data_t data;
int res = menu_return::RETURN_REPAINT;
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(-1);
//required exit keys
msg_list_t exit_keys[2];
exit_keys[0].msg = CRCInput::RC_setup;
exit_keys[1].msg = CRCInput::RC_home;
//allow exec loop
bool cancel_exec = false;
bool exit_loop = false;
while (!exit_loop)
//signal before exec
OnBeforeExec();
while (!cancel_exec)
{
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
//execute connected slots
OnExec(msg, data, res);
OnExec(msg, data, res, cancel_exec);
//exit loop
execExit(msg, data, res, exit_loop, exit_keys, 2);
execExit(msg, data, res, cancel_exec, v_exit_keys);
if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all)
{
dprintf(DEBUG_INFO, "[CComponentsForm] [%s - %d] messages_return::cancel_all\n", __func__, __LINE__);
res = menu_return::RETURN_EXIT_ALL;
exit_loop = EXIT;
cancel_exec = EXIT;
}
}
//signal after exec
OnAfterExec();
return res;
}
void CComponentsForm::execKey(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& exit_loop, const struct msg_list_t * const msg_list, const size_t& key_count, bool force_exit)
{
for(size_t i = 0; i < key_count; i++){
if (execKey(msg, data, res, exit_loop, msg_list[i].msg, force_exit)){
break;
}
}
}
void CComponentsForm::execKey(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& exit_loop, const std::vector<neutrino_msg_t>& v_msg_list, bool force_exit)
void CComponentsForm::execKey(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& cancel_exec, const std::vector<neutrino_msg_t>& v_msg_list, bool force_exit)
{
for(size_t i = 0; i < v_msg_list.size(); i++){
if (execKey(msg, data, res, exit_loop, v_msg_list[i], force_exit)){
if (execKey(msg, data, res, cancel_exec, v_msg_list[i], force_exit)){
break;
}
}
}
inline bool CComponentsForm::execKey(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& exit_loop, const neutrino_msg_t& msg_val, bool force_exit)
inline bool CComponentsForm::execKey(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& cancel_exec, const neutrino_msg_t& msg_val, bool force_exit)
{
if (msg == msg_val){
OnExecMsg(msg, data, res);
if (force_exit)
exit_loop = EXIT;
cancel_exec = EXIT;
return true;
}
return false;
}
void CComponentsForm::execPageScroll(neutrino_msg_t& msg, neutrino_msg_data_t& /*data*/, int& /*res*/)
void CComponentsForm::execPageScroll(neutrino_msg_t& msg, neutrino_msg_data_t& /*data*/, int& /*res*/, bool& /*cancel_exec*/)
{
if (page_scroll_mode == PG_SCROLL_M_OFF)
return;
@@ -178,9 +173,9 @@ void CComponentsForm::execPageScroll(neutrino_msg_t& msg, neutrino_msg_data_t& /
}
}
void CComponentsForm::execExit(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& exit_loop, const struct msg_list_t * const msg_list, const size_t& key_count)
void CComponentsForm::execExit(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& cancel_exec, const std::vector<neutrino_msg_t>& v_msg_list)
{
execKey(msg, data, res, exit_loop, msg_list, key_count, true);
execKey(msg, data, res, cancel_exec, v_msg_list, true);
}
@@ -497,7 +492,7 @@ void CComponentsForm::paintCCItems()
}
//check height and adapt if required
int bottom_frm = (cc_parent ? cc_yr : y) + height - 2*fr_thickness;
int bottom_frm = (cc_parent ? cc_yr : y) + height/* - 2*fr_thickness*/;
int bottom_item = cc_item->getRealYPos() + h_item;
int h_diff = bottom_item - bottom_frm;
int new_h = h_item - h_diff;
@@ -558,20 +553,20 @@ void CComponentsForm::setPageCount(const u_int8_t& pageCount)
u_int8_t CComponentsForm::getPageCount()
{
u_int8_t num = 1;
u_int8_t num = 0;
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);
page_count = static_cast<u_int8_t>(num+1);
return page_count;
}
void CComponentsForm::setSelectedItem(int item_id)
void CComponentsForm::setSelectedItem(int item_id, const fb_pixel_t& sel_frame_col, const fb_pixel_t& frame_col, const fb_pixel_t& sel_body_col, const fb_pixel_t& body_col, const int& frame_w, const int& sel_frame_w)
{
size_t count = v_cc_items.size();
int id = item_id;
@@ -595,19 +590,19 @@ void CComponentsForm::setSelectedItem(int item_id)
}
for (size_t i= 0; i< count; i++)
v_cc_items[i]->setSelected(i == (size_t)id);
v_cc_items[i]->setSelected(i == (size_t)id, sel_frame_col, frame_col, sel_body_col, body_col, frame_w, sel_frame_w);
OnSelect();
}
void CComponentsForm::setSelectedItem(CComponentsItem* cc_item)
void CComponentsForm::setSelectedItem(CComponentsItem* cc_item, const fb_pixel_t& sel_frame_col, const fb_pixel_t& frame_col, const fb_pixel_t& sel_body_col, const fb_pixel_t& body_col, const int& frame_w, const int& sel_frame_w)
{
int id = getCCItemId(cc_item);
if (id == -1){
dprintf(DEBUG_NORMAL, "[CComponentsForm] [%s - %d] invalid item parameter, no object available\n", __func__,__LINE__);
return;
}
setSelectedItem(id);
setSelectedItem(id, sel_frame_col, frame_col, sel_body_col, body_col, frame_w, sel_frame_w);
}
int CComponentsForm::getSelectedItem()

View File

@@ -56,6 +56,9 @@ class CComponentsForm : public CComponentsItem
///enable/disable page scrolling, default enabled with page scroll mode up/down keys, see also enablePageScroll()
int page_scroll_mode;
///container for exit keys, default exit keys are CRCInput::RC_home and CRCInput::RC_setup
std::vector <neutrino_msg_t> v_exit_keys;
///initialize basic properties
virtual void Init( const int& x_pos, const int& y_pos, const int& w, const int& h,
const fb_pixel_t& color_frame,
@@ -142,13 +145,30 @@ class CComponentsForm : public CComponentsItem
///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
virtual void setSelectedItem(int item_id);
virtual void setSelectedItem( int item_id,
const fb_pixel_t& sel_frame_col = COL_MENUCONTENTSELECTED_PLUS_0,
const fb_pixel_t& frame_col = COL_SHADOW_PLUS_0,
const fb_pixel_t& sel_body_col = COL_MENUCONTENT_PLUS_0,
const fb_pixel_t& body_col = COL_MENUCONTENT_PLUS_0,
const int& frame_w = 3,
const int& sel_frame_w = 3);
///select a definied item, parameter1 as CComponentsItem*
virtual void setSelectedItem(CComponentsItem* cc_item);
virtual void setSelectedItem( CComponentsItem* cc_item,
const fb_pixel_t& sel_frame_col = COL_MENUCONTENTSELECTED_PLUS_0,
const fb_pixel_t& frame_col = COL_SHADOW_PLUS_0,
const fb_pixel_t& sel_body_col = COL_MENUCONTENT_PLUS_0,
const fb_pixel_t& body_col = COL_MENUCONTENT_PLUS_0,
const int& frame_w = 3,
const int& sel_frame_w = 3);
///exec main method, see also sub exec methods
virtual int exec();
///adds additional exec key to current collection, default exit keys are CRCInput::RC_home and CRCInput::RC_setup
virtual void addExitKey(const neutrino_msg_t& key){v_exit_keys.push_back(key);}
///remove all current exec keys from current collection, NOTE: use addExitKey() if new exec key is required
virtual void removeExitKeys(){v_exit_keys.clear();}
///enum exec loop control
enum
{
@@ -156,38 +176,29 @@ class CComponentsForm : public CComponentsItem
EXIT = 1
};
///execKey() methods handle events for defined neutrino messages, see class CRCInput::, this methodes contains a signal handler named OnExecMsg, so it is possible to connect with any common function or method
///exec sub method for pressed keys, parameters1/2 by rev, parameter3 msg_list as struct contains a list of possible RC-messages for defined message, parameter4 defines size of struct, parameter5 force_exit default = false
virtual void execKey( neutrino_msg_t& msg,
neutrino_msg_data_t& data,
int& res,
bool& exit_loop,
const struct msg_list_t * const msg_list,
const size_t& key_count,
bool force_exit = false);
///exec sub method for pressed keys, parameters1/2 by rev, parameter3 msg_list as vector contains a list of possible RC-messages for defined message, parameter4 force_exit default = false
virtual void execKey( neutrino_msg_t& msg,
neutrino_msg_data_t& data,
int& res,
bool& exit_loop,
bool& cancel_exec,
const std::vector<neutrino_msg_t>& msg_list,
bool force_exit = false);
///exec sub method for pressed key, parameters1/2 by rev, parameter3 force_exit default = false
virtual bool execKey( neutrino_msg_t& msg,
neutrino_msg_data_t& data,
int& res,
bool& exit_loop,
bool& cancel_exec,
const neutrino_msg_t& msg_val,
bool force_exit = false);
///exec sub method for page scroll, parameter1 neutrino_msg_t by rev
virtual void execPageScroll(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res);
virtual void execPageScroll(neutrino_msg_t& msg, neutrino_msg_data_t& data, int& res, bool& cancel_exec);
///exec sub method for exit loop, parameters by rev
virtual void execExit( neutrino_msg_t& msg,
neutrino_msg_data_t& data,
int& res, bool& exit_loop,
const struct msg_list_t * const msg_list,
const size_t& key_count);
int& res, bool& cancel_exec,
const std::vector<neutrino_msg_t>& v_msg_list);
///enum scroll direction
enum

View File

@@ -101,7 +101,7 @@ void CComponentsButton::initVarButton( const int& x_pos, const int& y_pos, const
width = w;
height = h;
shadow = shadow_mode;
shadow_w = shadow ? OFFSET_SHADOW/2 : 0; //buttons are mostly small elements, so these elements should have a reasonable shadow width
shadow_w = shadow != CC_SHADOW_OFF ? (shadow_w == -1 ? OFFSET_SHADOW/2 : shadow_w) : 0; //buttons are mostly small elements, so these elements should have a reasonable shadow width
cc_body_gradient_enable = CC_COLGRAD_OFF/*g_settings.gradiant*/; //TODO: gradient is prepared for use but disabled at the moment till some other parts of gui parts are provide gradient
setColBodyGradient(cc_body_gradient_enable/*CColorGradient::gradientLight2Dark*/, CFrameBuffer::gradientVertical, CColorGradient::light);
@@ -124,7 +124,8 @@ void CComponentsButton::initVarButton( const int& x_pos, const int& y_pos, const
cc_btn_font = NULL;
cc_btn_icon = icon_name;
cc_btn_capt = caption;
cc_btn_msg = CRCInput::RC_nokey;
cc_directKey = CRCInput::RC_nokey;
cc_directKeyAlt = cc_directKey;
cc_btn_result = -1;
cc_btn_alias = -1;
@@ -187,43 +188,54 @@ void CComponentsButton::initCaption()
}
//set basic properties
int w_frame = fr_thickness;
if (cc_btn_capt_obj){
//position and size
int x_cap = fr_thickness;
int x_cap = w_frame;
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*65/100 /*- 2*fr_thickness*/;
int w_cap = width - w_frame - append_x_offset - x_cap - w_frame;
int h_cap = (height*85/100) - 2*w_frame;
/*NOTE:
paint of centered text in y direction without y_offset
looks unlovely displaced in y direction especially besides small icons and inside small areas,
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/2;
int y_cap = height/2 - h_cap/2;
cc_btn_capt_obj->setDimensionsAll(x_cap, y_cap, w_cap, h_cap);
//text and font
if (cc_btn_font == NULL)
cc_btn_font = *cc_btn_dy_font->getDynFont(w_cap, h_cap, cc_btn_capt);
Font* def_font = *cc_btn_dy_font->getDynFont(w_cap, h_cap, cc_btn_capt);
if (cc_btn_font == NULL){
/* use dynamic font as default font if no font defined */
cc_btn_font = def_font;
}else{
/* if button dimension too small, use dynamic font as default font size, this ignores possible defined font
* Otherwise definied font will be used.
*/
if (cc_btn_font->getHeight() > h_cap){
cc_btn_font = def_font;
}
}
cc_btn_capt_obj->setText(cc_btn_capt, CTextBox::NO_AUTO_LINEBREAK, cc_btn_font);
cc_btn_capt_obj->forceTextPaint(); //here required;
cc_btn_capt_obj->getCTextBoxObject()->setTextBorderWidth(0,0);
//set color
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);
cc_btn_capt_obj->setCorner(corner_rad-w_frame, corner_type);
}
//handle common position of icon and text inside container required for alignment
int w_required = fr_thickness + append_x_offset;
int w_required = w_frame + append_x_offset;
w_required += cc_btn_icon_obj ? cc_btn_icon_obj->getWidth() + append_x_offset : 0;
w_required += cc_btn_font ? cc_btn_font->getRenderWidth(cc_btn_capt) : 0;
w_required += append_x_offset + fr_thickness;
w_required += append_x_offset + w_frame;
//dynamic width
if (w_required > width){
@@ -235,7 +247,7 @@ void CComponentsButton::initCaption()
int x_icon = width/2 - w_required/2 /*+ fr_thickness + append_x_offset*/;
int w_icon = 0;
if (cc_btn_icon_obj){
x_icon += fr_thickness + append_x_offset;
x_icon += w_frame + append_x_offset;
cc_btn_icon_obj->setXPos(x_icon);
w_icon = cc_btn_icon_obj->getWidth();
/*in case of dynamic changed height of caption or button opbject itself,

View File

@@ -70,8 +70,10 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen
///property: icon name, only icons supported, to find in gui/widget/icons.h
std::string cc_btn_icon;
///property: assigned event message value, see driver/rcinput.h for possible values, default value = CRCInput::RC_nokey, see also setButtonEventMsg(), getButtonEventMsg()
neutrino_msg_t cc_btn_msg;
///property: assigned event message value, see driver/rcinput.h for possible values, default value = CRCInput::RC_nokey, see also setButtonDirectKey(), getButtonDirectKey()
neutrino_msg_t cc_directKey;
///property: assigned an alternate event message value, see driver/rcinput.h for possible values, default value = CRCInput::RC_nokey, see also setButtonDirectKeyAlt(), getButtonDirectKeyAlt()
neutrino_msg_t cc_directKeyAlt;
///property: assigned return value, see also setButtonResult(), getButtonResult(), default value = -1 (not defined)
int cc_btn_result;
///property: assigned alias value, see also setButtonAlias(), getButtonAlias(), default value = -1 (not defined)
@@ -133,7 +135,7 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen
fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
///set text 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;}
inline virtual void setButtonTextColor(fb_pixel_t caption_color){cc_btn_capt_col = caption_color;};
/**Member to modify background behavior of embeded caption object.
* @param[in] mode
@@ -162,9 +164,9 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen
virtual void setCaption(const neutrino_locale_t locale_text);
///get caption, type as std::string
virtual std::string getCaptionString(){return cc_btn_capt;};
inline virtual std::string getCaptionString(){return cc_btn_capt;};
///get loacalized caption id, type = neutrino_locale_t
virtual neutrino_locale_t getCaptionLocale(){return cc_btn_capt_locale;};
inline virtual neutrino_locale_t getCaptionLocale(){return cc_btn_capt_locale;};
///property: set font for label caption, parameter as font object, value NULL causes usaage of dynamic font
virtual void setButtonFont(Font* font){cc_btn_font = font; initCCBtnItems();};
@@ -176,17 +178,21 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
///assigns an event msg value to button object, parameter1 as neutrino_msg_t, see driver/rcinput.h for possible values
virtual void setButtonEventMsg(const neutrino_msg_t& msg){cc_btn_msg = msg;};
///return an event msg value to button object, see driver/rcinput.h for possible values
inline virtual neutrino_msg_t getButtonEventMsg(){return cc_btn_msg;};
inline virtual void setButtonDirectKey(const neutrino_msg_t& msg){cc_directKey = msg;};
///assigns an alternate event msg value to button object, parameter1 as neutrino_msg_t, see driver/rcinput.h for possible values
inline virtual void setButtonDirectKeyA(const neutrino_msg_t& msg){cc_directKeyAlt = msg;};
///returns an event msg value to button object, see driver/rcinput.h for possible values
inline virtual neutrino_msg_t getButtonDirectKey(){return cc_directKey;};
///returns an alternate event msg value to button object, but returns the primary direct key if no key was defined, see driver/rcinput.h for possible values
inline virtual neutrino_msg_t getButtonDirectKeyA(){return cc_directKeyAlt != CRCInput::RC_nokey ? cc_directKeyAlt : cc_directKey ;};
///assigns an return value to button object, parameter1 as int
virtual void setButtonResult(const int& result_value){cc_btn_result = result_value;};
inline virtual void setButtonResult(const int& result_value){cc_btn_result = result_value;};
///returns current result value of button object
inline virtual int getButtonResult(){return cc_btn_result;};
///assigns an alias value to button object, parameter1 as int, e.g. previous known as mbYes, mbNo... from message boxes
virtual void setButtonAlias(const int& alias_value){cc_btn_alias = alias_value;};
inline virtual void setButtonAlias(const int& alias_value){cc_btn_alias = alias_value;};
///returns an alias value from button object, see also cc_btn_alias
inline virtual int getButtonAlias(){return cc_btn_alias;};
};
@@ -239,6 +245,7 @@ class CComponentsButtonGreen : public CComponentsButton
:CComponentsButton(x_pos, y_pos, w, h, caption, NEUTRINO_ICON_BUTTON_GREEN, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow)
{
cc_item_type = CC_ITEMTYPE_BUTTON_GREEN;
};
CComponentsButtonGreen( const int& x_pos, const int& y_pos, const int& w, const int& h,
const neutrino_locale_t& caption_locale,

View File

@@ -190,8 +190,8 @@ void CComponentsFrmClock::initCCLockItems()
//background paint of item is not required
lbl->doPaintBg(false);
//set corner properties of label item
lbl->setCorner(corner_rad-fr_thickness, corner_type);
//preset corner properties of label item
lbl->setCorner(max(0, corner_rad-fr_thickness), corner_type);
//set text border to 0
lbl->setTextBorderWidth(0,0);
@@ -234,7 +234,7 @@ void CComponentsFrmClock::initCCLockItems()
else if (i == v_cc_items.size()-1)
lbl->setCornerType(corner_type & CORNER_RIGHT);// last label item
else
lbl->setCornerType(0);// inner items
lbl->setCorner(0,CORNER_NONE);// inner items don't need round corners
}
//extract timestring segment (char)

View File

@@ -34,6 +34,13 @@
using namespace std;
CComponentsExtTextForm::CComponentsExtTextForm(CComponentsForm* parent)
{
Font* t_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO];
initVarExtTextForm(0, 0, 300, t_font->getHeight(), "", "", t_font, parent, CC_SHADOW_OFF, COL_MENUCONTENTINACTIVE_TEXT, COL_MENUCONTENT_TEXT, COL_FRAME_PLUS_0, COL_MENUCONTENT_PLUS_0, COL_SHADOW_PLUS_0);
initCCTextItems();
}
CComponentsExtTextForm::CComponentsExtTextForm( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& label_text, const std::string& text,
Font* font_text,
@@ -47,20 +54,19 @@ CComponentsExtTextForm::CComponentsExtTextForm( const int& x_pos, const int& y_p
initCCTextItems();
}
CComponentsExtTextFormLocalized::CComponentsExtTextFormLocalized(const int& x_pos, const int& y_pos, const int& w, const int& h,
const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text,
Font* font_text,
CComponentsForm* parent,
int shadow_mode,
fb_pixel_t label_color,
fb_pixel_t text_color,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
: CComponentsExtTextForm( x_pos, y_pos, w, h,
g_Locale->getText(locale_label_text), g_Locale->getText(locale_text),
font_text,
parent,
shadow_mode,
label_color, text_color, color_frame, color_body, color_shadow){};
CComponentsExtTextForm::CComponentsExtTextForm( const int& x_pos, const int& y_pos, const int& w, const int& h,
neutrino_locale_t l_text, const std::string& text,
Font* font_text,
CComponentsForm* parent,
int shadow_mode,
fb_pixel_t label_color,
fb_pixel_t text_color,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{
initVarExtTextForm(x_pos, y_pos, w, h, (string)g_Locale->getText(l_text), text, font_text, parent, shadow_mode, label_color, text_color, color_frame, color_body, color_shadow);
initCCTextItems();
}
void CComponentsExtTextForm::initVarExtTextForm(const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& label_text, const std::string& text,
@@ -81,9 +87,13 @@ void CComponentsExtTextForm::initVarExtTextForm(const int& x_pos, const int& y_p
ccx_percent_label_w = DEF_LABEL_WIDTH_PERCENT;
ccx_label_width = ccx_percent_label_w * width/100;
ccx_text_width = width-ccx_label_width;
height = h;
if (height == 0)
height = DEF_HEIGHT;
y_text = 0;
ccx_label_text = label_text;
ccx_text = text;
shadow = shadow_mode;
@@ -95,8 +105,11 @@ void CComponentsExtTextForm::initVarExtTextForm(const int& x_pos, const int& y_p
ccx_label_obj = NULL;
ccx_text_obj = NULL;
corner_type = 0;
int dx = 0, dy = DEF_HEIGHT;
ccx_font = font_text == NULL ? *(CNeutrinoFonts::getInstance()->getDynFont(dx, dy)) : g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO];
ccx_font = font_text;
if (ccx_font == NULL){
int dx = 0, dy = height;
ccx_font = *(CNeutrinoFonts::getInstance()->getDynFont(dx, dy));
}
ccx_label_align = ccx_text_align = CTextBox::NO_AUTO_LINEBREAK;
initParent(parent);
@@ -120,9 +133,10 @@ void CComponentsExtTextForm::initLabel()
//set properties
if (ccx_label_obj){
ccx_label_width = (ccx_percent_label_w * width/100);
y_text = height/2 - height-2*fr_thickness;
ccx_label_obj->setText(ccx_label_text, ccx_label_align, ccx_font);
ccx_label_obj->setTextColor(ccx_label_color);
ccx_label_obj->setDimensionsAll(0, 0, ccx_label_width-2*fr_thickness, height-2*fr_thickness);
ccx_label_obj->setDimensionsAll(0, y_text, ccx_label_width-2*fr_thickness, height-2*fr_thickness);
ccx_label_obj->setCorner(this->corner_rad, CORNER_LEFT);
}
}
@@ -146,7 +160,7 @@ void CComponentsExtTextForm::initText()
ccx_text_width = width-ccx_label_obj->getWidth();
ccx_text_obj->setText(ccx_text, ccx_text_align, ccx_font);
ccx_text_obj->setTextColor(ccx_text_color);
ccx_text_obj->setDimensionsAll(CC_APPEND, 0, ccx_text_width-2*fr_thickness, height-2*fr_thickness);
ccx_text_obj->setDimensionsAll(ccx_label_obj->getWidth(), y_text, ccx_text_width-2*fr_thickness, height-2*fr_thickness);
ccx_text_obj->setCorner(this->corner_rad, CORNER_RIGHT);
}
}

View File

@@ -51,6 +51,8 @@ class CComponentsExtTextForm : public CComponentsForm, public CCTextScreen
Font* ccx_font;
///property: percentage val of label width related to full width, causes fit of text automatically into the available remaining size of item, see also setLabelWidthPercent()
uint8_t ccx_percent_label_w;
///centered y position of label and text
int y_text;
///object: label object
CComponentsLabel *ccx_label_obj;
@@ -79,7 +81,9 @@ class CComponentsExtTextForm : public CComponentsForm, public CCTextScreen
public:
///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as string
CComponentsExtTextForm( const int& x_pos = 1, const int& y_pos = 1, const int& w = 300, const int& h = 48,
CComponentsExtTextForm(CComponentsForm* parent = NULL);
CComponentsExtTextForm( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& label_text = "", const std::string& text = "",
Font* font_text = NULL,
CComponentsForm *parent = NULL,
@@ -89,6 +93,17 @@ class CComponentsExtTextForm : public CComponentsForm, public CCTextScreen
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
CComponentsExtTextForm( const int& x_pos, const int& y_pos, const int& w, const int& h,
neutrino_locale_t l_text = NONEXISTANT_LOCALE, const std::string& text = "",
Font* font_text = NULL,
CComponentsForm *parent = NULL,
int shadow_mode = CC_SHADOW_OFF,
fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT,
fb_pixel_t text_color = COL_MENUCONTENT_TEXT,
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
// ~CComponentsExtTextForm(); //inherited from CComponentsForm
///assigns texts for label and text, parameter as string, parameter Font is optional for required font type, default font is dependently from defined item height
@@ -142,20 +157,4 @@ class CComponentsExtTextForm : public CComponentsForm, public CCTextScreen
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
class CComponentsExtTextFormLocalized : public CComponentsExtTextForm
{
public:
///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as locales
CComponentsExtTextFormLocalized(const int& x_pos = 1, const int& y_pos = 1, const int& w = 300, const int& h = 48,
const neutrino_locale_t& locale_label_text = NONEXISTANT_LOCALE, const neutrino_locale_t& locale_text = NONEXISTANT_LOCALE,
Font* font_text = NULL,
CComponentsForm *parent = NULL,
int shadow_mode = CC_SHADOW_OFF,
fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT,
fb_pixel_t text_color = COL_MENUCONTENT_TEXT,
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
};
#endif

View File

@@ -69,13 +69,17 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
width = w == 0 ? frameBuffer->getScreenWidth(true) : w;
//init footer height
initCaptionFont();
height = max(h, cch_font->getHeight());
shadow = shadow_mode;
ccf_enable_button_shadow = false ;
ccf_button_shadow_width = shadow ? OFFSET_SHADOW/2 : 0;
ccf_button_shadow_force_paint = false;
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
cc_body_gradient_enable = cc_body_gradient_enable_old = g_settings.theme.menu_ButtonBar_gradient; //TODO: not complete implemented at the moment
cc_body_gradient_enable = cc_body_gradient_enable_old = CC_COLGRAD_OFF/*g_settings.theme.menu_ButtonBar_gradient*/; //TODO: not complete implemented at the moment
cc_body_gradient_direction = CFrameBuffer::gradientVertical;
cc_body_gradient_mode = CColorGradient::gradientDark2Light;
btn_auto_frame_col = false;
@@ -83,8 +87,8 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
corner_rad = RADIUS_LARGE;
corner_type = CORNER_BOTTOM;
btn_contour = false /*g_settings.theme.Button_gradient*/; //TODO: not implemented at the moment
ccf_btn_font = NULL;
ccf_enable_button_bg = false /*g_settings.theme.Button_gradient*/; //TODO: not implemented at the moment
ccf_btn_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT];
chain = NULL;
addContextButton(buttons);
@@ -94,46 +98,79 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
void CComponentsFooter::setButtonLabels(const struct button_label_s * const content, const size_t& label_count, const int& chain_width, const int& label_width)
{
//define required total width of button group, minimal width is >0, sensless values are nonsens!
int w_chain = chain_width > 0 ? chain_width : width;//TODO: alow and handle only with rational values >0, exit here
if (w_chain < 100){
dprintf(DEBUG_NORMAL, "[CComponentsFooter] [%s - %d] stupid width of chain: width = %d, values < 100 are nonsens, buttons not painted!\n", __func__, __LINE__, w_chain);
return;
/* clean up before init*/
if (chain)
chain->clear();
/* set general available full basic space for button chain,
* in this case this is footer width
*/
int w_chain = width - 2*cch_offset;
/* calculate current available space for button container depends
* of already enbedded footer objects.
* If already existing some items then subtract those width from footer width.
* ...so we have the possible usable size for button container.
*/
if(!v_cc_items.empty()){ //FIXME: footer container seems always not empty here, so here j initialized with = 1. I dont't know where it comes from! dbt!
for (size_t j= 1; j< size(); j++)
w_chain -= getCCItem(j)->getWidth();
}
//consider context button group on the right side of footer, if exist then subtract result from chain_width of button container
if (cch_btn_obj)
w_chain -= cch_btn_obj->getWidth();
/* On defined parameter chain_width
* calculate current available space for button container depends
* of passed chain with parameter
* Consider that chain_width is not too large.
*/
if (chain_width > 0 && chain_width <= w_chain){
if (chain_width <= w_chain){
w_chain = chain_width;
}
}
//calculate required position of button container
//consider icon (inherited) width, if exist then set evaluated result as x position for button label container and ...
int x_chain = 0;
/* initialize button container (chain object): this contains all passed (as interleaved) button label items,
* With this container we can work inside footer as primary container (in this context '=this') and the parent for the button label container (chain object).
* Button label container (chain object) itself is concurrent to the parent object for button objects.
*/
int x_chain = width/2 - w_chain/2;
if (cch_icon_obj)
x_chain = (cch_icon_obj->getXPos() + cch_offset + cch_icon_obj->getWidth());
//... reduce also total width for button label container
w_chain -= x_chain;
//initialize container (chain object) as button label container: this contains all passed (as interleaved) button label items, with this container we can work inside
//footer as primary container (in this context '=this') and the parent for the button label container (chain object),
//button label container (chain object) itself is concurrent the parent object for button objects.
x_chain = cch_offset+cch_icon_obj->getWidth()+cch_offset;
if (chain == NULL){
chain = new CComponentsFrmChain(x_chain, CC_CENTERED, w_chain, height, 0, CC_DIR_X, this, CC_SHADOW_OFF, COL_FRAME_PLUS_0, col_body);
chain = new CComponentsFrmChain(x_chain, 0, w_chain, height, 0, CC_DIR_X, this, CC_SHADOW_OFF, COL_MENUCONTENT_PLUS_6, col_body);
chain->setAppendOffset(0, 0);
chain->setCorner(this->corner_rad, this->corner_type);
chain->doPaintBg(false);
}
if (!chain->empty())
chain->clear();
//calculate default static width of button labels inside button object container related to available width of chain object
int w_btn_fix = chain->getWidth() / label_count;
int w_btn_min = min(label_width, w_btn_fix);
/* Calculate usable width of button labels inside button object container
* related to available width of chain object and passed
* label_width parameter.
* Parameter is used as minimal value and will be reduced
* if it is too large.
* Too small label_width parameter will be compensated by
* button objects itself.
*/
int w_offset = int((label_count-1)*cch_offset);
int w_btn = chain->getWidth()/label_count - w_offset;
if (label_width){
int w_label = label_width;
int w_defined = int(label_width*label_count);
int w_max = chain->getWidth() - w_offset;
while (w_defined > w_max){
w_label--;
w_defined = int(w_label*label_count) - w_offset;
}
w_btn = w_label;
}
int w_used = 0;
//generate and add button objects passed from button label content with default width to chain object.
/* generate button objects passed from button label content
* with default width to chain object.
*/
vector<CComponentsItem*> v_btns;
int h_btn = /*(ccf_enable_button_bg ? */(height*85/100)-2*fr_thickness-OFFSET_INNER_SMALL/* : height)*/-ccf_button_shadow_width;
for (size_t i= 0; i< label_count; i++){
string txt = content[i].text;
string icon_name = string(content[i].button);
string txt = content[i].text;
string icon_name = string(content[i].button);
//ignore item, if no text and icon are defined;
if (txt.empty() && icon_name.empty()){
@@ -141,14 +178,16 @@ void CComponentsFooter::setButtonLabels(const struct button_label_s * const cont
continue;
}
CComponentsButton *btn = new CComponentsButton(0, CC_CENTERED, w_btn_min, (btn_contour ? height-2*fr_thickness : height), txt, icon_name);
btn->setButtonFont(ccf_btn_font);
btn->doPaintBg(btn_contour);
btn->enableFrame(btn_contour);
btn->setButtonTextColor(COL_MENUFOOT_TEXT);
btn->setButtonEventMsg(content[i].btn_msg);
int y_btn = chain->getHeight()/2 - h_btn/2;
dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] y_btn [%d] ccf_button_shadow_width [%d]\n", __func__, __LINE__, y_btn, ccf_button_shadow_width);
CComponentsButton *btn = new CComponentsButton(0, y_btn, w_btn, h_btn, txt, icon_name, NULL, false, true, ccf_enable_button_shadow);
btn->doPaintBg(ccf_enable_button_bg);
btn->setButtonDirectKey(content[i].directKey);
btn->setButtonDirectKeyA(content[i].directKeyAlt);
btn->setButtonResult(content[i].btn_result);
btn->setButtonAlias(content[i].btn_alias);
btn->setButtonFont(ccf_btn_font);
//set button frames to icon color, predefined for available color buttons
if (btn_auto_frame_col){
@@ -164,32 +203,35 @@ void CComponentsFooter::setButtonLabels(const struct button_label_s * const cont
btn->setColorFrame(f_col);
}
chain->addCCItem(btn);
v_btns.push_back(btn);
//set x position of next button object
if (i != 0)
btn->setXPos(CC_APPEND);
//collect used button width inside chain object
w_used += btn->getWidth();
if (w_btn < btn->getWidth()){
btn->setWidth(w_btn);
btn->setButtonFont(NULL);
}
dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] button %s [%u] btn->getWidth() = %d w_btn = %d, (chain->getWidth() = %d)\n", __func__, __LINE__, txt.c_str(), i, btn->getWidth(), w_btn, chain->getWidth());
}
//calculate offset between button objects inside chain object
int w_rest = max(w_chain - w_used, 0);
int btn_offset = w_rest / chain->size();
chain->setAppendOffset(btn_offset, 0);
dprintf(DEBUG_INFO, "[CComponentsFooter] [%s - %d] btn_offset = %d, w_rest = %d, w_chain = %d, w_used = %d, chain->size() = %zu\n", __func__, __LINE__, btn_offset, w_rest, w_chain, w_used, chain->size());
/* add generated button objects to chain object.
*/
if (!v_btns.empty()){
/*add all buttons into button container*/
chain->addCCItem(v_btns);
//set x position of 1st button object inside chain, this is centering button objects inside chain
int x_1st_btn = btn_offset/2;
chain->getCCItem(0)->setXPos(x_1st_btn);
/* set position of labels, as centered inside button container*/
int w_chain_used = 0;
for (size_t a= 0; a< chain->size(); a++)
w_chain_used += chain->getCCItem(a)->getWidth();
w_chain_used += (chain->size()-1)*cch_offset;
//check used width of generated buttons, if required then use dynamic font, and try to fit buttons into chain container, dynamic font is used if ccf_btn_font==NULL
//NOTE: user should be set not too small window size and not too large fontsize, at some point this possibility will be depleted and it's no more space for readable caption
if (w_used > width && ccf_btn_font != NULL){
chain->clear();
ccf_btn_font = NULL;
setButtonLabels(content, label_count, chain_width, label_width);
int x_btn = chain->getWidth()/2 - w_chain_used/2;
chain->getCCItem(0)->setXPos(x_btn);
for (size_t c= 1; c< chain->size(); c++){
x_btn += chain->getCCItem(c-1)->getWidth()+ cch_offset;
chain->getCCItem(c)->setXPos(x_btn);
}
}
}
@@ -200,7 +242,8 @@ void CComponentsFooter::setButtonLabels(const struct button_label_l * const cont
for (size_t i= 0; i< label_count; i++){
buttons[i].button = content[i].button;
buttons[i].text = content[i].locale != NONEXISTANT_LOCALE ? g_Locale->getText(content[i].locale) : "";
buttons[i].btn_msg = content[i].btn_msg;
buttons[i].directKey = content[i].directKey;
buttons[i].directKeyAlt = content[i].directKeyAlt;
buttons[i].btn_result = content[i].btn_result;
buttons[i].btn_alias = content[i].btn_alias;
}
@@ -217,7 +260,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label * const conten
buttons[i].locale = content[i].locale;
//NOTE: here are used default values, because old button label struct don't know about this,
//if it possible, don't use this methode!
buttons[i].btn_msg = CRCInput::RC_nokey;
buttons[i].directKey = buttons[i].directKeyAlt = CRCInput::RC_nokey;
buttons[i].btn_result = -1;
buttons[i].btn_alias = -1;
}
@@ -232,7 +275,8 @@ void CComponentsFooter::setButtonLabels(const vector<button_label_l> &v_content,
for (size_t i= 0; i< label_count; i++){
buttons[i].button = v_content[i].button;
buttons[i].locale = v_content[i].locale;
buttons[i].btn_msg = v_content[i].btn_msg;
buttons[i].directKey = v_content[i].directKey;
buttons[i].directKeyAlt = v_content[i].directKeyAlt;
buttons[i].btn_result = v_content[i].btn_result;
buttons[i].btn_alias = v_content[i].btn_alias;
}
@@ -248,7 +292,8 @@ void CComponentsFooter::setButtonLabels(const vector<button_label_s> &v_content,
for (size_t i= 0; i< label_count; i++){
buttons[i].button = v_content[i].button;
buttons[i].text = v_content[i].text;
buttons[i].btn_msg = v_content[i].btn_msg;
buttons[i].directKey = v_content[i].directKey;
buttons[i].directKeyAlt = v_content[i].directKeyAlt;
buttons[i].btn_result = v_content[i].btn_result;
buttons[i].btn_alias = v_content[i].btn_alias;
}
@@ -256,39 +301,69 @@ void CComponentsFooter::setButtonLabels(const vector<button_label_s> &v_content,
setButtonLabels(buttons, label_count, chain_width, label_width);
}
void CComponentsFooter::setButtonLabel(const char *button_icon, const std::string& text, const int& chain_width, const int& label_width, const neutrino_msg_t& msg, const int& result_value, const int& alias_value)
void CComponentsFooter::setButtonLabel( const char *button_icon,
const std::string& text,
const int& chain_width,
const int& label_width,
const neutrino_msg_t& msg,
const int& result_value,
const int& alias_value,
const neutrino_msg_t& directKeyAlt)
{
button_label_s button[1];
button[0].button = button_icon;
button[0].text = text;
button[0].btn_msg = msg;
button[0].directKey = msg;
button[0].directKeyAlt = directKeyAlt;
button[0].btn_result = result_value;
button[0].btn_alias = alias_value;
setButtonLabels(button, 1, chain_width, label_width);
}
void CComponentsFooter::setButtonLabel(const char *button_icon, const neutrino_locale_t& locale, const int& chain_width, const int& label_width, const neutrino_msg_t& msg, const int& result_value, const int& alias_value)
void CComponentsFooter::setButtonLabel( const char *button_icon,
const neutrino_locale_t& locale,
const int& chain_width,
const int& label_width,
const neutrino_msg_t& msg,
const int& result_value,
const int& alias_value,
const neutrino_msg_t& directKeyAlt)
{
string txt = locale != NONEXISTANT_LOCALE ? g_Locale->getText(locale) : "";
setButtonLabel(button_icon, txt, chain_width, label_width, msg, result_value, alias_value);
setButtonLabel(button_icon, txt, chain_width, label_width, msg, result_value, alias_value, directKeyAlt);
}
void CComponentsFooter::showButtonContour(bool show)
void CComponentsFooter::enableButtonBg(bool enable)
{
btn_contour = show;
ccf_enable_button_bg = enable;
if (chain) {
for (size_t i= 0; i< chain->size(); i++)
chain->getCCItem(i)->doPaintBg(btn_contour);
chain->getCCItem(i)->doPaintBg(ccf_enable_button_bg);
}
}
void CComponentsFooter::setSelectedButton(size_t item_id)
void CComponentsFooter::setSelectedButton(size_t item_id,
const fb_pixel_t& fr_col, const fb_pixel_t& sel_fr_col,
const fb_pixel_t& bg_col, const fb_pixel_t& sel_bg_col,
const fb_pixel_t& text_col, const fb_pixel_t& sel_text_col,
const int& frame_width,
const int& sel_frame_width)
{
if (chain)
chain->setSelectedItem(item_id);
if (chain){
for (size_t i= 0; i< chain->size(); i++){
CComponentsButton *btn = static_cast<CComponentsButton*>(chain->getCCItem(i));
btn->setButtonTextColor(text_col);
}
fb_pixel_t sel_col = fr_col;
if (chain->size() > 1)
sel_col = sel_fr_col; //TODO: make it configurable
chain->setSelectedItem(item_id, sel_col, fr_col, sel_bg_col, bg_col, frame_width, sel_frame_width);
getSelectedButtonObject()->setButtonTextColor(sel_text_col);
}
}
int CComponentsFooter::getSelectedButton()
@@ -325,3 +400,29 @@ void CComponentsFooter::paintButtons(const int& x_pos,
this->paint(do_save_bg);
}
void CComponentsFooter::setButtonText(const uint& btn_id, const std::string& text)
{
CComponentsItem *item = getButtonChainObject()->getCCItem(btn_id);
if (item){
CComponentsButton *button = static_cast<CComponentsButton*>(item);
button->setCaption(text);
}
else
dprintf(DEBUG_NORMAL, "[CComponentsForm] [%s - %d] Error: can't set button text, possible wrong btn_id=%u, item=%p...\n", __func__, __LINE__, btn_id, item);
}
void CComponentsFooter::enableButtonShadow(int mode, const int& shadow_width, bool force_paint)
{
ccf_enable_button_shadow = mode;
ccf_button_shadow_width = shadow_width;
ccf_button_shadow_force_paint = force_paint;
if (chain){
for(size_t i=0; i<chain->size(); i++){
chain->getCCItem(i)->enableShadow(ccf_enable_button_shadow, ccf_button_shadow_width, ccf_button_shadow_force_paint);
int y_btn = ccf_enable_button_shadow == CC_SHADOW_OFF ? CC_CENTERED : chain->getHeight()/2 - chain->getCCItem(i)->getHeight()/2 - ccf_button_shadow_width;
chain->getCCItem(i)->setYPos(y_btn);
}
}
}

View File

@@ -34,7 +34,8 @@ typedef struct button_label_s
{
const char * button;
std::string text;
neutrino_msg_t btn_msg;
neutrino_msg_t directKey;
neutrino_msg_t directKeyAlt;
int btn_result;
int btn_alias;
} button_label_s_struct;
@@ -43,7 +44,8 @@ typedef struct button_label_l
{
const char * button;
neutrino_locale_t locale;
neutrino_msg_t btn_msg;
neutrino_msg_t directKey;
neutrino_msg_t directKeyAlt;
int btn_result;
int btn_alias;
} button_label_l_struct;
@@ -68,8 +70,14 @@ class CComponentsFooter : public CComponentsHeader
fb_pixel_t color_body,
fb_pixel_t color_shadow );
///show button frame and background, default false
bool btn_contour;
///show button with background, default false
bool ccf_enable_button_bg;
///enable button with shadow mode, default CC_SHADOW_OFF
int ccf_enable_button_shadow;
///set button shadow button width
int ccf_button_shadow_width;
///set button shadow button repaint mode
bool ccf_button_shadow_force_paint;
///enable/disable button frame in icon color, predefined for red, green, yellow and blue, default disabled
bool btn_auto_frame_col;
@@ -106,26 +114,83 @@ class CComponentsFooter : public CComponentsHeader
void setButtonLabels(const struct button_label * const content, const size_t& label_count, const int& chain_width = 0, const int& label_width = 0);
///add single button label with string label type as content, chain_width as int, label width as int
void setButtonLabel(const char *button_icon, const std::string& text, const int& chain_width = 0, const int& label_width = 0, const neutrino_msg_t& msg = CRCInput::RC_nokey, const int& result_value = -1, const int& alias_value = -1);
void setButtonLabel( const char *button_icon,
const std::string& text,
const int& chain_width = 0,
const int& label_width = 0,
const neutrino_msg_t& msg = CRCInput::RC_nokey,
const int& result_value = -1,
const int& alias_value = -1,
const neutrino_msg_t& directKeyAlt = CRCInput::RC_nokey);
///add single button label with locale label type as content, chain_width as int, label width as int
void setButtonLabel(const char *button_icon, const neutrino_locale_t& locale, const int& chain_width = 0, const int& label_width = 0, const neutrino_msg_t& msg = CRCInput::RC_nokey, const int& result_value = -1, const int& alias_value = -1);
void setButtonLabel( const char *button_icon,
const neutrino_locale_t& locale,
const int& chain_width = 0,
const int& label_width = 0,
const neutrino_msg_t& msg = CRCInput::RC_nokey,
const int& result_value = -1,
const int& alias_value = -1,
const neutrino_msg_t& directKeyAlt = CRCInput::RC_nokey);
///causes show/hide countour of button frame and background, parameter bool show, default= true
void showButtonContour(bool show = true);
///enables background of buttons, parameter bool show, default= true
void enableButtonBg(bool enable = true);
///disables background of buttons
void disableButtonBg(){enableButtonBg(false);}
///select a definied button, parameter1 as size_t
void setSelectedButton(size_t item_id);
/**Select a definied button inside button chain object
* @param[in] item_id
* @li optional: exepts type size_t
* @param[in] fr_col
* @li optional: exepts type fb_pixel_t, as default frame color
* @param[in] sel_fr_col
* @li optional: exepts type fb_pixel_t, as selected frame color
* @param[in] bg_col
* @li optional: exepts type fb_pixel_t, as default background color
* @param[in] sel_bg_col
* @li optional: exepts type fb_pixel_t, as selected background color
* @param[in] text_col
* @li optional: exepts type fb_pixel_t, as default text color
* @param[in] sel_text_col
* @li optional: exepts type fb_pixel_t, as selected text color
* @param[in] frame_width
* @li optional: exepts type int, default = 1
* @param[in] sel_frame_width
* @li optional: exepts type int, default = 2
*/
void setSelectedButton(size_t item_id,
const fb_pixel_t& fr_col = COL_MENUCONTENTSELECTED_PLUS_2,
const fb_pixel_t& sel_fr_col = COL_MENUCONTENTSELECTED_PLUS_0,
const fb_pixel_t& bg_col = COL_MENUCONTENT_PLUS_0,
const fb_pixel_t& sel_bg_col = COL_MENUCONTENTSELECTED_PLUS_0,
const fb_pixel_t& text_col = COL_MENUCONTENT_TEXT,
const fb_pixel_t& sel_text_col = COL_MENUCONTENTSELECTED_TEXT,
const int& frame_width = 1,
const int& sel_frame_width = 1);
///returns id of select button, return value as int, -1 = nothing is selected
int getSelectedButton();
///returns selected button object, return value as pointer to object, NULL means nothing is selected
CComponentsButton* getSelectedButtonObject();
/*!
Sets a new text to an already predefined button.
1st parameter 'btn_id' accepts current id of an already defined button. 2nd parameter sets the new text as std::string
Usage:
Buttons come with any text eg. 'Ok', 'No', 'Yes' ...whatever and this member allows to manipulate the text via button id.
Button id means the showed button begins from the left position of button chain, starts with value=0, also to get via getButtonChainObject()->getCCItemId([CComponentsButton*])
example: 1st buttons text is 'Hello', 2nd Button's text is 'You!',
Now we want to change the text of 2nd button to 'World", so we must do this:
setButtonText(1, "World");
Wrong id's will be ignored.
*/
void setButtonText(const uint& btn_id, const std::string& text);
///property: set font for label caption, parameter as font object, value NULL causes usage of dynamic font
void setButtonFont(Font* font){ccf_btn_font = font;};
///returns pointer to internal button container
CComponentsFrmChain* getButtonChainObject(){return chain;};
///this is a nearly methode similar with the older button handler find in gui/widget/buttons.h, some parameters are different, but require minimalized input
///this member sets some basic parameters and will paint concurrently on execute, explicit call of paint() is not required
void paintButtons( const int& x_pos,
@@ -146,7 +211,12 @@ class CComponentsFooter : public CComponentsHeader
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();};
virtual void setSizeMode(const int& size_mode){cch_size_mode = size_mode; initCCItems();}
///enable and sets shadow properties for embedded buttons
void enableButtonShadow(int mode = CC_SHADOW_ON, const int& shadow_width = OFFSET_SHADOW/2, bool force_paint = false);
///disable shadow for embedded buttons
void disbaleButtonShadow(){enableButtonShadow(CC_SHADOW_OFF);}
};
#endif

View File

@@ -119,8 +119,8 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen
CComponentsHeader(CComponentsForm *parent = NULL);
CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h = 0,
const std::string& caption = "",
const std::string& = "",
const std::string& caption = std::string(),
const std::string& = std::string(),
const int& buttons = 0,
CComponentsForm *parent = NULL,
int shadow_mode = CC_SHADOW_OFF,

View File

@@ -142,7 +142,7 @@ void CComponentsScrollBar::initSegments()
//init segment container
if (sb_segments_obj == NULL){
sb_segments_obj = new CComponentsFrmChain(CC_CENTERED, CC_APPEND, w_seg, h_seg_obj, NULL, CC_DIR_Y, this, false);
sb_segments_obj->setFrameThickness(0,0);
sb_segments_obj->setFrameThickness(0/*,0*/);
sb_segments_obj->setAppendOffset(0, 3);
}else
sb_segments_obj->setDimensionsAll(CC_CENTERED, CC_APPEND, w_seg, h_seg_obj);

View File

@@ -175,12 +175,12 @@ void CSignalBar::initSBarName()
sb_lbl->doPaintTextBoxBg(!cc_txt_save_screen);
sb_lbl->enableTboxSaveScreen(cc_txt_save_screen);
sb_lbl->setText(sb_name, CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, sb_font);
sb_lbl->setText(sb_name, CTextBox::NO_AUTO_LINEBREAK, sb_font);
//move and set dimensions
int lbl_x = sb_vlbl->getXPos()+ sb_vlbl->getWidth();
int lbl_h = sb_vlbl->getHeight();
sb_lbl->setDimensionsAll(lbl_x, 1, sb_lbl_width- append_x_offset, lbl_h);
sb_lbl->setDimensionsAll(lbl_x, 1, sb_lbl_width/*- append_x_offset*/, lbl_h);
//set current text and body color
sb_lbl->setTextColor(sb_caption_color);

View File

@@ -59,7 +59,7 @@ using namespace std;
//sub class CComponentsWindow inherit from CComponentsForm
CComponentsWindow::CComponentsWindow(CComponentsForm *parent)
{
initVarWindow(0, 0, 800, 600, "", "", parent);
initVarWindow(0, 0, 800, 600, "", "", parent, CC_SHADOW_OFF, COL_FRAME_PLUS_0, COL_MENUCONTENT_PLUS_0, COL_SHADOW_PLUS_0);
}
CComponentsWindow::CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h,
@@ -126,6 +126,7 @@ void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const
y = y_pos;
width = w;
height = h;
ccw_h_footer = 0; //auto
initWindowSize();
initWindowPos();
@@ -216,6 +217,8 @@ void CComponentsWindow::initFooter()
//add of footer item happens initCCWItems()
//set footer properties
if (ccw_footer){
if (ccw_h_footer)
ccw_footer->setHeight(ccw_h_footer);
ccw_footer->setPos(0, cc_yr + height - ccw_footer->getHeight()- fr_thickness);
ccw_footer->setWidth(width-2*fr_thickness);
ccw_footer->enableShadow(false/*shadow*/);
@@ -291,10 +294,11 @@ void CComponentsWindow::initBody()
int h_body = height - h_header - h_footer - fr_thickness;
int x_body = w_l_sidebar;
int w_body = width-2*fr_thickness - w_l_sidebar - w_r_sidebar;
ccw_body->setDimensionsAll(x_body, h_header, w_body, h_body);
ccw_body->doPaintBg(true);
ccw_body->setColorBody(col_body);
//handle corner behavior
if (!ccw_show_header)
ccw_body->setCornerType(CORNER_TOP);

View File

@@ -89,6 +89,8 @@ class CComponentsWindow : public CComponentsForm
fb_pixel_t ccw_col_head_text;
///footer bg color
fb_pixel_t ccw_col_footer;
///footer heigh, default defined by footer object itself
int ccw_h_footer;
///footer button font
Font* ccw_button_font;
@@ -105,14 +107,14 @@ class CComponentsWindow : public CComponentsForm
///initialze all window objects at once
void initCCWItems();
///initialize all attributes
void initVarWindow( const int& x_pos = CC_CENTERED, const int& y_pos = CC_CENTERED, const int& w = 0, const int& h = 0,
const std::string& caption = "",
const std::string& iconname = "",
CComponentsForm *parent = NULL,
int shadow_mode = CC_SHADOW_OFF,
fb_pixel_t color_frame = COL_FRAME_PLUS_0,
fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0,
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
void initVarWindow( const int& x_pos, const int& y_pos, const int& w, const int& h,
const std::string& caption,
const std::string& iconname,
CComponentsForm *parent,
int shadow_mode,
fb_pixel_t color_frame,
fb_pixel_t color_body,
fb_pixel_t color_shadow);
///initialize width and height
void initWindowSize();
///initialize position
@@ -222,6 +224,11 @@ class CComponentsWindow : public CComponentsForm
///paint all window items, this overwriting paint() from CComponentsForm
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
///adds additional exec key to current collection, default exit keys are CRCInput::RC_home and CRCInput::RC_setup
virtual void addExitKey(const neutrino_msg_t& key){getBodyObject()->addExitKey(key);}
///remove all current exec keys from current collection, NOTE: use addExitKey() if new exec key is required
virtual void removeExitKeys(){getBodyObject()->removeExitKeys();}
};
class CComponentsWindowMax : public CComponentsWindow

View File

@@ -3,7 +3,7 @@
Copyright (C) 2001 by Steffen Hehn 'McClean'
Classes for generic GUI-related components.
Copyright (C) 2012-2015, Thilo Graf 'dbt'
Copyright (C) 2012-2016, Thilo Graf 'dbt'
Copyright (C) 2012, Michael Liebmann 'micha-bbg'
License: GPL
@@ -72,49 +72,124 @@ void CComponentsItem::paintInit(bool do_save_bg)
is_painted = false; //force repaint if required
}
//calculate current needed frame thickeness and color, if item selected or not
fb_pixel_t col_frame_cur = col_frame;
int th = cc_enable_frame ? fr_thickness : 0;
if (v_fbdata.empty()){
int th = fr_thickness;
fb_pixel_t col_frame_cur = col_frame;
//set current position and dimensions
int ix = x, iy = y, dx = width, dy = height;
//and ensure sw is not larger than body dimensions, max x%
int sw = (shadow) ? min(shadow_w, min(dx, dy)*50/100) : 0;
/*ensure shadow is never < 0*/
sw = max(0, sw);
//calculate current needed frame thickeness and color, if item selected or not
if (cc_item_selected){
col_frame_cur = col_frame_sel;
th = max(fr_thickness_sel, fr_thickness);
}
//set current needed corner main box radius
int box_rad = corner_type ? corner_rad : 0;
//calculate current needed corner radius for body box, depends of frame thickness
int rad = (corner_rad>th) ? corner_rad-th : corner_rad;
int sw = (shadow) ? shadow_w : 0;
//and ensure max main box radius < dimensions
if (2*box_rad > dy)
box_rad -= max(0, 2*box_rad-dy);
if (2*box_rad > dx)
box_rad -= max(0, 2*box_rad-dy);
//evaluate shadow mode
bool sh_r = (shadow & CC_SHADOW_ON) || (shadow & CC_SHADOW_RIGHT);
bool sh_b = (shadow & CC_SHADOW_ON) || (shadow & CC_SHADOW_BOTTOM);
//Workaround: ensure radius values >= 0, framebuffer methode paintBoxRel() gets confused
box_rad = max(box_rad, 0);
//if item is bound on a parent form, we must use real x/y values and from parent form as reference
int ix = x, iy = y;
//if item is bound on a parent form,...
if (cc_parent){
//...we must use real x/y values and from parent form as reference
ix = cc_xr;
iy = cc_yr;
//...we must use color of parent body instead screen background
col_shadow_clean = cc_parent->getColorBody();
}
//handle shadow width
if (width <= sw || height <= sw){ //don't use shadow, if item dimensions too small
dprintf(DEBUG_NORMAL, "\033[33m[CComponentsItem]\t[%s - %d] shadow dimensions too small sw=%d, shadow is disabled set dimension to 0\033[0m\n",__func__, __LINE__, sw);
shadow = CC_SHADOW_OFF;
sw = 0;
}
int isw = sw*2;
int ixsr = ix + width - isw/2;
int iysb = iy + height - isw/2;
///evaluate shadow layer parts
//handle general shadow corner dimensions
int sh_cdx = box_rad+sw+th; //width
int sh_cdy = box_rad+sw+th; //height
//adapt shadow corner dimensions if body dimensions are too small, use an offset if required
int /*sh_cdx_size_offset,*/ sh_cdy_size_offset = 0;
if (sh_cdy*2 > dy)
sh_cdy_size_offset = sh_cdy*2-dy;
#if 0
if (sh_cdx*2 > dx)
sh_cdx_size_offset = sh_cdx*2-dx;
#endif
//handle shadow positions
//...corner bottom right
int sh_cbr_x = ix+dx-sh_cdx+sw;
int sh_cbr_y = iy+dy-sh_cdy+sw;
//...corner top right
int sh_ctr_x = sh_cbr_x;
int sh_ctr_y = iy+sw;
//...corner bottom left
int sh_cbl_x = ix+sw;
int sh_cbl_y = sh_cbr_y;
//handle general shadow bar dimensions
int sh_bdx = max(0, dx-sh_cdx-sh_cdx); /*ensure value is never < 0*/
int sh_rdy = dy-sh_cdy-sh_cdy;
//...bar bottom
int sh_bx = sh_cbl_x+sh_cdx;
int sh_by = iy+dy;
//...bar right
int sh_rx = ix+dx;
int sh_ry = sh_ctr_y+sh_cdy;
//corners
bool sh_ctr = (shadow & CC_SHADOW_CORNER_TOP_RIGHT);
bool sh_cbr = (shadow & CC_SHADOW_CORNER_BOTTOM_RIGHT);
bool sh_cbl = (shadow & CC_SHADOW_CORNER_BOTTOM_LEFT);
//...shadow bar right
bool sh_br = (shadow & CC_SHADOW_RIGHT);
if (sh_rdy < 1)
sh_br = false;
//...shadow bar bottom
bool sh_bb = (shadow & CC_SHADOW_BOTTOM);
if (sh_bdx < 1)
sh_bx = false;
//init paint layers
cc_fbdata_t fbdata[] =
{
{true, CC_FBDATA_TYPE_BGSCREEN, ix, iy, width+isw/2, height+isw/2, 0, 0, 0, 0, NULL, NULL, NULL, false}, //buffered bg
{sh_r, CC_FBDATA_TYPE_SHADOW_BOX, ixsr, iy+isw/2, isw, height, col_shadow, corner_rad, corner_type & CORNER_RIGHT, 0, NULL, NULL, NULL, false}, //shadow right
{sh_b, CC_FBDATA_TYPE_SHADOW_BOX, ix+isw/2, iysb, width, isw, col_shadow, corner_rad, corner_type & CORNER_BOTTOM, 0, NULL, NULL, NULL, false}, //shadow bottom
{true, CC_FBDATA_TYPE_BOX, ix+th, iy+th, width-2*th, height-2*th, col_body, rad, corner_type, 0, NULL, NULL, NULL, false}, //body
{true, CC_FBDATA_TYPE_FRAME, ix, iy, width, height, col_frame_cur, corner_rad, corner_type, th, NULL, NULL, NULL, false} //frame
//buffered bg
{true, CC_FBDATA_TYPE_BGSCREEN, ix, iy, dx+sw, dy+sw, 0, 0, 0, 0, NULL, NULL, NULL, false},
//shadow corner bottom left
{sh_cbl, CC_FBDATA_TYPE_SHADOW_BOX, sh_cbl_x, sh_cbl_y, sh_cdx, sh_cdy, col_shadow, box_rad, corner_type & CORNER_BOTTOM_LEFT, 0, NULL, NULL, NULL, false},
//clean up inside body
{sh_cbl, CC_FBDATA_TYPE_SHADOW_BOX, sh_cbl_x-sw+th, sh_cbl_y-sw, sh_cdx+sw, sh_cdy, col_shadow_clean, box_rad, corner_type & CORNER_BOTTOM_LEFT, 0, NULL, NULL, NULL, false},
//shadow bar bottom
{sh_bb, CC_FBDATA_TYPE_SHADOW_BOX, sh_bx, sh_by, sh_bdx, sw, col_shadow, 0, CORNER_NONE, 0, NULL, NULL, NULL, false},
//shadow corner bottom right
{sh_cbr, CC_FBDATA_TYPE_SHADOW_BOX, sh_cbr_x, sh_cbr_y, sh_cdx, sh_cdy, col_shadow, box_rad, corner_type & CORNER_BOTTOM_RIGHT, 0, NULL, NULL, NULL, false},
//clean up inside body
{sh_cbr, CC_FBDATA_TYPE_SHADOW_BOX, sh_cbr_x-sw, sh_cbr_y-sw, sh_cdx, sh_cdy, col_shadow_clean, box_rad, corner_type & CORNER_BOTTOM_RIGHT, 0, NULL, NULL, NULL, false},
//shadow bar right
{sh_br, CC_FBDATA_TYPE_SHADOW_BOX, sh_rx, sh_ry, sw, sh_rdy, col_shadow, 0, CORNER_NONE, 0, NULL, NULL, NULL, false},
//shadow corner top right
{sh_ctr, CC_FBDATA_TYPE_SHADOW_BOX, sh_ctr_x, sh_ctr_y, sh_cdx, sh_cdy-sh_cdy_size_offset, col_shadow, box_rad, corner_type & CORNER_TOP_RIGHT, 0, NULL, NULL, NULL, false},
//clean up inside body
{sh_ctr, CC_FBDATA_TYPE_SHADOW_BOX, sh_ctr_x-sw, sh_ctr_y-sw+th, sh_cdx, sh_cdy-sh_cdy_size_offset+sw, col_shadow_clean, box_rad, corner_type & CORNER_TOP_RIGHT, 0, NULL, NULL, NULL, false},
//main box
{true, CC_FBDATA_TYPE_BOX, ix+th, iy+th, dx-2*th, dy-2*th, col_body, max(0,box_rad-th), corner_type, 0, NULL, NULL, NULL, false},
//frame
{true, CC_FBDATA_TYPE_FRAME, ix, iy, dx, dy, col_frame_cur, box_rad, corner_type, th, NULL, NULL, NULL, false}
};
for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++) {
@@ -122,8 +197,16 @@ void CComponentsItem::paintInit(bool do_save_bg)
continue;
v_fbdata.push_back(fbdata[i]);
}
}
dprintf(DEBUG_DEBUG, "[CComponentsItem] %s:\ncc_item_type: %d\ncc_item_index = %d\nheight = %d\nwidth = %d\n", __func__, cc_item_type, cc_item_index, height, width);
//handle frame color for slected/not selected item
if (fr_thickness) {
for(size_t j =0; j< v_fbdata.size() ;j++) {
if ((v_fbdata[j].fbdata_type == CC_FBDATA_TYPE_FRAME)){
v_fbdata[j].color = col_frame_cur;
v_fbdata[j].frame_thickness = th;
}
}
}
paintFbItems(do_save_bg);
}
@@ -219,3 +302,11 @@ void CComponentsItem::setFocus(bool focus)
}
cc_has_focus = focus;
}
void CComponentsItem::setSelected(bool selected, const fb_pixel_t& sel_frame_col, const fb_pixel_t& frame_col, const fb_pixel_t& sel_body_col, const fb_pixel_t& body_col, const int& frame_w, const int& sel_frame_w)
{
cc_item_selected = selected;
fr_thickness = cc_item_selected ? sel_frame_w : frame_w;
col_body = cc_item_selected ? sel_body_col : body_col;
col_frame = cc_item_selected ? sel_frame_col : frame_col;
}

View File

@@ -105,8 +105,14 @@ class CComponentsItem : public CComponents
///syncronizes item colors with current color settings if required, NOTE: overwrites internal values!
virtual void syncSysColors();
///set select mode, see also col_frame_sel
virtual void setSelected(bool selected){cc_item_selected = selected;};
///set select mode
virtual void setSelected(bool selected,
const fb_pixel_t& sel_frame_col = COL_MENUCONTENTSELECTED_PLUS_0,
const fb_pixel_t& frame_col = COL_SHADOW_PLUS_0,
const fb_pixel_t& sel_body_col = COL_MENUCONTENT_PLUS_0,
const fb_pixel_t& body_col = COL_MENUCONTENT_PLUS_0,
const int& frame_w = 3,
const int& sel_frame_w = 3);
///set enable mode, see also cc_item_enabled
virtual void setEnable(bool enabled){cc_item_enabled = enabled;};

View File

@@ -83,6 +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);
///retur internal picture object
CComponentsPicture * getPictureObject(){return pic;}
///paint item
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};

View File

@@ -82,6 +82,7 @@ void CComponentsPicture::init( const int &x_pos, const int &y_pos, const int &w,
col_frame = color_frame;
col_body = color_background;
col_shadow = color_shadow;
col_shadow_clean= col_body;
do_scale = allow_scale;
image_cache = NULL; //image
enable_cache = false;
@@ -216,17 +217,21 @@ void CComponentsPicture::initCCItem()
* by setters setWidth/setHeight
* these steps are required to assign the current image dimensions to item dimensions
*/
if (keep_dx_aspect && dy){
if (keep_dx_aspect && dy)
{
float h_ratio = float(height)*100/(float)dy;
width = int(h_ratio*(float)dx/100);
#ifdef BOXMODEL_APOLLO
if (do_scale && (width > 10 || height > 10))
width = GetWidth4FB_HW_ACC(x+fr_thickness, width-2*fr_thickness)+2*fr_thickness;
#endif
keep_dx_aspect = false;
}
if (keep_dy_aspect && dx){
if (keep_dy_aspect && dx)
{
float w_ratio = float(width)*100/(float)dx;
height = int(w_ratio*(float)dy/100);
keep_dy_aspect = false;
}
//resize image and apply current assigned scale values
@@ -247,11 +252,11 @@ void CComponentsPicture::initPosition(int *x_position, int *y_position)
}
void CComponentsPicture::getSize(int* width_image, int *height_image)
{
*width_image = width;
*height_image = height;
}
// void CComponentsPicture::getSize(int* width_image, int *height_image)
// {
// *width_image = width;
// *height_image = height;
// }
int CComponentsPicture::getWidth()
{
@@ -344,6 +349,15 @@ bool CComponentsPicture::hasChanges()
return ret;
}
void CComponentsPicture::paintTrigger()
{
if (!is_painted && !isPicPainted())
paint1();
else
hide();
}
CComponentsChannelLogo::CComponentsChannelLogo( const int &x_pos, const int &y_pos, const int &w, const int &h,
const std::string& channelName,
const uint64_t& channelId,

View File

@@ -81,6 +81,9 @@ class CComponentsPicture : public CComponentsItem
///helper: indicate for reinit
bool need_init;
///paint item with changed paint and hide effect
void paintTrigger();
void init( const int &x_pos, const int &y_pos, const int &w, const int &h,
const std::string& image_name,
CComponentsForm *parent,
@@ -144,12 +147,12 @@ class CComponentsPicture : public CComponentsItem
///returns current assigned image name
std::string getPictureName(){return pic_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();
// ///handle image size
// void getSize(int* width_image, int *height_image);
///return width of item
int getWidth();
///return height of item
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);

View File

@@ -86,10 +86,11 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w
ct_text_mode = mode;
ct_text_style = font_style;
iX = x = x_old = x_pos; //TODO: equalize inhertited member names
iY = y = y_old = y_pos;
iWidth = width_old = width = w;
iHeight = height_old = height = h;
fr_thickness = 0;
x = x_old = x_pos;
y = y_old = y_pos;
width = width_old = w;
height = height_old = h;
/* we need a minimal borderwith of 1px because the edge-smoothing
(or fontrenderer?) otherwise will paint single pixels outside the
@@ -103,7 +104,7 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w
col_frame = color_frame;
col_body = color_body;
col_shadow = color_shadow;
fr_thickness = 0;
ct_text_sent = false;
ct_paint_textbg = false;
ct_force_text_paint = false;
@@ -114,6 +115,27 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w
}
void CComponentsText::initCBox()
{
x = max(0, x);
y = max(0, y);
int x_box = x + fr_thickness;
int y_box = y + fr_thickness;
if (cc_parent){
ct_box.iX = cc_xr;
ct_box.iY = cc_yr;
}else{
ct_box.iX = x_box;
ct_box.iY = y_box;
}
ct_box.iWidth = width - 2*fr_thickness;
ct_box.iHeight = height - 2*fr_thickness;
}
void CComponentsText::initCCText()
{
//set default font, if is no font definied
@@ -121,41 +143,32 @@ void CComponentsText::initCCText()
ct_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO];
//define height from font size
height = max(height, ct_font->getHeight());
//init CBox dimensions
iWidth = width-2*fr_thickness;
iHeight = height-2*fr_thickness;
//using of real x/y values to paint textbox if this text object is bound in a parent form
if (cc_parent){
int th_parent_fr = cc_parent->getFrameThickness();
iX = cc_xr + (x <= th_parent_fr ? th_parent_fr : 0);
iY = cc_yr - (y <= th_parent_fr ? th_parent_fr : 0);
}else{
iX = x;
iY = y;
}
iX += fr_thickness;
iY += fr_thickness;
int h_tmp = ct_font->getHeight();
height = max(height, h_tmp-2*fr_thickness);
if (width == 0)
width = max(width, CTextBox::getMaxLineWidth(ct_text, ct_font)-2*fr_thickness);
//init textbox
initCBox();
if (ct_textbox == NULL)
ct_textbox = new CTextBox();
//set text box properties
//set text properties
ct_textbox->setTextFont(ct_font);
ct_textbox->setTextMode(ct_text_mode);
ct_textbox->setWindowPos(this);
ct_textbox->setTextColor(ct_col_text);
ct_textbox->enableUTF8(ct_utf8_encoded);
//set text box properties
ct_textbox->setWindowPos(&ct_box);
ct_textbox->setWindowMaxDimensions(ct_box.iWidth, ct_box.iHeight);
ct_textbox->setWindowMinDimensions(ct_box.iWidth, ct_box.iHeight);
ct_textbox->setTextBorderWidth(ct_text_Hborder, ct_text_Vborder);
ct_textbox->enableBackgroundPaint(ct_paint_textbg && !cc_txt_save_screen);
ct_textbox->setBackGroundColor(col_body);
ct_textbox->setBackGroundRadius(corner_rad-fr_thickness, corner_type);
ct_textbox->setTextColor(ct_col_text);
ct_textbox->setWindowMaxDimensions(iWidth, iHeight);
ct_textbox->setWindowMinDimensions(iWidth, iHeight);
ct_textbox->setBackGroundRadius(0/*(corner_type ? corner_rad-fr_thickness : 0), corner_type*/);
ct_textbox->enableSaveScreen(cc_txt_save_screen && !ct_paint_textbg);
ct_textbox->enableUTF8(ct_utf8_encoded);
//observe behavior of parent form if available
bool force_text_paint = ct_force_text_paint;
@@ -169,7 +182,7 @@ void CComponentsText::initCCText()
#endif
//send text to CTextBox object, but force text paint text if force_text_paint option is enabled
//this is managed by CTextBox object itself
ct_text_sent = ct_textbox->setText(&ct_text, this->iWidth, force_text_paint);
ct_text_sent = ct_textbox->setText(&ct_text, ct_box.iWidth, force_text_paint);
//set current text status, needed by textChanged()
if (ct_text_sent){
@@ -180,7 +193,7 @@ void CComponentsText::initCCText()
//ensure clean font rendering on transparency background
ct_textbox->setTextRenderModeFullBG(!paint_bg);
// dprintf(DEBUG_NORMAL, "[CComponentsText] [%s - %d] init text: %s [x %d x_old %d, y %d y_old %d, w %d, h %d]\n", __func__, __LINE__, ct_text.c_str(), this->x, x_old, this->y, y_old, this->iWidth, this->iHeight);
// dprintf(DEBUG_NORMAL, "[CComponentsText] [%s - %d] ct_text = %s, x = %d , x_old = %d , y = %d , y_old = %d , \nct_box.iWidth = %d , ct_box.iHeight = %d , width = %d , height = %d, corner_rad = %d\n", __func__, __LINE__, ct_text.c_str(), x, x_old, y, y_old, ct_box.iWidth, ct_box.iHeight, width, height, corner_rad);
}
void CComponentsText::clearCCText()
@@ -287,25 +300,25 @@ void CComponentsText::hide()
void CComponentsText::setXPos(const int& xpos)
{
CCDraw::setXPos(xpos);
iX = x;
initCBox();
}
void CComponentsText::setYPos(const int& ypos)
{
CCDraw::setYPos(ypos);
iY = y;
initCBox();
}
void CComponentsText::setHeight(const int& h)
{
CCDraw::setHeight(h);
iHeight = height;
initCBox();
}
void CComponentsText::setWidth(const int& w)
{
CCDraw::setWidth(w);
iWidth = width;
initCBox();
}
//small helper to remove excessiv linbreaks

View File

@@ -40,11 +40,12 @@ Handling of text parts based up CTextBox attributes and methodes.
CComponentsText provides a interface to the embedded CTextBox object.
*/
class CComponentsText : public CCTextScreen, public CComponentsItem, public CBox
class CComponentsText : public CCTextScreen, public CComponentsItem
{
protected:
///object: CTextBox object
CTextBox * ct_textbox;
CBox ct_box;
///object: Fontrenderer object
Font * ct_font;
///property: font style
@@ -96,6 +97,9 @@ class CComponentsText : public CCTextScreen, public CComponentsItem, public CBox
///initialize all required attributes for text and send to the CTextBox object
void initCCText();
///init internal CBox object required by CTextBox object
void initCBox();
///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:
@@ -105,7 +109,7 @@ class CComponentsText : public CCTextScreen, public CComponentsItem, public CBox
FONT_STYLE_ITALIC = 2
};
CComponentsText( const int x_pos = 10, const int y_pos = 10, const int w = 150, const int h = 50,
CComponentsText( const int x_pos = 10, const int y_pos = 10, const int w = 0, const int h = 0,
std::string text = "",
const int mode = CTextBox::AUTO_WIDTH,
Font* font_text = NULL,

View File

@@ -102,7 +102,7 @@ class CComponentsSignals : public sigc::trackable
sigc::signal<void> OnAfterExec;
///signal on execute of CComponentsForm::exec()
sigc::signal<void, neutrino_msg_t&, neutrino_msg_data_t&, int&> OnExec;
sigc::signal<void, neutrino_msg_t&, neutrino_msg_data_t&, int&, bool&> OnExec;
///signal on received message in CComponentsForm::execKey()
sigc::signal<void, neutrino_msg_t&, neutrino_msg_data_t&, int&> OnExecMsg;

View File

@@ -36,10 +36,11 @@
using namespace std;
CComponentsTimer::CComponentsTimer(const int& interval)
CComponentsTimer::CComponentsTimer(const int& interval, bool is_nano)
{
tm_thread = 0;
tm_interval = interval;
tm_enable_nano = is_nano;
sl_stop_timer = sigc::mem_fun(*this, &CComponentsTimer::stopTimer);
@@ -59,7 +60,10 @@ void CComponentsTimer::runSharedTimerAction()
while(tm_enable && tm_interval > 0) {
tm_mutex.lock();
OnTimer();
mySleep(tm_interval);
if (!tm_enable_nano)
mySleep(tm_interval);
else
usleep((useconds_t)tm_interval);
tm_mutex.unlock();
}
@@ -142,10 +146,11 @@ bool CComponentsTimer::stopTimer()
return false;
}
void CComponentsTimer::setTimerInterval(const int& seconds)
void CComponentsTimer::setTimerInterval(const int& interval, bool is_nano)
{
if (tm_interval == seconds)
if (tm_interval == interval && tm_enable_nano == is_nano)
return;
tm_interval = seconds;
tm_enable_nano = is_nano;
tm_interval = interval;
}

View File

@@ -47,6 +47,8 @@ class CComponentsTimer : public sigc::trackable
///refresh interval in seconds
int tm_interval;
bool tm_enable_nano;
///init function to init shared timer action
static void* initThreadAction(void *arg);
@@ -71,10 +73,12 @@ class CComponentsTimer : public sigc::trackable
* @param[in] interval
* @li int interval in seconds, default value=1 (1 sec)
* If init value for interval > 0, timer starts immediately
* @li bool default = false as seconds mode, true = nano seconds mode
* @see
* setTimerInterval();
*/
CComponentsTimer(const int& interval = 1);
CComponentsTimer(const int& interval = 1, bool is_nano = false);
~CComponentsTimer();
/**Starts timer thread
@@ -105,15 +109,16 @@ class CComponentsTimer : public sigc::trackable
*/
bool isRun() const {return tm_thread;};
/**set interval in seconds
* @param[in] seconds
* @li int
/**set timer interval
* @param[in] interval
* @li int default interval in seconds, if second parameter = true interval is used as nano seconds
* @li bool default = false as seconds mode, true = nano seconds mode
* @return
* void
* @see
* tm_interval
*/
void setTimerInterval(const int& seconds);
void setTimerInterval(const int& interval, bool is_nano = false);
/**Provides a signal handler to receive any function or methode.
* Use this in your class where ever you need time controled actions.

View File

@@ -30,7 +30,7 @@
#include <system/localize.h>
#include <driver/fontrenderer.h>
#include <driver/rcinput.h>
#include <gui/color_custom.h>
class CComponentsForm;
class CComponentsScrollBar;
@@ -125,9 +125,9 @@ typedef struct cc_screen_data_t
//combination of rc messages with related icon
typedef struct msg_list_t
{
neutrino_msg_t msg;
neutrino_msg_t directKey;
const char* icon;
} key_list_t;
} msg_list_struct_t;
//align types
enum
@@ -186,10 +186,13 @@ typedef struct cc_string_ext_txt_t
#define CC_WIDTH_MIN 16
#define CC_HEIGHT_MIN 16
#define CC_SHADOW_OFF 0
#define CC_SHADOW_ON 1
#define CC_SHADOW_RIGHT 2
#define CC_SHADOW_BOTTOM 4
#define CC_SHADOW_OFF 0x0
#define CC_SHADOW_RIGHT 0x2
#define CC_SHADOW_BOTTOM 0x4
#define CC_SHADOW_CORNER_BOTTOM_LEFT 0x8
#define CC_SHADOW_CORNER_BOTTOM_RIGHT 0x10
#define CC_SHADOW_CORNER_TOP_RIGHT 0x20
#define CC_SHADOW_ON CC_SHADOW_RIGHT | CC_SHADOW_BOTTOM | CC_SHADOW_CORNER_BOTTOM_LEFT | CC_SHADOW_CORNER_BOTTOM_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT
#define CC_SAVE_SCREEN_YES true
#define CC_SAVE_SCREEN_NO false