3djc/improve widgets (#3696)
* Add color option to Value widget * Fix color handling Add shadow effect
This commit is contained in:
@@ -35,6 +35,7 @@ class ValueWidget: public Widget
|
|||||||
|
|
||||||
const ZoneOption ValueWidget::options[] = {
|
const ZoneOption ValueWidget::options[] = {
|
||||||
{ "Source", ZoneOption::Source, OPTION_VALUE_UNSIGNED(MIXSRC_Rud) },
|
{ "Source", ZoneOption::Source, OPTION_VALUE_UNSIGNED(MIXSRC_Rud) },
|
||||||
|
{ "Color", ZoneOption::Color, OPTION_VALUE_UNSIGNED(WHITE) },
|
||||||
{ NULL, ZoneOption::Bool }
|
{ NULL, ZoneOption::Bool }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -43,8 +44,8 @@ void ValueWidget::refresh()
|
|||||||
const int NUMBERS_PADDING = 4;
|
const int NUMBERS_PADDING = 4;
|
||||||
|
|
||||||
mixsrc_t field = persistentData->options[0].unsignedValue;
|
mixsrc_t field = persistentData->options[0].unsignedValue;
|
||||||
|
lcdSetColor(persistentData->options[1].unsignedValue);
|
||||||
|
|
||||||
LcdFlags color = TEXT_INVERTED_COLOR;
|
|
||||||
int x = zone.x;
|
int x = zone.x;
|
||||||
int y = zone.y;
|
int y = zone.y;
|
||||||
|
|
||||||
@@ -78,22 +79,26 @@ void ValueWidget::refresh()
|
|||||||
if (field >= MIXSRC_FIRST_TIMER && field <= MIXSRC_LAST_TIMER) {
|
if (field >= MIXSRC_FIRST_TIMER && field <= MIXSRC_LAST_TIMER) {
|
||||||
TimerState & timerState = timersStates[field-MIXSRC_FIRST_TIMER];
|
TimerState & timerState = timersStates[field-MIXSRC_FIRST_TIMER];
|
||||||
if (timerState.val < 0) {
|
if (timerState.val < 0) {
|
||||||
color = ALARM_COLOR;
|
lcdSetColor(ALARM_COLOR_INDEX);
|
||||||
}
|
}
|
||||||
putsMixerSource(x+NUMBERS_PADDING, y+2, field, color);
|
putsMixerSource(x+NUMBERS_PADDING, y+2, field, CUSTOM_COLOR);
|
||||||
putsTimer(xValue, yValue, abs(timerState.val), attrValue|DBLSIZE|color);
|
putsMixerSource(x+NUMBERS_PADDING + 1, y + 3, field, BLACK);
|
||||||
|
putsTimer(xValue, yValue, abs(timerState.val), attrValue|DBLSIZE|CUSTOM_COLOR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field >= MIXSRC_FIRST_TELEM) {
|
if (field >= MIXSRC_FIRST_TELEM) {
|
||||||
TelemetryItem & telemetryItem = telemetryItems[(field-MIXSRC_FIRST_TELEM)/3]; // TODO macro to convert a source to a telemetry index
|
TelemetryItem & telemetryItem = telemetryItems[(field-MIXSRC_FIRST_TELEM)/3]; // TODO macro to convert a source to a telemetry index
|
||||||
if (!telemetryItem.isAvailable() || telemetryItem.isOld()) {
|
if (!telemetryItem.isAvailable() || telemetryItem.isOld()) {
|
||||||
color = ALARM_COLOR;
|
lcdSetColor(ALARM_COLOR_INDEX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
putsMixerSource(xLabel, yLabel, field, attrLabel|color);
|
putsMixerSource(xLabel + 1, yLabel + 1, field, attrLabel|BLACK);
|
||||||
putsChannel(xValue, yValue, field, attrValue|color);
|
putsMixerSource(xLabel, yLabel, field, attrLabel|CUSTOM_COLOR);
|
||||||
|
putsChannel(xValue + 1, yValue + 1, field, attrValue|BLACK);
|
||||||
|
putsChannel(xValue, yValue, field, attrValue|CUSTOM_COLOR);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseWidgetFactory<ValueWidget> ValueWidget("Value", ValueWidget::options);
|
BaseWidgetFactory<ValueWidget> ValueWidget("Value", ValueWidget::options);
|
||||||
|
|||||||
Reference in New Issue
Block a user