Skip to content

Commit

Permalink
feat(color): Add LVGL scroll bar where needed (#3268)
Browse files Browse the repository at this point in the history
* Add scroll bar to radio settings/config pages.

* Add scroll bar to mode settings/config pages and screen settings pages.

* For pages display via TabsGroup class. move the scroll bar setting to the 'body' window.

* Fix position of new line on Inputs and Mixes pages.

* chore: Bump `libopenui`
  • Loading branch information
philmoz authored Mar 24, 2023
1 parent 1aa28a6 commit 8fc5a1c
Show file tree
Hide file tree
Showing 26 changed files with 104 additions and 149 deletions.
7 changes: 2 additions & 5 deletions radio/src/gui/colorlcd/curveedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ CurveDataEdit::CurveDataEdit(Window * parent, const rect_t & rect, uint8_t index
Window(parent, rect, FORM_FORWARD_FOCUS),
index(index)
{
lv_obj_set_style_bg_color(lvobj, makeLvColor(COLOR_THEME_SECONDARY3), 0);
lv_obj_set_scrollbar_mode(lvobj, LV_SCROLLBAR_MODE_AUTO);
}

#if LCD_W > LCD_H
Expand Down Expand Up @@ -169,11 +171,6 @@ void CurveDataEdit::update()
}
}

void CurveDataEdit::paint(BitmapBuffer* dc)
{
dc->clear(COLOR_THEME_SECONDARY3);
}

void CurveEdit::SetCurrentSource(uint32_t source)
{
CurveEdit::currentSource = source;
Expand Down
2 changes: 0 additions & 2 deletions radio/src/gui/colorlcd/curveedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ class CurveDataEdit : public Window
update();
}

void paint(BitmapBuffer * dc) override;

void update();

protected:
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/input_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) :
auto box = new Window(&body, rect_t{});
auto box_obj = box->getLvObj();
lv_obj_set_flex_grow(box_obj, 2);
lv_obj_set_scrollbar_mode(box->getLvObj(), LV_SCROLLBAR_MODE_AUTO);

#if LCD_H > LCD_W // portrait
box->setWidth(body.width() - 2*lv_dpx(8));
Expand Down
8 changes: 4 additions & 4 deletions radio/src/gui/colorlcd/model_curves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ void ModelCurvesPage::build(FormWindow * window)
#endif
static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};

auto form = new FormWindow(window, rect_t{});
form->setFlexLayout();
window->padAll(6);
window->setFlexLayout();

FlexGridLayout grid(col_dsc, row_dsc);

Expand All @@ -218,7 +218,7 @@ void ModelCurvesPage::build(FormWindow * window)
for (uint8_t index = 0; index < MAX_CURVES; index++) {
if (isCurveUsed(index)) {
if ((curveIndex % PER_ROW) == 0) {
line = form->newLine(&grid);
line = window->newLine(&grid);
lv_obj_set_grid_align(line->getLvObj(), LV_GRID_ALIGN_SPACE_BETWEEN, LV_GRID_ALIGN_SPACE_BETWEEN);
}

Expand Down Expand Up @@ -281,7 +281,7 @@ void ModelCurvesPage::build(FormWindow * window)

if (curveIndex < MAX_CURVES) {
if ((curveIndex % PER_ROW) == 0) {
line = form->newLine(&grid);
line = window->newLine(&grid);
lv_obj_set_grid_align(line->getLvObj(), LV_GRID_ALIGN_SPACE_BETWEEN,
LV_GRID_ALIGN_SPACE_BETWEEN);
}
Expand Down
13 changes: 4 additions & 9 deletions radio/src/gui/colorlcd/model_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void ModelInputsPage::removeLine(InputMixButton* l)
}
}

InputMixGroup* ModelInputsPage::createGroup(FormGroup* form, mixsrc_t src)
InputMixGroup* ModelInputsPage::createGroup(FormWindow* form, mixsrc_t src)
{
return new InputMixGroup(form, src);
}
Expand Down Expand Up @@ -442,15 +442,10 @@ void ModelInputsPage::pasteInputAfter(uint8_t dst_idx)

void ModelInputsPage::build(FormWindow *window)
{
window->setFlexLayout();
window->padRow(lv_dpx(8));
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3);

form = new FormGroup(window, rect_t{});
form->setFlexLayout();
form->padRow(lv_dpx(4));

auto form_obj = form->getLvObj();
lv_obj_set_width(form_obj, lv_pct(100));
form = new FormWindow(window, rect_t{});
form->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3);

