infoviewer: use widget for record info

This is replacing tasks inside showRecordIcon().
This commit is contained in:
2022-01-18 22:04:05 +01:00
parent d77b57d919
commit 7800bf5d4c
2 changed files with 38 additions and 117 deletions

View File

@@ -94,7 +94,7 @@ CInfoViewer::CInfoViewer ()
: fader(g_settings.theme.infobar_alpha) : fader(g_settings.theme.infobar_alpha)
{ {
sigbox = NULL; sigbox = NULL;
header = numbox = body = rec = NULL; header = numbox = body = NULL;
txt_curr_start = txt_curr_event = txt_curr_rest = txt_next_start = txt_next_event = txt_next_in = NULL; txt_curr_start = txt_curr_event = txt_curr_rest = txt_next_start = txt_next_event = txt_next_in = NULL;
timescale = NULL; timescale = NULL;
clock = NULL; clock = NULL;
@@ -103,6 +103,10 @@ CInfoViewer::CInfoViewer ()
info_CurrentNext.flags = 0; info_CurrentNext.flags = 0;
frameBuffer = CFrameBuffer::getInstance(); frameBuffer = CFrameBuffer::getInstance();
infoViewerBB = CInfoViewerBB::getInstance(); infoViewerBB = CInfoViewerBB::getInstance();
weather = CWeather::getInstance();
rec = NULL;
InfoHeightY = 0; InfoHeightY = 0;
ButtonWidth = 0; ButtonWidth = 0;
ChanNameX = 0; ChanNameX = 0;
@@ -269,128 +273,41 @@ void CInfoViewer::initClock()
void CInfoViewer::showRecordIcon (const bool show) void CInfoViewer::showRecordIcon (const bool show)
{ {
/* FIXME if record or timeshift stopped while infobar visible, artifacts */ CRecordManager *crm = CRecordManager::getInstance();
recordModeActive = crm->RecordingStatus();
CRecordManager * crm = CRecordManager::getInstance(); if (!recordModeActive)
recordModeActive = crm->RecordingStatus();
if (recordModeActive)
{ {
std::string rec_icon = NEUTRINO_ICON_REC_GRAY; if (rec)
std::string ts_icon = NEUTRINO_ICON_AUTO_SHIFT_GRAY;
t_channel_id cci = g_RemoteControl->current_channel_id;
/* global record mode */
int rec_mode = crm->GetRecordMode();
/* channel record mode */
int ccrec_mode = crm->GetRecordMode(cci);
/* set 'active' icons for current channel */
if (ccrec_mode & CRecordManager::RECMODE_REC)
rec_icon = NEUTRINO_ICON_REC;
if (ccrec_mode & CRecordManager::RECMODE_TSHIFT)
ts_icon = NEUTRINO_ICON_AUTO_SHIFT;
int records = crm->GetRecordCount();
int txt_h = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight();
int txt_w = 0;
int box_x = BoxStartX + ChanWidth + 2*OFFSET_SHADOW;
int box_y = BoxStartY + OFFSET_SHADOW;
int box_w = 0;
int box_h = txt_h;
int icon_space = OFFSET_INTER;
int rec_icon_x = 0, rec_icon_w = 0, rec_icon_h = 0;
int ts_icon_x = 0, ts_icon_w = 0, ts_icon_h = 0;
frameBuffer->getIconSize(rec_icon.c_str(), &rec_icon_w, &rec_icon_h);
frameBuffer->getIconSize(ts_icon.c_str(), &ts_icon_w, &ts_icon_h);
int icon_h = std::max(rec_icon_h, ts_icon_h);
box_h = std::max(box_h, icon_h);
box_h += icon_space;
int icon_y = box_y + box_h/2 - icon_h/2;
int txt_y = box_y + (box_h + txt_h)/2;
char records_msg[14];
if (rec_mode == CRecordManager::RECMODE_REC)
{ {
snprintf(records_msg, sizeof(records_msg)-1, "%d%s", records, "x"); rec->kill();
txt_w = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getRenderWidth(records_msg); delete rec;
rec = NULL;
box_w = rec_icon_w + txt_w + icon_space*3;
rec_icon_x = box_x + icon_space;
} }
else if (rec_mode == CRecordManager::RECMODE_TSHIFT) return;
{ }
box_w = ts_icon_w + icon_space*2;
ts_icon_x = box_x + icon_space;
}
else if (rec_mode == CRecordManager::RECMODE_REC_TSHIFT)
{
//subtract ts
records--;
snprintf(records_msg, sizeof(records_msg)-1, "%d%s", records, "x");
txt_w = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getRenderWidth(records_msg);
box_w = ts_icon_w + rec_icon_w + txt_w + icon_space*5; if (show)
ts_icon_x = box_x + icon_space; {
rec_icon_x = ts_icon_x + ts_icon_w + icon_space; if (!rec)
}
if (show)
{ {
if (rec == NULL){ //TODO: full refactoring of this icon handler int box_x = BoxStartX + ChanWidth + 2*OFFSET_SHADOW;
rec = new CComponentsShapeSquare(box_x, box_y , box_w, box_h, NULL, CC_SHADOW_ON, COL_RED, COL_INFOBAR_PLUS_0); int box_y = BoxStartY + OFFSET_SHADOW;
rec->setItemName("rec"); rec = new CRecInfo(box_x, box_y , 0, 0, NULL, CC_SHADOW_ON, COL_RED, COL_INFOBAR_PLUS_0);
rec->setFrameThickness(FRAME_WIDTH_NONE); rec->setFrameThickness(FRAME_WIDTH_NONE);
rec->setShadowWidth(OFFSET_SHADOW/2); rec->setShadowWidth(OFFSET_SHADOW/2);
rec->setCorner(RADIUS_MIN, CORNER_ALL); rec->setCorner(RADIUS_MIN, CORNER_ALL);
} }
if (rec->getWidth() != box_w)
rec->setWidth(box_w);
if (!rec->isPainted()) if (rec->isPainted())
rec->paint(CC_SAVE_SCREEN_NO); {
if (rec->getCCItem(NEUTRINO_ICON_REC)->isPainted())
if (rec_mode != CRecordManager::RECMODE_TSHIFT) rec->getCCItem(NEUTRINO_ICON_REC)->kill();
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->RenderString(rec_icon_x + rec_icon_w + icon_space, txt_y, txt_w, records_msg, COL_INFOBAR_TEXT); else
rec->getCCItem(NEUTRINO_ICON_REC)->paint();
if (rec_mode == CRecordManager::RECMODE_REC)
{
paintImage(rec_icon, rec_icon_x, icon_y);
}
else if (rec_mode == CRecordManager::RECMODE_TSHIFT)
{
paintImage(ts_icon, ts_icon_x, icon_y);
}
else if (rec_mode == CRecordManager::RECMODE_REC_TSHIFT)
{
paintImage(rec_icon, rec_icon_x, icon_y);
paintImage(ts_icon, ts_icon_x, icon_y);
}
} }
else else
{ rec->paint();
int icon_x, icon_w;
if (rec_mode == CRecordManager::RECMODE_REC){
icon_x = rec_icon_x;
icon_w = rec_icon_w;
}else if (rec_mode == CRecordManager::RECMODE_TSHIFT){
icon_x = ts_icon_x;
icon_w = ts_icon_w;
}else if (rec_mode == CRecordManager::RECMODE_REC_TSHIFT){
icon_x = ts_icon_x;
icon_w = ts_icon_w + rec_icon_w + icon_space*2;
}
PaintBoxRel(icon_x, icon_y, icon_w, icon_h, COL_INFOBAR_PLUS_0);
}
} }
} }

View File

@@ -40,6 +40,8 @@
#include <string> #include <string>
#include <zapit/channel.h> #include <zapit/channel.h>
#include <gui/components/cc.h> #include <gui/components/cc.h>
#include <gui/weather.h>
#include "widget/record_info.h"
class CFrameBuffer; class CFrameBuffer;
class COSDFader; class COSDFader;
@@ -48,11 +50,13 @@ class CInfoViewer : public sigc::trackable
{ {
private: private:
CFrameBuffer * frameBuffer; CFrameBuffer *frameBuffer;
CInfoViewerBB* infoViewerBB; CInfoViewerBB *infoViewerBB;
CComponentsFrmClock *clock; CComponentsFrmClock *clock;
CComponentsShapeSquare *header , *numbox, *body, *rec; CComponentsShapeSquare *header, *numbox, *body;
CComponentsTextTransp *txt_curr_start, *txt_curr_event, *txt_curr_rest, *txt_next_start, *txt_next_event, *txt_next_in; CComponentsTextTransp *txt_curr_start, *txt_curr_event, *txt_curr_rest, *txt_next_start, *txt_next_event, *txt_next_in;
CRecInfo *rec;
CWeather *weather;
bool gotTime; bool gotTime;
bool recordModeActive; bool recordModeActive;