Skip to content

Commit

Permalink
Fix layout consistency.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed Jan 17, 2025
1 parent 784d7d2 commit e3bd05b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 36 deletions.
20 changes: 1 addition & 19 deletions radio/src/gui/colorlcd/libui/etx_lv_theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,6 @@ const lv_style_const_prop_t pad_tiny_props[] = {
};
LV_STYLE_CONST_MULTI_INIT(EdgeTxStyles::pad_tiny, pad_tiny_props);

#if LANDSCAPE_LCD_SMALL
const lv_style_const_prop_t pad_tiny_gap_props[] = {
LV_STYLE_CONST_PAD_TOP(PAD_TINY_GAP), LV_STYLE_CONST_PAD_BOTTOM(PAD_TINY_GAP),
LV_STYLE_CONST_PAD_LEFT(PAD_TINY_GAP), LV_STYLE_CONST_PAD_RIGHT(PAD_TINY_GAP),
LV_STYLE_CONST_PAD_ROW(PAD_TINY_GAP), LV_STYLE_CONST_PAD_COLUMN(PAD_TINY_GAP),
LV_STYLE_PROP_INV,
};
LV_STYLE_CONST_MULTI_INIT(EdgeTxStyles::pad_tiny_gap, pad_tiny_gap_props);
#endif

