Skip to content

Commit

Permalink
Only add scrollbar styles when scrollbar is needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed Dec 22, 2023
1 parent 783da75 commit 5a0e89e
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/curveedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CurveDataEdit::CurveDataEdit(Window* parent, const rect_t& rect,
uint8_t index) :
Window(parent, rect), index(index)
{
lv_obj_set_scrollbar_mode(lvobj, LV_SCROLLBAR_MODE_AUTO);
etx_scrollbar(lvobj);
}

#if LCD_W > LCD_H
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/input_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,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);
etx_scrollbar(box_obj);

#if LCD_H > LCD_W // portrait
box->setWidth(body.width() - 2 * lv_dpx(8));
Expand Down
4 changes: 2 additions & 2 deletions radio/src/gui/colorlcd/model_select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,8 @@ void ModelLabelsWindow::buildBody(Window *window)
lblselector->setMultiSelect(true);
lblselector->setSelected(modelslabels.filteredLabels());
updateFilteredLabels(modelslabels.filteredLabels(), false);
lv_obj_set_scrollbar_mode(lbl_obj, LV_SCROLLBAR_MODE_AUTO);
lv_obj_set_scrollbar_mode(mdl_obj, LV_SCROLLBAR_MODE_AUTO);
etx_scrollbar(lbl_obj);
etx_scrollbar(mdl_obj);

