mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
CComponentsFrmClock: add slot to handle enforced repaint of segments
If clock removed from screen and instance is not destroyed, then we must ensure repaint of segments after painted background. This is required if segments are only will paint if their content was changed and attribut ct_force_text_paint = false.
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "cc_frm_clock.h"
|
#include "cc_frm_clock.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <sigc++/bind.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -98,7 +98,10 @@ CComponentsFrmClock::CComponentsFrmClock( const int& x_pos,
|
|||||||
initParent(parent);
|
initParent(parent);
|
||||||
|
|
||||||
//init slot for running clock
|
//init slot for running clock
|
||||||
cl_sl = sigc::mem_fun0(*this, &CComponentsFrmClock::ShowTime);
|
cl_sl_show = sigc::mem_fun0(*this, &CComponentsFrmClock::ShowTime);
|
||||||
|
|
||||||
|
//init slot to ensure paint segments after painted background
|
||||||
|
cl_sl_repaint = sigc::bind<0>(sigc::mem_fun1(*this, &CComponentsFrmClock::forceSegemnentsPaint), true);
|
||||||
|
|
||||||
//run clock already if required
|
//run clock already if required
|
||||||
if (activ)
|
if (activ)
|
||||||
@@ -297,6 +300,11 @@ void CComponentsFrmClock::initCCLockItems()
|
|||||||
x_lbl += v_cc_items[i-1]->getWidth();
|
x_lbl += v_cc_items[i-1]->getWidth();
|
||||||
v_cc_items[i]->setPos(x_lbl, y_lbl);
|
v_cc_items[i]->setPos(x_lbl, y_lbl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//init slot to handle repaint of segments if background was repainted
|
||||||
|
OnAfterPaintBg.clear();
|
||||||
|
if (paint_bg)
|
||||||
|
OnAfterPaintBg.connect(cl_sl_repaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -321,7 +329,7 @@ bool CComponentsFrmClock::startClock()
|
|||||||
cl_timer = new CComponentsTimer(0);
|
cl_timer = new CComponentsTimer(0);
|
||||||
if (cl_timer->OnTimer.empty()){
|
if (cl_timer->OnTimer.empty()){
|
||||||
dprintf(DEBUG_INFO,"\033[33m[CComponentsFrmClock]\t[%s] init slot...\033[0m\n", __func__);
|
dprintf(DEBUG_INFO,"\033[33m[CComponentsFrmClock]\t[%s] init slot...\033[0m\n", __func__);
|
||||||
cl_timer->OnTimer.connect(cl_sl);
|
cl_timer->OnTimer.connect(cl_sl_show);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cl_timer->setTimerInterval(cl_interval);
|
cl_timer->setTimerInterval(cl_interval);
|
||||||
@@ -338,6 +346,7 @@ bool CComponentsFrmClock::stopClock()
|
|||||||
if (cl_timer){
|
if (cl_timer){
|
||||||
if (cl_timer->stopTimer()){
|
if (cl_timer->stopTimer()){
|
||||||
dprintf(DEBUG_INFO, "[CComponentsFrmClock] [%s] stopping clock...\n", __func__);
|
dprintf(DEBUG_INFO, "[CComponentsFrmClock] [%s] stopping clock...\n", __func__);
|
||||||
|
clear();
|
||||||
delete cl_timer;
|
delete cl_timer;
|
||||||
cl_timer = NULL;
|
cl_timer = NULL;
|
||||||
return true;
|
return true;
|
||||||
@@ -374,10 +383,6 @@ void CComponentsFrmClock::paint(bool do_save_bg)
|
|||||||
|
|
||||||
//paint form contents
|
//paint form contents
|
||||||
CComponentsForm::paint(do_save_bg);
|
CComponentsForm::paint(do_save_bg);
|
||||||
#if 0 //has no effect
|
|
||||||
if (may_blit)
|
|
||||||
frameBuffer->blit();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsFrmClock::setClockFont(Font *font, const int& style)
|
void CComponentsFrmClock::setClockFont(Font *font, const int& style)
|
||||||
@@ -450,3 +455,9 @@ bool CComponentsFrmClock::enableColBodyGradient(const int& enable_mode, const fb
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CComponentsFrmClock::forceSegemnentsPaint(bool force)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < v_cc_items.size(); i++)
|
||||||
|
static_cast <CComponentsLabel*>(v_cc_items[i])->forceTextPaint(force);
|
||||||
|
}
|
||||||
|
@@ -52,7 +52,10 @@ class CComponentsFrmClock : public CComponentsForm, public CCTextScreen
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
///slot for timer event, reserved for ShowTime()
|
///slot for timer event, reserved for ShowTime()
|
||||||
sigc::slot0<void> cl_sl;
|
sigc::slot0<void> cl_sl_show;
|
||||||
|
|
||||||
|
///slot for background paint event, reserved for initCCLockItems()
|
||||||
|
sigc::slot0<void> cl_sl_repaint;
|
||||||
|
|
||||||
///refresh interval in seconds
|
///refresh interval in seconds
|
||||||
int cl_interval;
|
int cl_interval;
|
||||||
@@ -90,6 +93,8 @@ class CComponentsFrmClock : public CComponentsForm, public CCTextScreen
|
|||||||
void toggleFormat();
|
void toggleFormat();
|
||||||
///init internal font
|
///init internal font
|
||||||
void initClockFont(int dx, int dy);
|
void initClockFont(int dx, int dy);
|
||||||
|
///force repaint of all segments
|
||||||
|
void forceSegemnentsPaint(bool force);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user