mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 23:42:58 +02:00
CComponentsFooter: simplify implementation of button labels
button_label_l and button_label_s are now merged to button_label_cc with prepared default values for text and locales.This type contains all possible button label properties. Values for locales and string are evaluated in setButtonLabels(), so it's possible to remove some overloaded methodes.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Classes for generic GUI-related components.
|
||||
Copyright (C) 2013-2014, Thilo Graf 'dbt'
|
||||
Copyright (C) 2013-2017, Thilo Graf 'dbt'
|
||||
|
||||
License: GPL
|
||||
|
||||
@@ -102,7 +102,7 @@ void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const
|
||||
initParent(parent);
|
||||
}
|
||||
|
||||
void CComponentsFooter::setButtonLabels(const struct button_label_s * const content, const size_t& label_count, const int& chain_width, const int& label_width)
|
||||
void CComponentsFooter::setButtonLabels(const struct button_label_cc * const content, const size_t& label_count, const int& chain_width, const int& label_width)
|
||||
{
|
||||
/* clean up before init*/
|
||||
if (chain)
|
||||
@@ -178,7 +178,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label_s * const cont
|
||||
vector<CComponentsItem*> v_btns;
|
||||
int h_btn = /*(ccf_enable_button_bg ? */chain->getHeight()-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 txt = content[i].locale == NONEXISTANT_LOCALE ? content[i].text : g_Locale->getText(content[i].locale);
|
||||
string icon_name = string(content[i].button);
|
||||
|
||||
//ignore item, if no text and icon are defined;
|
||||
@@ -244,26 +244,10 @@ void CComponentsFooter::setButtonLabels(const struct button_label_s * const cont
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsFooter::setButtonLabels(const struct button_label_l * const content, const size_t& label_count, const int& chain_width, const int& label_width)
|
||||
{
|
||||
button_label_s buttons[label_count];
|
||||
|
||||
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].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;
|
||||
}
|
||||
|
||||
setButtonLabels(buttons, label_count, chain_width, label_width);
|
||||
}
|
||||
|
||||
void CComponentsFooter::setButtonLabels(const struct button_label * const content, const size_t& label_count, const int& chain_width, const int& label_width)
|
||||
{
|
||||
//conversion for compatibility with older paintButtons() methode, find in /gui/widget/buttons.h
|
||||
button_label_l buttons[label_count];
|
||||
button_label_cc buttons[label_count];
|
||||
for (size_t i = 0; i< label_count; i++){
|
||||
buttons[i].button = content[i].button;
|
||||
buttons[i].locale = content[i].locale;
|
||||
@@ -276,31 +260,15 @@ 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_cc> &v_content, const int& chain_width, const int& label_width)
|
||||
{
|
||||
size_t label_count = v_content.size();
|
||||
button_label_l buttons[label_count];
|
||||
|
||||
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].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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
size_t label_count = v_content.size();
|
||||
button_label_s buttons[label_count];
|
||||
button_label_cc buttons[label_count];
|
||||
|
||||
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].locale = v_content[i].locale;
|
||||
buttons[i].directKey = v_content[i].directKey;
|
||||
buttons[i].directKeyAlt = v_content[i].directKeyAlt;
|
||||
buttons[i].btn_result = v_content[i].btn_result;
|
||||
@@ -319,7 +287,7 @@ void CComponentsFooter::setButtonLabel( const char *button_icon,
|
||||
const int& alias_value,
|
||||
const neutrino_msg_t& directKeyAlt)
|
||||
{
|
||||
button_label_s button[1];
|
||||
button_label_cc button[1];
|
||||
|
||||
button[0].button = button_icon;
|
||||
button[0].text = text;
|
||||
|
@@ -3,7 +3,7 @@
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Classes for generic GUI-related components.
|
||||
Copyright (C) 2012, 2013, 2014, Thilo Graf 'dbt'
|
||||
Copyright (C) 2012-2017, Thilo Graf 'dbt'
|
||||
|
||||
License: GPL
|
||||
|
||||
@@ -30,25 +30,17 @@
|
||||
#include <gui/widget/buttons.h> //for compatibility with 'button_label' type
|
||||
|
||||
//for 'button_label' type with string
|
||||
typedef struct button_label_s
|
||||
typedef struct button_label_cc
|
||||
{
|
||||
const char * button;
|
||||
std::string text;
|
||||
neutrino_msg_t directKey;
|
||||
neutrino_msg_t directKeyAlt;
|
||||
int btn_result;
|
||||
int btn_alias;
|
||||
} button_label_s_struct;
|
||||
|
||||
typedef struct button_label_l
|
||||
{
|
||||
const char * button;
|
||||
neutrino_locale_t locale;
|
||||
neutrino_msg_t directKey;
|
||||
neutrino_msg_t directKeyAlt;
|
||||
int btn_result;
|
||||
int btn_alias;
|
||||
} button_label_l_struct;
|
||||
button_label_cc(): text(std::string()), locale(NONEXISTANT_LOCALE){}
|
||||
} button_label_cc_struct;
|
||||
|
||||
/*!
|
||||
CComponentsFooter, sub class of CComponentsHeader provides prepared container for footer
|
||||
@@ -101,13 +93,9 @@ class CComponentsFooter : public CComponentsHeader
|
||||
fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
|
||||
|
||||
///add button labels with string label type as content, count as size_t, chain_width as int, label width as int
|
||||
void setButtonLabels(const struct button_label_s * 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, 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 struct button_label_cc * const content, const size_t& label_count, const int& chain_width = 0, const int& label_width = 0);
|
||||
///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_cc> &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;}
|
||||
|
@@ -139,27 +139,27 @@ int CLuaInstCCWindow::CCWindowNew(lua_State *L)
|
||||
else {
|
||||
CComponentsFooter* footer = (*udata)->w->getFooterObject();
|
||||
if (footer) {
|
||||
vector<button_label_s> buttons;
|
||||
vector<button_label_cc> buttons;
|
||||
if (!btnRed.empty()) {
|
||||
button_label_s btnSred;
|
||||
button_label_cc btnSred;
|
||||
btnSred.button = NEUTRINO_ICON_BUTTON_RED;
|
||||
btnSred.text = btnRed;
|
||||
buttons.push_back(btnSred);
|
||||
}
|
||||
if (!btnGreen.empty()) {
|
||||
button_label_s btnSgreen;
|
||||
button_label_cc btnSgreen;
|
||||
btnSgreen.button = NEUTRINO_ICON_BUTTON_GREEN;
|
||||
btnSgreen.text = btnGreen;
|
||||
buttons.push_back(btnSgreen);
|
||||
}
|
||||
if (!btnYellow.empty()) {
|
||||
button_label_s btnSyellow;
|
||||
button_label_cc btnSyellow;
|
||||
btnSyellow.button = NEUTRINO_ICON_BUTTON_YELLOW;
|
||||
btnSyellow.text = btnYellow;
|
||||
buttons.push_back(btnSyellow);
|
||||
}
|
||||
if (!btnBlue.empty()) {
|
||||
button_label_s btnSblue;
|
||||
button_label_cc btnSblue;
|
||||
btnSblue.button = NEUTRINO_ICON_BUTTON_BLUE;
|
||||
btnSblue.text = btnBlue;
|
||||
buttons.push_back(btnSblue);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
Günther@tuxbox.berlios.org
|
||||
|
||||
Implementation of CComponent Window class.
|
||||
Copyright (C) 2014-2016 Thilo Graf 'dbt'
|
||||
Copyright (C) 2014-2017 Thilo Graf 'dbt'
|
||||
|
||||
License: GPL
|
||||
|
||||
@@ -117,8 +117,8 @@ void CMsgBox::initTimeOut()
|
||||
|
||||
void CMsgBox::initButtons()
|
||||
{
|
||||
button_label_s btn;
|
||||
vector<button_label_s> v_buttons;
|
||||
button_label_cc btn;
|
||||
vector<button_label_cc> v_buttons;
|
||||
|
||||
//evaluate combinations
|
||||
if (mb_show_button & mbAll)
|
||||
|
Reference in New Issue
Block a user