Skip to content

Commit

Permalink
chore(color): color UI code cleanup - round 3 (#5351)
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed Aug 1, 2024
1 parent a362fee commit 23df4f6
Show file tree
Hide file tree
Showing 104 changed files with 554 additions and 824 deletions.
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/access_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ void ModuleOptions::update()
if (!optionsAvailable) {
// no options available
line = form->newLine(grid);
new StaticText(line, rect_t{}, STR_NO_TX_OPTIONS, 0);
new StaticText(line, rect_t{}, STR_NO_TX_OPTIONS);
} else {
// some options available
if (optionsAvailable & (1 << MODULE_OPTION_EXTERNAL_ANTENNA)) {
Expand Down
21 changes: 10 additions & 11 deletions radio/src/gui/colorlcd/channel_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,30 +219,29 @@ ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect,
uint8_t _channel, bool isInHeader) :
Window(parent, rect), channel(_channel)
{
LcdFlags textColor =
isInHeader ? COLOR_THEME_PRIMARY2 : COLOR_THEME_SECONDARY1;
LcdColorIndex txtColIdx = isInHeader ? COLOR_THEME_PRIMARY2_INDEX : COLOR_THEME_SECONDARY1_INDEX;

outputChannelBar = new OutputChannelBar(
this, {ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT + ChannelBar::TMARGIN, width() - ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT},
this, {PAD_TINY, ChannelBar::BAR_HEIGHT + PAD_TINY, width() - PAD_TINY, ChannelBar::BAR_HEIGHT},
channel, isInHeader);

new MixerChannelBar(
this,
{ChannelBar::LMARGIN, (2 * ChannelBar::BAR_HEIGHT) + ChannelBar::TMARGIN + 1, width() - ChannelBar::LMARGIN, ChannelBar::BAR_HEIGHT},
{PAD_TINY, (2 * ChannelBar::BAR_HEIGHT) + PAD_TINY + 1, width() - PAD_TINY, ChannelBar::BAR_HEIGHT},
channel);

// Channel number
char chanString[] = TR_CH "32 ";
strAppendSigned(&chanString[2], channel + 1, 2);
new StaticText(this, {ChannelBar::LMARGIN, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, chanString,
textColor | FONT(XS) | LEFT);
new StaticText(this, {PAD_TINY, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, chanString,
txtColIdx, FONT(XS) | LEFT);

// Channel name
if (g_model.limitData[channel].name[0]) {
char nm[LEN_CHANNEL_NAME + 1];
strAppend(nm, g_model.limitData[channel].name, LEN_CHANNEL_NAME);
new StaticText(this, {ChannelBar::LMARGIN + ChannelBar::VAL_W, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, nm,
textColor | FONT(XS) | LEFT);
new StaticText(this, {PAD_TINY + ChannelBar::VAL_W, 0, LV_SIZE_CONTENT, ChannelBar::VAL_H}, nm,
txtColIdx, FONT(XS) | LEFT);
}

// Channel value in µS
Expand All @@ -254,20 +253,20 @@ ComboChannelBar::ComboChannelBar(Window* parent, const rect_t& rect,
return calcRESXto100(channelOutputs[channel]);
return PPM_CH_CENTER(channel) + channelOutputs[channel] / 2;
},
textColor | FONT(XS) | RIGHT, "", suffix);
txtColIdx, FONT(XS) | RIGHT, "", suffix);

// Override icon
#if defined(OVERRIDE_CHANNEL_FUNCTION)
overrideIcon = new StaticIcon(
this, 0, 5, ICON_CHAN_MONITOR_LOCKED, textColor);
this, 0, 5, ICON_CHAN_MONITOR_LOCKED, txtColIdx);
overrideIcon->show(safetyCh[channel] != OVERRIDE_CHANNEL_UNDEFINED);
#endif

// Channel reverted icon
LimitData* ld = limitAddress(channel);
if (ld && ld->revert) {
new StaticIcon(this, 0, ICON_SZ, ICON_CHAN_MONITOR_INVERTED,
textColor);
txtColIdx);
}
}

Expand Down
2 changes: 0 additions & 2 deletions radio/src/gui/colorlcd/channel_bar.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class ChannelBar : public Window
LcdColorIndex textColorIndex = COLOR_THEME_SECONDARY1_INDEX);

