radiotext: rework radiotext handling

Radiotext moved into a separate class and will be shown with screensaver.
This commit is contained in:
2020-01-05 21:17:59 +01:00
parent b1f9c3c7f3
commit df64925b30
12 changed files with 732 additions and 192 deletions

View File

@@ -254,7 +254,7 @@ void CInfoViewer::initClock()
clock->setClockFormat("%H:%M", "%H %M");
}
CInfoClock::getInstance()->disableInfoClock();
CInfoClock::getInstance()->block();
clock->clear();
clock->enableColBodyGradient(gradient_top, COL_INFOBAR_PLUS_0);
clock->doPaintBg(!gradient_top);
@@ -566,10 +566,6 @@ void CInfoViewer::showMovieTitle(const int playState, const t_channel_id &Channe
zap_mode = _zap_mode;
reset_allScala();
if (g_settings.radiotext_enable && g_Radiotext) {
g_Radiotext->RT_MsgShow = true;
}
if(!is_visible)
fader.StartFadeIn();
@@ -906,7 +902,7 @@ void CInfoViewer::showTitle(CZapitChannel * channel, const bool calledFromNumZap
if (CNeutrinoApp::getInstance()->getMode() == NeutrinoModes::mode_radio || CNeutrinoApp::getInstance()->getMode() == NeutrinoModes::mode_webradio)
{
if ((g_settings.radiotext_enable) && (!recordModeActive) && (!calledFromNumZap))
showRadiotext();
enableRadiotext();
else if (showButtonBar)
infoViewerBB->showIcon_RadioText(false);
}
@@ -1180,7 +1176,7 @@ void CInfoViewer::loop(bool show_dot)
show_dot = !show_dot;
showInfoFile();
if ((g_settings.radiotext_enable) && (CNeutrinoApp::getInstance()->getMode() == NeutrinoModes::mode_radio))
showRadiotext();
enableRadiotext();
infoViewerBB->showIcon_16_9();
//infoViewerBB->paint_ca_icons(0);
@@ -1376,100 +1372,12 @@ void CInfoViewer::showMotorMoving (int duration)
ShowHint (LOCALE_MESSAGEBOX_INFO, text, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(text) + 2*OFFSET_INNER_MID, duration);
}
void CInfoViewer::killRadiotext()
void CInfoViewer::enableRadiotext() //TODO: remove this roundabout way
{
if (g_Radiotext->S_RtOsd)
frameBuffer->paintBackgroundBoxRel(rt_x, rt_y, rt_w + OFFSET_SHADOW, rt_h + OFFSET_SHADOW);
rt_x = rt_y = rt_h = rt_w = 0;
CInfoClock::getInstance()->enableInfoClock(true);
}
void CInfoViewer::showRadiotext()
{
/*
Maybe there's a nice CComponents solution with user's gradients.
*/
if (g_Radiotext == NULL)
return;
OnEnableRadiotext();
if (showButtonBar)
infoViewerBB->showIcon_RadioText(g_Radiotext->haveRadiotext());
char stext[3][100];
bool RTisUTF8 = false;
if (g_Radiotext->S_RtOsd)
{
CInfoClock::getInstance()->enableInfoClock(false);
int rt_font = SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO;
int item_h = g_Font[rt_font]->getHeight();
// dimensions of radiotext window
rt_x = BoxStartX;
rt_y = g_settings.screen_StartY + OFFSET_INNER_MID;
rt_w = BoxEndX - BoxStartX;
rt_h = (g_Radiotext->S_RtOsdRows + 1)*item_h + 4*OFFSET_INNER_SMALL;
int item_x = rt_x + OFFSET_INNER_MID;
int item_y = rt_y + OFFSET_INNER_SMALL + item_h;
int item_w = rt_w - 2*OFFSET_INNER_MID;
int item = 0;
int lines = 0;
for (int i = 0; i < g_Radiotext->S_RtOsdRows; i++)
{
if (g_Radiotext->RT_Text[i][0] != '\0')
lines++;
}
if (lines == 0)
frameBuffer->paintBackgroundBoxRel(rt_x, rt_y, rt_w + OFFSET_SHADOW, rt_h + OFFSET_SHADOW);
if (g_Radiotext->RT_MsgShow)
{
// Title
if (g_Radiotext->S_RtOsdTitle == 1)
{
if (lines || g_Radiotext->RT_PTY != 0)
{
sprintf(stext[0], g_Radiotext->RT_PTY == 0 ? "%s %s%s" : "%s (%s)%s", tr("Radiotext"), g_Radiotext->RT_PTY == 0 ? g_Radiotext->RDS_PTYN : g_Radiotext->ptynr2string(g_Radiotext->RT_PTY), ":");
int title_w = g_Font[rt_font]->getRenderWidth(stext[0]) + 2*OFFSET_INNER_MID;
frameBuffer->paintBoxRel(rt_x + OFFSET_SHADOW, rt_y + OFFSET_SHADOW, title_w, 2*OFFSET_INNER_SMALL + item_h, COL_SHADOW_PLUS_0, RADIUS_LARGE, CORNER_TOP);
frameBuffer->paintBoxRel(rt_x, rt_y, title_w, 2*OFFSET_INNER_SMALL + item_h, COL_INFOBAR_PLUS_0, RADIUS_LARGE, CORNER_TOP);
g_Font[rt_font]->RenderString(item_x, item_y, title_w, stext[0], COL_INFOBAR_TEXT, 0, RTisUTF8);
}
item = 1;
}
// Body
if (lines)
{
frameBuffer->paintBoxRel(rt_x + OFFSET_SHADOW, rt_y + 2*OFFSET_INNER_SMALL + item_h + OFFSET_SHADOW, rt_w, item_h*g_Radiotext->S_RtOsdRows + 2*OFFSET_INNER_SMALL, COL_SHADOW_PLUS_0, RADIUS_LARGE, item == 1 ? CORNER_TOP_RIGHT|CORNER_BOTTOM : CORNER_ALL);
frameBuffer->paintBoxRel(rt_x, rt_y + 2*OFFSET_INNER_SMALL + item_h, rt_w, item_h*g_Radiotext->S_RtOsdRows + 2*OFFSET_INNER_SMALL, COL_INFOBAR_PLUS_0, RADIUS_LARGE, item == 1 ? CORNER_TOP_RIGHT|CORNER_BOTTOM : CORNER_ALL);
item_y += 2*OFFSET_INNER_SMALL;
// RT-Text roundloop
int index = (g_Radiotext->RT_Index == 0) ? g_Radiotext->S_RtOsdRows - 1 : g_Radiotext->RT_Index - 1;
if (g_Radiotext->S_RtOsdLoop == 1) // latest bottom
{
for (int i = index + 1; i < g_Radiotext->S_RtOsdRows; i++)
g_Font[rt_font]->RenderString(item_x, item_y + (item++)*item_h, item_w, g_Radiotext->RT_Text[i], COL_INFOBAR_TEXT, 0, RTisUTF8);
for (int i = 0; i <= index; i++)
g_Font[rt_font]->RenderString(item_x, item_y + (item++)*item_h, item_w, g_Radiotext->RT_Text[i], COL_INFOBAR_TEXT, 0, RTisUTF8);
}
else // latest top
{
for (int i = index; i >= 0; i--)
g_Font[rt_font]->RenderString(item_x, item_y + (item++)*item_h, item_w, g_Radiotext->RT_Text[i], COL_INFOBAR_TEXT, 0, RTisUTF8);
for (int i = g_Radiotext->S_RtOsdRows - 1; i > index; i--)
g_Font[rt_font]->RenderString(item_x, item_y + (item++)*item_h, item_w, g_Radiotext->RT_Text[i], COL_INFOBAR_TEXT, 0, RTisUTF8);
}
}
}
}
g_Radiotext->RT_MsgShow = false;
}
int CInfoViewer::handleMsg (const neutrino_msg_t msg, neutrino_msg_data_t data)
@@ -2166,13 +2074,12 @@ void CInfoViewer::killTitle()
if (timescale)
if (g_settings.infobar_progressbar == SNeutrinoSettings::INFOBAR_PROGRESSBAR_ARRANGEMENT_DEFAULT)
timescale->kill();
if (g_settings.radiotext_enable && g_Radiotext) {
g_Radiotext->S_RtOsd = g_Radiotext->haveRadiotext() ? 1 : 0;
killRadiotext();
}
}
showButtonBar = false;
CInfoClock::getInstance()->enableInfoClock();
OnAfterKillTitle();
}
#if 0