groups.clear();
lines.clear();
Expand Down
4 changes: 2 additions & 2 deletions radio/src/gui/colorlcd/model_inputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ModelInputsPage : public PageTab
void build(FormWindow *window) override;

protected:
FormGroup* form = nullptr;
FormWindow* form = nullptr;
std::list<InputMixGroup*> groups;
std::list<InputMixButton*> lines;
InputMixButton* _copySrc = nullptr;
Expand All @@ -49,7 +49,7 @@ class ModelInputsPage : public PageTab

virtual void addLineButton(uint8_t index);
virtual void addLineButton(mixsrc_t src, uint8_t index);
virtual InputMixGroup* createGroup(FormGroup* form, mixsrc_t src);
virtual InputMixGroup* createGroup(FormWindow* form, mixsrc_t src);
virtual InputMixButton* createLineButton(InputMixGroup *group, uint8_t index);

void newInput();
Expand Down
9 changes: 3 additions & 6 deletions radio/src/gui/colorlcd/model_logical_switches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,7 @@ void ModelLogicalSwitchesPage::build(FormWindow* window)
static const lv_coord_t l_col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};

window->padAll(4);

auto form = new FormWindow(window, rect_t{});
form->setFlexLayout();
form->padAll(0);
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 0);

FlexGridLayout grid(l_col_dsc, row_dsc, 2);

Expand All @@ -584,7 +581,7 @@ void ModelLogicalSwitchesPage::build(FormWindow* window)
bool isActive = (ls->func != LS_FUNC_NONE);

if (isActive) {
line = form->newLine(&grid);
line = window->newLine(&grid);

button = new LogicalSwitchButton(line, rect_t{0, 0, window->width() - 12, LS_BUTTON_H}, i);

Expand Down Expand Up @@ -647,7 +644,7 @@ void ModelLogicalSwitchesPage::build(FormWindow* window)
}

