[Horus] Cosmetics
This commit is contained in:
@@ -141,7 +141,7 @@ bool menuWidgetChoice(evt_t event)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
case EVT_ROTARY_RIGHT:
|
case EVT_ROTARY_RIGHT:
|
||||||
if (menuHorizontalPosition < countRegisteredWidgets-1) {
|
if (menuHorizontalPosition < int(countRegisteredWidgets-1)) {
|
||||||
delete currentWidget;
|
delete currentWidget;
|
||||||
currentWidget = registeredWidgets[++menuHorizontalPosition]->create(currentScreen->getZone(currentZone), &tempData);
|
currentWidget = registeredWidgets[++menuHorizontalPosition]->create(currentScreen->getZone(currentZone), &tempData);
|
||||||
}
|
}
|
||||||
@@ -447,6 +447,7 @@ bool menuScreenAdd(evt_t event)
|
|||||||
void onScreenSetupMenu(const char * result)
|
void onScreenSetupMenu(const char * result)
|
||||||
{
|
{
|
||||||
if (result == STR_REMOVE_SCREEN) {
|
if (result == STR_REMOVE_SCREEN) {
|
||||||
|
delete customScreens[menuHorizontalPosition];
|
||||||
if (menuHorizontalPosition != MAX_CUSTOM_SCREENS-1) {
|
if (menuHorizontalPosition != MAX_CUSTOM_SCREENS-1) {
|
||||||
memmove(&g_model.screenData[menuHorizontalPosition], &g_model.screenData[menuHorizontalPosition + 1], sizeof(CustomScreenData) * (MAX_CUSTOM_SCREENS - menuHorizontalPosition - 1));
|
memmove(&g_model.screenData[menuHorizontalPosition], &g_model.screenData[menuHorizontalPosition + 1], sizeof(CustomScreenData) * (MAX_CUSTOM_SCREENS - menuHorizontalPosition - 1));
|
||||||
memmove(&customScreens[menuHorizontalPosition], &customScreens[menuHorizontalPosition + 1], sizeof(Layout *) * (MAX_CUSTOM_SCREENS - menuHorizontalPosition - 1));
|
memmove(&customScreens[menuHorizontalPosition], &customScreens[menuHorizontalPosition + 1], sizeof(Layout *) * (MAX_CUSTOM_SCREENS - menuHorizontalPosition - 1));
|
||||||
|
|||||||
@@ -40,20 +40,11 @@ const WidgetFactory * getWidgetFactory(const char * name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget * createWidget(const char * name, const Zone & zone, Widget::PersistentData * persistentData)
|
|
||||||
{
|
|
||||||
const WidgetFactory * factory = getWidgetFactory(name);
|
|
||||||
if (factory) {
|
|
||||||
return factory->create(zone, persistentData);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget * loadWidget(const char * name, const Zone & zone, Widget::PersistentData * persistentData)
|
Widget * loadWidget(const char * name, const Zone & zone, Widget::PersistentData * persistentData)
|
||||||
{
|
{
|
||||||
const WidgetFactory * factory = getWidgetFactory(name);
|
const WidgetFactory * factory = getWidgetFactory(name);
|
||||||
if (factory) {
|
if (factory) {
|
||||||
return factory->load(zone, persistentData);
|
return factory->create(zone, persistentData, false);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,13 +70,13 @@ class Widget
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void create()
|
virtual ~Widget()
|
||||||
{
|
{
|
||||||
memset(persistentData, 0, sizeof(PersistentData));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void load()
|
virtual void init()
|
||||||
{
|
{
|
||||||
|
memset(persistentData, 0, sizeof(PersistentData));
|
||||||
}
|
}
|
||||||
|
|
||||||
const WidgetFactory * getFactory() const
|
const WidgetFactory * getFactory() const
|
||||||
@@ -107,9 +107,8 @@ void registerWidget(const WidgetFactory * factory);
|
|||||||
class WidgetFactory
|
class WidgetFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WidgetFactory(const char * name, const char * bitmap):
|
WidgetFactory(const char * name):
|
||||||
name(name),
|
name(name)
|
||||||
bitmap(bitmap)
|
|
||||||
{
|
{
|
||||||
registerWidget(this);
|
registerWidget(this);
|
||||||
}
|
}
|
||||||
@@ -121,21 +120,18 @@ class WidgetFactory
|
|||||||
|
|
||||||
virtual const ZoneOption * getOptions() const = 0;
|
virtual const ZoneOption * getOptions() const = 0;
|
||||||
|
|
||||||
virtual Widget * create(const Zone & zone, Widget::PersistentData * persistentData) const = 0;
|
virtual Widget * create(const Zone & zone, Widget::PersistentData * persistentData, bool init=true) const = 0;
|
||||||
|
|
||||||
virtual Widget * load(const Zone & zone, Widget::PersistentData * persistentData) const = 0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const char * name;
|
const char * name;
|
||||||
const char * bitmap;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class BaseWidgetFactory: public WidgetFactory
|
class BaseWidgetFactory: public WidgetFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BaseWidgetFactory(const char * name, const char * bitmap, const ZoneOption * options):
|
BaseWidgetFactory(const char * name, const ZoneOption * options):
|
||||||
WidgetFactory(name, bitmap),
|
WidgetFactory(name),
|
||||||
options(options)
|
options(options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -145,17 +141,12 @@ class BaseWidgetFactory: public WidgetFactory
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Widget * create(const Zone & zone, Widget::PersistentData * persistentData) const
|
virtual Widget * create(const Zone & zone, Widget::PersistentData * persistentData, bool init=true) const
|
||||||
{
|
{
|
||||||
Widget * widget = new T(this, zone, persistentData);
|
Widget * widget = new T(this, zone, persistentData);
|
||||||
widget->create();
|
if (init) {
|
||||||
return widget;
|
widget->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Widget * load(const Zone & zone, Widget::PersistentData * persistentData) const
|
|
||||||
{
|
|
||||||
Widget * widget = new T(this, zone, persistentData);
|
|
||||||
widget->load();
|
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +157,6 @@ class BaseWidgetFactory: public WidgetFactory
|
|||||||
#define MAX_REGISTERED_WIDGETS 10
|
#define MAX_REGISTERED_WIDGETS 10
|
||||||
extern unsigned int countRegisteredWidgets;
|
extern unsigned int countRegisteredWidgets;
|
||||||
extern const WidgetFactory * registeredWidgets[MAX_REGISTERED_WIDGETS];
|
extern const WidgetFactory * registeredWidgets[MAX_REGISTERED_WIDGETS];
|
||||||
Widget * createWidget(const char * name, const Zone & zone, Widget::PersistentData * persistentData);
|
|
||||||
Widget * loadWidget(const char * name, const Zone & zone, Widget::PersistentData * persistentData);
|
Widget * loadWidget(const char * name, const Zone & zone, Widget::PersistentData * persistentData);
|
||||||
|
|
||||||
#endif // _WIDGET_H_
|
#endif // _WIDGET_H_
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class GaugeWidget: public Widget
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void create()
|
virtual void init()
|
||||||
{
|
{
|
||||||
persistentData->options[0].unsignedValue = 1;
|
persistentData->options[0].unsignedValue = 1;
|
||||||
persistentData->options[1].signedValue = -RESX;
|
persistentData->options[1].signedValue = -RESX;
|
||||||
@@ -36,7 +36,7 @@ class GaugeWidget: public Widget
|
|||||||
persistentData->options[3].unsignedValue = RED;
|
persistentData->options[3].unsignedValue = RED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void refresh();
|
virtual void refresh();
|
||||||
|
|
||||||
static const ZoneOption options[];
|
static const ZoneOption options[];
|
||||||
};
|
};
|
||||||
@@ -76,4 +76,4 @@ void GaugeWidget::refresh()
|
|||||||
lcdInvertRect(zone.x + w, zone.y + 15, zone.w - w, 16, CUSTOM_COLOR);
|
lcdInvertRect(zone.x + w, zone.y + 15, zone.w - w, 16, CUSTOM_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseWidgetFactory<GaugeWidget> gaugeWidget("Gauge", "", GaugeWidget::options);
|
BaseWidgetFactory<GaugeWidget> gaugeWidget("Gauge", GaugeWidget::options);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class ModelPanelWidget: public Widget
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void refresh();
|
virtual void refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
void ModelPanelWidget::refresh()
|
void ModelPanelWidget::refresh()
|
||||||
@@ -53,4 +53,4 @@ void ModelPanelWidget::refresh()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseWidgetFactory<ModelPanelWidget> modelPanelWidget("ModelPanel", "", NULL);
|
BaseWidgetFactory<ModelPanelWidget> modelPanelWidget("ModelPanel", NULL);
|
||||||
|
|||||||
@@ -28,14 +28,14 @@ class TextWidget: public Widget
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void create()
|
virtual void init()
|
||||||
{
|
{
|
||||||
str2zchar(persistentData->options[0].stringValue, "Label", sizeof(persistentData->options[0].stringValue));
|
str2zchar(persistentData->options[0].stringValue, "Label", sizeof(persistentData->options[0].stringValue));
|
||||||
persistentData->options[1].unsignedValue = RED;
|
persistentData->options[1].unsignedValue = RED;
|
||||||
persistentData->options[2].unsignedValue = 0;
|
persistentData->options[2].unsignedValue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void refresh();
|
virtual void refresh();
|
||||||
|
|
||||||
static const ZoneOption options[];
|
static const ZoneOption options[];
|
||||||
};
|
};
|
||||||
@@ -54,4 +54,4 @@ void TextWidget::refresh()
|
|||||||
lcdDrawSizedText(zone.x, zone.y, persistentData->options[0].stringValue, sizeof(persistentData->options[0].stringValue), ZCHAR|fontsize|CUSTOM_COLOR);
|
lcdDrawSizedText(zone.x, zone.y, persistentData->options[0].stringValue, sizeof(persistentData->options[0].stringValue), ZCHAR|fontsize|CUSTOM_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseWidgetFactory<TextWidget> textWidget("Text", "", TextWidget::options);
|
BaseWidgetFactory<TextWidget> textWidget("Text", TextWidget::options);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class TimerWidget: public Widget
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void refresh();
|
virtual void refresh();
|
||||||
|
|
||||||
static const ZoneOption options[];
|
static const ZoneOption options[];
|
||||||
};
|
};
|
||||||
@@ -58,4 +58,4 @@ void TimerWidget::refresh()
|
|||||||
drawStringWithIndex(zone.x+137, zone.y+17, "TMR", index+1, SMLSIZE|TEXT_COLOR);
|
drawStringWithIndex(zone.x+137, zone.y+17, "TMR", index+1, SMLSIZE|TEXT_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseWidgetFactory<TimerWidget> timerWidget("Timer", "", TimerWidget::options);
|
BaseWidgetFactory<TimerWidget> timerWidget("Timer", TimerWidget::options);
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ class ValueWidget: public Widget
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void create()
|
virtual void init()
|
||||||
{
|
{
|
||||||
persistentData->options[0].unsignedValue = 1;
|
persistentData->options[0].unsignedValue = 1;
|
||||||
persistentData->options[3].unsignedValue = RED;
|
persistentData->options[3].unsignedValue = RED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void refresh();
|
virtual void refresh();
|
||||||
|
|
||||||
static const ZoneOption options[];
|
static const ZoneOption options[];
|
||||||
};
|
};
|
||||||
@@ -46,9 +46,6 @@ const ZoneOption ValueWidget::options[] = {
|
|||||||
|
|
||||||
void ValueWidget::refresh()
|
void ValueWidget::refresh()
|
||||||
{
|
{
|
||||||
const int NUMBERS_W = 56;
|
|
||||||
const int NUMBERS_H = 30;
|
|
||||||
const int NUMBERS_MARGIN = 16;
|
|
||||||
const int NUMBERS_PADDING = 4;
|
const int NUMBERS_PADDING = 4;
|
||||||
|
|
||||||
mixsrc_t field = persistentData->options[0].unsignedValue;
|
mixsrc_t field = persistentData->options[0].unsignedValue;
|
||||||
@@ -96,4 +93,4 @@ void ValueWidget::refresh()
|
|||||||
putsChannel(xValue, yValue, field, attr|DBLSIZE|color);
|
putsChannel(xValue, yValue, field, attr|DBLSIZE|color);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseWidgetFactory<ValueWidget> ValueWidget("Value", "", ValueWidget::options);
|
BaseWidgetFactory<ValueWidget> ValueWidget("Value", ValueWidget::options);
|
||||||
|
|||||||
Reference in New Issue
Block a user