diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index c57fdfe18..f4a0dbf7f 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -2158,7 +2158,7 @@ void CChannelList::paintHead() fb_pixel_t header_txt_col = (edit_state ? COL_RED : COL_MENUHEAD_TEXT); header->setColorBody(COL_MENUHEAD_PLUS_0); - header->setCaption(header_txt, CTextBox::NO_AUTO_LINEBREAK, header_txt_col); + header->setCaption(header_txt, DEFAULT_TITLE_ALIGN, header_txt_col); if (timeset) { if(!edit_state){ diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index f6e20c5a0..f0a5ba052 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -130,7 +130,7 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const cch_logo.dy_max = -1; cch_logo.Align = DEFAULT_LOGO_ALIGN; cch_col_text = COL_MENUHEAD_TEXT; - cch_caption_align = CTextBox::NO_AUTO_LINEBREAK; + cch_caption_align = DEFAULT_TITLE_ALIGN; cch_items_y = CC_CENTERED; cch_offset = OFFSET_INNER_MID; cch_icon_x = cch_offset; @@ -163,7 +163,7 @@ CComponentsHeader::~CComponentsHeader() v_cch_btn.clear(); } -void CComponentsHeader::setCaption(const std::string& caption, const int& align_mode, const fb_pixel_t& text_color) +void CComponentsHeader::setCaption(const std::string& caption, const cc_title_alignment_t& align_mode, const fb_pixel_t& text_color) { if (cch_cl_obj) cch_cl_obj->Stop(); @@ -172,7 +172,7 @@ void CComponentsHeader::setCaption(const std::string& caption, const int& align_ cch_col_text = text_color; } -void CComponentsHeader::setCaption(neutrino_locale_t caption_locale, const int& align_mode, const fb_pixel_t& text_color) +void CComponentsHeader::setCaption(neutrino_locale_t caption_locale, const cc_title_alignment_t& align_mode, const fb_pixel_t& text_color) { setCaption(string(g_Locale->getText(caption_locale)), align_mode, text_color); } @@ -302,13 +302,23 @@ void CComponentsHeader::initLogo() //right end int x_logo_right = width - cch_logo_obj->getWidth(); - if (cch_btn_obj) - x_logo_right -= cch_btn_obj->getWidth(); - if (cch_cl_obj) - x_logo_right -= cch_cl_obj->getWidth(); + if (!(cch_caption_align & CC_TITLE_RIGHT)){ + if (cch_btn_obj) + x_logo_right -= cch_btn_obj->getWidth(); + if (cch_cl_obj) + x_logo_right -= cch_cl_obj->getWidth(); + }else{ + if (cch_icon_obj) + x_logo_right += cch_icon_obj->getWidth(); + } //left end - int x_logo_left = getCCItem(prev_id) ? getCCItem(prev_id)->getXPos() + getCCItem(prev_id)->getWidth() : 0; + int x_logo_left = cch_offset; + if (!(cch_caption_align & CC_TITLE_RIGHT)) + x_logo_left = getCCItem(prev_id) ? getCCItem(prev_id)->getXPos() + getCCItem(prev_id)->getWidth() : 0; + else + if (cch_icon_obj) + x_logo_left += cch_icon_obj->getWidth(); //calculate available space int logo_space = x_logo_right + cch_logo_obj->getWidth() - x_logo_left; @@ -319,17 +329,30 @@ void CComponentsHeader::initLogo() //set final logo position int x_logo = 0; - if (cch_logo.Align == CC_LOGO_RIGHT) - x_logo = x_logo_right; - if (cch_logo.Align == CC_LOGO_LEFT) + if (cch_logo.Align & CC_LOGO_RIGHT){ + if (cch_caption_align & CC_TITLE_RIGHT){ + if (cch_text_obj) + x_logo = cch_text_obj->getXPos() - cch_logo_obj->getWidth(); + }else + x_logo = x_logo_right; + } + if (cch_logo.Align & CC_LOGO_LEFT) x_logo = x_logo_left; - if (cch_logo.Align == CC_LOGO_CENTER){ + if (cch_logo.Align & CC_LOGO_CENTER){ x_logo = width/2 - cch_logo_obj->getWidth()/2; - //fallback if previous item and logo are overlapping - if (getCCItem(prev_id)){ - int x_tmp = x_logo_left + logo_space/2 - cch_logo_obj->getWidth()/2; - if (x_logo <= x_logo_left) - x_logo = x_tmp; + //fallback if adjacent item and logo are overlapping + if (!(cch_caption_align & CC_TITLE_RIGHT)){ + if (getCCItem(prev_id)){ + int x_tmp = x_logo_left + logo_space/2 - cch_logo_obj->getWidth()/2; + if (x_logo <= x_logo_left) + x_logo = x_tmp; + } + }else{ + if (cch_text_obj){ + if (x_logo + cch_logo_obj->getWidth() >= cch_text_obj->getXPos()){ + x_logo = (x_logo_left + cch_text_obj->getXPos())/2 - cch_logo_obj->getWidth()/2; + } + } } } @@ -576,20 +599,26 @@ void CComponentsHeader::initCaption() //set header text properties if (cch_text_obj){ - //set alignment of text item in dependency from text alignment - if (cch_caption_align == CTextBox::CENTER) - cch_text_x = CC_CENTERED; + int w_free = cc_text_w; //recalc caption width cc_text_w = min(cc_text_w, cch_font->getRenderWidth(cch_text)+ OFFSET_INNER_MID); + //set alignment of text item in dependency from text alignment + if (cch_caption_align & CC_TITLE_CENTER) + cch_text_x = width/2 - cc_text_w/2; + + if (cch_caption_align & CC_TITLE_RIGHT){ + cch_text_x += w_free; + cch_text_x -= max(cc_text_w, cch_font->getRenderWidth(cch_text)+ OFFSET_INNER_MID); + } + //assign general properties cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, cc_text_w, height); cch_text_obj->setColorBody(col_body); if (cc_body_gradient_enable != cc_body_gradient_enable_old) cch_text_obj->getCTextBoxObject()->clearScreenBuffer(); - cch_text_obj->setTextColor(cch_col_text); - cch_text_obj->setText(cch_text, cch_caption_align, cch_font); + cch_text_obj->setText(cch_text, cch_caption_align, cch_font, cch_col_text); cch_text_obj->enableTboxSaveScreen(cc_body_gradient_enable || cc_txt_save_screen); //corner of text item diff --git a/src/gui/components/cc_frm_header.h b/src/gui/components/cc_frm_header.h index 9550d1134..e26d28ff2 100644 --- a/src/gui/components/cc_frm_header.h +++ b/src/gui/components/cc_frm_header.h @@ -32,25 +32,29 @@ #include "cc_frm_clock.h" #include -#define DEFAULT_LOGO_ALIGN CComponentsHeader::CC_LOGO_CENTER +#define DEFAULT_LOGO_ALIGN CCHeaderTypes::CC_LOGO_CENTER +#define DEFAULT_TITLE_ALIGN CCHeaderTypes::CC_TITLE_LEFT -//! Sub class of CComponentsForm. Shows a header with prepared items. -/*! -CComponentsHeader provides prepared items like icon, caption and context button icons, mostly for usage in menues or simple windows -*/ - -class CComponentsHeader : public CComponentsForm, public CCTextScreen +class CCHeaderTypes { public: ///logo position options typedef enum { - CC_LOGO_RIGHT , - CC_LOGO_LEFT , - CC_LOGO_CENTER + CC_LOGO_RIGHT = 0x01, + CC_LOGO_LEFT = 0x02, + CC_LOGO_CENTER = 0x04 }cc_logo_alignment_t; - private: + ///title position options + typedef enum + { /*for compatibilty use CTextBox enums values*/ + CC_TITLE_LEFT = 0x400, + CC_TITLE_CENTER = 0x40 , + CC_TITLE_RIGHT = 0x80 + }cc_title_alignment_t; + + protected: ///required logo data type typedef struct cch_logo_t { @@ -60,7 +64,17 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen int32_t dy_max; cc_logo_alignment_t Align; } cch_logo_struct_t; +}; + +//! Sub class of CComponentsForm. Shows a header with prepared items. +/*! +CComponentsHeader provides prepared items like icon, caption and context button icons, mostly for usage in menues or simple windows +*/ + +class CComponentsHeader : public CComponentsForm, public CCTextScreen, CCHeaderTypes +{ + private: ///member: init genaral variables, parameters for mostly used properties void initVarHeader( const int& x_pos, const int& y_pos, const int& w, const int& h, const std::string& caption, @@ -116,8 +130,8 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen 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; + ///property: alignment of caption within header, see also setCaptionAlignment() + cc_title_alignment_t cch_caption_align; ///property: enable/disable of clock, see also enableClock() bool cch_cl_enable; ///property: clock format @@ -167,12 +181,12 @@ class CComponentsHeader : public CComponentsForm, public CCTextScreen 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, const fb_pixel_t& text_color = COL_MENUHEAD_TEXT); + virtual void setCaption(const std::string& caption, const cc_title_alignment_t& align_mode = DEFAULT_TITLE_ALIGN, const fb_pixel_t& text_color = COL_MENUHEAD_TEXT); ///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, const fb_pixel_t& text_color = COL_MENUHEAD_TEXT); + virtual void setCaption(neutrino_locale_t caption_locale, const cc_title_alignment_t& align_mode = DEFAULT_TITLE_ALIGN, const fb_pixel_t& text_color = COL_MENUHEAD_TEXT); - ///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 alignment of caption within header, possible paramters are CComponentsHeader::CC_TITLE_LEFT, CComponentsHeader::CC_TITLE_RIGHT, CComponentsHeader::CC_TITLE_CENTER + virtual void setCaptionAlignment(const cc_title_alignment_t& align_mode){cch_caption_align = align_mode;} /**Set text font for title. * Internal default font is g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE] and diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp index bbce38a9e..39aaffbf8 100644 --- a/src/gui/components/cc_frm_window.cpp +++ b/src/gui/components/cc_frm_window.cpp @@ -150,7 +150,7 @@ void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const ccw_buttons = 0; //no header buttons ccw_show_footer = true; ccw_show_header = true; - ccw_align_mode = CTextBox::NO_AUTO_LINEBREAK; + ccw_align_mode = DEFAULT_TITLE_ALIGN; ccw_show_l_sideber = false; ccw_show_r_sideber = false; ccw_w_sidebar = 40; @@ -191,7 +191,7 @@ void CComponentsWindow::initWindowPos() y = frameBuffer->getScreenY(); } -void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const int& align_mode) +void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const cc_title_alignment_t& align_mode) { ccw_caption = g_Locale->getText(locale_text); ccw_align_mode = align_mode; diff --git a/src/gui/components/cc_frm_window.h b/src/gui/components/cc_frm_window.h index 52b4e0012..6dfe67df8 100644 --- a/src/gui/components/cc_frm_window.h +++ b/src/gui/components/cc_frm_window.h @@ -54,7 +54,7 @@ items like text, labels, pictures ... */ -class CComponentsWindow : public CComponentsForm +class CComponentsWindow : public CComponentsForm, CCHeaderTypes { protected: ///object: header object, to get access to header properties see also getHeaderObject() @@ -70,7 +70,7 @@ class CComponentsWindow : public CComponentsForm ///property: caption in header, see also getHeaderObject() std::string ccw_caption; ///property: alignment mode for header caption - int ccw_align_mode; + cc_title_alignment_t ccw_align_mode; ///property: icon name in header, see also getHeaderObject() std::string ccw_icon_name; ///property: assigned default icon buttons in header, see also getHeaderObject() @@ -241,20 +241,20 @@ class CComponentsWindow : public CComponentsForm * @param[in] text * @li expects type const std::string&, defines title of window header * @param[in] align_mode - * @li optional: expects type const int&, defines allignment of title text + * @li optional: expects type const cc_title_alignment_t&, defines allignment of title text * @see CTextBox for alignment modes */ - void setWindowCaption(const std::string& text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK){ccw_caption = text; ccw_align_mode = align_mode;} + void setWindowCaption(const std::string& text, const cc_title_alignment_t& align_mode = DEFAULT_TITLE_ALIGN){ccw_caption = text; ccw_align_mode = align_mode;} /** * sets title text in header * @param[in] text * @li expects type neutrino_locale_t * @param[in] align_mode - * @li optional: expects type const int&, defines allignment of title text + * @li optional: expects type const cc_title_alignment_t&, defines allignment of title text * @see CTextBox for alignment modes */ - void setWindowCaption(neutrino_locale_t locale_text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK); + void setWindowCaption(neutrino_locale_t locale_text, const cc_title_alignment_t& align_mode = DEFAULT_TITLE_ALIGN); /** * Sets header text color @@ -273,10 +273,10 @@ class CComponentsWindow : public CComponentsForm /** * sets title text alignment * @param[in] align_mode - * @li expects type const int& + * @li expects type const cc_title_alignment_t& * @see CTextBox for alignment modes */ - void setWindowCaptionAlignment(const int& align_mode){ccw_align_mode = align_mode;}; + void setWindowCaptionAlignment(const cc_title_alignment_t& align_mode){ccw_align_mode = align_mode;}; /** * Sets icon name of window header. diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index 4d0bab909..3bfe6f4fd 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -126,7 +126,7 @@ void EpgPlus::Header::paint(const char * Name) this->logo->allowPaint(false); } this->head->setDimensionsAll(this->x, this->y, this->width, this->font->getHeight()); - this->head->setCaption(caption, CTextBox::NO_AUTO_LINEBREAK); + this->head->setCaption(caption); this->head->paint(CC_SAVE_SCREEN_NO); } } diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 1c298bb59..d64ff7c71 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -896,7 +896,7 @@ void CEventList::paintHead(t_channel_id _channel_id, std::string _channelname, s if (header->isPainted()) header->getChannelLogoObject()->hide(); header->setChannelLogo(_channel_id,_channelname); - header->setCaption(_channelname,CTextBox::CENTER); + header->setCaption(_channelname, CCHeaderTypes::CC_TITLE_CENTER); header->paint(CC_SAVE_SCREEN_NO); diff --git a/src/gui/lua/lua_api_version.h b/src/gui/lua/lua_api_version.h index 1edd9814a..4320eacbe 100644 --- a/src/gui/lua/lua_api_version.h +++ b/src/gui/lua/lua_api_version.h @@ -4,4 +4,4 @@ * to luainstance.h changes */ #define LUA_API_VERSION_MAJOR 1 -#define LUA_API_VERSION_MINOR 74 +#define LUA_API_VERSION_MINOR 75 diff --git a/src/gui/lua/lua_cc_window.cpp b/src/gui/lua/lua_cc_window.cpp index 8fb985e67..0d4c9d412 100644 --- a/src/gui/lua/lua_cc_window.cpp +++ b/src/gui/lua/lua_cc_window.cpp @@ -89,7 +89,7 @@ int CLuaInstCCWindow::CCWindowNew(lua_State *L) tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name); tableLookup(L, "icon", icon); - int has_shadow = CC_SHADOW_OFF; + lua_Integer has_shadow = CC_SHADOW_OFF; if (!tableLookup(L, "has_shadow", has_shadow)) { tmp1 = "false"; if (tableLookup(L, "has_shadow", tmp1)) @@ -221,10 +221,10 @@ int CLuaInstCCWindow::CCWindowSetCaption(lua_State *L) std::string name = ""; tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name); - lua_Integer alignment = (lua_Integer)CTextBox::NO_AUTO_LINEBREAK; + lua_Integer alignment = (lua_Integer)DEFAULT_TITLE_ALIGN; tableLookup(L, "alignment", alignment); - D->w->setWindowCaption(name, alignment | (lua_Integer)CTextBox::NO_AUTO_LINEBREAK); + D->w->setWindowCaption(name, (cc_title_alignment_t)alignment); return 0; } diff --git a/src/gui/lua/lua_cc_window.h b/src/gui/lua/lua_cc_window.h index 98cd9ac86..2c5c961f3 100644 --- a/src/gui/lua/lua_cc_window.h +++ b/src/gui/lua/lua_cc_window.h @@ -29,7 +29,7 @@ class CLuaCCWindow ~CLuaCCWindow() { delete w; } }; -class CLuaInstCCWindow +class CLuaInstCCWindow : CCHeaderTypes { public: CLuaInstCCWindow() {}; diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index 26a00d41c..1709db61e 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -507,7 +507,7 @@ void CScanTs::paintLine(int px, int py, int w, const char * const txt) void CScanTs::paint(bool fortest) { CComponentsHeaderLocalized header(x, y, width, hheight, fortest ? LOCALE_SCANTS_TEST : LOCALE_SCANTS_HEAD); - header.setCaptionAlignment(CTextBox::CENTER); + header.setCaptionAlignment(CCHeaderTypes::CC_TITLE_CENTER); 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/test_menu.cpp b/src/gui/test_menu.cpp index 5bc587c4a..9f6637d6b 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -744,11 +744,11 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) else if (actionKey == "window"){ if (window == NULL){ window = new CComponentsWindow(); - window->setWindowCaption("|........HEADER........|", CTextBox::CENTER); + window->setWindowCaption("|........HEADER........|", CCHeaderTypes::CC_TITLE_CENTER); window->setDimensionsAll(50, 50, 500, 500); window->setWindowIcon(NEUTRINO_ICON_INFO); window->enableShadow(); - window->getFooterObject()->setCaption("|........FOOTER........|", CTextBox::CENTER); + window->getFooterObject()->setCaption("|........FOOTER........|", CCHeaderTypes::CC_TITLE_CENTER); CComponentsShapeCircle *c10 = new CComponentsShapeCircle(0, 0, 28); CComponentsShapeCircle *c11 = new CComponentsShapeCircle(0, CC_APPEND, 28);