From 71e5f964ab7967d0d778fc6e9ce54e22c585ac35 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Wed, 22 Jan 2014 18:38:30 +0100 Subject: [PATCH 01/20] CLuaInstance: Fix bool parameter in CWindow/SignalBox => paint()/hide() --- src/gui/luainstance.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 39cdcd8ca..ae4ddda32 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -1335,28 +1335,30 @@ CLuaCWindow *CLuaInstance::CWindowCheck(lua_State *L, int n) int CLuaInstance::CWindowPaint(lua_State *L) { lua_assert(lua_istable(L,1)); - int do_save_bg = 1; - tableLookup(L, "do_save_bg", do_save_bg); + std::string tmp = "true"; + tableLookup(L, "do_save_bg", tmp); + bool do_save_bg = (tmp == "true" || tmp == "1" || tmp == "yes"); CLuaCWindow *m = CWindowCheck(L, 1); if (!m) return 0; - m->w->paint((do_save_bg!=0)?true:false); + m->w->paint(do_save_bg); return 0; } int CLuaInstance::CWindowHide(lua_State *L) { lua_assert(lua_istable(L,1)); - int no_restore = 0; - tableLookup(L, "no_restore", no_restore); + std::string tmp = "false"; + tableLookup(L, "no_restore", tmp); + bool no_restore = (tmp == "true" || tmp == "1" || tmp == "yes"); CLuaCWindow *m = CWindowCheck(L, 1); if (!m) return 0; - m->w->hide((no_restore!=0)?true:false); + m->w->hide(no_restore); return 0; } @@ -1418,14 +1420,15 @@ int CLuaInstance::SignalBoxNew(lua_State *L) int CLuaInstance::SignalBoxPaint(lua_State *L) { lua_assert(lua_istable(L,1)); - int do_save_bg = 1; - tableLookup(L, "do_save_bg", do_save_bg); + std::string tmp = "true"; + tableLookup(L, "do_save_bg", tmp); + bool do_save_bg = (tmp == "true" || tmp == "1" || tmp == "yes"); CLuaSignalBox *m = SignalBoxCheck(L, 1); if (!m) return 0; - m->s->paint((do_save_bg!=0)?true:false); + m->s->paint(do_save_bg); return 0; } From 94558db6f88f860426baf5388a3a17a180a49d9a Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Thu, 23 Jan 2014 17:16:32 +0100 Subject: [PATCH 02/20] CNFSMountGui::menuEntry init type --- src/gui/nfs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/nfs.cpp b/src/gui/nfs.cpp index 86e8ccc60..619512d47 100644 --- a/src/gui/nfs.cpp +++ b/src/gui/nfs.cpp @@ -218,7 +218,7 @@ const CMenuOptionChooser::keyval NFS_TYPE_OPTIONS[NFS_TYPE_OPTION_COUNT] = int CNFSMountGui::menuEntry(int nr) { - int type; + int type = (int) CFSMounter::NFS; char cmd[9]; char cmd2[9]; From 4da2a33b29aff0a7bccb86c25bc740557d0eb0a9 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Thu, 23 Jan 2014 14:12:15 +0100 Subject: [PATCH 03/20] Revert "CLuaInstance: Fix compiler warnings" This reverts commit 87031add9489c8766005f62ad559da2252ea6fd2. This is wrong in so many aspects... just look up the definition of lua_integer... --- src/gui/luainstance.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index ae4ddda32..8e1ca929f 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -39,7 +39,7 @@ struct table_key { const char *name; - uint32_t code; + long code; }; struct lua_envexport { @@ -224,20 +224,20 @@ static void set_lua_variables(lua_State *L) { "TOP_RIGHT", CORNER_TOP_RIGHT }, { "BOTTOM_LEFT", CORNER_BOTTOM_LEFT }, { "BOTTOM_RIGHT", CORNER_BOTTOM_RIGHT }, - { "RADIUS_LARGE", (uint32_t) RADIUS_LARGE }, /* those depend on g_settings.rounded_corners */ - { "RADIUS_MID", (uint32_t) RADIUS_MID }, - { "RADIUS_SMALL", (uint32_t) RADIUS_SMALL }, - { "RADIUS_MIN", (uint32_t) RADIUS_MIN }, + { "RADIUS_LARGE", RADIUS_LARGE }, /* those depend on g_settings.rounded_corners */ + { "RADIUS_MID", RADIUS_MID }, + { "RADIUS_SMALL", RADIUS_SMALL }, + { "RADIUS_MIN", RADIUS_MIN }, { NULL, 0 } }; /* screen offsets, exported as e.g. SCREEN['END_Y'] */ table_key screenopts[] = { - { "OFF_X", (uint32_t) g_settings.screen_StartX }, - { "OFF_Y", (uint32_t) g_settings.screen_StartY }, - { "END_X", (uint32_t) g_settings.screen_EndX }, - { "END_Y", (uint32_t) g_settings.screen_EndY }, + { "OFF_X", g_settings.screen_StartX }, + { "OFF_Y", g_settings.screen_StartY }, + { "END_X", g_settings.screen_EndX }, + { "END_Y", g_settings.screen_EndY }, { NULL, 0 } }; table_key menureturn[] = @@ -696,7 +696,7 @@ bool CLuaMenuChangeObserver::changeNotify(lua_State *L, const std::string &luaAc lua_pushstring(L, luaId.c_str()); lua_pushstring(L, optionValue); lua_pcall(L, 2 /* two args */, 1 /* one result */, 0); - int res = lua_isnumber(L, -1) ? (int)lua_tonumber(L, -1) : 0; + double res = lua_isnumber(L, -1) ? lua_tonumber(L, -1) : 0; lua_pop(L, 2); return ((res == menu_return::RETURN_REPAINT) || (res == menu_return::RETURN_EXIT_REPAINT)); } @@ -1275,7 +1275,7 @@ int CLuaInstance::MessageboxExec(lua_State *L) tmp = "cancel"; for (int i = 0; mbr[i].name; i++) - if ((uint32_t)res == mbr[i].code) { + if (res == mbr[i].code) { tmp = mbr[i].name; break; } From 116065f7acb0b93a9ab89fdd3e836e61e2a1ec2b Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Thu, 23 Jan 2014 14:16:45 +0100 Subject: [PATCH 04/20] luainstance: do not export machine specific stuff It's an exported API, so it should be somewhat useful/stable, not change for every machine... --- src/gui/luainstance.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 8e1ca929f..945d33d7c 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -122,7 +122,7 @@ static void set_lua_variables(lua_State *L) { "mute_off", CRCInput::RC_mute_off }, { "analog_on", CRCInput::RC_analog_on }, { "analog_off", CRCInput::RC_analog_off }, -#if !HAVE_COOL_HARDWARE +#if 0 { "find", CRCInput::RC_find }, { "pip", CRCInput::RC_pip }, { "folder", CRCInput::RC_archive }, @@ -636,7 +636,7 @@ int CLuaInstance::GCWindow(lua_State *L) return 0; } -#if HAVE_COOL_HARDWARE +#if 1 int CLuaInstance::Blit(lua_State *) { return 0; From 2cd5aa4b1f5d50e915292deaaa8eb1fb7bd3cb2e Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Thu, 23 Jan 2014 14:55:43 +0100 Subject: [PATCH 05/20] luainstance: make the type of table_key.code explicitly clear --- src/gui/luainstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 945d33d7c..32a45151b 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -39,7 +39,7 @@ struct table_key { const char *name; - long code; + lua_Integer code; }; struct lua_envexport { From 1ab77083baed0dbbdef2bb4c903dfb8c97fc05c4 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Thu, 23 Jan 2014 15:36:13 +0100 Subject: [PATCH 06/20] luainstance: fix -Wnarrowing compiler warnings on 32bit platforms --- src/gui/luainstance.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 32a45151b..087a3b26b 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -170,21 +170,21 @@ static void set_lua_variables(lua_State *L) { "LIGHT_BLUE", MAGIC_COLOR | (COL_LIGHT_BLUE0) }, { "WHITE", MAGIC_COLOR | (COL_WHITE0) }, { "BLACK", MAGIC_COLOR | (COL_BLACK0) }, - { "COLORED_EVENTS_TEXT", (COL_COLORED_EVENTS_TEXT) }, - { "INFOBAR_TEXT", (COL_INFOBAR_TEXT) }, - { "INFOBAR_SHADOW_TEXT", (COL_INFOBAR_SHADOW_TEXT) }, - { "MENUHEAD_TEXT", (COL_MENUHEAD_TEXT) }, - { "MENUCONTENT_TEXT", (COL_MENUCONTENT_TEXT) }, - { "MENUCONTENT_TEXT_PLUS_1", (COL_MENUCONTENT_TEXT_PLUS_1) }, - { "MENUCONTENT_TEXT_PLUS_2", (COL_MENUCONTENT_TEXT_PLUS_2) }, - { "MENUCONTENT_TEXT_PLUS_3", (COL_MENUCONTENT_TEXT_PLUS_3) }, - { "MENUCONTENTDARK_TEXT", (COL_MENUCONTENTDARK_TEXT) }, - { "MENUCONTENTDARK_TEXT_PLUS_1", (COL_MENUCONTENTDARK_TEXT_PLUS_1) }, - { "MENUCONTENTDARK_TEXT_PLUS_2", (COL_MENUCONTENTDARK_TEXT_PLUS_2) }, - { "MENUCONTENTSELECTED_TEXT", (COL_MENUCONTENTSELECTED_TEXT) }, - { "MENUCONTENTSELECTED_TEXT_PLUS_1", (COL_MENUCONTENTSELECTED_TEXT_PLUS_1) }, - { "MENUCONTENTSELECTED_TEXT_PLUS_2", (COL_MENUCONTENTSELECTED_TEXT_PLUS_2) }, - { "MENUCONTENTINACTIVE_TEXT", (COL_MENUCONTENTINACTIVE_TEXT) }, + { "COLORED_EVENTS_TEXT", (lua_Integer) (COL_COLORED_EVENTS_TEXT) }, + { "INFOBAR_TEXT", (lua_Integer) (COL_INFOBAR_TEXT) }, + { "INFOBAR_SHADOW_TEXT", (lua_Integer) (COL_INFOBAR_SHADOW_TEXT) }, + { "MENUHEAD_TEXT", (lua_Integer) (COL_MENUHEAD_TEXT) }, + { "MENUCONTENT_TEXT", (lua_Integer) (COL_MENUCONTENT_TEXT) }, + { "MENUCONTENT_TEXT_PLUS_1", (lua_Integer) (COL_MENUCONTENT_TEXT_PLUS_1) }, + { "MENUCONTENT_TEXT_PLUS_2", (lua_Integer) (COL_MENUCONTENT_TEXT_PLUS_2) }, + { "MENUCONTENT_TEXT_PLUS_3", (lua_Integer) (COL_MENUCONTENT_TEXT_PLUS_3) }, + { "MENUCONTENTDARK_TEXT", (lua_Integer) (COL_MENUCONTENTDARK_TEXT) }, + { "MENUCONTENTDARK_TEXT_PLUS_1", (lua_Integer) (COL_MENUCONTENTDARK_TEXT_PLUS_1) }, + { "MENUCONTENTDARK_TEXT_PLUS_2", (lua_Integer) (COL_MENUCONTENTDARK_TEXT_PLUS_2) }, + { "MENUCONTENTSELECTED_TEXT", (lua_Integer) (COL_MENUCONTENTSELECTED_TEXT) }, + { "MENUCONTENTSELECTED_TEXT_PLUS_1", (lua_Integer) (COL_MENUCONTENTSELECTED_TEXT_PLUS_1) }, + { "MENUCONTENTSELECTED_TEXT_PLUS_2", (lua_Integer) (COL_MENUCONTENTSELECTED_TEXT_PLUS_2) }, + { "MENUCONTENTINACTIVE_TEXT", (lua_Integer) (COL_MENUCONTENTINACTIVE_TEXT) }, { NULL, 0 } }; From 8652b5c925cd1dfa7117cf8bc0199f8a968da6fa Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Fri, 24 Jan 2014 16:40:49 +0100 Subject: [PATCH 07/20] CNFSMountGui::menuEntry -fix init type (thx Gaucho316) --- src/gui/nfs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/nfs.cpp b/src/gui/nfs.cpp index 619512d47..76ff59e63 100644 --- a/src/gui/nfs.cpp +++ b/src/gui/nfs.cpp @@ -218,7 +218,7 @@ const CMenuOptionChooser::keyval NFS_TYPE_OPTIONS[NFS_TYPE_OPTION_COUNT] = int CNFSMountGui::menuEntry(int nr) { - int type = (int) CFSMounter::NFS; + int type = g_settings.network_nfs[nr].type; char cmd[9]; char cmd2[9]; From 0b30c8f2c52cf498b9726f7b79f67b98ff135e83 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Fri, 24 Jan 2014 18:01:59 +0100 Subject: [PATCH 08/20] supplement to 8652b5c925cd1dfa7117cf8bc0199f8a968da6fa --- src/gui/nfs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/nfs.cpp b/src/gui/nfs.cpp index 76ff59e63..6216884cf 100644 --- a/src/gui/nfs.cpp +++ b/src/gui/nfs.cpp @@ -218,7 +218,7 @@ const CMenuOptionChooser::keyval NFS_TYPE_OPTIONS[NFS_TYPE_OPTION_COUNT] = int CNFSMountGui::menuEntry(int nr) { - int type = g_settings.network_nfs[nr].type; + int &type = g_settings.network_nfs[nr].type; char cmd[9]; char cmd2[9]; From 5ea7ec48dfd36323ed09e85b967d75cf64fde015 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 18 Jan 2014 20:41:55 +0100 Subject: [PATCH 09/20] CComponentsHeader: rework constructors, add CComponentsHeaderLocalized Member initVarHeader() now used with parameters, so it's possible to remove multiple code in constructors, but some class must be renamed to CComponentsHeaderLocalized. --- src/gui/audioplayer.cpp | 2 +- src/gui/bedit/bouqueteditor_bouquets.cpp | 2 +- src/gui/bedit/bouqueteditor_channels.cpp | 2 +- src/gui/bookmarkmanager.cpp | 2 +- src/gui/bouquetlist.cpp | 2 +- src/gui/channellist.cpp | 2 +- src/gui/components/cc_frm_footer.cpp | 56 +++++--- src/gui/components/cc_frm_header.cpp | 151 +++++++++++--------- src/gui/components/cc_frm_header.h | 172 ++++++++++++++++++----- src/gui/epgplus.cpp | 2 +- src/gui/filebrowser.cpp | 2 +- src/gui/motorcontrol.cpp | 2 +- src/gui/pictureviewer.cpp | 2 +- src/gui/pluginlist.cpp | 2 +- src/gui/scan.cpp | 4 +- src/gui/timerlist.cpp | 2 +- src/gui/upnpbrowser.cpp | 2 +- src/gui/widget/menue.cpp | 2 +- 18 files changed, 271 insertions(+), 140 deletions(-) diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index 8f082c969..776b13a5a 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -1579,7 +1579,7 @@ void CAudioPlayerGui::paintHead() if (!m_show_playlist || m_screensaver) return; - CComponentsHeader header(m_x, m_y + m_title_height, m_width, m_theight, LOCALE_AUDIOPLAYER_HEAD, NEUTRINO_ICON_MP3); + CComponentsHeaderLocalized header(m_x, m_y + m_title_height, m_width, m_theight, LOCALE_AUDIOPLAYER_HEAD, NEUTRINO_ICON_MP3); header.setCorner(RADIUS_MID, CORNER_TOP); if (m_inetmode) diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index e8d112740..b89218f4c 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -133,7 +133,7 @@ void CBEBouquetWidget::paint() void CBEBouquetWidget::paintHead() { - CComponentsHeader header(x, y, width, theight, LOCALE_BOUQUETLIST_HEAD, NULL /*no header icon*/, CComponentsHeader::CC_BTN_MENU); + CComponentsHeaderLocalized header(x, y, width, theight, LOCALE_BOUQUETLIST_HEAD, "" /*no header icon*/, CComponentsHeaderLocalized::CC_BTN_MENU); header.paint(CC_SAVE_SCREEN_NO); } diff --git a/src/gui/bedit/bouqueteditor_channels.cpp b/src/gui/bedit/bouqueteditor_channels.cpp index 2095ceebb..4c9ccd46c 100644 --- a/src/gui/bedit/bouqueteditor_channels.cpp +++ b/src/gui/bedit/bouqueteditor_channels.cpp @@ -168,7 +168,7 @@ void CBEChannelWidget::paint() void CBEChannelWidget::paintHead() { - CComponentsHeader header(x, y, width, theight, caption.c_str(), NULL /*no header icon*/); + CComponentsHeader header(x, y, width, theight, caption); header.paint(CC_SAVE_SCREEN_NO); } diff --git a/src/gui/bookmarkmanager.cpp b/src/gui/bookmarkmanager.cpp index ebebd8f1b..56894699c 100644 --- a/src/gui/bookmarkmanager.cpp +++ b/src/gui/bookmarkmanager.cpp @@ -403,7 +403,7 @@ void CBookmarkManager::hide() //------------------------------------------------------------------------ void CBookmarkManager::paintHead() { - CComponentsHeader header(x, y, width, theight, LOCALE_BOOKMARKMANAGER_NAME, NEUTRINO_ICON_BOOKMARK_MANAGER, CComponentsHeader::CC_BTN_HELP); + CComponentsHeaderLocalized header(x, y, width, theight, LOCALE_BOOKMARKMANAGER_NAME, NEUTRINO_ICON_BOOKMARK_MANAGER, CComponentsHeaderLocalized::CC_BTN_HELP); header.paint(CC_SAVE_SCREEN_NO); } diff --git a/src/gui/bouquetlist.cpp b/src/gui/bouquetlist.cpp index 0ee809b31..f8846cdf8 100644 --- a/src/gui/bouquetlist.cpp +++ b/src/gui/bouquetlist.cpp @@ -590,7 +590,7 @@ void CBouquetList::paintItem(int pos) void CBouquetList::paintHead() { - CComponentsHeader header(x, y, width, theight, name, NULL /*no header icon*/); + CComponentsHeader header(x, y, width, theight, name); header.paint(CC_SAVE_SCREEN_NO); } diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 997e4a25c..91eaa3395 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -2118,7 +2118,7 @@ void CChannelList::paintItem(int pos, const bool firstpaint) void CChannelList::paintHead() { - CComponentsHeader header(x, y, full_width, theight, name, NULL /*no header icon*/); + CComponentsHeader header(x, y, full_width, theight, name /*no header icon*/); header.paint(CC_SAVE_SCREEN_NO); if (g_Sectionsd->getIsTimeSet()) { diff --git a/src/gui/components/cc_frm_footer.cpp b/src/gui/components/cc_frm_footer.cpp index 8ad8ff113..f03a2f37e 100644 --- a/src/gui/components/cc_frm_footer.cpp +++ b/src/gui/components/cc_frm_footer.cpp @@ -17,10 +17,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public - License along with this program; if not, write to the - Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ #ifdef HAVE_CONFIG_H @@ -38,34 +36,50 @@ using namespace std; CComponentsFooter::CComponentsFooter() { //CComponentsFooter - initVarFooter(); + initVarFooter(1, 1, 0, 0); } -CComponentsFooter::CComponentsFooter( const int x_pos, const int y_pos, const int w, const int h, const int buttons, bool has_shadow, - fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow ) +CComponentsFooter::CComponentsFooter( const int& x_pos, const int& y_pos, const int& w, const int& h, + const int& buttons, + bool has_shadow, + fb_pixel_t color_frame, + fb_pixel_t color_body, + fb_pixel_t color_shadow ) { //CComponentsFooter - initVarFooter(); + initVarFooter(x_pos, y_pos, w, h, buttons, has_shadow, color_frame, color_body, color_shadow); +} - x = x_pos; - y = y_pos; - width = w; - height = h; +void CComponentsFooter::initVarFooter( const int& x_pos, const int& y_pos, const int& w, const int& h, + const int& buttons, + bool has_shadow, + fb_pixel_t color_frame, + fb_pixel_t color_body, + fb_pixel_t color_shadow ) +{ + cc_item_type = CC_ITEMTYPE_FOOTER; + + x = x_pos; + y = y_pos; + + //init footer width + width = w == 0 ? frameBuffer->getScreenWidth(true) : w; + //init header height + cch_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]; + if (h > 0) + height = h; + else + height = cch_font->getHeight(); + + cch_buttons = buttons; shadow = has_shadow; col_frame = color_frame; col_body = color_body; col_shadow = color_shadow; - cch_buttons = buttons; + corner_rad = RADIUS_LARGE; + corner_type = CORNER_BOTTOM; initDefaultButtons(); initCCItems(); } - - -void CComponentsFooter::initVarFooter() -{ - cc_item_type = CC_ITEMTYPE_FOOTER; - corner_rad = RADIUS_LARGE; - corner_type = CORNER_BOTTOM; -} diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index d1f14e5fd..89afd950d 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -37,80 +37,79 @@ using namespace std; CComponentsHeader::CComponentsHeader() { //CComponentsHeader - initVarHeader(); + initVarHeader(1, 1, 0, 0, "", "", 0); } -CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const int w, const int h, const std::string& caption, const char* icon_name, const int buttons, bool has_shadow, - fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) +CComponentsHeader::CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h, + const std::string& caption, + const std::string& icon_name, + const int& buttons, + bool has_shadow, + fb_pixel_t color_frame, + fb_pixel_t color_body, + fb_pixel_t color_shadow) { - //CComponentsHeader - initVarHeader(); - - x = x_pos; - y = y_pos; - width = w; - if (h > 0) { - userHeight = true; - height = h; - } - shadow = has_shadow; - col_frame = color_frame; - col_body = color_body; - col_shadow = color_shadow; - - cch_text = caption; - cch_icon_name = icon_name; - cch_buttons = buttons; - - initDefaultButtons(); - initCCItems(); + initVarHeader(x_pos, y_pos, w, h, caption, icon_name, buttons, has_shadow, color_frame, color_body, color_shadow); } -CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const int w, const int h, neutrino_locale_t caption_locale, const char* icon_name, const int buttons, bool has_shadow, - fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) -{ - //CComponentsHeader - initVarHeader(); - - x = x_pos; - y = y_pos; - width = w; - if (h > 0) { - userHeight = true; - height = h; - } - shadow = has_shadow; - col_frame = color_frame; - col_body = color_body; - col_shadow = color_shadow; - - cch_text = g_Locale->getText(caption_locale); - cch_icon_name = icon_name; - cch_buttons = buttons; +CComponentsHeaderLocalized::CComponentsHeaderLocalized( const int& x_pos, const int& y_pos, const int& w, const int& h, + neutrino_locale_t caption_locale, + const std::string& icon_name, + const int& buttons, + bool has_shadow, + fb_pixel_t color_frame, + fb_pixel_t color_body, + fb_pixel_t color_shadow) + :CComponentsHeader( x_pos, y_pos, w, h, + g_Locale->getText(caption_locale), + icon_name, buttons, + has_shadow, + color_frame, color_body, color_shadow){}; - initDefaultButtons(); - initCCItems(); -} - -void CComponentsHeader::initVarHeader() +void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const int& w, const int& h, + const std::string& caption, + const std::string& icon_name, + const int& buttons, + bool has_shadow, + fb_pixel_t color_frame, + fb_pixel_t color_body, + fb_pixel_t color_shadow) { cc_item_type = CC_ITEMTYPE_FRM_HEADER; - col_body = COL_MENUHEAD_PLUS_0; - corner_rad = RADIUS_LARGE, - corner_type = CORNER_TOP; + x = x_pos; + y = y_pos; + + //init header width + width = w == 0 ? frameBuffer->getScreenWidth(true) : w; + //init header height cch_size_mode = CC_HEADER_SIZE_LARGE; cch_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]; - height = cch_font->getHeight(); - userHeight = false; - - //CComponentsHeader + if (h > 0) { + userHeight = true; + height = h; + } + else{ + userHeight = false; + height = cch_font->getHeight(); + } + + shadow = has_shadow; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + col_body = COL_MENUHEAD_PLUS_0; + cch_text = caption; + cch_icon_name = icon_name; + cch_buttons = buttons; + + corner_rad = RADIUS_LARGE, + corner_type = CORNER_TOP; + cch_icon_obj = NULL; cch_text_obj = NULL; - cch_icon_name = NULL; cch_btn_obj = NULL; - cch_text = ""; cch_col_text = COL_MENUHEAD_TEXT; cch_caption_align = CTextBox::NO_AUTO_LINEBREAK; cch_items_y = 0; @@ -118,11 +117,12 @@ void CComponentsHeader::initVarHeader() cch_icon_x = cch_offset; cch_icon_w = 0; cch_text_x = cch_offset; - cch_buttons = 0; cch_buttons_w = 0; cch_buttons_h = 0; cch_buttons_space = cch_offset; - v_cch_btn.clear(); + + initDefaultButtons(); + initCCItems(); } CComponentsHeader::~CComponentsHeader() @@ -152,6 +152,16 @@ void CComponentsHeader::setCaptionFont(Font* font_name) } void CComponentsHeader::setIcon(const char* icon_name) +{ + if (icon_name){ + string s_icon = static_cast(icon_name); + setIcon(s_icon); + } + else + setIcon(""); +} + +void CComponentsHeader::setIcon(const std::string& icon_name) { cch_icon_name = icon_name; } @@ -159,18 +169,19 @@ void CComponentsHeader::setIcon(const char* icon_name) void CComponentsHeader::initIcon() { //init cch_icon_obj only if an icon available - if (cch_icon_name == NULL) { + if (cch_icon_name.empty()) { cch_icon_w = 0; - if (cch_icon_obj) + if (cch_icon_obj){ delete cch_icon_obj; - cch_icon_obj = NULL; + cch_icon_obj = NULL; + } return; } //create instance for cch_icon_obj if (cch_icon_obj == NULL){ #ifdef DEBUG_CC - printf(" [CComponentsHeader]\n [%s - %d] init header icon: %s\n", __func__, __LINE__, cch_icon_name); + printf(" [CComponentsHeader]\n [%s - %d] init header icon: %s\n", __func__, __LINE__, cch_icon_name.c_str()); #endif cch_icon_obj = new CComponentsPicture(cch_icon_x, cch_items_y, 0, 0, cch_icon_name); } @@ -179,12 +190,14 @@ void CComponentsHeader::initIcon() if (!cch_icon_obj->isAdded()) addCCItem(cch_icon_obj); //icon - //get dimensions of header icon - int iw, ih; - frameBuffer->getIconSize(cch_icon_name, &iw, &ih); + //set properties for icon object if (cch_icon_obj){ + //get dimensions of header icon + int iw = 0; + int ih = 0; + cch_icon_obj->getPictureSize(&iw, &ih); cch_icon_obj->setWidth(iw); cch_icon_obj->setHeight(ih); cch_icon_obj->doPaintBg(false); @@ -318,7 +331,7 @@ void CComponentsHeader::initCaption() { //recalc header text position if header icon is defined int cc_text_w = 0; - if (cch_icon_name != NULL){ + if (!cch_icon_name.empty()){ cch_text_x = cch_icon_x+cch_icon_w+cch_offset; } diff --git a/src/gui/components/cc_frm_header.h b/src/gui/components/cc_frm_header.h index d681b57b5..9a422024c 100644 --- a/src/gui/components/cc_frm_header.h +++ b/src/gui/components/cc_frm_header.h @@ -30,31 +30,122 @@ #include "cc_item_text.h" #include "cc_frm_icons.h" +//! Sub class of CComponentsForm. Shows a header with prepared items. +/*! +CComponentsHeader provides prepared items like icon, caption and context button icons +*/ class CComponentsHeader : public CComponentsForm { private: - void initVarHeader(); + ///member: init genaral variables, parameters for mostly used properties + void initVarHeader( const int& x_pos, const int& y_pos, const int& w, const int& h = 0, + const std::string& caption = "header", + const std::string& = "", + const int& buttons = 0, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, + fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, + fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + protected: + ///object: icon object, see also setIcon() CComponentsPicture * cch_icon_obj; + ///object: caption object, see also setCaption() CComponentsText * cch_text_obj; + ///object: context button object, see also addButtonIcon(), removeButtonIcons() CComponentsIconForm * cch_btn_obj; + + ///property: caption text, see also setCaption() std::string cch_text; - const char* cch_icon_name; + ///property: icon name, see also setIcon() + std::string cch_icon_name; + ///property: caption text color, see also setCaptionColor() fb_pixel_t cch_col_text; + ///property: caption font, see also setCaptionFont() Font* cch_font; - int cch_items_y, cch_icon_x, cch_icon_w, cch_text_x, cch_buttons, cch_buttons_w, cch_buttons_h, cch_buttons_space, cch_offset; + + ///property: internal y-position for all items + int cch_items_y; + ///property: internal x-position for icon object + int cch_icon_x; + ///property: internal width for icon object + int cch_icon_w; + ///property: internal x-position for caption object + int cch_text_x; + ///property: internal context button definition button icons, see modes CC_BTN_HELP, CC_BTN_INFO, CC_BTN_MENU, CC_BTN_EXIT + int cch_buttons; + ///property: internal width for context button object + int cch_buttons_w; + ///property: internal height for context button object + int cch_buttons_h; + ///property: internal offset of context button icons within context button object + int cch_buttons_space; + ///property: internal offset for header items + int cch_offset; + ///property: internal container of icon names for context button object, see also addButtonIcon() std::vector v_cch_btn; + ///property: size of header, possible values are CC_HEADER_SIZE_LARGE, CC_HEADER_SIZE_SMALL int cch_size_mode; + ///property: alignment of caption within header, see also setCaptionAlignment(), possible values are CTextBox::CENTER, default = CTextBox::NO_AUTO_LINEBREAK (left) int cch_caption_align; + bool userHeight; + ///sub: init icon object void initIcon(); + ///sub: init caption object void initCaption(); + ///sub: init context button object void initButtons(); + ///sub: init default buttons for context button object void initDefaultButtons(); + ///sub: init default buttons for context button object void initButtonFormSize(); public: + enum + { + CC_HEADER_ITEM_ICON = 0, + CC_HEADER_ITEM_TEXT = 1, + CC_HEADER_ITEM_BUTTONS = 2 + }; + + CComponentsHeader(); + CComponentsHeader( const int& x_pos, const int& y_pos, const int& w, const int& h = 0, + const std::string& caption = "", + const std::string& = "", + const int& buttons = 0, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, + fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, + fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + + virtual ~CComponentsHeader(); + + ///set caption text, parameters: string, int align_mode (default left) + virtual void setCaption(const std::string& caption, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK); + ///set caption text, parameters: loacle, int align_mode (default left) + virtual void setCaption(neutrino_locale_t caption_locale, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK); + + ///set alignment of caption within header, possible paramters are CTextBox::CENTER, CTextBox::NO_AUTO_LINEBREAK + virtual void setCaptionAlignment(const int& align_mode){cch_caption_align = align_mode;}; + ///set text font object for caption + virtual void setCaptionFont(Font* font_name); + ///set text color for caption + virtual void setCaptionColor(fb_pixel_t text_color){cch_col_text = text_color;}; + + ///set offset between items + virtual void setOffset(const int offset){cch_offset = offset;}; + ///set name of icon + virtual void setIcon(const char* icon_name); + ///set name of icon + virtual void setIcon(const std::string& icon_name); + + ///add separate button icons to context button object + virtual void addButtonIcon(const std::string& button_name); + ///remove button icons from context button object + virtual void removeButtonIcons(); + enum { CC_BTN_HELP = 0x02, @@ -63,55 +154,68 @@ class CComponentsHeader : public CComponentsForm CC_BTN_EXIT = 0x80 }; - - enum - { - CC_HEADER_ITEM_ICON = 0, - CC_HEADER_ITEM_TEXT = 1, - CC_HEADER_ITEM_BUTTONS = 2 - }; + ///set internal context button icons, possible modes CC_BTN_HELP, CC_BTN_INFO, CC_BTN_MENU, CC_BTN_EXIT + virtual void setDefaultButtons(const int buttons); + ///set offset between icons within context button object + virtual void setButtonsSpace(const int buttons_space){cch_buttons_space = buttons_space;}; enum { CC_HEADER_SIZE_LARGE = 0, CC_HEADER_SIZE_SMALL = 1 }; - CComponentsHeader(); - CComponentsHeader(const int x_pos, const int y_pos, const int w, const int h = 0, const std::string& caption = "header", const char* icon_name = NULL, const int buttons = 0, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); - CComponentsHeader(const int x_pos, const int y_pos, const int w, const int h = 0, neutrino_locale_t caption_locale = NONEXISTANT_LOCALE, const char* icon_name = NULL, const int buttons = 0,bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); - virtual ~CComponentsHeader(); - - - virtual void setCaption(const std::string& caption, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK); - virtual void setCaption(neutrino_locale_t caption_locale, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK); - virtual void setCaptionAlignment(const int& align_mode){cch_caption_align = align_mode;}; - virtual void setCaptionFont(Font* font_name); - virtual void setCaptionColor(fb_pixel_t text_color){cch_col_text = text_color;}; - virtual void setOffset(const int offset){cch_offset = offset;}; - virtual void setIcon(const char* icon_name); - virtual void addButtonIcon(const std::string& button_name); - virtual void removeButtonIcons(); - virtual void setDefaultButtons(const int buttons); - virtual void setButtonsSpace(const int buttons_space){cch_buttons_space = buttons_space;}; - virtual void initCCItems(); + ///set size of header, possible values are CC_HEADER_SIZE_LARGE, CC_HEADER_SIZE_SMALL virtual void setSizeMode(const int& size_mode){cch_size_mode = size_mode;}; + + ///init all items within header object + virtual void initCCItems(); + ///returns the text object virtual CComponentsText* getTextObject(){return cch_text_obj;}; + + ///paint header virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); }; +//! Sub class of CComponentsHeader. Shows a header with prepared items. +/*! +CComponentsHeaderLocalized provides prepared items like icon, caption and context button icons +Caption is defined with locales. +*/ +class CComponentsHeaderLocalized : public CComponentsHeader +{ + public: + CComponentsHeaderLocalized( const int& x_pos, const int& y_pos, const int& w, const int& h = 0, + neutrino_locale_t caption_locale = NONEXISTANT_LOCALE, + const std::string& = "", + const int& buttons = 0, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, + fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, + fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); +}; + +/*! +CComponentsFooter provides prepared container for footer +Is mostly usable like a header but without caption, and context button icons. +*/ class CComponentsFooter : public CComponentsHeader { protected: - void initVarFooter(); + void initVarFooter( const int& x_pos, const int& y_pos, const int& w, const int& h = 0, + const int& buttons = 0, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, + fb_pixel_t color_body = COL_INFOBAR_SHADOW_PLUS_1, + fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); public: CComponentsFooter(); - CComponentsFooter( const int x_pos, const int y_pos, const int w, const int h = 0, - const int buttons = 0, + CComponentsFooter( const int& x_pos, const int& y_pos, const int& w, const int& h = 0, + const int& buttons = 0, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_INFOBAR_SHADOW_PLUS_1, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, + fb_pixel_t color_body = COL_INFOBAR_SHADOW_PLUS_1, + fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); }; #endif diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index 9e899fe7b..dfeaf45d4 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -124,7 +124,7 @@ void EpgPlus::Header::paint(const char * Name) { std::string head = Name ? Name : g_Locale->getText (LOCALE_EPGPLUS_HEAD); - CComponentsHeader header(this->x, this->y, this->width, this->font->getHeight()+4, head, NULL /*no header icon*/); + CComponentsHeader header(this->x, this->y, this->width, this->font->getHeight()+4, head); header.paint(CC_SAVE_SCREEN_NO); } diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index 0fb560727..f5d21d53e 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -1321,7 +1321,7 @@ void CFileBrowser::paintHead() while ((fnt_title->getRenderWidth(&l_name[i]) > width - 20) && (i < l)) i++; - CComponentsHeader header(x, y, width, theight, &l_name[i], NULL /*no header icon*/); + CComponentsHeader header(x, y, width, theight, &l_name[i]); header.paint(CC_SAVE_SCREEN_NO); free(l_name); diff --git a/src/gui/motorcontrol.cpp b/src/gui/motorcontrol.cpp index 954aad025..1eca47b51 100644 --- a/src/gui/motorcontrol.cpp +++ b/src/gui/motorcontrol.cpp @@ -447,7 +447,7 @@ void CMotorControl::paintStatus() void CMotorControl::paintHead() { - CComponentsHeader header(x, y, width, hheight, LOCALE_MOTORCONTROL_HEAD, NULL /*no header icon*/); + CComponentsHeaderLocalized header(x, y, width, hheight, LOCALE_MOTORCONTROL_HEAD); header.paint(CC_SAVE_SCREEN_NO); } diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index 99b8ae043..af95d92c4 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -705,7 +705,7 @@ void CPictureViewerGui::paintItem(int pos) void CPictureViewerGui::paintHead() { - CComponentsHeader header(x, y, width, theight, LOCALE_PICTUREVIEWER_HEAD, NEUTRINO_ICON_MP3, CComponentsHeader::CC_BTN_HELP); + CComponentsHeaderLocalized header(x, y, width, theight, LOCALE_PICTUREVIEWER_HEAD, NEUTRINO_ICON_MP3, CComponentsHeaderLocalized::CC_BTN_HELP); #ifdef ENABLE_GUI_MOUNT header.addButtonIcon(NEUTRINO_ICON_BUTTON_MENU); diff --git a/src/gui/pluginlist.cpp b/src/gui/pluginlist.cpp index 3855d78fb..450f6219f 100644 --- a/src/gui/pluginlist.cpp +++ b/src/gui/pluginlist.cpp @@ -306,7 +306,7 @@ void CPluginList::paintHead() if (listmaxshow < pluginlist.size()) h_width += 15; - CComponentsHeader header(x, y, h_width, theight, name, NULL /* no header icon */); + CComponentsHeaderLocalized header(x, y, h_width, theight, name); if (pluginlisttype == CPlugins::P_TYPE_GAME) header.setIcon(NEUTRINO_ICON_GAMES); diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index f7d9baa9e..f553be1a4 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -326,7 +326,7 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) g_RCInput->open_click(); } if(!test) { - CComponentsHeader header(x, y, width, hheight, success ? LOCALE_SCANTS_FINISHED : LOCALE_SCANTS_FAILED, NULL /*no header icon*/); + CComponentsHeaderLocalized header(x, y, width, hheight, success ? LOCALE_SCANTS_FINISHED : LOCALE_SCANTS_FAILED); header.paint(CC_SAVE_SCREEN_NO); uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(0xFFFF); do { @@ -490,7 +490,7 @@ void CScanTs::paintLine(int px, int py, int w, const char * const txt) void CScanTs::paint(bool fortest) { - CComponentsHeader header(x, y, width, hheight, fortest ? LOCALE_SCANTS_TEST : LOCALE_SCANTS_HEAD, NULL /*no header icon*/); + CComponentsHeaderLocalized header(x, y, width, hheight, fortest ? LOCALE_SCANTS_TEST : LOCALE_SCANTS_HEAD); header.paint(CC_SAVE_SCREEN_NO); frameBuffer->paintBoxRel(x, y + hheight, width, height - hheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 90e530189..9dc613458 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -870,7 +870,7 @@ void CTimerList::paintItem(int pos) void CTimerList::paintHead() { - CComponentsHeader header(x, y, width, theight, LOCALE_TIMERLIST_NAME, NEUTRINO_ICON_TIMER); + CComponentsHeaderLocalized header(x, y, width, theight, LOCALE_TIMERLIST_NAME, NEUTRINO_ICON_TIMER); header.setShadowOnOff(CC_SHADOW_ON); header.paint(CC_SAVE_SCREEN_NO); } diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index 9486289eb..54a09a72f 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -948,7 +948,7 @@ void CUpnpBrowserGui::paintDevices() CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, "Select UPnP Device"); // Head - CComponentsHeader header(m_x, m_y + m_title_height, m_width, m_theight, LOCALE_UPNPBROWSER_HEAD, NEUTRINO_ICON_UPNP); + CComponentsHeaderLocalized header(m_x, m_y + m_title_height, m_width, m_theight, LOCALE_UPNPBROWSER_HEAD, NEUTRINO_ICON_UPNP); if (CNeutrinoApp::getInstance()->isMuted()) header.addButtonIcon(NEUTRINO_ICON_BUTTON_MUTE_SMALL); header.paint(CC_SAVE_SCREEN_NO); diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 8023ddf53..a86fc473c 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -932,7 +932,7 @@ void CMenuWidget::paint() CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8 /*, nameString.c_str()*/); // paint head - CComponentsHeader header(x, y, width + sb_width, hheight, nameString, iconfile.c_str()); + CComponentsHeader header(x, y, width + sb_width, hheight, nameString, iconfile); header.setShadowOnOff(CC_SHADOW_ON); header.setOffset(10); header.paint(CC_SAVE_SCREEN_NO); From 21e0321c533ddbd78141d1b330f315b12e894d22 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 24 Jan 2014 23:12:51 +0100 Subject: [PATCH 10/20] CComponentsWindow: rework constructors, add CComponentsWindowMax Member initVarWindow() now used with parameters, so it's possible to remove multiple code in constructors, but some class must be renamed to CComponentsWindowMax. --- src/gui/components/cc_frm_window.cpp | 111 +++++++++------------------ src/gui/components/cc_frm_window.h | 52 +++++++------ src/gui/imageinfo.cpp | 2 +- src/gui/imageinfo.h | 2 +- 4 files changed, 70 insertions(+), 97 deletions(-) diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp index 8bd6e4c74..4daada27f 100644 --- a/src/gui/components/cc_frm_window.cpp +++ b/src/gui/components/cc_frm_window.cpp @@ -38,109 +38,74 @@ using namespace std; CComponentsWindow::CComponentsWindow() { initVarWindow(); - - initCCWItems(); } -CComponentsWindow::CComponentsWindow(const std::string& caption, const char* iconname) -{ - initVarWindow(); - - ccw_caption = caption; - ccw_icon_name = iconname; - - initCCWItems(); -} - -CComponentsWindow::CComponentsWindow(neutrino_locale_t locale_caption, const char* iconname) -{ - initVarWindow(); - - ccw_caption = g_Locale->getText(locale_caption); - ccw_icon_name = iconname; - - initCCWItems(); -} - -CComponentsWindow::CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h, +CComponentsWindow::CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h, neutrino_locale_t locale_caption, - const char* iconname, + const string& iconname, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) { - initVarWindow(); - - x = x_pos; - y = y_pos; - width = w; - height = h; - shadow = has_shadow; - col_frame = color_frame; - col_body = color_body; - col_shadow = color_shadow; - - ccw_caption = g_Locale->getText(locale_caption); - ccw_icon_name = iconname; - - initCCWItems(); + string s_caption = locale_caption != NONEXISTANT_LOCALE ? g_Locale->getText(locale_caption) : ""; + initVarWindow(x_pos, y_pos, w, h, s_caption, iconname, has_shadow, color_frame, color_body, color_shadow); } -CComponentsWindow::CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h, - const std::string& caption, - const char* iconname, +CComponentsWindow::CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h, + const string& caption, + const string& iconname, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) { - initVarWindow(); - - x = x_pos; - y = y_pos; - width = w; - height = h; - shadow = has_shadow; - col_frame = color_frame; - col_body = color_body; - col_shadow = color_shadow; - - ccw_caption = caption;; - ccw_icon_name = iconname; - - initCCWItems(); + initVarWindow(x_pos, y_pos, w, h, caption, iconname, has_shadow, color_frame, color_body, color_shadow); } -CComponentsWindow::~CComponentsWindow() -{ -#ifdef DEBUG_CC - printf("[~CComponentsWindow] [%s - %d] delete...\n", __func__, __LINE__); -#endif -} +CComponentsWindowMax::CComponentsWindowMax(const string& caption, const string& iconname) + :CComponentsWindow(0, 0, 0, 0, caption, iconname){}; -void CComponentsWindow::initVarWindow() +CComponentsWindowMax::CComponentsWindowMax(neutrino_locale_t locale_caption, const string& iconname) + :CComponentsWindow(0, 0, 0, 0, locale_caption != NONEXISTANT_LOCALE ? g_Locale->getText(locale_caption) : "", iconname){}; + +void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const int& w, const int& h, + const string& caption, + const string& iconname, + bool has_shadow, + fb_pixel_t color_frame, + fb_pixel_t color_body, + fb_pixel_t color_shadow) { //CComponentsForm cc_item_type = CC_ITEMTYPE_FRM_WINDOW; - //using current screen settings for default dimensions - width = frameBuffer->getScreenWidth(); - height = frameBuffer->getScreenHeight(); - x=getScreenStartX(width); - y=getScreenStartY(height); + //using current screen settings for default dimensions, do centering if default values == 0 + width = w == 0 ? frameBuffer->getScreenWidth(true) : w; + height = h == 0 ? frameBuffer->getScreenHeight(true) : h; + x = x_pos == (CC_CENTERED || 0) ? getScreenStartX(width)/2 - width/2 : x_pos; + y = y_pos == (CC_CENTERED || 0) ? getScreenStartY(height)/2 - height/2 : y_pos; + + ccw_caption = caption; + ccw_icon_name = iconname; +#ifdef DEBUG_CC + printf("[CComponentsWindow] [%s - %d] icon name = %s\n", __func__, __LINE__, ccw_icon_name.c_str()); +#endif + shadow = has_shadow; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; ccw_head = NULL; ccw_body = NULL; ccw_footer = NULL; - ccw_caption = ""; - ccw_icon_name = NULL; + ccw_buttons = 0; //no header buttons ccw_show_footer = true; ccw_show_header = true; ccw_align_mode = CTextBox::NO_AUTO_LINEBREAK; - setShadowOnOff(true); + initCCWItems(); } void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const int& align_mode) @@ -163,7 +128,7 @@ void CComponentsWindow::initHeader() // ccw_head->setPos(0, 0); ccw_head->setIcon(ccw_icon_name); ccw_head->setCaption(ccw_caption, ccw_align_mode); - ccw_head->initCCItems(); +// ccw_head->initCCItems(); ccw_head->setDefaultButtons(ccw_buttons); } } diff --git a/src/gui/components/cc_frm_window.h b/src/gui/components/cc_frm_window.h index 80e7e49f3..81c8c415b 100644 --- a/src/gui/components/cc_frm_window.h +++ b/src/gui/components/cc_frm_window.h @@ -65,7 +65,7 @@ class CComponentsWindow : public CComponentsForm ///property: alignment mode for header caption int ccw_align_mode; ///property: icon name in header, see also getHeaderObject() - const char* ccw_icon_name; + std::string ccw_icon_name; ///property: assigned default icon buttons in header, see also getHeaderObject() int ccw_buttons; ///property: value = true, let show footer, see showFooter() @@ -82,44 +82,40 @@ class CComponentsWindow : public CComponentsForm ///initialze all window objects at once void initCCWItems(); ///initialize all attributes - void initVarWindow(); + 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 = "", + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, + fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, + fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); public: enum { CC_WINDOW_ITEM_HEADER = 0 }; - ///simple constructor for CComponentsWindow + ///simple constructor for CComponentsWindow, this shows a window over full screen CComponentsWindow(); - ///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption as string - CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h, - const std::string& caption, - const char* iconname = NULL, + ///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption as string, x_pos or y_pos = 0 will center window + CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h, + const std::string& caption = "", + const std::string& iconname = "", bool has_shadow = CC_SHADOW_OFF, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); - ///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption from locales - CComponentsWindow( const int x_pos, const int y_pos, const int w, const int h, - neutrino_locale_t locale_caption, - const char* iconname = NULL, + ///advanced constructor for CComponentsWindow, provides parameters for the most required properties, and caption from locales, x_pos or y_pos = 0 will center window + CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h, + neutrino_locale_t locale_text = NONEXISTANT_LOCALE, + const std::string& iconname = "", bool has_shadow = CC_SHADOW_OFF, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); - ///simple constructor for CComponentsWindow, provides parameters for caption as string and icon, position of window is general centered and bound - ///to current screen settings, this shows a window over full screen - CComponentsWindow(const std::string& caption, const char* iconname = NULL); - - ///simple constructor for CComponentsWindow, provides parameters for caption from locales and icon, position of window is general centered and bound - ///to current screen settings, this shows a window over full screen - CComponentsWindow(neutrino_locale_t locale_caption, const char* iconname = NULL); - - ~CComponentsWindow(); - ///add item to body object, also usable is addCCItem() to add items to the windo object void addWindowItem(CComponentsItem* cc_Item); @@ -137,7 +133,7 @@ class CComponentsWindow : public CComponentsForm void setWindowCaptionAlignment(const int& align_mode){ccw_align_mode = align_mode;}; ///set icon name in header, see also getHeaderObject() - void setWindowIcon(const char* iconname){ccw_icon_name = iconname;}; + void setWindowIcon(const std::string& iconname){ccw_icon_name = iconname;}; ///set default header icon buttons, see also getHeaderObject() void setWindowHeaderButtons(const int& buttons){ccw_buttons = buttons;}; @@ -157,4 +153,16 @@ class CComponentsWindow : public CComponentsForm virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); }; +class CComponentsWindowMax : public CComponentsWindow +{ + public: + ///simple constructor for CComponentsWindow, provides parameters for caption as string and icon, position of window is general centered and bound + ///to current screen settings, this shows a window over full screen + CComponentsWindowMax(const std::string& caption, const std::string& iconname = ""); + + ///simple constructor for CComponentsWindow, provides parameters for caption from locales and icon, position of window is general centered and bound + ///to current screen settings, this shows a window over full screen + CComponentsWindowMax(neutrino_locale_t locale_caption, const std::string& iconname = ""); +}; + #endif diff --git a/src/gui/imageinfo.cpp b/src/gui/imageinfo.cpp index ff7c64da0..4d980e519 100644 --- a/src/gui/imageinfo.cpp +++ b/src/gui/imageinfo.cpp @@ -181,7 +181,7 @@ void CImageInfo::ShowWindow() { CComponentsFooter *footer = NULL; if (cc_win == NULL){ - cc_win = new CComponentsWindow(LOCALE_IMAGEINFO_HEAD, NEUTRINO_ICON_INFO); + cc_win = new CComponentsWindowMax(LOCALE_IMAGEINFO_HEAD, NEUTRINO_ICON_INFO); cc_win->setWindowHeaderButtons(CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT); footer = cc_win->getFooterObject(); footer->setColorBody(COL_INFOBAR_SHADOW_PLUS_1); diff --git a/src/gui/imageinfo.h b/src/gui/imageinfo.h index 81c588bc2..46e7615eb 100644 --- a/src/gui/imageinfo.h +++ b/src/gui/imageinfo.h @@ -64,7 +64,7 @@ class CImageInfo : public CMenuTarget void ShowWindow(); void ScrollLic(bool scrollDown); - CComponentsWindow *cc_win; + CComponentsWindowMax *cc_win; CComponentsForm *cc_info; CComponentsPIP *cc_tv; CComponentsInfoBox *cc_lic; From 8cad2a3ca509480ad0fb9d43c81fecf6a64c0e6b Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 18 Jan 2014 23:49:26 +0100 Subject: [PATCH 11/20] CComponentsWindow: add member doCenter() Allows centering of window on screen, mostly senseful for window objects without parent --- src/gui/components/cc_frm_window.cpp | 17 ++++++++++++----- src/gui/components/cc_frm_window.h | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp index 4daada27f..0b7358700 100644 --- a/src/gui/components/cc_frm_window.cpp +++ b/src/gui/components/cc_frm_window.cpp @@ -80,11 +80,13 @@ void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const //CComponentsForm cc_item_type = CC_ITEMTYPE_FRM_WINDOW; - //using current screen settings for default dimensions, do centering if default values == 0 - width = w == 0 ? frameBuffer->getScreenWidth(true) : w; - height = h == 0 ? frameBuffer->getScreenHeight(true) : h; - x = x_pos == (CC_CENTERED || 0) ? getScreenStartX(width)/2 - width/2 : x_pos; - y = y_pos == (CC_CENTERED || 0) ? getScreenStartY(height)/2 - height/2 : y_pos; + //using current screen settings for default dimensions, do use full screen if default values for width/height = 0 + int w_tmp = frameBuffer->getScreenWidth(w == 0 ? true : false); + int h_tmp = frameBuffer->getScreenHeight(h == 0 ? true : false); + width = w == 0 ? w_tmp : w; + height = h == 0 ? h_tmp : h; + x = x_pos; + y = y_pos; ccw_caption = caption; ccw_icon_name = iconname; @@ -108,6 +110,11 @@ void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const initCCWItems(); } +void CComponentsWindow::doCenter(){ + x = cc_parent ? cc_parent->getWidth() - width/2 : frameBuffer->getScreenWidth(true)/2 - width/2; + y = cc_parent ? cc_parent->getHeight() - height/2 : frameBuffer->getScreenHeight(true)/2 -height/2; +} + void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const int& align_mode) { ccw_caption = g_Locale->getText(locale_text); diff --git a/src/gui/components/cc_frm_window.h b/src/gui/components/cc_frm_window.h index 81c8c415b..43e22724f 100644 --- a/src/gui/components/cc_frm_window.h +++ b/src/gui/components/cc_frm_window.h @@ -89,6 +89,8 @@ class CComponentsWindow : public CComponentsForm fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + ///allow centering of window on screen, mostly senseful for window object without parent + void doCenter(); public: enum From 39d634059831666bbcfe0acac946773ef9e69fda Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 18 Jan 2014 21:40:55 +0100 Subject: [PATCH 12/20] CComponents: rework some debug outputs This shows also x or y values < 0. --- src/gui/components/cc_base.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/gui/components/cc_base.cpp b/src/gui/components/cc_base.cpp index 8b30596b9..a2d688000 100644 --- a/src/gui/components/cc_base.cpp +++ b/src/gui/components/cc_base.cpp @@ -90,8 +90,18 @@ void CComponents::paintFbItems(bool do_save_bg) if (firstPaint && do_save_bg) { for(size_t i=0; isave screen: %d, fbdata_type: %d\n", __func__, __LINE__, firstPaint, v_fbdata[i].fbdata_type); + printf("\t[CComponents]\n\t[%s - %d] firstPaint->save screen: %d, fbdata_type: %d\n\tx = %d\n\ty = %d\n\tdx = %d\n\tdy = %d\n", + __func__, + __LINE__, + firstPaint, + v_fbdata[i].fbdata_type, + v_fbdata[i].x, + v_fbdata[i].y, + v_fbdata[i].dx, + v_fbdata[i].dy); #endif saved_screen.x = v_fbdata[i].x; saved_screen.y = v_fbdata[i].y; @@ -109,18 +119,21 @@ void CComponents::paintFbItems(bool do_save_bg) // Don't paint if dx or dy are 0 if ((v_fbdata[i].dx == 0) || (v_fbdata[i].dy == 0)){ #ifdef DEBUG_CC - printf(" [CComponents] WARNING: [%s - %d], dx = %d dy = %d\n", __func__, __LINE__, v_fbdata[i].dx, v_fbdata[i].dy); + printf("\t[CComponents] WARNING: [%s - %d], dx = %d dy = %d\n", __func__, __LINE__, v_fbdata[i].dx, v_fbdata[i].dy); #endif continue; } - if ((v_fbdata[i].x == 0) || (v_fbdata[i].y == 0)){ - printf(" [CComponents] WARNING: [%s - %d], x = %d y = %d\n", __func__, __LINE__, v_fbdata[i].x, v_fbdata[i].y); - } - int fbtype = v_fbdata[i].fbdata_type; #ifdef DEBUG_CC - printf(" [CComponents]\n [%s - %d], fbdata_[%d] \n x = %d\n y = %d\n dx = %d\n dy = %d\n", __func__, __LINE__, (int)i, v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy); + printf("\t[CComponents]\n\t[%s - %d], fbdata_[%d]\n\tx = %d\n\ty = %d\n\tdx = %d\n\tdy = %d\n", + __func__, + __LINE__, + (int)i, + v_fbdata[i].x, + v_fbdata[i].y, + v_fbdata[i].dx, + v_fbdata[i].dy); #endif //some elements can be assembled from lines and must be handled as one unit (see details line), //so all individual backgrounds of boxes must be saved and painted in "firstpaint mode" From 66ae0963722488c3ee162949ed048f27b1e36f9c Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 24 Jan 2014 22:26:58 +0100 Subject: [PATCH 13/20] CComponentsWindow: adapt header and footer corners for parent window Corners of header and footer were not adapted to parent form. It's unsightly, if these elements are not using the same corner types like the parent window. --- src/gui/components/cc_frm_window.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp index 0b7358700..fe4614afc 100644 --- a/src/gui/components/cc_frm_window.cpp +++ b/src/gui/components/cc_frm_window.cpp @@ -137,6 +137,7 @@ void CComponentsWindow::initHeader() ccw_head->setCaption(ccw_caption, ccw_align_mode); // ccw_head->initCCItems(); ccw_head->setDefaultButtons(ccw_buttons); + ccw_head->setCorner(corner_rad, CORNER_TOP); } } @@ -176,6 +177,7 @@ void CComponentsWindow::initFooter() ccw_footer->setPos(0, CC_APPEND); ccw_footer->setWidth(width-2*fr_thickness); ccw_footer->setShadowOnOff(shadow); + ccw_footer->setCorner(corner_rad, CORNER_BOTTOM); } } From d35da1afb6d6a472865192d6801602aca1bec07d Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 24 Jan 2014 23:28:15 +0100 Subject: [PATCH 14/20] CComponentsWindow: cleanup --- src/gui/components/cc_frm_window.cpp | 68 +++++++++++++--------------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp index fe4614afc..cdc596f99 100644 --- a/src/gui/components/cc_frm_window.cpp +++ b/src/gui/components/cc_frm_window.cpp @@ -123,32 +123,39 @@ void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const in void CComponentsWindow::initHeader() { - if (ccw_head == NULL){ + if (ccw_head == NULL) ccw_head = new CComponentsHeader(); - initHeader(); - //add of header item happens initCCWItems() - } - + //add of header item happens initCCWItems() //set header properties //TODO: assigned properties with internal header objekt have no effect! if (ccw_head){ ccw_head->setWidth(width-2*fr_thickness); // ccw_head->setPos(0, 0); ccw_head->setIcon(ccw_icon_name); ccw_head->setCaption(ccw_caption, ccw_align_mode); -// ccw_head->initCCItems(); ccw_head->setDefaultButtons(ccw_buttons); ccw_head->setCorner(corner_rad, CORNER_TOP); } } +void CComponentsWindow::initFooter() +{ + if (ccw_footer== NULL) + ccw_footer= new CComponentsFooter(); + //add of footer item happens initCCWItems() + //set footer properties + if (ccw_footer){ + ccw_footer->setPos(0, CC_APPEND); + ccw_footer->setWidth(width-2*fr_thickness); + ccw_footer->setShadowOnOff(shadow); + ccw_footer->setCorner(corner_rad, CORNER_BOTTOM); + } +} + void CComponentsWindow::initBody() { - if (ccw_body== NULL){ + if (ccw_body== NULL) ccw_body = new CComponentsForm(); - initBody(); - //add of body item happens initCCWItems() - } - + //add of body item happens initCCWItems() //set body properties if (ccw_body){ ccw_body->setCornerType(0); @@ -164,35 +171,16 @@ void CComponentsWindow::initBody() } } -void CComponentsWindow::initFooter() -{ - if (ccw_footer== NULL){ - ccw_footer= new CComponentsFooter(); - initFooter(); - //add of footer item happens initCCWItems() - } - - //set footer properties - if (ccw_footer){ - ccw_footer->setPos(0, CC_APPEND); - ccw_footer->setWidth(width-2*fr_thickness); - ccw_footer->setShadowOnOff(shadow); - ccw_footer->setCorner(corner_rad, CORNER_BOTTOM); - } -} - -void CComponentsWindow::addWindowItem(CComponentsItem* cc_Item) -{ - if (ccw_body) - ccw_body->addCCItem(cc_Item); -} - void CComponentsWindow::initCCWItems() { #ifdef DEBUG_CC printf("[CComponentsWindow] [%s - %d] init items...\n", __func__, __LINE__); #endif - //add header if required + initHeader(); + initFooter(); + initBody(); + + //add/remove header if required if (ccw_show_header){ initHeader(); }else{ @@ -202,7 +190,7 @@ void CComponentsWindow::initCCWItems() } } - //add footer if required + //add/remove footer if required if (ccw_show_footer){ initFooter(); }else{ @@ -211,7 +199,6 @@ void CComponentsWindow::initCCWItems() ccw_footer = NULL; } } - initBody(); //add header, body and footer items only one time if (ccw_head) @@ -224,6 +211,13 @@ void CComponentsWindow::initCCWItems() addCCItem(ccw_footer); } +void CComponentsWindow::addWindowItem(CComponentsItem* cc_Item) +{ + if (ccw_body) + ccw_body->addCCItem(cc_Item); +} + + void CComponentsWindow::paint(bool do_save_bg) { //prepare items before paint From 1838a71c2094e4cc3c7158caf61f125408c09975 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 24 Jan 2014 23:36:24 +0100 Subject: [PATCH 15/20] CComponentsHeader: cleanup -remove variable userHeight, is not used -change name of parameter in member initCaptionFont(), "font_name" is not a suitable name for a type object. --- src/gui/components/cc_frm_header.cpp | 48 +++++++++++++++++----------- src/gui/components/cc_frm_header.h | 8 ++--- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index 89afd950d..4c1cc4c4b 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -83,17 +83,11 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const //init header width width = w == 0 ? frameBuffer->getScreenWidth(true) : w; - //init header height - cch_size_mode = CC_HEADER_SIZE_LARGE; - cch_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]; - if (h > 0) { - userHeight = true; - height = h; - } - else{ - userHeight = false; - height = cch_font->getHeight(); - } + //init header default height + height = max(h, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight()); + + cch_size_mode = CC_HEADER_SIZE_LARGE; + initCaptionFont(); //sets cch_font and calculate height if required; shadow = has_shadow; col_frame = color_frame; @@ -145,10 +139,29 @@ void CComponentsHeader::setCaption(neutrino_locale_t caption_locale, const int& cch_caption_align = align_mode; } -void CComponentsHeader::setCaptionFont(Font* font_name) +void CComponentsHeader::setCaptionFont(Font* font) { - cch_font = font_name; - height = std::max(height, cch_font->getHeight()); + initCaptionFont(font); //cch_font = font +} + +void CComponentsHeader::initCaptionFont(Font* font) +{ + Font *l_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]; + Font *s_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]; + + if (font == NULL){ + cch_font = (cch_size_mode == CC_HEADER_SIZE_LARGE? l_font : s_font); + + //select matching height + if (cch_size_mode == CC_HEADER_SIZE_LARGE) + height = std::max(height, l_font->getHeight()); + else + height = std::min(height, s_font->getHeight()); + } + else{ + cch_font = font; + height = std::max(height, cch_font->getHeight()); + } } void CComponentsHeader::setIcon(const char* icon_name) @@ -378,11 +391,8 @@ void CComponentsHeader::initCaption() void CComponentsHeader::initCCItems() { //set size - if (!userHeight) { - cch_font = (cch_size_mode == CC_HEADER_SIZE_LARGE? g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE] : g_Font[SNeutrinoSettings::FONT_TYPE_MENU]); - height = cch_font->getHeight(); - } - + initCaptionFont(); + //init icon initIcon(); diff --git a/src/gui/components/cc_frm_header.h b/src/gui/components/cc_frm_header.h index 9a422024c..96b32f9c4 100644 --- a/src/gui/components/cc_frm_header.h +++ b/src/gui/components/cc_frm_header.h @@ -89,8 +89,8 @@ class CComponentsHeader : public CComponentsForm ///property: alignment of caption within header, see also setCaptionAlignment(), possible values are CTextBox::CENTER, default = CTextBox::NO_AUTO_LINEBREAK (left) int cch_caption_align; - bool userHeight; - + ///init font object and recalculates height if required + void initCaptionFont(Font* font = NULL); ///sub: init icon object void initIcon(); ///sub: init caption object @@ -130,7 +130,7 @@ class CComponentsHeader : public CComponentsForm ///set alignment of caption within header, possible paramters are CTextBox::CENTER, CTextBox::NO_AUTO_LINEBREAK virtual void setCaptionAlignment(const int& align_mode){cch_caption_align = align_mode;}; ///set text font object for caption - virtual void setCaptionFont(Font* font_name); + virtual void setCaptionFont(Font* font); ///set text color for caption virtual void setCaptionColor(fb_pixel_t text_color){cch_col_text = text_color;}; @@ -165,7 +165,7 @@ class CComponentsHeader : public CComponentsForm CC_HEADER_SIZE_SMALL = 1 }; ///set size of header, possible values are CC_HEADER_SIZE_LARGE, CC_HEADER_SIZE_SMALL - virtual void setSizeMode(const int& size_mode){cch_size_mode = size_mode;}; + virtual void setSizeMode(const int& size_mode){cch_size_mode = size_mode; initCCItems();}; ///init all items within header object virtual void initCCItems(); From 4b6d2d310ca23a57deb138f6f2340c4cd09db653 Mon Sep 17 00:00:00 2001 From: striper Date: Sat, 25 Jan 2014 14:36:12 +0100 Subject: [PATCH 16/20] - rewrite Lua handling * depend pkg checks on enable-lua switch * define STATIC_LUAPOSIX in case of static lua build to exclude unwanted code in neutrino * remove DYNAMIC_LUAPOSIX code as it's not needed in case of dynamic lua build --- configure.ac | 37 +++++++++++++++++-------------------- src/gui/luainstance.cpp | 35 ++--------------------------------- 2 files changed, 19 insertions(+), 53 deletions(-) diff --git a/configure.ac b/configure.ac index 45043c41c..6c6401ac4 100644 --- a/configure.ac +++ b/configure.ac @@ -95,16 +95,6 @@ TUXBOX_APPS_LIB_PKGCONFIG(AVFORMAT,libavformat) TUXBOX_APPS_LIB_PKGCONFIG(AVCODEC,libavcodec) TUXBOX_APPS_LIB_PKGCONFIG(AVUTIL,libavutil) -# either use dynamic lualib in package lua (openSUSE) -# ... or in package lua5.2 (debian-derivates) -# ... and if all fails, assume it is in the linker path (cross build) -PKG_CHECK_MODULES([LUA], [lua >= 5.2], echo "lua >= 5.2 found", [ - PKG_CHECK_MODULES([LUA], [lua5.2 >= 5.2], echo "lua5.2 found", [ - echo "=> lualib not found, assuming static lua in linker path..." - LUA_LIBS="-llua -ldl" - ]) -]) - #TUXBOX_APPS_LIB_PKGCONFIG(CONFIGFILE,tuxbox-configfile) #TUXBOX_APPS_LIB_PKGCONFIG(CONNECTION,tuxbox-connection) #TUXBOX_APPS_LIB_PKGCONFIG(EVENTSERVER,tuxbox-eventserver) @@ -162,6 +152,23 @@ if test "$enable_upnp" = "yes"; then AC_DEFINE(ENABLE_UPNP,1,[include UPNP support - currently broken]) fi +# Lua - embeddable scripting language +AC_ARG_ENABLE(lua, + AS_HELP_STRING(--enable-lua,include Lua support), + ,[enable_lua=no]) + +AM_CONDITIONAL(ENABLE_LUA,test "$enable_lua" = "yes") +if test "$enable_lua" = "yes"; then + AC_DEFINE(ENABLE_LUA,1,[include Lua support]) + PKG_CHECK_MODULES([LUA], [lua >= 5.2], echo "lua >= 5.2 found", [ + PKG_CHECK_MODULES([LUA], [lua5.2 >= 5.2], echo "lua5.2 found", [ + echo "=> lualib not found, assuming static lua in linker path..." + LUA_LIBS="-llua -ldl" + AC_DEFINE(STATIC_LUAPOSIX,1,[Define to 1 for static lua build.]) + ]) + ]) +fi + AC_ARG_ENABLE(cleanup, [ --enable-cleanup enable cleanup on exit], [AC_DEFINE(EXIT_CLEANUP,1,[enable cleanup on exit])]) @@ -179,16 +186,6 @@ if test "$enable_testmenu" = "yes"; then AC_DEFINE(ENABLE_TEST_MENU,1,[include test menu in neutrino main menu - not recommended for general users!]) fi - -AC_ARG_ENABLE(lua, - AS_HELP_STRING(--enable-lua,enable LUA support)) - -AM_CONDITIONAL(ENABLE_LUA,test "$enable_lua" = "yes") -if test "$enable_lua" = "yes"; then - AC_DEFINE(ENABLE_LUA,1,[include LUA support]) -fi - - if test "$BOXTYPE" = "coolstream"; then if test -e ${srcdir}/lib/libcoolstream/nevis_ir.h; then AC_DEFINE(HAVE_COOLSTREAM_NEVIS_IR_H,1,[Define to 1 if you have the header file.]) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 087a3b26b..08d8f1a95 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -347,35 +347,12 @@ const luaL_Reg CLuaInstance::methods[] = { NULL, NULL } }; -#ifndef DYNAMIC_LUAPOSIX +#ifdef STATIC_LUAPOSIX /* hack: we link against luaposix, which is included in our * custom built lualib */ extern "C" { LUAMOD_API int (luaopen_posix_c) (lua_State *L); } -#else -static int dolibrary (lua_State *L, const char *name) -{ - int status = 0; - const char *msg = ""; - lua_getglobal(L, "require"); - lua_pushstring(L, name); - status = lua_pcall(L, 1, 0, 0); - if (status && !lua_isnil(L, -1)) - { - msg = lua_tostring(L, -1); - if (NULL == msg) - { - msg = "(error object is not a string)"; - } - fprintf(stderr, "[CLuaInstance::%s] error in dolibrary: %s (%s)\n", __func__, name,msg); - lua_pop(L, 1); - } - else - { - printf("[CLuaInstance::%s] loaded library: %s\n", __func__, name); - } - return status; -} #endif + /* load basic functions and register our own C callbacks */ void CLuaInstance::registerFunctions() { @@ -384,14 +361,6 @@ void CLuaInstance::registerFunctions() luaopen_io(lua); luaopen_string(lua); luaopen_math(lua); -#ifndef DYNAMIC_LUAPOSIX -#if !HAVE_COOL_HARDWARE - luaopen_posix_c(lua); -#endif -#else - dolibrary(lua,"posix"); -#endif - lua_newtable(lua); int methodtable = lua_gettop(lua); luaL_newmetatable(lua, className); From cd5fd9dab3a64d7cb5f8631921b6525b5219da6c Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Sat, 25 Jan 2014 21:11:34 +0100 Subject: [PATCH 17/20] Fix compiler warnings (-Wconversion) - THX SatBaby for the info --- src/gui/bedit/bouqueteditor_bouquets.cpp | 4 ++-- src/gui/bookmarkmanager.cpp | 5 ++--- src/gui/bouquetlist.cpp | 4 ++-- src/gui/eventlist.cpp | 4 ++-- src/gui/pictureviewer.cpp | 4 ++-- src/gui/timerlist.cpp | 8 ++++---- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index b89218f4c..804ccea25 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -124,11 +124,11 @@ void CBEBouquetWidget::paint() if (sbc < 1) sbc = 1; - float sbh= (sb- 4)/ sbc; + int sbh = ((sb - 4) * 1024) / sbc; int sbs= (selected/listmaxshow); //scrollbar - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(sbs* sbh) , 11, int(sbh), COL_MENUCONTENT_PLUS_3); + frameBuffer->paintBoxRel(x+width-13, ypos+2+(sbs*sbh)/1024, 11, sbh/1024, COL_MENUCONTENT_PLUS_3); } void CBEBouquetWidget::paintHead() diff --git a/src/gui/bookmarkmanager.cpp b/src/gui/bookmarkmanager.cpp index 56894699c..3a0ccb791 100644 --- a/src/gui/bookmarkmanager.cpp +++ b/src/gui/bookmarkmanager.cpp @@ -456,10 +456,9 @@ void CBookmarkManager::paint() int sbc= ((bookmarks.size()- 1)/ listmaxshow)+ 1; if (sbc < 1) sbc = 1; + int sbh = ((sb - 4) * 1024) / sbc; - float sbh= (sb- 4)/ sbc; - - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(page_nr * sbh) , 11, int(sbh), COL_MENUCONTENT_PLUS_3); + frameBuffer->paintBoxRel(x+width-13, ypos+2+(page_nr*sbh)/1024, 11, sbh/1024, COL_MENUCONTENT_PLUS_3); } paintFoot(); diff --git a/src/gui/bouquetlist.cpp b/src/gui/bouquetlist.cpp index f8846cdf8..10150efaa 100644 --- a/src/gui/bouquetlist.cpp +++ b/src/gui/bouquetlist.cpp @@ -634,8 +634,8 @@ void CBouquetList::paint() frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); int sbc= ((bsize - 1)/ listmaxshow)+ 1; /* bsize is > 0, so sbc is also > 0 */ - float sbh= (sb - 4)/ sbc; + int sbh = ((sb - 4) * 1024) / sbc; int sbs= (selected/listmaxshow); - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(sbs* sbh) , 11, int(sbh), COL_MENUCONTENT_PLUS_3); + frameBuffer->paintBoxRel(x+width-13, ypos+2+(sbs*sbh)/1024, 11, sbh/1024, COL_MENUCONTENT_PLUS_3); } diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 7c808e6ba..87e54015f 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -921,10 +921,10 @@ void CNeutrinoEventList::paint(t_channel_id channel_id) if (sbc < 1) sbc = 1; - float sbh= (sb- 4)/ sbc; + int sbh = ((sb - 4) * 1024) / sbc; int sbs= (selected/listmaxshow); - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(sbs* sbh) , 11, int(sbh), COL_MENUCONTENT_PLUS_3); + frameBuffer->paintBoxRel(x+width-13, ypos+2+(sbs*sbh)/1024, 11, sbh/1024, COL_MENUCONTENT_PLUS_3); } diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index af95d92c4..ceb216b61 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -760,10 +760,10 @@ void CPictureViewerGui::paint() if (sbc < 1) sbc = 1; - float sbh= (sb- 4)/ sbc; + int sbh = ((sb - 4) * 1024) / sbc; int sbs= (selected/listmaxshow); - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(sbs* sbh) , 11, int(sbh), COL_MENUCONTENT_PLUS_3); + frameBuffer->paintBoxRel(x+width-13, ypos+2+(sbs*sbh)/1024, 11, sbh/1024, COL_MENUCONTENT_PLUS_3); paintFoot(); paintInfo(); diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 9dc613458..983c9d3c3 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -285,8 +285,8 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) if (timer_apids_dflt) timerlist[selected].apids = TIMERD_APIDS_CONF; else - timerlist[selected].apids = (timer_apids_std * TIMERD_APIDS_STD) | (timer_apids_ac3 * TIMERD_APIDS_AC3) | - (timer_apids_alt * TIMERD_APIDS_ALT); + timerlist[selected].apids = (unsigned char)((timer_apids_std * TIMERD_APIDS_STD) | (timer_apids_ac3 * TIMERD_APIDS_AC3) | + (timer_apids_alt * TIMERD_APIDS_ALT)); Timer->modifyTimerAPid(timerlist[selected].eventID,timerlist[selected].apids); Timer->modifyRecordTimerEvent(timerlist[selected].eventID, timerlist[selected].announceTime, timerlist[selected].alarmTime, @@ -917,9 +917,9 @@ void CTimerList::paint() frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); int sbc= ((timerlist.size()- 1)/ listmaxshow)+ 1; - float sbh= (sb- 4)/ sbc; + int sbh = ((sb - 4) * 1024) / sbc; - frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(page_nr * sbh) , 11, int(sbh), COL_MENUCONTENT_PLUS_3, RADIUS_SMALL); + frameBuffer->paintBoxRel(x+width-13, ypos+2+(page_nr*sbh)/1024, 11, sbh/1024, COL_MENUCONTENT_PLUS_3, RADIUS_SMALL); } paintFoot(); From 06408a8325d3fa80763ab6b04d67c975bf84ad2a Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Sat, 25 Jan 2014 23:04:27 +0100 Subject: [PATCH 18/20] Fix segfault in eventlist --- src/gui/eventlist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 87e54015f..712174f44 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -281,7 +281,7 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c infozone_width = full_width - width; // init right info_zone - if (g_settings.eventlist_additional) + if ((g_settings.eventlist_additional) && (cc_infozone == NULL)) cc_infozone = new CComponentsText(x+width+10, y+theight, infozone_width-20, listmaxshow*fheight); int res = menu_return::RETURN_REPAINT; From f10057118fa7c43f99b0b7d7fab124d8a35aede2 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 26 Jan 2014 00:16:30 +0100 Subject: [PATCH 19/20] Revert "- rewrite Lua handling" This reverts commit 4b6d2d310ca23a57deb138f6f2340c4cd09db653. It broke static linked lua+luaposix completely, which is useful for debugging and thus should be kept working. --- configure.ac | 37 ++++++++++++++++++++----------------- src/gui/luainstance.cpp | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 19 deletions(-) diff --git a/configure.ac b/configure.ac index 6c6401ac4..45043c41c 100644 --- a/configure.ac +++ b/configure.ac @@ -95,6 +95,16 @@ TUXBOX_APPS_LIB_PKGCONFIG(AVFORMAT,libavformat) TUXBOX_APPS_LIB_PKGCONFIG(AVCODEC,libavcodec) TUXBOX_APPS_LIB_PKGCONFIG(AVUTIL,libavutil) +# either use dynamic lualib in package lua (openSUSE) +# ... or in package lua5.2 (debian-derivates) +# ... and if all fails, assume it is in the linker path (cross build) +PKG_CHECK_MODULES([LUA], [lua >= 5.2], echo "lua >= 5.2 found", [ + PKG_CHECK_MODULES([LUA], [lua5.2 >= 5.2], echo "lua5.2 found", [ + echo "=> lualib not found, assuming static lua in linker path..." + LUA_LIBS="-llua -ldl" + ]) +]) + #TUXBOX_APPS_LIB_PKGCONFIG(CONFIGFILE,tuxbox-configfile) #TUXBOX_APPS_LIB_PKGCONFIG(CONNECTION,tuxbox-connection) #TUXBOX_APPS_LIB_PKGCONFIG(EVENTSERVER,tuxbox-eventserver) @@ -152,23 +162,6 @@ if test "$enable_upnp" = "yes"; then AC_DEFINE(ENABLE_UPNP,1,[include UPNP support - currently broken]) fi -# Lua - embeddable scripting language -AC_ARG_ENABLE(lua, - AS_HELP_STRING(--enable-lua,include Lua support), - ,[enable_lua=no]) - -AM_CONDITIONAL(ENABLE_LUA,test "$enable_lua" = "yes") -if test "$enable_lua" = "yes"; then - AC_DEFINE(ENABLE_LUA,1,[include Lua support]) - PKG_CHECK_MODULES([LUA], [lua >= 5.2], echo "lua >= 5.2 found", [ - PKG_CHECK_MODULES([LUA], [lua5.2 >= 5.2], echo "lua5.2 found", [ - echo "=> lualib not found, assuming static lua in linker path..." - LUA_LIBS="-llua -ldl" - AC_DEFINE(STATIC_LUAPOSIX,1,[Define to 1 for static lua build.]) - ]) - ]) -fi - AC_ARG_ENABLE(cleanup, [ --enable-cleanup enable cleanup on exit], [AC_DEFINE(EXIT_CLEANUP,1,[enable cleanup on exit])]) @@ -186,6 +179,16 @@ if test "$enable_testmenu" = "yes"; then AC_DEFINE(ENABLE_TEST_MENU,1,[include test menu in neutrino main menu - not recommended for general users!]) fi + +AC_ARG_ENABLE(lua, + AS_HELP_STRING(--enable-lua,enable LUA support)) + +AM_CONDITIONAL(ENABLE_LUA,test "$enable_lua" = "yes") +if test "$enable_lua" = "yes"; then + AC_DEFINE(ENABLE_LUA,1,[include LUA support]) +fi + + if test "$BOXTYPE" = "coolstream"; then if test -e ${srcdir}/lib/libcoolstream/nevis_ir.h; then AC_DEFINE(HAVE_COOLSTREAM_NEVIS_IR_H,1,[Define to 1 if you have the header file.]) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 08d8f1a95..087a3b26b 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -347,12 +347,35 @@ const luaL_Reg CLuaInstance::methods[] = { NULL, NULL } }; -#ifdef STATIC_LUAPOSIX +#ifndef DYNAMIC_LUAPOSIX /* hack: we link against luaposix, which is included in our * custom built lualib */ extern "C" { LUAMOD_API int (luaopen_posix_c) (lua_State *L); } +#else +static int dolibrary (lua_State *L, const char *name) +{ + int status = 0; + const char *msg = ""; + lua_getglobal(L, "require"); + lua_pushstring(L, name); + status = lua_pcall(L, 1, 0, 0); + if (status && !lua_isnil(L, -1)) + { + msg = lua_tostring(L, -1); + if (NULL == msg) + { + msg = "(error object is not a string)"; + } + fprintf(stderr, "[CLuaInstance::%s] error in dolibrary: %s (%s)\n", __func__, name,msg); + lua_pop(L, 1); + } + else + { + printf("[CLuaInstance::%s] loaded library: %s\n", __func__, name); + } + return status; +} #endif - /* load basic functions and register our own C callbacks */ void CLuaInstance::registerFunctions() { @@ -361,6 +384,14 @@ void CLuaInstance::registerFunctions() luaopen_io(lua); luaopen_string(lua); luaopen_math(lua); +#ifndef DYNAMIC_LUAPOSIX +#if !HAVE_COOL_HARDWARE + luaopen_posix_c(lua); +#endif +#else + dolibrary(lua,"posix"); +#endif + lua_newtable(lua); int methodtable = lua_gettop(lua); luaL_newmetatable(lua, className); From f625a18324824cc1a5cf4e140e27b6964bedad44 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 26 Jan 2014 00:32:23 +0100 Subject: [PATCH 20/20] Revert "Fix compiler warnings (-Wconversion)" This reverts commit cd5fd9dab3a64d7cb5f8631921b6525b5219da6c. I have a different, simpler version in my tree. Keep only the (unsigned char) cast in timerlist.cpp --- src/gui/bedit/bouqueteditor_bouquets.cpp | 4 ++-- src/gui/bookmarkmanager.cpp | 5 +++-- src/gui/bouquetlist.cpp | 4 ++-- src/gui/eventlist.cpp | 4 ++-- src/gui/pictureviewer.cpp | 4 ++-- src/gui/timerlist.cpp | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index 804ccea25..b89218f4c 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -124,11 +124,11 @@ void CBEBouquetWidget::paint() if (sbc < 1) sbc = 1; - int sbh = ((sb - 4) * 1024) / sbc; + float sbh= (sb- 4)/ sbc; int sbs= (selected/listmaxshow); //scrollbar - frameBuffer->paintBoxRel(x+width-13, ypos+2+(sbs*sbh)/1024, 11, sbh/1024, COL_MENUCONTENT_PLUS_3); + frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(sbs* sbh) , 11, int(sbh), COL_MENUCONTENT_PLUS_3); } void CBEBouquetWidget::paintHead() diff --git a/src/gui/bookmarkmanager.cpp b/src/gui/bookmarkmanager.cpp index 3a0ccb791..56894699c 100644 --- a/src/gui/bookmarkmanager.cpp +++ b/src/gui/bookmarkmanager.cpp @@ -456,9 +456,10 @@ void CBookmarkManager::paint() int sbc= ((bookmarks.size()- 1)/ listmaxshow)+ 1; if (sbc < 1) sbc = 1; - int sbh = ((sb - 4) * 1024) / sbc; - frameBuffer->paintBoxRel(x+width-13, ypos+2+(page_nr*sbh)/1024, 11, sbh/1024, COL_MENUCONTENT_PLUS_3); + float sbh= (sb- 4)/ sbc; + + frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(page_nr * sbh) , 11, int(sbh), COL_MENUCONTENT_PLUS_3); } paintFoot(); diff --git a/src/gui/bouquetlist.cpp b/src/gui/bouquetlist.cpp index 10150efaa..f8846cdf8 100644 --- a/src/gui/bouquetlist.cpp +++ b/src/gui/bouquetlist.cpp @@ -634,8 +634,8 @@ void CBouquetList::paint() frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); int sbc= ((bsize - 1)/ listmaxshow)+ 1; /* bsize is > 0, so sbc is also > 0 */ - int sbh = ((sb - 4) * 1024) / sbc; + float sbh= (sb - 4)/ sbc; int sbs= (selected/listmaxshow); - frameBuffer->paintBoxRel(x+width-13, ypos+2+(sbs*sbh)/1024, 11, sbh/1024, COL_MENUCONTENT_PLUS_3); + frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(sbs* sbh) , 11, int(sbh), COL_MENUCONTENT_PLUS_3); } diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 712174f44..8bdb1ddf0 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -921,10 +921,10 @@ void CNeutrinoEventList::paint(t_channel_id channel_id) if (sbc < 1) sbc = 1; - int sbh = ((sb - 4) * 1024) / sbc; + float sbh= (sb- 4)/ sbc; int sbs= (selected/listmaxshow); - frameBuffer->paintBoxRel(x+width-13, ypos+2+(sbs*sbh)/1024, 11, sbh/1024, COL_MENUCONTENT_PLUS_3); + frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(sbs* sbh) , 11, int(sbh), COL_MENUCONTENT_PLUS_3); } diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index ceb216b61..af95d92c4 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -760,10 +760,10 @@ void CPictureViewerGui::paint() if (sbc < 1) sbc = 1; - int sbh = ((sb - 4) * 1024) / sbc; + float sbh= (sb- 4)/ sbc; int sbs= (selected/listmaxshow); - frameBuffer->paintBoxRel(x+width-13, ypos+2+(sbs*sbh)/1024, 11, sbh/1024, COL_MENUCONTENT_PLUS_3); + frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(sbs* sbh) , 11, int(sbh), COL_MENUCONTENT_PLUS_3); paintFoot(); paintInfo(); diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 983c9d3c3..93732057e 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -917,9 +917,9 @@ void CTimerList::paint() frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); int sbc= ((timerlist.size()- 1)/ listmaxshow)+ 1; - int sbh = ((sb - 4) * 1024) / sbc; + float sbh= (sb- 4)/ sbc; - frameBuffer->paintBoxRel(x+width-13, ypos+2+(page_nr*sbh)/1024, 11, sbh/1024, COL_MENUCONTENT_PLUS_3, RADIUS_SMALL); + frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(page_nr * sbh) , 11, int(sbh), COL_MENUCONTENT_PLUS_3, RADIUS_SMALL); } paintFoot();