chore(color): Cleanup layout refresh logic (#4074)
This commit is contained in:
@@ -53,21 +53,6 @@ void Layout::paint(BitmapBuffer * dc)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Layout::checkEvents()
|
|
||||||
{
|
|
||||||
LayoutBase::checkEvents();
|
|
||||||
adjustLayout();
|
|
||||||
|
|
||||||
// uint32_t now = RTOS_GET_MS();
|
|
||||||
// if (now - lastRefresh >= LAYOUT_REFRESH) {
|
|
||||||
// lastRefresh = now;
|
|
||||||
// invalidate();
|
|
||||||
// #if defined(DEBUG_WINDOWS)
|
|
||||||
// TRACE_WINDOWS("# %s refresh: %s", factory->getId(), getWindowDebugString().c_str());
|
|
||||||
// #endif
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
void Layout::setTrimsVisible(bool visible)
|
void Layout::setTrimsVisible(bool visible)
|
||||||
{
|
{
|
||||||
decoration->setTrimsVisible(visible);
|
decoration->setTrimsVisible(visible);
|
||||||
|
|||||||
@@ -79,8 +79,6 @@ class Layout: public LayoutBase
|
|||||||
{
|
{
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkEvents() override;
|
|
||||||
|
|
||||||
bool hasTopbar() const {
|
bool hasTopbar() const {
|
||||||
return getOptionValue(LAYOUT_OPTION_TOPBAR)->boolValue;
|
return getOptionValue(LAYOUT_OPTION_TOPBAR)->boolValue;
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ void TopBar::checkEvents()
|
|||||||
uint32_t now = RTOS_GET_MS();
|
uint32_t now = RTOS_GET_MS();
|
||||||
if (now - lastRefresh >= TOPBAR_REFRESH) {
|
if (now - lastRefresh >= TOPBAR_REFRESH) {
|
||||||
lastRefresh = now;
|
lastRefresh = now;
|
||||||
invalidate();
|
TopBarBase::checkEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
#include "widgets_container_impl.h"
|
#include "widgets_container_impl.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
|
||||||
|
constexpr uint32_t WIDGET_REFRESH = 1000 / 10; // 10 Hz
|
||||||
|
|
||||||
#define W_AUDIO_X 0
|
#define W_AUDIO_X 0
|
||||||
#define W_USB_X 32
|
#define W_USB_X 32
|
||||||
#define W_LOG_X 32
|
#define W_LOG_X 32
|
||||||
@@ -84,14 +86,34 @@ STATIC_LZ4_BITMAP(LBM_TOPMENU_TXBATT);
|
|||||||
STATIC_LZ4_BITMAP(LBM_TOPMENU_TXBATT_CHARGING);
|
STATIC_LZ4_BITMAP(LBM_TOPMENU_TXBATT_CHARGING);
|
||||||
STATIC_LZ4_BITMAP(LBM_TOPMENU_ANTENNA);
|
STATIC_LZ4_BITMAP(LBM_TOPMENU_ANTENNA);
|
||||||
|
|
||||||
class RadioInfoWidget: public Widget
|
class TopBarWidget : public Widget
|
||||||
{
|
{
|
||||||
protected:
|
public:
|
||||||
|
TopBarWidget(const WidgetFactory* factory, Window* parent,
|
||||||
|
const rect_t& rect, Widget::PersistentData* persistentData) :
|
||||||
|
Widget(factory, parent, rect, persistentData)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkEvents() override
|
||||||
|
{
|
||||||
|
Widget::checkEvents();
|
||||||
|
uint32_t now = RTOS_GET_MS();
|
||||||
|
if (now - lastRefresh >= WIDGET_REFRESH) {
|
||||||
|
lastRefresh = now;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t lastRefresh = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class RadioInfoWidget: public TopBarWidget
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
RadioInfoWidget(const WidgetFactory* factory, Window* parent,
|
RadioInfoWidget(const WidgetFactory* factory, Window* parent,
|
||||||
const rect_t& rect, Widget::PersistentData* persistentData) :
|
const rect_t& rect, Widget::PersistentData* persistentData) :
|
||||||
Widget(factory, parent, rect, persistentData)
|
TopBarWidget(factory, parent, rect, persistentData)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,14 +181,6 @@ class RadioInfoWidget: public Widget
|
|||||||
dc->drawSolidFilledRect(W_AUDIO_X + 2 + 4 * i, 27, 2, 8, i >= bars ? COLOR_THEME_PRIMARY3 : COLOR_THEME_PRIMARY2);
|
dc->drawSolidFilledRect(W_AUDIO_X + 2 + 4 * i, 27, 2, 8, i >= bars ? COLOR_THEME_PRIMARY3 : COLOR_THEME_PRIMARY2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkEvents() override
|
|
||||||
{
|
|
||||||
Widget::checkEvents();
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
static const ZoneOption options[];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BaseWidgetFactory<RadioInfoWidget> RadioInfoWidget("Radio Info", nullptr, "Radio Info");
|
BaseWidgetFactory<RadioInfoWidget> RadioInfoWidget("Radio Info", nullptr, "Radio Info");
|
||||||
@@ -178,14 +192,12 @@ BaseWidgetFactory<RadioInfoWidget> RadioInfoWidget("Radio Info", nullptr, "Radio
|
|||||||
#define DT_OFFSET 1
|
#define DT_OFFSET 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class DateTimeWidget: public Widget
|
class DateTimeWidget: public TopBarWidget
|
||||||
{
|
{
|
||||||
protected:
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DateTimeWidget(const WidgetFactory* factory, Window* parent,
|
DateTimeWidget(const WidgetFactory* factory, Window* parent,
|
||||||
const rect_t& rect, Widget::PersistentData* persistentData) :
|
const rect_t& rect, Widget::PersistentData* persistentData) :
|
||||||
Widget(factory, parent, rect, persistentData)
|
TopBarWidget(factory, parent, rect, persistentData)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,9 +211,17 @@ class DateTimeWidget: public Widget
|
|||||||
void checkEvents() override
|
void checkEvents() override
|
||||||
{
|
{
|
||||||
Widget::checkEvents();
|
Widget::checkEvents();
|
||||||
invalidate();
|
// Only update if minute value has changed
|
||||||
|
struct gtm t;
|
||||||
|
gettime(&t);
|
||||||
|
if (t.tm_min != lastMinute) {
|
||||||
|
lastMinute = t.tm_min;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int8_t lastMinute = 0;
|
||||||
|
|
||||||
static const ZoneOption options[];
|
static const ZoneOption options[];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -220,14 +240,12 @@ static const uint8_t _LBM_TOPMENU_GPS[] = {
|
|||||||
|
|
||||||
STATIC_LZ4_BITMAP(LBM_TOPMENU_GPS);
|
STATIC_LZ4_BITMAP(LBM_TOPMENU_GPS);
|
||||||
|
|
||||||
class InternalGPSWidget: public Widget
|
class InternalGPSWidget: public TopBarWidget
|
||||||
{
|
{
|
||||||
protected:
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InternalGPSWidget(const WidgetFactory* factory, Window* parent,
|
InternalGPSWidget(const WidgetFactory* factory, Window* parent,
|
||||||
const rect_t& rect, Widget::PersistentData* persistentData) :
|
const rect_t& rect, Widget::PersistentData* persistentData) :
|
||||||
Widget(factory, parent, rect, persistentData)
|
TopBarWidget(factory, parent, rect, persistentData)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,14 +262,6 @@ class InternalGPSWidget: public Widget
|
|||||||
(gpsData.fix) ? COLOR_THEME_PRIMARY2 : COLOR_THEME_PRIMARY3);
|
(gpsData.fix) ? COLOR_THEME_PRIMARY2 : COLOR_THEME_PRIMARY3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkEvents() override
|
|
||||||
{
|
|
||||||
Widget::checkEvents();
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
static const ZoneOption options[];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BaseWidgetFactory<InternalGPSWidget> InternalGPSWidget("Internal GPS", nullptr, "Internal GPS");
|
BaseWidgetFactory<InternalGPSWidget> InternalGPSWidget("Internal GPS", nullptr, "Internal GPS");
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ class WidgetsContainerImpl : public WidgetsContainer
|
|||||||
inline void setOptionValue(unsigned int index, const ZoneOptionValue& value)
|
inline void setOptionValue(unsigned int index, const ZoneOptionValue& value)
|
||||||
{
|
{
|
||||||
persistentData->options[index].value = value;
|
persistentData->options[index].value = value;
|
||||||
|
adjustLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getZonesCount() const override = 0;
|
unsigned int getZonesCount() const override = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user