Skip to content

Commit c80638c

Browse files
feat(shell): scrollbar
1 parent e4829fb commit c80638c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/shell/config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ struct config {
3535
float icon_padding = 4;
3636
float right_icon_padding = 20;
3737
float multibutton_line_gap = -6;
38+
float scrollbar_width = 6;
39+
float scrollbar_radius = 3;
3840

3941
std::string acrylic_color_light = "#fefefe00";
4042
std::string acrylic_color_dark = "#28282800";

src/shell/contextmenu/menu_widget.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,21 @@ void mb_shell::menu_widget::render(ui::nanovg_context ctx) {
350350
bg_submenu->render(ctx2);
351351
}
352352
render_children(ctx2, rendering_submenus);
353+
354+
// scrollbar
355+
if (height->dest() < actual_height) {
356+
auto scrollbar_width = config::current->context_menu.theme.scrollbar_width;
357+
auto scrollbar_height = height->dest() * height->dest() / actual_height;
358+
auto scrollbar_x = width->dest() - scrollbar_width - 2 + *x;
359+
auto scrollbar_y = *y - *scroll_top / (actual_height - height->dest()) *
360+
(height->dest() - scrollbar_height);
361+
362+
float c = menu_render::current.value()->light_color ? 0 : 1;
363+
ctx.fillColor(nvgRGBAf(c, c, c, 0.1));
364+
ctx.fillRoundedRect(scrollbar_x, scrollbar_y, scrollbar_width,
365+
scrollbar_height,
366+
config::current->context_menu.theme.scrollbar_radius);
367+
}
353368
}
354369
void mb_shell::menu_item_normal_widget::reset_appear_animation(float delay) {
355370
this->opacity->after_animate = [this](float dest) {

0 commit comments

Comments
 (0)