Skip to content

Commit fd2750a

Browse files
committed
fix(UI): set sidebar width based on content
1 parent cbc8b60 commit fd2750a

File tree

84 files changed

+13
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+13
-2
lines changed

src/UI/Screens/Home/HomeView.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace UI
1313
HomeView* HomeView::s_overrideInstance = nullptr;
1414
std::atomic<bool> HomeView::s_instanceInitialized = false;
1515

16-
static constexpr int32_t s_layoutColDsc[] = {LV_GRID_FR(1),
16+
static constexpr int32_t s_layoutColDsc[] = {LV_GRID_CONTENT,
1717
LV_GRID_FR(9),
1818
#if CONSOLE_SIDE_PANEL
1919
LV_GRID_FR(5),
@@ -41,7 +41,7 @@ namespace UI
4141
setLayoutStyle(LV_LAYOUT_GRID);
4242
setGridDsc(s_layoutColDsc, s_layoutRowDsc);
4343
setGridCell(m_statusBar, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_START, 0, 1);
44-
setGridCell(m_sideBar, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_STRETCH, 0, 2);
44+
setGridCell(m_sideBar, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_STRETCH, 0, 2);
4545
setGridCell(m_mainWindow, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_STRETCH, 1, 1);
4646
#if CONSOLE_SIDE_PANEL
4747
setGridCell(m_consoleView, LV_GRID_ALIGN_STRETCH, 2, 1, LV_GRID_ALIGN_STRETCH, 1, 1);
@@ -55,6 +55,7 @@ namespace UI
5555
m_files.setSize(LV_PCT(100), LV_PCT(100));
5656

5757
// Main Window Layout
58+
m_sideBar.setWidth(LV_SIZE_CONTENT);
5859
m_sideBar.moveToFront();
5960
#if !CONSOLE_SIDE_PANEL
6061
m_consoleView.hide();

src/UI/Styles/Themes/SoftTheme.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,7 @@ namespace UI::Themes
129129
lv_style_merge(components.file, lvgl.bg_light);
130130
lv_style_set_pad_hor(components.file, 16);
131131
lv_style_set_pad_ver(components.file, 14);
132+
133+
lv_style_set_pad_all(components.sidebar_btn, 16);
132134
});
133135
} // namespace UI::Themes

src/UI/Widgets/SideBar/SideBar.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ namespace UI
3131
setFlag(LV_OBJ_FLAG_SCROLLABLE, false);
3232

3333
m_btns.setSize(LV_PCT(100), LV_PCT(100));
34+
m_btns.setMinWidth(LV_SIZE_CONTENT);
3435
m_btns.setFlexFlow(LV_FLEX_FLOW_COLUMN);
3536
m_btns.setFlexAlign(LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
3637

3738
m_btns.setFlag(LV_OBJ_FLAG_SCROLLABLE, false);
3839

3940
m_homeBtn.setWidth(LV_PCT(100));
41+
m_homeBtn.setMinWidth(LV_SIZE_CONTENT);
4042
m_homeBtn.setFlexGrow(1);
4143
m_homeBtn.setText(_("side_bar.home"));
4244
m_homeBtn.setIcon("home.png");
@@ -46,6 +48,7 @@ namespace UI
4648

4749
#if SIDE_BAR_BACK_BUTTON
4850
m_backBtn.setWidth(LV_PCT(100));
51+
m_backBtn.setMinWidth(LV_SIZE_CONTENT);
4952
m_backBtn.setFlexGrow(1);
5053
m_backBtn.setText(_("side_bar.back"));
5154
m_backBtn.setIcon("back.png");
@@ -55,6 +58,7 @@ namespace UI
5558
#endif
5659

5760
m_controlBtn.setWidth(LV_PCT(100));
61+
m_controlBtn.setMinWidth(LV_SIZE_CONTENT);
5862
m_controlBtn.setFlexGrow(1);
5963
m_controlBtn.setText(_("side_bar.control"));
6064
m_controlBtn.setIcon("control.png");
@@ -63,6 +67,7 @@ namespace UI
6367
m_controlBtn.getLabel().setLongMode(LV_LABEL_LONG_MODE_CLIP);
6468

6569
m_filesBtn.setWidth(LV_PCT(100));
70+
m_filesBtn.setMinWidth(LV_SIZE_CONTENT);
6671
m_filesBtn.setFlexGrow(1);
6772
m_filesBtn.setText(_("side_bar.files"));
6873
m_filesBtn.setIcon("macros.png");
@@ -72,6 +77,7 @@ namespace UI
7277

7378
#if SIDE_BAR_APP_DRAWER
7479
m_menuBtn.setWidth(LV_PCT(100));
80+
m_menuBtn.setMinWidth(LV_SIZE_CONTENT);
7581
m_menuBtn.setFlexGrow(1);
7682
m_menuBtn.setText(_("side_bar.menu"));
7783
m_menuBtn.setIcon(APP_DRAWER_ICON);
@@ -82,6 +88,7 @@ namespace UI
8288

8389
#if SIDE_BAR_CONSOLE_BUTTON
8490
m_consoleBtn.setWidth(LV_PCT(100));
91+
m_consoleBtn.setMinWidth(LV_SIZE_CONTENT);
8592
m_consoleBtn.setFlexGrow(1);
8693
m_consoleBtn.setText(_("side_bar.console"));
8794
m_consoleBtn.setIcon("console.png");
@@ -93,6 +100,7 @@ namespace UI
93100

94101
#if SIDE_BAR_SETTINGS_BUTTON
95102
m_settingsBtn.setWidth(LV_PCT(100));
103+
m_settingsBtn.setMinWidth(LV_SIZE_CONTENT);
96104
m_settingsBtn.setFlexGrow(1);
97105
m_settingsBtn.setText(_("side_bar.settings"));
98106
m_settingsBtn.setIcon("settings.png");
92 Bytes
85 Bytes
8 Bytes
85 Bytes
-56 Bytes
1 Byte
12 Bytes

0 commit comments

Comments
 (0)