diff --git a/src/driver/neutrinofonts.h b/src/driver/neutrinofonts.h index e5c99d55e..ce6e623c2 100644 --- a/src/driver/neutrinofonts.h +++ b/src/driver/neutrinofonts.h @@ -91,6 +91,7 @@ class CNeutrinoFonts }; enum { FONT_ID_VOLBAR, + FONT_ID_INFOCLOCK, FONT_ID_MAX }; diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index da76721b8..13bbb708d 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -29,6 +29,7 @@ #include #include +#include #include "cc_frm_clock.h" #include @@ -70,16 +71,19 @@ CComponentsFrmClock::CComponentsFrmClock( const int x_pos, const int y_pos, cons void CComponentsFrmClock::initVarClock() { initVarForm(); - cc_item_type = CC_ITEMTYPE_FRM_CLOCK; - corner_rad = RADIUS_SMALL; + cc_item_type = CC_ITEMTYPE_FRM_CLOCK; + corner_rad = RADIUS_SMALL; - cl_font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO]; - cl_col_text = COL_MENUCONTENT_TEXT; - cl_format_str = "%H:%M"; - cl_align = CC_ALIGN_VER_CENTER | CC_ALIGN_HOR_CENTER; + cl_font_type = SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO; + cl_font = &g_Font[cl_font_type]; + dyn_font_size = 0; - cl_thread = 0; - cl_interval = 1; + cl_col_text = COL_MENUCONTENT_TEXT; + cl_format_str = "%H:%M"; + cl_align = CC_ALIGN_VER_CENTER | CC_ALIGN_HOR_CENTER; + + cl_thread = 0; + cl_interval = 1; } CComponentsFrmClock::~CComponentsFrmClock() @@ -117,8 +121,8 @@ void CComponentsFrmClock::initCCLockItems() string s_time = cl_timestr; //get minimal required height, width from raw text - int min_text_w = cl_font->getRenderWidth(s_time, true);; - int min_text_h = cl_font->getHeight(); + int min_text_w = (*getClockFont())->getRenderWidth(s_time, true);; + int min_text_h = (*getClockFont())->getHeight(); height = max(height, min_text_h); width = max(width, min_text_w); @@ -169,13 +173,13 @@ void CComponentsFrmClock::initCCLockItems() string stmp = s_time.substr(i, 1); //get width of current segment - int wtmp = cl_font->getRenderWidth(stmp, true); + int wtmp = (*getClockFont())->getRenderWidth(stmp, true); //set size, text, color of current item lbl->setDimensionsAll(cl_x, cl_y, wtmp, cl_h); lbl->setTextColor(cl_col_text); lbl->setColorAll(col_frame, col_body, col_shadow); - lbl->setText(stmp, CTextBox::CENTER, cl_font); + lbl->setText(stmp, CTextBox::CENTER, *getClockFont()); //use matching height for digits for better vertical centerring into form CTextBox* ctb = lbl->getCTextBoxObject(); @@ -333,3 +337,24 @@ void CComponentsFrmClock::paint(bool do_save_bg) //paint form contents paintForm(do_save_bg); } + +void CComponentsFrmClock::setClockFontSize(int size) +{ + int tmp_w = 0; + dyn_font_size = size; + cl_font = CNeutrinoFonts::getInstance()->getDynFont(tmp_w, dyn_font_size, "", CNeutrinoFonts::FONT_STYLE_BOLD, CNeutrinoFonts::FONT_ID_INFOCLOCK); +} + +void CComponentsFrmClock::setClockFont(int font) +{ + cl_font_type = font; + cl_font = &g_Font[cl_font_type]; +} + +Font** CComponentsFrmClock::getClockFont() +{ + if (dyn_font_size == 0) + cl_font = &g_Font[cl_font_type]; + return cl_font; + +} diff --git a/src/gui/components/cc_frm_clock.h b/src/gui/components/cc_frm_clock.h index 1af9d2580..860126edc 100644 --- a/src/gui/components/cc_frm_clock.h +++ b/src/gui/components/cc_frm_clock.h @@ -62,7 +62,11 @@ class CComponentsFrmClock : public CComponentsForm bool activeClock; ///object: font render object - Font *cl_font; + Font **cl_font; + + int cl_font_type; + int dyn_font_size; + ///text color int cl_col_text; ///time format @@ -80,6 +84,9 @@ class CComponentsFrmClock : public CComponentsForm ///initialize of general alignment of timestring segments within form area void initSegmentAlign(int* segment_width, int* segment_height); + ///return pointer of font object + inline Font** getClockFont(); + public: CComponentsFrmClock(); CComponentsFrmClock( const int x_pos, const int y_pos, const int w, const int h, @@ -87,8 +94,9 @@ class CComponentsFrmClock : public CComponentsForm fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); virtual ~CComponentsFrmClock(); - ///set font type for segments - virtual void setClockFont(Font *font){cl_font = font;}; + ///set font type or font size for segments + virtual void setClockFont(int font); + virtual void setClockFontSize(int size); ///set text color virtual void setTextColor(fb_pixel_t color_text){ cl_col_text = color_text;}; diff --git a/src/gui/infoclock.cpp b/src/gui/infoclock.cpp index 1b5381588..c6635fff4 100644 --- a/src/gui/infoclock.cpp +++ b/src/gui/infoclock.cpp @@ -58,8 +58,7 @@ void CInfoClock::initVarInfoClock() void CInfoClock::Init() { int x_old = x, y_old = y, width_old = width, height_old = height; - cl_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]; - CVolumeHelper::getInstance()->refresh(); + CVolumeHelper::getInstance()->refresh(cl_font); CVolumeHelper::getInstance()->getInfoClockDimensions(&x, &y, &width, &height); if ((x_old != x) || (y_old != y) || (width_old != width) || (height_old != height)) { cleanCCForm(); diff --git a/src/gui/volumebar.cpp b/src/gui/volumebar.cpp index 7d450b367..781ea51f8 100644 --- a/src/gui/volumebar.cpp +++ b/src/gui/volumebar.cpp @@ -269,7 +269,7 @@ CVolumeHelper::CVolumeHelper() Init(); } -void CVolumeHelper::Init() +void CVolumeHelper::Init(Font** font) { x = frameBuffer->getScreenX() + h_spacer; @@ -279,15 +279,26 @@ void CVolumeHelper::Init() initVolBarSize(); initMuteIcon(); - initInfoClock(); + initInfoClock(font); } -void CVolumeHelper::initInfoClock() +void CVolumeHelper::initInfoClock(Font** font) { - digit_offset = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getDigitOffset(); - digit_h = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getDigitHeight(); - int t1 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(widest_number); - int t2 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(":"); + if (clock_font == NULL){ + if (font == NULL) { + clock_font = &g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]; + } + else + clock_font = font; + } + else { + if (font != NULL) + clock_font = font; + } + digit_offset = (*clock_font)->getDigitOffset(); + digit_h = (*clock_font)->getDigitHeight(); + int t1 = (*clock_font)->getRenderWidth(widest_number); + int t2 = (*clock_font)->getRenderWidth(":"); clock_dy = digit_h + (int)((float)digit_offset * 1.3); clock_dx = t1*7 + t2*2; clock_ax = sw - clock_dx; @@ -347,9 +358,9 @@ int CVolumeHelper::getInfoClockX() return clock_ax; } -void CVolumeHelper::refresh() +void CVolumeHelper::refresh(Font** font) { - Init(); + Init(font); } CVolumeHelper* CVolumeHelper::getInstance() diff --git a/src/gui/volumebar.h b/src/gui/volumebar.h index d6864b636..b028da0a5 100644 --- a/src/gui/volumebar.h +++ b/src/gui/volumebar.h @@ -108,10 +108,10 @@ class CVolumeHelper Font** clock_font; CFrameBuffer *frameBuffer; - void Init(); + void Init(Font** font=NULL); void initVolBarSize(); void initMuteIcon(); - void initInfoClock(); + void initInfoClock(Font** font); public: @@ -128,7 +128,7 @@ class CVolumeHelper void getInfoClockDimensions(int *_x, int *_y, int *w, int *h) { *_x = getInfoClockX(); *_y = clock_ay; *w = clock_dx; *h = clock_dy; } void getVolBarDimensions(int *_y, int *_dy) { *_y = vol_ay; *_dy = vol_height; } void setMuteIconCorrY(int corr) { mute_corrY = corr; } - void refresh(); + void refresh(Font** font=NULL); }; #endif