mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 08:21:12 +02:00
CComponentsFrmClock/CInfoClock: simplify font init
This commit is contained in:
@@ -75,11 +75,8 @@ CComponentsFrmClock::CComponentsFrmClock( const int& x_pos,
|
|||||||
//init default font
|
//init default font
|
||||||
cl_font = font;
|
cl_font = font;
|
||||||
cl_font_style = font_style;
|
cl_font_style = font_style;
|
||||||
if (cl_font == NULL){
|
if (cl_font == NULL)
|
||||||
int dx = 0;
|
initClockFont(0, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight());
|
||||||
int dy = 30;
|
|
||||||
setClockFont(*CNeutrinoFonts::getInstance()->getDynFont(dx, dy, cl_format_str, cl_font_style));
|
|
||||||
}
|
|
||||||
|
|
||||||
//init general clock dimensions
|
//init general clock dimensions
|
||||||
height = cl_font->getHeight();
|
height = cl_font->getHeight();
|
||||||
@@ -114,6 +111,11 @@ CComponentsFrmClock::~CComponentsFrmClock()
|
|||||||
delete cl_timer;
|
delete cl_timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CComponentsFrmClock::initClockFont(int dx, int dy)
|
||||||
|
{
|
||||||
|
setClockFont(*CNeutrinoFonts::getInstance()->getDynFont(dx, dy, cl_format_str, cl_font_style));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CComponentsFrmClock::initTimeString()
|
void CComponentsFrmClock::initTimeString()
|
||||||
{
|
{
|
||||||
@@ -380,15 +382,13 @@ void CComponentsFrmClock::paint(bool do_save_bg)
|
|||||||
|
|
||||||
void CComponentsFrmClock::setClockFont(Font *font, const int& style)
|
void CComponentsFrmClock::setClockFont(Font *font, const int& style)
|
||||||
{
|
{
|
||||||
|
if (cl_font != font || (cl_font != font)){
|
||||||
if (cl_font != font)
|
if (cl_font != font)
|
||||||
cl_font = font;
|
cl_font = font;
|
||||||
|
|
||||||
if (style != -1)
|
if (style != -1)
|
||||||
cl_font_style = style;
|
cl_font_style = style;
|
||||||
|
//initCCLockItems();
|
||||||
// setHeight(cl_font->getHeight());
|
}
|
||||||
// setWidth(cl_font->getRenderWidth(cl_format_str));
|
|
||||||
initCCLockItems();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Font* CComponentsFrmClock::getClockFont()
|
Font* CComponentsFrmClock::getClockFont()
|
||||||
|
@@ -88,9 +88,8 @@ class CComponentsFrmClock : public CComponentsForm, public CCTextScreen
|
|||||||
bool stopClock();
|
bool stopClock();
|
||||||
///switch between primary and secondary format
|
///switch between primary and secondary format
|
||||||
void toggleFormat();
|
void toggleFormat();
|
||||||
|
///init internal font
|
||||||
///return pointer of font object
|
void initClockFont(int dx, int dy);
|
||||||
Font* getClockFont();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -121,6 +120,9 @@ class CComponentsFrmClock : public CComponentsForm, public CCTextScreen
|
|||||||
*/
|
*/
|
||||||
void setClockFont(Font * font, const int& style = -1);
|
void setClockFont(Font * font, const int& style = -1);
|
||||||
|
|
||||||
|
///return pointer of font object
|
||||||
|
Font* getClockFont();
|
||||||
|
|
||||||
///set text color
|
///set text color
|
||||||
virtual void setTextColor(fb_pixel_t color_text){ cl_col_text = color_text;}
|
virtual void setTextColor(fb_pixel_t color_text){ cl_col_text = color_text;}
|
||||||
|
|
||||||
@@ -132,6 +134,8 @@ class CComponentsFrmClock : public CComponentsForm, public CCTextScreen
|
|||||||
///use string expession: "%H:%M" = 12:22, "%H:%M:%S" = 12:22:12
|
///use string expession: "%H:%M" = 12:22, "%H:%M:%S" = 12:22:12
|
||||||
///set current time format string, 1st parameter set the default format, 2nd parameter sets an alternatively format for use as blink effect
|
///set current time format string, 1st parameter set the default format, 2nd parameter sets an alternatively format for use as blink effect
|
||||||
virtual void setClockFormat(const char* prformat_str, const char* secformat_str = NULL);
|
virtual void setClockFormat(const char* prformat_str, const char* secformat_str = NULL);
|
||||||
|
///get current time format string,
|
||||||
|
std::string getClockFormat(){return cl_format;}
|
||||||
|
|
||||||
///start and paint ticking clock
|
///start and paint ticking clock
|
||||||
virtual bool Start();
|
virtual bool Start();
|
||||||
|
@@ -73,17 +73,12 @@ void CInfoClock::initCCLockItems()
|
|||||||
setClockFormat("%H:%M", "%H %M");
|
setClockFormat("%H:%M", "%H %M");
|
||||||
|
|
||||||
//set height, NOTE: height is strictly bound to settings
|
//set height, NOTE: height is strictly bound to settings
|
||||||
if (g_settings.infoClockFontSize != height){
|
|
||||||
height = g_settings.infoClockFontSize;
|
height = g_settings.infoClockFontSize;
|
||||||
int dx = 0;
|
initClockFont(0, height);
|
||||||
int dy = height;
|
|
||||||
setClockFont(*CNeutrinoFonts::getInstance()->getDynFont(dx, dy, cl_format_str, cl_font_style));
|
|
||||||
}
|
|
||||||
|
|
||||||
// set corner radius depending on clock height
|
// set corner radius depending on clock height
|
||||||
corner_rad = (g_settings.rounded_corners) ? std::max(height/10, CORNER_RADIUS_SMALL) : 0;
|
corner_rad = (g_settings.rounded_corners) ? std::max(height/10, CORNER_RADIUS_SMALL) : 0;
|
||||||
|
|
||||||
CComponentsFrmClock::initCCLockItems();
|
|
||||||
CVolumeHelper::getInstance()->refresh(cl_font);
|
CVolumeHelper::getInstance()->refresh(cl_font);
|
||||||
CVolumeHelper::getInstance()->getInfoClockDimensions(&x, &y, &width, &height);
|
CVolumeHelper::getInstance()->getInfoClockDimensions(&x, &y, &width, &height);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user