const lv_style_const_prop_t pad_small_props[] = {
LV_STYLE_CONST_PAD_TOP(PAD_SMALL),
LV_STYLE_CONST_PAD_BOTTOM(PAD_SMALL),
Expand Down Expand Up @@ -195,7 +185,7 @@ const lv_style_const_prop_t border_thin_props[] = {
LV_STYLE_CONST_MULTI_INIT(EdgeTxStyles::border_thin, border_thin_props);

static const lv_style_const_prop_t outline_props[] = {
LV_STYLE_CONST_OUTLINE_WIDTH(2),
LV_STYLE_CONST_OUTLINE_WIDTH(PAD_TINY),
LV_STYLE_CONST_OUTLINE_OPA(LV_OPA_COVER),
LV_STYLE_CONST_OUTLINE_PAD(1),
LV_STYLE_PROP_INV,
Expand Down Expand Up @@ -557,20 +547,12 @@ void etx_padding(lv_obj_t* obj, PaddingSize padding,
lv_style_selector_t selector)
{
lv_obj_remove_style(obj, (lv_style_t*)&styles->pad_tiny, selector);
#if LANDSCAPE_LCD_SMALL
lv_obj_remove_style(obj, (lv_style_t*)&styles->pad_tiny_gap, selector);
#endif
lv_obj_remove_style(obj, (lv_style_t*)&styles->pad_small, selector);
lv_obj_remove_style(obj, (lv_style_t*)&styles->pad_medium, selector);
lv_obj_remove_style(obj, (lv_style_t*)&styles->pad_large, selector);
lv_obj_remove_style(obj, (lv_style_t*)&styles->pad_zero, selector);
lv_obj_remove_style(obj, (lv_style_t*)&styles->pad_button, selector);
switch (padding) {
#if LANDSCAPE_LCD_SMALL
case PAD_TINY_GAP:
etx_obj_add_style(obj, styles->pad_tiny_gap, selector);
break;
#endif
case PAD_TINY:
etx_obj_add_style(obj, styles->pad_tiny, selector);
break;
Expand Down
5 changes: 0 additions & 5 deletions radio/src/gui/colorlcd/libui/etx_lv_theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
enum PaddingSize {
PAD_ZERO = 0,
PAD_TINY = 1,
PAD_TINY_GAP = 2,
PAD_SMALL = 3,
PAD_MEDIUM = 4,
PAD_LARGE = 6
Expand All @@ -46,7 +45,6 @@ enum PaddingSize {
enum PaddingSize {
PAD_ZERO = 0,
PAD_TINY = 2,
PAD_TINY_GAP = 2,
PAD_SMALL = 4,
PAD_MEDIUM = 6,
PAD_LARGE = 8
Expand Down Expand Up @@ -187,9 +185,6 @@ class EdgeTxStyles
// Static styles
static const lv_style_t pad_zero;
static const lv_style_t pad_tiny;
#if LANDSCAPE_LCD_SMALL
static const lv_style_t pad_tiny_gap;
#endif
static const lv_style_t pad_small;
static const lv_style_t pad_medium;
static const lv_style_t pad_large;
Expand Down
4 changes: 2 additions & 2 deletions radio/src/gui/colorlcd/libui/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,9 @@ SetupLine::SetupLine(Window* parent, coord_t y, coord_t col2, PaddingSize paddin
padAll(PAD_ZERO);
coord_t titleY = PAD_LARGE + lblYOffset;
coord_t titleH = EdgeTxStyles::PAGE_LINE_HEIGHT;
coord_t h = EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_TINY_GAP * 2 + lblYOffset * 2;
coord_t h = EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_TINY * 2 + lblYOffset * 2;
if (createEdit) {
coord_t editY = PAD_TINY_GAP;
coord_t editY = PAD_TINY;
coord_t lblWidth = col2 - PAD_SMALL - PAD_TINY;
if (title) {
if (getTextWidth(title) >= lblWidth) {
Expand Down
8 changes: 4 additions & 4 deletions radio/src/gui/colorlcd/model/function_switches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class FunctionSwitch : public Window
{
public:
FunctionSwitch(Window* parent, uint8_t sw) :
Window(parent, {0, 0, LCD_W - PAD_SMALL * 2, EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_TINY_GAP * 2}), switchIndex(sw)
Window(parent, {0, 0, LCD_W - PAD_SMALL * 2, EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_TINY * 2}), switchIndex(sw)
{
padAll(PAD_TINY_GAP);
padAll(PAD_TINY);

std::string s(STR_CHAR_SWITCH);
s += switchGetName(switchIndex + switchGetMaxSwitches());
Expand Down Expand Up @@ -195,9 +195,9 @@ class SwitchGroup : public Window
{
public:
SwitchGroup(Window* parent, uint8_t group) :
Window(parent, {0, 0, LCD_W - PAD_SMALL * 2, EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_TINY_GAP * 2}), groupIndex(group)
Window(parent, {0, 0, LCD_W - PAD_SMALL * 2, EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_TINY * 2}), groupIndex(group)
{
padAll(PAD_TINY_GAP);
padAll(PAD_TINY);

new StaticText(this, {0, PAD_MEDIUM, NM_W, EdgeTxStyles::PAGE_LINE_HEIGHT},
STR_FUNCTION_SWITCH_GROUPS[groupIndex]);
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/model/special_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class FunctionLineButton : public ListLineButton
static constexpr coord_t RP_Y = NM_Y;
static constexpr coord_t RP_H = NM_H;
static constexpr coord_t EN_X = RP_X + RP_W + PAD_TINY;
static constexpr coord_t EN_Y = NM_Y + PAD_TINY_GAP;
static constexpr coord_t EN_Y = NM_Y + PAD_TINY;
static LAYOUT_VAL(EN_SZ, 16, 16, LS(16))

protected:
Expand Down
10 changes: 5 additions & 5 deletions radio/src/gui/colorlcd/radio/radio_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class DateTimeWindow : public Window
// Absolute layout for date/time setion due to slow performance
// of lv_textarea in a flex layout.
static LAYOUT_VAL(DT_EDT_W, 80, 52, LS(80))
static LAYOUT_VAL(DT_Y1, PAD_TINY_GAP, PAD_TINY_GAP, PAD_TINY_GAP)
static LAYOUT_VAL(DT_Y1, PAD_TINY, PAD_TINY, PAD_TINY)
static LAYOUT_VAL(DT_Y2, DT_Y1 + EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_MEDIUM, DT_Y1 + EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_MEDIUM, DT_Y1 + EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_MEDIUM)

protected:
Expand Down Expand Up @@ -123,7 +123,7 @@ class DateTimeWindow : public Window
m_last_tm = m_tm;

// Date
new StaticText(this, rect_t{PAD_TINY_GAP, DT_Y1 + PAD_MEDIUM, SubPage::EDT_X - PAD_TINY_GAP - PAD_SMALL, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_DATE);
new StaticText(this, rect_t{PAD_TINY, DT_Y1 + PAD_MEDIUM, SubPage::EDT_X - PAD_TINY - PAD_SMALL, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_DATE);
year = new NumberEdit(
this, rect_t{SubPage::EDT_X, DT_Y1, DT_EDT_W, 0}, 2023, 2037,
[=]() -> int32_t { return TM_YEAR_BASE + m_tm.tm_year; },
Expand All @@ -134,7 +134,7 @@ class DateTimeWindow : public Window
});

month = new NumberEdit(
this, rect_t{SubPage::EDT_X + DT_EDT_W + PAD_TINY_GAP, DT_Y1, DT_EDT_W, 0}, 1, 12,
this, rect_t{SubPage::EDT_X + DT_EDT_W + PAD_TINY, DT_Y1, DT_EDT_W, 0}, 1, 12,
[=]() -> int32_t { return 1 + m_tm.tm_mon; },
[=](int32_t newValue) {
m_last_tm.tm_mon = m_tm.tm_mon = newValue - 1;
Expand All @@ -155,7 +155,7 @@ class DateTimeWindow : public Window
[](int32_t value) { return formatNumberAsString(value, LEADING0, 2); });

// Time
new StaticText(this, rect_t{PAD_TINY_GAP, DT_Y2 + PAD_MEDIUM, SubPage::EDT_X - PAD_TINY_GAP - PAD_SMALL, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_TIME);
new StaticText(this, rect_t{PAD_TINY, DT_Y2 + PAD_MEDIUM, SubPage::EDT_X - PAD_TINY - PAD_SMALL, EdgeTxStyles::PAGE_LINE_HEIGHT}, STR_TIME);
hour = new NumberEdit(
this, rect_t{SubPage::EDT_X, DT_Y2, DT_EDT_W, 0}, 0, 23,
[=]() -> int32_t { return m_tm.tm_hour; },
Expand All @@ -167,7 +167,7 @@ class DateTimeWindow : public Window
[](int32_t value) { return formatNumberAsString(value, LEADING0, 2); });

minutes = new NumberEdit(
this, rect_t{SubPage::EDT_X + DT_EDT_W + PAD_TINY_GAP, DT_Y2, DT_EDT_W, 0}, 0, 59,
this, rect_t{SubPage::EDT_X + DT_EDT_W + PAD_TINY, DT_Y2, DT_EDT_W, 0}, 0, 59,
[=]() -> int32_t { return m_tm.tm_min; },
[=](int32_t newValue) {
m_last_tm.tm_min = m_tm.tm_min = newValue;
Expand Down

0 comments on commit e3bd05b

Please sign in to comment.