mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 17:01:15 +02:00
cc_frm_header.cpp/h: remove CTextBox types for title allignment
Title object has only width of current text content. This causes CTextBox types have not a really visible effect. Now we have only three align types for title and these are related to cc-text object position. Involved classes adjusted too.
This commit is contained in:
@@ -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,7 +302,7 @@ void CComponentsHeader::initLogo()
|
||||
|
||||
//right end
|
||||
int x_logo_right = width - cch_logo_obj->getWidth();
|
||||
if (cch_caption_align != CTextBox::RIGHT){
|
||||
if (!(cch_caption_align & CC_TITLE_RIGHT)){
|
||||
if (cch_btn_obj)
|
||||
x_logo_right -= cch_btn_obj->getWidth();
|
||||
if (cch_cl_obj)
|
||||
@@ -314,7 +314,7 @@ void CComponentsHeader::initLogo()
|
||||
|
||||
//left end
|
||||
int x_logo_left = cch_offset;
|
||||
if (cch_caption_align != CTextBox::RIGHT)
|
||||
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)
|
||||
@@ -329,19 +329,19 @@ void CComponentsHeader::initLogo()
|
||||
|
||||
//set final logo position
|
||||
int x_logo = 0;
|
||||
if (cch_logo.Align == CC_LOGO_RIGHT){
|
||||
if (cch_caption_align == CTextBox::RIGHT){
|
||||
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)
|
||||
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 adjacent item and logo are overlapping
|
||||
if (cch_caption_align != CTextBox::RIGHT){
|
||||
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)
|
||||
@@ -605,10 +605,10 @@ void CComponentsHeader::initCaption()
|
||||
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 == CTextBox::CENTER)
|
||||
if (cch_caption_align & CC_TITLE_CENTER)
|
||||
cch_text_x = width/2 - cc_text_w/2;
|
||||
|
||||
if (cch_caption_align == CTextBox::RIGHT){
|
||||
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);
|
||||
}
|
||||
|
@@ -32,25 +32,29 @@
|
||||
#include "cc_frm_clock.h"
|
||||
#include <driver/colorgradient.h>
|
||||
|
||||
#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<std::string> 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
|
||||
|
@@ -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;
|
||||
@@ -187,7 +187,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;
|
||||
|
@@ -52,7 +52,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()
|
||||
@@ -68,7 +68,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()
|
||||
@@ -168,15 +168,17 @@ class CComponentsWindow : public CComponentsForm
|
||||
void enableSidebar(const int& sidbar_type = CC_WINDOW_LEFT_SIDEBAR | CC_WINDOW_RIGHT_SIDEBAR);
|
||||
|
||||
///set caption in header with string, see also getHeaderObject()
|
||||
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;}
|
||||
///set header text color
|
||||
|
||||
void setWindowHeaderTextColor(const fb_pixel_t& color){ccw_col_head_text = color;}
|
||||
///set background to header
|
||||
void setWindowHeaderColor(const fb_pixel_t& color){ccw_col_head = color;}
|
||||
|
||||
///set caption in header from locales, see also getHeaderObject()
|
||||
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);
|
||||
///set caption alignment, see CTextBox for possible 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;};
|
||||
|
||||
///set icon name in header, see also getHeaderObject()
|
||||
void setWindowIcon(const std::string& iconname){ccw_icon_name = iconname; initHeader();};
|
||||
|
Reference in New Issue
Block a user