lblselector->setMultiSelectHandler([=](std::set<uint32_t> selected,
std::set<uint32_t> oldselection) {
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Page::Page(EdgeTxIcon icon, PaddingSize padding) :
etx_solid_bg(lvobj);
lv_obj_set_style_max_height(body.getLvObj(), LCD_H - MENU_HEADER_HEIGHT,
LV_PART_MAIN);
lv_obj_set_scrollbar_mode(body.getLvObj(), LV_SCROLLBAR_MODE_AUTO);
etx_scrollbar(body.getLvObj());

Layer::back()->hide();
Layer::push(this);
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/radio_theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ void ThemeSetupPage::setupListbox(Window *window, rect_t r,
ThemePersistance *tp)
{
listBox = new ListBox(window, r, tp->getNames());
lv_obj_set_scrollbar_mode(listBox->getLvObj(), LV_SCROLLBAR_MODE_AUTO);
etx_scrollbar(listBox->getLvObj());
listBox->setAutoEdit(true);
listBox->setSelected(currentTheme);
listBox->setActiveItem(tp->getThemeIndex());
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/tabsgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ TabsGroup::TabsGroup(EdgeTxIcon icon) :
{
etx_solid_bg(lvobj);
lv_obj_set_style_max_height(body.getLvObj(), MENU_BODY_HEIGHT, LV_PART_MAIN);
lv_obj_set_scrollbar_mode(body.getLvObj(), LV_SCROLLBAR_MODE_AUTO);
etx_scrollbar(body.getLvObj());

Layer::back()->hide();
Layer::push(this);
Expand Down
5 changes: 3 additions & 2 deletions radio/src/gui/colorlcd/themes/etx_lv_theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ LV_STYLE_CONST_SINGLE_INIT(EdgeTxStyles::pad_left_2, LV_STYLE_PAD_LEFT, 2);

// Scrollbar
const lv_style_const_prop_t scrollbar_props[] = {
LV_STYLE_CONST_BG_OPA(LV_OPA_50),
LV_STYLE_CONST_PAD_TOP(3), LV_STYLE_CONST_PAD_BOTTOM(3),
LV_STYLE_CONST_PAD_LEFT(3), LV_STYLE_CONST_PAD_RIGHT(3),
LV_STYLE_CONST_WIDTH(4), LV_STYLE_PROP_INV,
Expand Down Expand Up @@ -471,7 +472,7 @@ void etx_padding(lv_obj_t* obj, PaddingSize padding,
etx_obj_add_style(obj, styles->pad_large, selector);
break;
default:
etx_obj_add_style(obj, styles->pad_zero, selector);
// etx_obj_add_style(obj, styles->pad_zero, selector);
break;
};
}
Expand All @@ -486,11 +487,11 @@ void etx_std_style(lv_obj_t* obj, lv_style_selector_t selector,

void etx_scrollbar(lv_obj_t* obj)
{
etx_obj_add_style(obj, styles->bg_opacity_50, LV_PART_SCROLLBAR);
etx_obj_add_style(obj, styles->scrollbar, LV_PART_SCROLLBAR);
etx_obj_add_style(obj, styles->bg_color_grey, LV_PART_SCROLLBAR);
etx_obj_add_style(obj, styles->bg_opacity_cover,
LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
lv_obj_set_scrollbar_mode(obj, LV_SCROLLBAR_MODE_AUTO);
}

void etx_textarea_style(lv_obj_t* obj)
Expand Down
4 changes: 2 additions & 2 deletions radio/src/gui/colorlcd/view_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void ViewTextWindow::buildBody(Window* window)
lv_obj_add_flag(
obj, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_WITH_ARROW |
LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_CLICK_FOCUSABLE);
lv_obj_set_scrollbar_mode(obj, LV_SCROLLBAR_MODE_AUTO);
etx_scrollbar(obj);
// prevents resetting the group's edit mode
lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICK_FOCUSABLE);

Expand Down Expand Up @@ -333,7 +333,7 @@ class ViewChecklistWindow : public ViewTextWindow
lv_obj_add_flag(
obj, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_WITH_ARROW |
LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_CLICK_FOCUSABLE);
lv_obj_set_scrollbar_mode(obj, LV_SCROLLBAR_MODE_AUTO);
etx_scrollbar(obj);
// prevents resetting the group's edit mode
lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICK_FOCUSABLE);

Expand Down
1 change: 0 additions & 1 deletion radio/src/thirdparty/libopenui/src/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class BaseDialogForm : public Window
public:
BaseDialogForm(Window* parent, lv_coord_t width) : Window(parent, rect_t{})
{
lv_obj_set_scrollbar_mode(lvobj, LV_SCROLLBAR_MODE_AUTO);
etx_scrollbar(lvobj);
padAll(PAD_MEDIUM);
setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_MEDIUM, width, LV_SIZE_CONTENT);
Expand Down
2 changes: 1 addition & 1 deletion radio/src/thirdparty/libopenui/src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class MenuBody : public TableField
// Allow encoder acceleration
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_ENCODER_ACCEL);
// Add scroll bar if needed
lv_obj_set_scrollbar_mode(lvobj, LV_SCROLLBAR_MODE_AUTO);
etx_scrollbar(lvobj);

setColumnWidth(0, rect.w);

Expand Down
2 changes: 1 addition & 1 deletion radio/src/thirdparty/libopenui/src/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static void table_event(const lv_obj_class_t* class_p, lv_event_t* e)
TableField::TableField(Window* parent, const rect_t& rect) :
Window(parent, rect, OPAQUE, 0, table_create)
{
lv_obj_set_scrollbar_mode(lvobj, LV_SCROLLBAR_MODE_AUTO);
etx_scrollbar(lvobj);
lv_table_set_col_cnt(lvobj, 1);
}

Expand Down
10 changes: 2 additions & 8 deletions radio/src/thirdparty/libopenui/src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,9 @@

std::list<Window *> Window::trash;

static void window_base_constructor(const lv_obj_class_t *class_p,
lv_obj_t *obj)
{
etx_scrollbar(obj);
}

const lv_obj_class_t window_base_class = {
.base_class = &lv_obj_class,
.constructor_cb = window_base_constructor,
.constructor_cb = nullptr,
.destructor_cb = nullptr,
.user_data = nullptr,
.event_cb = nullptr,
Expand Down Expand Up @@ -111,7 +105,7 @@ Window::Window(Window *parent, const rect_t &rect, WindowFlags windowFlags,
if (rect.w) lv_obj_set_width(lvobj, rect.w);
if (rect.h) lv_obj_set_height(lvobj, rect.h);

lv_obj_set_scrollbar_mode(lvobj, LV_SCROLLBAR_MODE_OFF);
// lv_obj_set_scrollbar_mode(lvobj, LV_SCROLLBAR_MODE_OFF);
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_SCROLL_ELASTIC);

if (parent) {
Expand Down

0 comments on commit 5a0e89e

Please sign in to comment.