[Horus] Cosmetics
This commit is contained in:
@@ -141,7 +141,7 @@ bool menuWidgetChoice(evt_t event)
|
||||
return false;
|
||||
|
||||
case EVT_ROTARY_RIGHT:
|
||||
if (menuHorizontalPosition < countRegisteredWidgets-1) {
|
||||
if (menuHorizontalPosition < int(countRegisteredWidgets-1)) {
|
||||
delete currentWidget;
|
||||
currentWidget = registeredWidgets[++menuHorizontalPosition]->create(currentScreen->getZone(currentZone), &tempData);
|
||||
}
|
||||
@@ -447,6 +447,7 @@ bool menuScreenAdd(evt_t event)
|
||||
void onScreenSetupMenu(const char * result)
|
||||
{
|
||||
if (result == STR_REMOVE_SCREEN) {
|
||||
delete customScreens[menuHorizontalPosition];
|
||||
if (menuHorizontalPosition != MAX_CUSTOM_SCREENS-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));
|
||||
|
||||
@@ -40,20 +40,11 @@ const WidgetFactory * getWidgetFactory(const char * name)
|
||||
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)
|
||||
{
|
||||
const WidgetFactory * factory = getWidgetFactory(name);
|
||||
if (factory) {
|
||||
return factory->load(zone, persistentData);
|
||||
return factory->create(zone, persistentData, false);
|
||||
}
|
||||
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
|
||||
@@ -107,9 +107,8 @@ void registerWidget(const WidgetFactory * factory);
|
||||
class WidgetFactory
|
||||
{
|
||||
public:
|
||||
WidgetFactory(const char * name, const char * bitmap):
|
||||
name(name),
|
||||
bitmap(bitmap)
|
||||
WidgetFactory(const char * name):
|
||||
name(name)
|
||||
{
|
||||
registerWidget(this);
|
||||
}
|
||||
@@ -121,21 +120,18 @@ class WidgetFactory
|
||||
|
||||
virtual const ZoneOption * getOptions() const = 0;
|
||||
|
||||
virtual Widget * create(const Zone & zone, Widget::PersistentData * persistentData) const = 0;
|
||||
|
||||
virtual Widget * load(const Zone & zone, Widget::PersistentData * persistentData) const = 0;
|
||||
virtual Widget * create(const Zone & zone, Widget::PersistentData * persistentData, bool init=true) const = 0;
|
||||
|
||||
protected:
|
||||
const char * name;
|
||||
const char * bitmap;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class BaseWidgetFactory: public WidgetFactory
|
||||
{
|
||||
public:
|
||||
BaseWidgetFactory(const char * name, const char * bitmap, const ZoneOption * options):
|
||||
WidgetFactory(name, bitmap),
|
||||
BaseWidgetFactory(const char * name, const ZoneOption * options):
|
||||
WidgetFactory(name),
|
||||
options(options)
|
||||
{
|
||||
}
|
||||
@@ -145,17 +141,12 @@ class BaseWidgetFactory: public WidgetFactory
|
||||
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->create();
|
||||
return widget;
|
||||
}
|
||||
|
||||
virtual Widget * load(const Zone & zone, Widget::PersistentData * persistentData) const
|
||||
{
|
||||
Widget * widget = new T(this, zone, persistentData);
|
||||
widget->load();
|
||||
if (init) {
|
||||
widget->init();
|
||||
}
|
||||
return widget;
|
||||
}
|
||||
|
||||
@@ -166,7 +157,6 @@ class BaseWidgetFactory: public WidgetFactory
|
||||
#define MAX_REGISTERED_WIDGETS 10
|
||||
extern unsigned int countRegisteredWidgets;
|
||||
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);
|
||||
|
||||
#endif // _WIDGET_H_
|
||||
|
||||
@@ -28,7 +28,7 @@ class GaugeWidget: public Widget
|
||||
{
|
||||
}
|
||||
|
||||
virtual void create()
|
||||
virtual void init()
|
||||
{
|
||||
persistentData->options[0].unsignedValue = 1;
|
||||
persistentData->options[1].signedValue = -RESX;
|
||||
@@ -36,7 +36,7 @@ class GaugeWidget: public Widget
|
||||
persistentData->options[3].unsignedValue = RED;
|
||||
}
|
||||
|
||||
void refresh();
|
||||
virtual void refresh();
|
||||
|
||||
static const ZoneOption options[];
|
||||
};
|
||||
@@ -76,4 +76,4 @@ void GaugeWidget::refresh()
|
||||
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()
|
||||
@@ -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));
|
||||
persistentData->options[1].unsignedValue = RED;
|
||||
persistentData->options[2].unsignedValue = 0;
|
||||
}
|
||||
|
||||
void refresh();
|
||||
virtual void refresh();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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[];
|
||||
};
|
||||
@@ -58,4 +58,4 @@ void TimerWidget::refresh()
|
||||
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[3].unsignedValue = RED;
|
||||
}
|
||||
|
||||
void refresh();
|
||||
virtual void refresh();
|
||||
|
||||
static const ZoneOption options[];
|
||||
};
|
||||
@@ -46,9 +46,6 @@ const ZoneOption ValueWidget::options[] = {
|
||||
|
||||
void ValueWidget::refresh()
|
||||
{
|
||||
const int NUMBERS_W = 56;
|
||||
const int NUMBERS_H = 30;
|
||||
const int NUMBERS_MARGIN = 16;
|
||||
const int NUMBERS_PADDING = 4;
|
||||
|
||||
mixsrc_t field = persistentData->options[0].unsignedValue;
|
||||
@@ -96,4 +93,4 @@ void ValueWidget::refresh()
|
||||
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