fix(color): Make size/appearance of number/text edit controls consistent with other UI elements (#3481)

* Fix minor layout issues arising from libopenui PR 89.

* chore: Bump libopenui

---------

Co-authored-by: Phil Mitchell <phil.a.mitchell@gmail.com>
This commit is contained in:
philmoz
2023-05-07 14:04:35 +10:00
committed by GitHub
co-authored by Phil Mitchell
parent 93d8992fed
commit 7a083fe0f7
7 changed files with 26 additions and 19 deletions
@@ -237,8 +237,10 @@ class LogicalSwitchEditPage : public Page
void buildBody(FormWindow* window)
{
window->setFlexLayout();
window->padAll(0);
window->padLeft(4);
window->padRight(4);
FlexGridLayout grid(col_dsc, row_dsc, 2);
lv_obj_set_style_pad_all(window->getLvObj(), lv_dpx(8), 0);
LogicalSwitchData* cs = lswAddress(index);
+2 -2
View File
@@ -90,7 +90,7 @@ class USBChannelEditStatusBar : public Window
Window(parent, rect), _channel(channel)
{
channelBar = new ComboChannelBar(this, {USBCH_EDIT_STATUS_BAR_MARGIN, 0, rect.w - (USBCH_EDIT_STATUS_BAR_MARGIN * 2), rect.h}, channel);
channelBar->setLeftMargin(0);
channelBar->setLeftMargin(15);
channelBar->setTextColor(COLOR_THEME_PRIMARY2);
channelBar->setOutputChannelBarLimitColor(COLOR_THEME_EDIT);
}
@@ -215,7 +215,7 @@ class USBChannelEditWindow : public Page
Page(ICON_MODEL_USB), channel(channel)
{
auto form = new FormWindow(&body, rect_t{});
form->padAll(4);
form->padAll(2);
form->padLeft(8);
form->padRight(8);
+1 -1
View File
@@ -148,7 +148,7 @@ PreflightChecks::PreflightChecks() : Page(ICON_MODEL_SETUP)
#if NUM_POTS + NUM_SLIDERS
line = form->newLine(&grid);
new StaticText(line, rect_t{}, STR_POTWARNINGSTATE, 0, COLOR_THEME_PRIMARY1);
auto pots_wm = new Choice(line, rect_t{}, {STR_PREFLIGHT_POTSLIDER_CHECK}, 0, 2,
auto pots_wm = new Choice(line, rect_t{}, STR_PREFLIGHT_POTSLIDER_CHECK, 0, 2,
GET_SET_DEFAULT(g_model.potsWarnMode));
#if (NUM_POTS)
// Pot warnings
+6 -13
View File
@@ -181,21 +181,18 @@ class ThemedTextEdit : public TextEdit
public:
ThemedTextEdit(Window *parent, const rect_t &rect, char *text,
int colorBackgroundIndex, int colorTextIndex) :
TextEdit(parent, rect, text, strlen(text)),
TextEdit(parent, rect, text, strlen(text), NO_FOCUS),
_colorBackgroundIndex(colorBackgroundIndex),
_colorTextIndex(colorTextIndex)
{
setBackgroundHandler([=] (FormField *field) {
return COLOR(_colorBackgroundIndex);
});
}
void paint(BitmapBuffer *dc) override
{
colorMaintainer.applyColorValues();
lv_obj_set_style_bg_color(lvobj, makeLvColor(COLOR(_colorBackgroundIndex)), LV_PART_MAIN);
lv_obj_set_style_text_color(lvobj, lv_color_white(), LV_PART_MAIN);
FormField::paint(dc);
dc->drawSizedText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, length, COLOR(_colorTextIndex));
colorMaintainer.restoreColorValues();
}
@@ -206,7 +203,6 @@ class ThemedTextEdit : public TextEdit
}
#endif
#if defined(HARDWARE_KEYS)
void onEvent(event_t event) override
{
@@ -214,7 +210,6 @@ class ThemedTextEdit : public TextEdit
}
#endif
protected:
int _colorBackgroundIndex;
int _colorTextIndex;
@@ -243,15 +238,13 @@ class PreviewWindow : public FormGroup
new ThemedStaticText(this, {5, 115, 100, LINE_HEIGHT}, "Warning Text", COLOR_THEME_WARNING_INDEX);
new ThemedStaticText(this, {5, 140, 100, LINE_HEIGHT}, "Disabled Text", COLOR_THEME_DISABLED_INDEX);
static char EditText[128];
strcpy(EditText, "Edit");
static char EditText[] = "Edit";
new ThemedTextEdit(this, {5, 160, 100, LINE_HEIGHT + 1}, EditText,
COLOR_THEME_EDIT_INDEX, COLOR_THEME_PRIMARY2_INDEX);
static char FocusText[128];
strcpy(FocusText, "Focus");
static char FocusText[] = "Focus";
new ThemedTextEdit(this, {110, 160, 100, LINE_HEIGHT + 1}, FocusText,
COLOR_THEME_FOCUS_INDEX, COLOR_THEME_PRIMARY2_INDEX);
ticks = getTicks();
ticks = 0;
lv_group_set_default(def_group);
}
@@ -63,6 +63,7 @@ void RadioHardwarePage::build(FormWindow * window)
auto box = new FormGroup(line, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(4));
lv_obj_set_style_grid_cell_x_align(box->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
lv_obj_set_flex_align(box->getLvObj(), LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND);
auto batMin =
new NumberEdit(box, rect_t{}, -60 + 90, g_eeGeneral.vBatMax + 29 + 90,
+12 -1
View File
@@ -133,6 +133,10 @@ class ThemeDetailsDialog: public Dialog
theme(theme),
saveHandler(saveHandler)
{
content->form.padAll(4);
content->form.padLeft(8);
content->form.padRight(8);
lv_obj_set_style_bg_color(content->getLvObj(), makeLvColor(COLOR_THEME_SECONDARY3), 0);
lv_obj_set_style_bg_opa(content->getLvObj(), LV_OPA_100, LV_PART_MAIN);
auto form = new FormWindow(&content->form, rect_t{});
@@ -141,12 +145,15 @@ class ThemeDetailsDialog: public Dialog
FlexGridLayout grid(d_col_dsc, row_dsc, 2);
auto line = form->newLine(&grid);
line->padAll(0);
new StaticText(line, rect_t{}, STR_NAME, 0, COLOR_THEME_PRIMARY1);
auto te = new TextEdit(line, rect_t{}, this->theme.getName(), SELECTED_THEME_NAME_LEN);
lv_obj_set_grid_cell(te->getLvObj(), LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_CENTER, 0, 1);
line = form->newLine(&grid);
line->padAll(0);
line->padTop(2);
new StaticText(line, rect_t{}, STR_AUTHOR, 0, COLOR_THEME_PRIMARY1);
te = new TextEdit(line, rect_t{}, this->theme.getAuthor(), AUTHOR_LENGTH);
@@ -155,14 +162,17 @@ class ThemeDetailsDialog: public Dialog
FlexGridLayout grid2(b_col_dsc, row_dsc, 2);
line = form->newLine(&grid2);
line->padAll(0);
new StaticText(line, rect_t{}, STR_DESCRIPTION, 0, COLOR_THEME_PRIMARY1);
line = form->newLine(&grid2);
line->padAll(0);
te = new TextEdit(line, rect_t{}, this->theme.getInfo(), INFO_LENGTH);
lv_obj_set_grid_cell(te->getLvObj(), LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_CENTER, 0, 1);
line = form->newLine(&grid2);
line->padTop(20);
line->padAll(0);
line->padTop(10);
auto button = new TextButton(line, rect_t{0, 0, lv_pct(30), 32}, STR_SAVE, [=] () {
if (saveHandler != nullptr)
@@ -389,6 +399,7 @@ class ThemeEditPage : public Page
started = true;
_themeName->setText(_theme.getName());
}
Window::checkEvents();
}
void editColorPage()