if (hasEmptySwitch) {
line = form->newLine(&grid);
line = window->newLine(&grid);
addButton =
new TextButton(line, rect_t{0, 0, window->width() - 12, LS_BUTTON_H},
LV_SYMBOL_PLUS, [=]() {
Expand Down
9 changes: 3 additions & 6 deletions radio/src/gui/colorlcd/model_mixer_scripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,16 @@ void ModelMixerScriptsPage::rebuild(FormWindow * window, int8_t focusIdx)

void ModelMixerScriptsPage::build(FormWindow * window, int8_t focusIdx)
{
window->padAll(0);

auto form = new FormWindow(window, rect_t{});
form->setFlexLayout();
form->padAll(4);
window->padAll(4);
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 0);

FlexGridLayout grid(col_dsc, row_dsc, 2);

FormWindow::Line* line;

int8_t scriptIdx = 0;
for (int8_t idx = 0; idx < MAX_SCRIPTS; idx++) {
auto line = form->newLine(&grid);
auto line = window->newLine(&grid);

ScriptInternalData* runtimeData = nullptr;
ScriptData* const sd = &(g_model.scriptsData[idx]);
Expand Down
12 changes: 4 additions & 8 deletions radio/src/gui/colorlcd/model_mixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ InputMixGroup* ModelMixesPage::getGroupByIndex(uint8_t index)
return getGroupBySrc(MIXSRC_CH1 + ch);
}

InputMixGroup* ModelMixesPage::createGroup(FormGroup* form, mixsrc_t src)
InputMixGroup* ModelMixesPage::createGroup(FormWindow* form, mixsrc_t src)
{
auto group = new InputMixGroup(form, src);
if (showMonitors) group->enableMixerMonitor(src - MIXSRC_CH1);
Expand Down Expand Up @@ -512,15 +512,11 @@ void ModelMixesPage::pasteMixAfter(uint8_t dst_idx)
void ModelMixesPage::build(FormWindow * window)
{
scroll_win = window->getParent();
window->setFlexLayout();
window->padRow(lv_dpx(8));

form = new FormGroup(window, rect_t{});
form->setFlexLayout();
form->padRow(lv_dpx(4));
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3);

auto form_obj = form->getLvObj();
lv_obj_set_width(form_obj, lv_pct(100));
form = new FormWindow(window, rect_t{});
form->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3);

groups.clear();
lines.clear();
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/model_mixes.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ModelMixesPage : public ModelInputsPage

void addLineButton(uint8_t index) override;
void addLineButton(mixsrc_t src, uint8_t index) override;
InputMixGroup* createGroup(FormGroup* form, mixsrc_t src) override;
InputMixGroup* createGroup(FormWindow* form, mixsrc_t src) override;
InputMixButton* createLineButton(InputMixGroup* group,
uint8_t index) override;

Expand Down
30 changes: 13 additions & 17 deletions radio/src/gui/colorlcd/model_outputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,32 +293,28 @@ ModelOutputsPage::ModelOutputsPage() :

void ModelOutputsPage::build(FormWindow *window)
{
window->setFlexLayout();
window->padRow(lv_dpx(4));
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 3);

auto form = new FormGroup(window, rect_t{});
form->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(16));
form->padRow(lv_dpx(8));
form->padBottom(lv_dpx(4));
lv_obj_set_style_flex_cross_place(window->getLvObj(), LV_FLEX_ALIGN_START, 0);

auto form_obj = form->getLvObj();
lv_obj_set_style_flex_cross_place(form_obj, LV_FLEX_ALIGN_CENTER, 0);
auto box = new FormWindow(window, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, lv_dpx(8));
box->padRow(4);
lv_obj_set_style_flex_cross_place(box->getLvObj(), LV_FLEX_ALIGN_CENTER, 0);

new TextButton(form, rect_t{}, STR_ADD_ALL_TRIMS_TO_SUBTRIMS, [=]() {
new TextButton(box, rect_t{}, STR_ADD_ALL_TRIMS_TO_SUBTRIMS, [=]() {
moveTrimsToOffsets();
window->invalidate();
return 0;
});

auto box = new FormGroup(form, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
auto box2 = new FormWindow(box, rect_t{});
box2->setFlexLayout(LV_FLEX_FLOW_ROW, lv_dpx(8));
box2->setWidth(LV_SIZE_CONTENT);
lv_obj_set_style_flex_cross_place(box2->getLvObj(), LV_FLEX_ALIGN_CENTER, 0);

auto box_obj = box->getLvObj();
lv_obj_set_width(box_obj, LV_SIZE_CONTENT);
lv_obj_set_style_flex_cross_place(box_obj, LV_FLEX_ALIGN_CENTER, 0);

new StaticText(box, rect_t{}, STR_ELIMITS, 0, COLOR_THEME_PRIMARY1);
new CheckBox(box, rect_t{}, GET_SET_DEFAULT(g_model.extendedLimits));
new StaticText(box2, rect_t{}, STR_ELIMITS, 0, COLOR_THEME_PRIMARY1);
auto cb = new CheckBox(box2, rect_t{}, GET_SET_DEFAULT(g_model.extendedLimits));

for (uint8_t ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++) {

Expand Down
41 changes: 1 addition & 40 deletions radio/src/gui/colorlcd/model_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ struct ModelBitmapEdit : public FileChoice {
}
};

struct TimerBtnMatrix : public ButtonMatrix {
TimerBtnMatrix(Window* parent, const rect_t& rect);
void onPress(uint8_t btn_id) override;
bool isActive(uint8_t btn_id) override;
};

class SubScreenButton : public Button
{
std::string text;
Expand Down Expand Up @@ -233,7 +227,7 @@ static const lv_coord_t line_row_dsc[] = {LV_GRID_CONTENT,

void ModelSetupPage::build(FormWindow * window)
{
window->setFlexLayout();
window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 0);

FlexGridLayout grid(line_col_dsc, line_row_dsc, 2);

Expand Down Expand Up @@ -343,36 +337,3 @@ void ModelSetupPage::build(FormWindow * window)
lv_obj_set_grid_cell(btn->getLvObj(), LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1);
#endif
}

#define MAX_SUBSCREEN_BTNS 9

TimerBtnMatrix::TimerBtnMatrix(Window* parent, const rect_t& r) :
ButtonMatrix(parent, r)
{
initBtnMap(3, MAX_TIMERS);
setText(0, TR_TIMER "1");
setText(1, TR_TIMER "2");
setText(2, TR_TIMER "3");
update();

lv_btnmatrix_set_btn_width(lvobj, 3, 2);
lv_obj_set_width(lvobj, lv_pct(100));
lv_obj_set_height(lvobj, LV_DPI_DEF / 2);

lv_obj_set_style_bg_opa(lvobj, LV_OPA_0, 0);
lv_obj_set_style_pad_all(lvobj, lv_dpx(8), 0);

lv_obj_set_style_pad_row(lvobj, lv_dpx(8), 0);
lv_obj_set_style_pad_column(lvobj, lv_dpx(8), 0);
}

void TimerBtnMatrix::onPress(uint8_t btn_id)
{
if (btn_id >= MAX_TIMERS) return;
new TimerWindow((uint8_t)(btn_id));
}

bool TimerBtnMatrix::isActive(uint8_t btn_id)
{
return false;
}
Loading

0 comments on commit 8fc5a1c

Please sign in to comment.