screensaver: add optional colored property

This commit is contained in:
defans
2016-01-07 20:47:15 +01:00
committed by Thilo Graf
parent 19d33dfb98
commit 0f2c73aed3
6 changed files with 37 additions and 4 deletions

View File

@@ -2159,6 +2159,7 @@ screensaver.dir Directory
screensaver.menu Screensaver
screensaver.mode Mode
screensaver.mode_clock Clock
screensaver.mode_clock_color Clock colored
screensaver.mode_image Images
screensaver.off Screensaver off
screensaver.random Random Images

View File

@@ -1422,11 +1422,12 @@ void COsdSetup::showOsdScreenShotSetup(CMenuWidget *menu_screenshot)
menu_screenshot->addItem(mc);
}
#define SCREENSAVER_MODE_OPTION_COUNT 2
#define SCREENSAVER_MODE_OPTION_COUNT 3
const CMenuOptionChooser::keyval SCREENSAVER_MODE_OPTIONS[SCREENSAVER_MODE_OPTION_COUNT] =
{
{ 0, LOCALE_SCREENSAVER_MODE_IMAGE },
{ 1, LOCALE_SCREENSAVER_MODE_CLOCK }
{ 1, LOCALE_SCREENSAVER_MODE_CLOCK },
{ 2, LOCALE_SCREENSAVER_MODE_CLOCK_COLOR }
};
void COsdSetup::showOsdScreensaverSetup(CMenuWidget *menu_screensaver)

View File

@@ -53,6 +53,7 @@ CScreenSaver::CScreenSaver()
index = 0;
status_mute = CAudioMute::getInstance()->getStatus();
scr_clock = NULL;
clr.i_color = COL_DARK_GRAY;
}
CScreenSaver::~CScreenSaver()
@@ -250,7 +251,6 @@ void CScreenSaver::paint()
if (!scr_clock){
scr_clock = new CComponentsFrmClock(1, 1, NULL, "%H.%M:%S", "%H.%M %S", true);
scr_clock->setClockFont(g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_NUMBER]);
scr_clock->setTextColor(COL_DARK_GRAY);
scr_clock->enableSaveBg();
scr_clock->doPaintBg(false);
}
@@ -258,7 +258,26 @@ void CScreenSaver::paint()
scr_clock->Stop();
scr_clock->kill();
scr_clock->setTextColor(clr.i_color);
scr_clock->setPosP(rand() % 80, rand() % 90);
scr_clock->Start();
if (g_settings.screensaver_mode == SCR_MODE_CLOCK_COLOR) {
srand (time(NULL));
uint32_t brightness;
// sorcery, no darkness
do {
clr.i_color = rand();
brightness = (unsigned int)clr.uc_color.r * 19595 + (unsigned int)clr.uc_color.g * 38469 + (unsigned int)clr.uc_color.b * 7471;
//printf("[%s] %s: brightness: %d\n", __FILE__, __FUNCTION__, brightness>> 16);
}
while(brightness >> 16 < 80);
clr.i_color &= 0x00FFFFFF;
//printf("[%s] %s: clr.i_color: r %02x g %02x b %02x a %02x\n", __FILE__, __FUNCTION__, clr.uc_color.r, clr.uc_color.g, clr.uc_color.b, clr.uc_color.a);
}
else
clr.i_color = COL_DARK_GRAY;
}
}

View File

@@ -46,11 +46,21 @@ class CScreenSaver : public sigc::trackable
bool ReadDir();
void paint();
union u_color {
struct s_color {
uint8_t b, g, r, a;
} uc_color;
unsigned int i_color;
};
u_color clr;
public:
enum
{
SCR_MODE_IMAGE,
SCR_MODE_CLOCK
SCR_MODE_CLOCK,
SCR_MODE_CLOCK_COLOR
};
CScreenSaver();
~CScreenSaver();

View File

@@ -2186,6 +2186,7 @@ typedef enum
LOCALE_SCREENSAVER_MENU,
LOCALE_SCREENSAVER_MODE,
LOCALE_SCREENSAVER_MODE_CLOCK,
LOCALE_SCREENSAVER_MODE_CLOCK_COLOR,
LOCALE_SCREENSAVER_MODE_IMAGE,
LOCALE_SCREENSAVER_OFF,
LOCALE_SCREENSAVER_RANDOM,

View File

@@ -2186,6 +2186,7 @@ const char * locale_real_names[] =
"screensaver.menu",
"screensaver.mode",
"screensaver.mode_clock",
"screensaver.mode_clock_color",
"screensaver.mode_image",
"screensaver.off",
"screensaver.random",