Fix initializer list issue with ZoneOptionValue (#4203)
* [480x272] Fix initializer list issue with ZoneOptionValue (technically not C++11), now works x-platform as well, lowers Flash use; Spit out Zone, ZoneOption, ZoneOptionValue to own unit. (Fixes https://github.com/opentx/opentx/pull/4199/files#r94867147) * [480x272] Revert to Flash usage for ZoneOptionValue types (still fixes MSVC build). (Ref: https://github.com/opentx/opentx/commit/82dce3ee601049cf548ff4518902ab8e8fa62a0b#commitcomment-20388918 & https://github.com/opentx/opentx/pull/4199#discussion_r94835251) * Cosmetics. * [480x272] Cosmetics.
This commit is contained in:
committed by
Bertrand Songis
parent
1f788723f9
commit
4f988babbf
@@ -21,59 +21,11 @@
|
|||||||
#ifndef _WIDGET_H_
|
#ifndef _WIDGET_H_
|
||||||
#define _WIDGET_H_
|
#define _WIDGET_H_
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include "zone.h"
|
||||||
|
|
||||||
#define MAX_WIDGET_OPTIONS 5
|
#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 WidgetFactory;
|
||||||
class Widget
|
class Widget
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
|
#define TEXT_WIDGET_DEFAULT_LABEL '\15', '\347', '\0', '\14', '\377', '\376', '\373', '\364' // "My Label"
|
||||||
|
|
||||||
class TextWidget: public Widget
|
class TextWidget: public Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -34,7 +36,7 @@ class TextWidget: public Widget
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ZoneOption TextWidget::options[] = {
|
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) },
|
{ "Color", ZoneOption::Color, OPTION_VALUE_UNSIGNED(RED) },
|
||||||
{ "Size", ZoneOption::TextSize, OPTION_VALUE_UNSIGNED(0) },
|
{ "Size", ZoneOption::TextSize, OPTION_VALUE_UNSIGNED(0) },
|
||||||
{ NULL, ZoneOption::Bool }
|
{ NULL, ZoneOption::Bool }
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
|
||||||
|
#ifndef _ZONE_H_
|
||||||
|
#define _ZONE_H_
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#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
|
||||||
Reference in New Issue
Block a user