diff --git a/radio/src/gui/480x272/widget.h b/radio/src/gui/480x272/widget.h index 52807428e..257c4de39 100644 --- a/radio/src/gui/480x272/widget.h +++ b/radio/src/gui/480x272/widget.h @@ -21,59 +21,11 @@ #ifndef _WIDGET_H_ #define _WIDGET_H_ -#include -#include #include +#include "zone.h" #define MAX_WIDGET_OPTIONS 5 -struct Zone -{ - uint16_t x, y, w, h; -}; - -#define LEN_ZONE_OPTION_STRING 8 -union ZoneOptionValue -{ - uint32_t unsignedValue; - int32_t signedValue; - bool boolValue; - char stringValue[LEN_ZONE_OPTION_STRING]; -}; - -#if defined(_MSC_VER) - #define OPTION_VALUE_UNSIGNED(x) uint32_t(x) - #define OPTION_VALUE_SIGNED(x) uint32_t(x) - #define OPTION_VALUE_BOOL(x) uint32_t(x) - #define OPTION_VALUE_STRING(...) { .stringValue = {__VA_ARGS__} } -#else - #define OPTION_VALUE_UNSIGNED(x) { .unsignedValue = (x) } - #define OPTION_VALUE_SIGNED(x) { .signedValue = (x) } - #define OPTION_VALUE_BOOL(x) { .boolValue = (x) } - #define OPTION_VALUE_STRING(...) { .stringValue = {__VA_ARGS__} } -#endif - -struct ZoneOption -{ - enum Type { - Integer, - Source, - Bool, - String, - File, - TextSize, - Timer, - Switch, - Color - }; - - const char * name; - Type type; - ZoneOptionValue deflt; - ZoneOptionValue min; - ZoneOptionValue max; -}; - class WidgetFactory; class Widget { diff --git a/radio/src/gui/480x272/widgets/text.cpp b/radio/src/gui/480x272/widgets/text.cpp index e35085839..19d6ef039 100644 --- a/radio/src/gui/480x272/widgets/text.cpp +++ b/radio/src/gui/480x272/widgets/text.cpp @@ -20,6 +20,8 @@ #include "opentx.h" +#define TEXT_WIDGET_DEFAULT_LABEL '\15', '\347', '\0', '\14', '\377', '\376', '\373', '\364' // "My Label" + class TextWidget: public Widget { public: @@ -34,7 +36,7 @@ class TextWidget: public Widget }; const ZoneOption TextWidget::options[] = { - { "Text", ZoneOption::String, OPTION_VALUE_STRING('\15', '\347', '\0', '\14', '\377', '\376', '\373', '\364') }, + { "Text", ZoneOption::String, OPTION_VALUE_STRING(TEXT_WIDGET_DEFAULT_LABEL) }, { "Color", ZoneOption::Color, OPTION_VALUE_UNSIGNED(RED) }, { "Size", ZoneOption::TextSize, OPTION_VALUE_UNSIGNED(0) }, { NULL, ZoneOption::Bool } diff --git a/radio/src/gui/480x272/zone.h b/radio/src/gui/480x272/zone.h new file mode 100644 index 000000000..196749522 --- /dev/null +++ b/radio/src/gui/480x272/zone.h @@ -0,0 +1,55 @@ + +#ifndef _ZONE_H_ +#define _ZONE_H_ + +#include + +#define LEN_ZONE_OPTION_STRING 8 + +#if defined(_MSC_VER) + #define OPTION_VALUE_UNSIGNED(x) uint32_t(x) + #define OPTION_VALUE_SIGNED(x) uint32_t(x) + #define OPTION_VALUE_BOOL(x) bool(x) + #define OPTION_VALUE_STRING(...) *(ZoneOptionValue *)(const char *) #__VA_ARGS__ +#else + #define OPTION_VALUE_UNSIGNED(x) { .unsignedValue = (x) } + #define OPTION_VALUE_SIGNED(x) { .signedValue = (x) } + #define OPTION_VALUE_BOOL(x) { .boolValue = (x) } + #define OPTION_VALUE_STRING(...) { .stringValue = {__VA_ARGS__} } +#endif + +struct Zone +{ + uint16_t x, y, w, h; +}; + +union ZoneOptionValue +{ + uint32_t unsignedValue; + int32_t signedValue; + bool boolValue; + char stringValue[LEN_ZONE_OPTION_STRING]; +}; + +struct ZoneOption +{ + enum Type { + Integer, + Source, + Bool, + String, + File, + TextSize, + Timer, + Switch, + Color + }; + + const char * name; + Type type; + ZoneOptionValue deflt; + ZoneOptionValue min; + ZoneOptionValue max; +}; + +#endif