- timerlist: formatting code using astyle; some manual code nicenings

Conflicts:
	src/gui/timeosd.cpp

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2021-12-06 05:18:19 +01:00
committed by Thilo Graf
parent ee297bc77a
commit fd2302fbf6
2 changed files with 37 additions and 30 deletions

View File

@@ -6,7 +6,7 @@
Copyright (C) 2013, Thilo Graf 'dbt' Copyright (C) 2013, Thilo Graf 'dbt'
Copyright (C) 2013, Michael Liebmann 'micha-bbg' Copyright (C) 2013, Michael Liebmann 'micha-bbg'
Copyright (C) 2013, martii Copyright (C) 2013, martii
License: GPL License: GPL
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@@ -33,17 +33,17 @@
#include <neutrino.h> #include <neutrino.h>
#include <gui/volumebar.h> #include <gui/volumebar.h>
#include <gui/infoclock.h> #include <gui/infoclock.h>
#include <gui/timeosd.h> #include <gui/timeosd.h>
#include "screensaver.h" #include "screensaver.h"
CTimeOSD::CTimeOSD(): CComponentsFrmClock(1, 1, NULL, "%H:%M:%S", NULL, false, 1, NULL, CC_SHADOW_ON)
CTimeOSD::CTimeOSD():CComponentsFrmClock( 1, 1, NULL, "%H:%M:%S", NULL, false, 1, NULL, CC_SHADOW_ON)
{ {
m_mode = MODE_HIDE; m_mode = MODE_HIDE;
tmp_mode = MODE_HIDE; tmp_mode = MODE_HIDE;
m_restore = false; m_restore = false;
mp_time_forced = false; mp_time_forced = false;
cc_item_type.name = "time_osd_box"; cc_item_type.name = "time_osd_box";
Init(); Init();
} }
@@ -52,14 +52,17 @@ void CTimeOSD::Init()
paint_bg = g_settings.infoClockBackground; paint_bg = g_settings.infoClockBackground;
m_time_show = time(0); m_time_show = time(0);
//use current theme colors // use current theme colors
setColorAll(COL_FRAME_PLUS_0, COL_MENUCONTENT_PLUS_0, COL_SHADOW_PLUS_0); setColorAll(COL_FRAME_PLUS_0, COL_MENUCONTENT_PLUS_0, COL_SHADOW_PLUS_0);
//set text color // set text color
if (paint_bg){ if (paint_bg)
{
cl_col_text = COL_MENUCONTENT_TEXT; cl_col_text = COL_MENUCONTENT_TEXT;
setColorBody(COL_MENUCONTENT_PLUS_0); setColorBody(COL_MENUCONTENT_PLUS_0);
}else{ }
else
{
cl_col_text = COL_INFOCLOCK_TEXT; cl_col_text = COL_INFOCLOCK_TEXT;
setColorBody(COL_BACKGROUND_PLUS_0); setColorBody(COL_BACKGROUND_PLUS_0);
} }
@@ -67,7 +70,7 @@ void CTimeOSD::Init()
setClockFont(CInfoClock::getInstance()->getClockFont()); setClockFont(CInfoClock::getInstance()->getClockFont());
// set corner radius depending on clock height // set corner radius depending on clock height
corner_rad = (g_settings.theme.rounded_corners) ? std::max(height/10, CORNER_RADIUS_SMALL) : 0; corner_rad = (g_settings.theme.rounded_corners) ? std::max(height / 10, CORNER_RADIUS_SMALL) : 0;
CComponentsFrmClock::initCCLockItems(); CComponentsFrmClock::initCCLockItems();
CVolumeHelper::getInstance()->refresh(cl_font); CVolumeHelper::getInstance()->refresh(cl_font);
@@ -75,7 +78,8 @@ void CTimeOSD::Init()
timescale.setType(CProgressBar::PB_TIMESCALE); timescale.setType(CProgressBar::PB_TIMESCALE);
} }
#if 0 //if hide() or kill() required, it's recommended to use it separately #if 0
// if hide() or kill() required, it's recommended to use it separately
CTimeOSD::~CTimeOSD() CTimeOSD::~CTimeOSD()
{ {
CComponents::kill(); CComponents::kill();
@@ -83,10 +87,10 @@ CTimeOSD::~CTimeOSD()
} }
#endif #endif
CTimeOSD* CTimeOSD::getInstance() CTimeOSD *CTimeOSD::getInstance()
{ {
static CTimeOSD* timeOSD = NULL; static CTimeOSD *timeOSD = NULL;
if(!timeOSD) if (!timeOSD)
timeOSD = new CTimeOSD(); timeOSD = new CTimeOSD();
return timeOSD; return timeOSD;
} }
@@ -97,7 +101,7 @@ void CTimeOSD::initTimeString()
toggleFormat(); toggleFormat();
if (m_mode == MODE_DESC) if (m_mode == MODE_DESC)
cl_format = "-" + cl_format; cl_format = "-" + cl_format;
strftime((char*) &cl_timestr, sizeof(cl_timestr), cl_format.c_str(), gmtime_r(&m_time_show, &t)); strftime((char *) &cl_timestr, sizeof(cl_timestr), cl_format.c_str(), gmtime_r(&m_time_show, &t));
} }
void CTimeOSD::show(time_t time_show, bool force) void CTimeOSD::show(time_t time_show, bool force)
@@ -107,7 +111,7 @@ void CTimeOSD::show(time_t time_show, bool force)
return; return;
m_time_show = time_show; m_time_show = time_show;
setColorAll(COL_FRAME_PLUS_0, COL_MENUCONTENT_PLUS_0, COL_SHADOW_PLUS_0); //use current theme colors setColorAll(COL_FRAME_PLUS_0, COL_MENUCONTENT_PLUS_0, COL_SHADOW_PLUS_0); // use current theme colors
paint_bg = true; paint_bg = true;
if (g_settings.infoClockBackground) if (g_settings.infoClockBackground)
@@ -123,18 +127,19 @@ void CTimeOSD::show(time_t time_show, bool force)
void CTimeOSD::updatePos(int position, int duration) void CTimeOSD::updatePos(int position, int duration)
{ {
int percent = (duration && duration > 100) ? (position * 100 / duration) : 0; int percent = (duration && duration > 100) ? (position * 100 / duration) : 0;
if(percent > 100) if (percent > 100)
percent = 100; percent = 100;
else if(percent < 0) else if (percent < 0)
percent = 0; percent = 0;
timescale.setProgress(x, y + height/4, width, height/2, percent, 100); timescale.setProgress(x, y + height / 4, width, height / 2, percent, 100);
timescale.paint(); timescale.paint();
} }
void CTimeOSD::update(int position, int duration) void CTimeOSD::update(int position, int duration)
{ {
switch(m_mode) { switch (m_mode)
{
case MODE_ASC: case MODE_ASC:
show(position, false); show(position, false);
break; break;
@@ -151,7 +156,8 @@ void CTimeOSD::update(int position, int duration)
void CTimeOSD::switchMode(int position, int duration) void CTimeOSD::switchMode(int position, int duration)
{ {
switch (m_mode) { switch (m_mode)
{
case MODE_ASC: case MODE_ASC:
m_mode = MODE_DESC; m_mode = MODE_DESC;
CComponents::kill(); CComponents::kill();
@@ -172,7 +178,8 @@ void CTimeOSD::switchMode(int position, int duration)
void CTimeOSD::kill() void CTimeOSD::kill()
{ {
if (m_mode != MODE_HIDE) { if (m_mode != MODE_HIDE)
{
KillAndResetTimescale(); KillAndResetTimescale();
CComponents::kill(); CComponents::kill();
} }

View File

@@ -39,9 +39,9 @@ class CTimeOSD : public CComponentsFrmClock
MODE_BAR, MODE_BAR,
MODE_HIDE MODE_HIDE
}; };
private: private:
CProgressBar timescale; CProgressBar timescale;
mode m_mode, tmp_mode; mode m_mode, tmp_mode;
bool m_restore; bool m_restore;
bool mp_time_forced; bool mp_time_forced;
@@ -53,21 +53,21 @@ class CTimeOSD : public CComponentsFrmClock
public: public:
CTimeOSD(); CTimeOSD();
// ~CTimeOSD(); is inherited //~CTimeOSD(); is inherited
void Init(); void Init();
static CTimeOSD* getInstance(); static CTimeOSD *getInstance();
void show(time_t time_show, bool force = true); void show(time_t time_show, bool force = true);
void kill(); void kill();
bool IsVisible() {return m_mode != MODE_HIDE;} bool IsVisible() {return m_mode != MODE_HIDE;}
void update(int position, int duration); void update(int position, int duration);
void switchMode(int position, int duration); void switchMode(int position, int duration);
mode getMode() { return m_mode; }; mode getMode() { return m_mode; };
void setMode (mode mode_) { m_mode = mode_; }; void setMode(mode mode_) { m_mode = mode_; };
mode getTmpMode() { return tmp_mode; }; mode getTmpMode() { return tmp_mode; };
void setTmpMode () { tmp_mode = m_mode; }; void setTmpMode() { tmp_mode = m_mode; };
bool getRestore() { return m_restore; }; bool getRestore() { return m_restore; };
void setRestore(bool m) { m_restore = m; }; void setRestore(bool m) { m_restore = m; };
void setHeight(const int){}//NOTE: dummy member, height is strictly bound to settings void setHeight(const int) {} // NOTE: dummy member, height is strictly bound to settings
bool getMpTimeForced() { return mp_time_forced; }; bool getMpTimeForced() { return mp_time_forced; };
void setMpTimeForced(bool m) { mp_time_forced = m; }; void setMpTimeForced(bool m) { mp_time_forced = m; };
}; };