static LAYOUT_VAL(BAR_HEIGHT, 13, 13)
static LAYOUT_VAL(LMARGIN, 2, 2)
static LAYOUT_VAL(TMARGIN, 2, 2)

static LAYOUT_VAL(VAL_W, 45, 45)
static LAYOUT_VAL(VAL_H, 14, 14)
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/color_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "themes/etx_lv_theme.h"

ColorList::ColorList(Window *parent, const rect_t &rect,
std::vector<ColorEntry> colors, LcdFlags lcdFlags) :
std::vector<ColorEntry> colors) :
ListBox(parent, rect, getColorListNames(colors)), _colorList(colors)
{
setSelected(0);
Expand Down
3 changes: 1 addition & 2 deletions radio/src/gui/colorlcd/color_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
class ColorList : public ListBox
{
public:
ColorList(Window* parent, const rect_t& rect, std::vector<ColorEntry> colors,
LcdFlags lcdFlags = 0);
ColorList(Window* parent, const rect_t& rect, std::vector<ColorEntry> colors);

inline ColorEntry getSelectedColor()
{
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/color_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class ColorEditorPopup : public BaseDialog
colorPad = new ColorSwatch(hbox, {0, 0, COLOR_PAD_WIDTH, COLOR_PAD_HEIGHT},
COLOR_THEME_PRIMARY1);

hexStr = new StaticText(hbox, {0, 0, CVAL_W, 0}, "", COLOR_THEME_PRIMARY1 | FONT(L));
hexStr = new StaticText(hbox, {0, 0, CVAL_W, 0}, "", COLOR_THEME_PRIMARY1_INDEX, FONT(L));

updateColor(color);

Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/crossfire_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ CrossfireSettings::CrossfireSettings(Window* parent, const FlexGridLayout& g,
// getStringAtIndex(buf, STR_CRSF_BAUDRATE,
// CROSSFIRE_STORE_TO_INDEX(
// g_eeGeneral.internalModuleBaudrate)),
// 0, COLOR_THEME_PRIMARY1);
// COLOR_THEME_PRIMARY1);
}

auto line = newLine(grid);
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Curve::Curve(Window* parent, const rect_t& rect,
posHLine = lv_line_create(lvobj);
etx_obj_add_style(posHLine, styles->graph_position_line, LV_PART_MAIN);

positionValue = new StaticText(this, {10, 10, LV_SIZE_CONTENT, 17}, "", COLOR_THEME_PRIMARY1 | FONT(XS));
positionValue = new StaticText(this, {10, 10, LV_SIZE_CONTENT, 17}, "", COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
positionValue->padLeft(PAD_TINY);
positionValue->padRight(PAD_TINY);
etx_solid_bg(positionValue->getLvObj(), COLOR_THEME_ACTIVE_INDEX);
Expand Down
12 changes: 6 additions & 6 deletions radio/src/gui/colorlcd/curveedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ class CurveDataEdit : public Window
{PTNUM_X + (i * (NUM_BTN_WIDTH + PAD_TINY)), y,
NUM_BTN_WIDTH, PTNUM_H},
std::to_string(i + start + 1),
COLOR_THEME_PRIMARY1 | FONT(XS) | CENTERED);
COLOR_THEME_PRIMARY1_INDEX, FONT(XS) | CENTERED);
}

y += NUM_HDR_HEIGHT;

new StaticText(
parent, {1, y + PAD_MEDIUM, PTNUM_X, EdgeTxStyles::UI_ELEMENT_HEIGHT},
"X", COLOR_THEME_PRIMARY1 | CENTERED);
"X", COLOR_THEME_PRIMARY1_INDEX, CENTERED);

int8_t* points = curveAddress(index);

Expand All @@ -110,7 +110,7 @@ class CurveDataEdit : public Window
parent,
{PTNUM_X + (i * (NUM_BTN_WIDTH + PAD_TINY)), y + PAD_MEDIUM,
NUM_BTN_WIDTH, EdgeTxStyles::UI_ELEMENT_HEIGHT},
"-100", COLOR_THEME_SECONDARY1 | CENTERED);
"-100", COLOR_THEME_SECONDARY1_INDEX, CENTERED);
i += 1;
}
if ((start + count) == curvePointsCount) {
Expand Down Expand Up @@ -145,7 +145,7 @@ class CurveDataEdit : public Window
parent,
{PTNUM_X + (i * (NUM_BTN_WIDTH + PAD_TINY)), y + PAD_MEDIUM,
NUM_BTN_WIDTH, EdgeTxStyles::UI_ELEMENT_HEIGHT},
"100", COLOR_THEME_SECONDARY1 | CENTERED);
"100", COLOR_THEME_SECONDARY1_INDEX, CENTERED);
}
} else {
for (uint8_t i = 0; i < count; i++) {
Expand All @@ -154,15 +154,15 @@ class CurveDataEdit : public Window
rect_t{PTNUM_X + (i * (NUM_BTN_WIDTH + PAD_TINY)), y + PAD_MEDIUM,
NUM_BTN_WIDTH, EdgeTxStyles::UI_ELEMENT_HEIGHT},
std::to_string(-100 + (200 * (i + start)) / (curvePointsCount - 1)),
COLOR_THEME_SECONDARY1 | CENTERED);
COLOR_THEME_SECONDARY1_INDEX, CENTERED);
}
}

y += EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_TINY;

new StaticText(
parent, {1, y + PAD_MEDIUM, PTNUM_X, EdgeTxStyles::UI_ELEMENT_HEIGHT},
"Y", COLOR_THEME_PRIMARY1 | CENTERED);
"Y", COLOR_THEME_PRIMARY1_INDEX, CENTERED);

// y value
for (uint8_t i = 0; i < count; i++) {
Expand Down
4 changes: 2 additions & 2 deletions radio/src/gui/colorlcd/custom_failsafe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ class ChannelFSCombo : public Window
lv_obj_set_style_flex_cross_place(lvobj, LV_FLEX_ALIGN_CENTER, 0);

edit = new ChannelFailsafeEdit(this, ch, vmin, vmax);
auto btn = new TextButton(this, rect_t{}, LV_SYMBOL_SETTINGS, [=]() {
new TextButton(this, rect_t{}, LV_SYMBOL_SETTINGS, [=]() {
edit->toggle();
return 0;
});

btn = new TextButton(this, rect_t{}, LV_SYMBOL_COPY, [=]() {
new TextButton(this, rect_t{}, LV_SYMBOL_COPY, [=]() {
edit->copyChannel();
return 0;
});
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/file_carosell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ FileCarosell::FileCarosell(Window *parent, const rect_t &rect,
{
setWindowFlag(NO_FOCUS);

message = new StaticText(this, {0, rect.h/2, rect.w, EdgeTxStyles::PAGE_LINE_HEIGHT * 2}, "", CENTERED | FONT(L) | COLOR_THEME_PRIMARY1);
message = new StaticText(this, {0, rect.h/2, rect.w, EdgeTxStyles::PAGE_LINE_HEIGHT * 2}, "", COLOR_THEME_PRIMARY1_INDEX, CENTERED | FONT(L));

setFileNames(fileNames);
}
Expand Down
6 changes: 3 additions & 3 deletions radio/src/gui/colorlcd/fullscreen_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void FullScreenDialog::build()
new StaticIcon(
this, ALERT_BITMAP_LEFT, ALERT_BITMAP_TOP,
(type == WARNING_TYPE_INFO) ? ICON_BUSY : ICON_ERROR,
COLOR_THEME_WARNING);
COLOR_THEME_WARNING_INDEX);

std::string t;
if (type == WARNING_TYPE_ALERT) {
Expand All @@ -95,14 +95,14 @@ void FullScreenDialog::build()
rect_t{ALERT_TITLE_LEFT, ALERT_TITLE_TOP,
LCD_W - ALERT_TITLE_LEFT - PAD_MEDIUM,
LCD_H - ALERT_TITLE_TOP - PAD_MEDIUM},
t.c_str(), COLOR_THEME_WARNING | FONT(XL));
t.c_str(), COLOR_THEME_WARNING_INDEX, FONT(XL));

messageLabel =
new StaticText(this,
rect_t{ALERT_MESSAGE_LEFT, ALERT_MESSAGE_TOP,
LCD_W - ALERT_MESSAGE_LEFT - PAD_MEDIUM,
LCD_H - ALERT_MESSAGE_TOP - PAD_MEDIUM},
message.c_str(), COLOR_THEME_PRIMARY1 | FONT(BOLD));
message.c_str(), COLOR_THEME_PRIMARY1_INDEX, FONT(BOLD));

if (!action.empty()) {
auto btn = new TextButton(
Expand Down
23 changes: 10 additions & 13 deletions radio/src/gui/colorlcd/function_switches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ class FunctionSwitch : public Window
std::string s(STR_CHAR_SWITCH);
s += switchGetName(switchIndex + switchGetMaxSwitches());

new StaticText(this, {PAD_LARGE, PAD_MEDIUM, SW_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, s,
COLOR_THEME_PRIMARY1);
new StaticText(this, {PAD_LARGE, PAD_MEDIUM, SW_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, s);

new ModelTextEdit(this, {NM_X, 0, NM_W, 0},
g_model.switchNames[switchIndex], LEN_SWITCH_NAME);
Expand Down Expand Up @@ -146,7 +145,7 @@ class FunctionSwitch : public Window
void checkEvents() override
{
setState();
if (lastType != FSWITCH_CONFIG(switchIndex)) {
if (lastType != (int)FSWITCH_CONFIG(switchIndex)) {
lastType = FSWITCH_CONFIG(switchIndex);
typeChoice->setValue(lastType);
}
Expand All @@ -163,8 +162,7 @@ class SwitchGroup : public Window
padAll(PAD_TINY_GAP);

new StaticText(this, {0, PAD_MEDIUM, NM_W, EdgeTxStyles::PAGE_LINE_HEIGHT},
STR_FUNCTION_SWITCH_GROUPS[groupIndex],
COLOR_THEME_PRIMARY1);
STR_FUNCTION_SWITCH_GROUPS[groupIndex]);

auto btn = new TextButton(
this, {AO_X, 0, AO_W, 0}, STR_GROUP_ALWAYS_ON, [=]() -> int8_t {
Expand All @@ -178,8 +176,7 @@ class SwitchGroup : public Window
});
btn->check(IS_FSWITCH_GROUP_ON(groupIndex));

new StaticText(this, {SL_X, PAD_MEDIUM, SL_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_SWITCH_STARTUP,
COLOR_THEME_PRIMARY1);
new StaticText(this, {SL_X, PAD_MEDIUM, SL_W, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_SWITCH_STARTUP);

startChoice = new Choice(
this, {ST_X, 0, ST_W, 0}, STR_FSSWITCHES, 0,
Expand Down Expand Up @@ -234,13 +231,13 @@ ModelFunctionSwitches::ModelFunctionSwitches() : Page(ICON_MODEL_SETUP)
FlexGridLayout grid2(line_col_dsc2, line_row_dsc, PAD_TINY);

auto line = body->newLine(grid2);
new StaticText(line, rect_t{}, STR_SWITCHES, COLOR_THEME_PRIMARY1);
new StaticText(line, rect_t{}, STR_NAME, COLOR_THEME_PRIMARY1 | FONT(XS));
new StaticText(line, rect_t{}, STR_SWITCHES);
new StaticText(line, rect_t{}, STR_NAME, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
new StaticText(line, rect_t{}, STR_SWITCH_TYPE,
COLOR_THEME_PRIMARY1 | FONT(XS));
new StaticText(line, rect_t{}, STR_GROUP, COLOR_THEME_PRIMARY1 | FONT(XS));
COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
new StaticText(line, rect_t{}, STR_GROUP, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
startupHeader = new StaticText(line, rect_t{}, STR_SWITCH_STARTUP,
COLOR_THEME_PRIMARY1 | FONT(XS));
COLOR_THEME_PRIMARY1_INDEX, FONT(XS));

for (uint8_t i = 0; i < NUM_FUNCTIONS_SWITCHES; i += 1) {
new FunctionSwitch(body, i);
Expand All @@ -254,7 +251,7 @@ ModelFunctionSwitches::ModelFunctionSwitches() : Page(ICON_MODEL_SETUP)

line = body->newLine(grid1);

new StaticText(line, rect_t{}, STR_MORE_INFO, COLOR_THEME_PRIMARY1);
new StaticText(line, rect_t{}, STR_MORE_INFO);

line = body->newLine(grid1);
line->padBottom(PAD_LARGE);
Expand Down
3 changes: 1 addition & 2 deletions radio/src/gui/colorlcd/gvar_numberedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ GVarNumberEdit::GVarNumberEdit(Window* parent, int32_t vmin,

num_field = new NumberEdit(
this, {0, 0, NUM_EDIT_W, 0}, vmin, vmax, [=]() { return getValue() + voffset; },
nullptr);
num_field->setTextFlag(textFlags);
nullptr, textFlags);
num_field->setDefault(vdefault);

#if defined(GVARS)
Expand Down
6 changes: 2 additions & 4 deletions radio/src/gui/colorlcd/hw_bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class BTDetailsDialog : public BaseDialog
[=]() {
return std::string(bluetooth.localAddr[0] ? bluetooth.localAddr
: "---");
},
COLOR_THEME_PRIMARY1);
});

// Remote MAC
line = form->newLine(grid);
Expand All @@ -62,8 +61,7 @@ class BTDetailsDialog : public BaseDialog
[=]() {
return std::string(bluetooth.distantAddr[0] ? bluetooth.distantAddr
: "---");
},
COLOR_THEME_PRIMARY1);
});
}
};

Expand Down
6 changes: 3 additions & 3 deletions radio/src/gui/colorlcd/hw_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ HWPots::HWPots(Window* parent) :
}
});

new StaticText(this, {P_NM_X, -2, 0, 0}, STR_NAME, FONT(XS));
new StaticText(this, {P_TYP_X, -2, 0, 0}, STR_TYPE, FONT(XS));
new StaticText(this, {P_INV_X, -2, 0, 0}, STR_MENU_INVERT, FONT(XS));
new StaticText(this, {P_NM_X, -2, 0, 0}, STR_NAME, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
new StaticText(this, {P_TYP_X, -2, 0, 0}, STR_TYPE, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
new StaticText(this, {P_INV_X, -2, 0, 0}, STR_MENU_INVERT, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));

coord_t yo = EdgeTxStyles::PAGE_LINE_HEIGHT - 2;

Expand Down
4 changes: 2 additions & 2 deletions radio/src/gui/colorlcd/hw_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ SerialConfigWindow::SerialConfigWindow(Window *parent, FlexGridLayout& grid)
grid.setColSpan(2);
auto line = parent->newLine(grid);
line->padLeft(WARN_PADL);
line->padBottom(WARN_PADB);
new StaticText(line, rect_t{}, STR_TTL_WARNING, COLOR_THEME_WARNING);
line->padBottom(PAD_MEDIUM);
new StaticText(line, rect_t{}, STR_TTL_WARNING, COLOR_THEME_WARNING_INDEX);
grid.setColSpan(1);
}
}
Expand Down
1 change: 0 additions & 1 deletion radio/src/gui/colorlcd/hw_serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ class SerialConfigWindow
SerialConfigWindow(Window *parent, FlexGridLayout& grid);

static LAYOUT_VAL(WARN_PADL, 20, 20);
static LAYOUT_VAL(WARN_PADB, 6, 6);
};
2 changes: 0 additions & 2 deletions radio/src/gui/colorlcd/layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
#define MAX_LAYOUT_ZONES 10
#define MAX_LAYOUT_OPTIONS 10

constexpr uint32_t LAYOUT_REFRESH = 1000 / 2; // 2 Hz

#if !defined(YAML_GENERATOR)
typedef WidgetsContainerPersistentData<MAX_LAYOUT_ZONES, MAX_LAYOUT_OPTIONS>
LayoutPersistentData;
Expand Down
Loading

0 comments on commit 23df4f6

Please sign in to comment.