feat: use panel background in filelist view scrollbar
This commit is contained in:
		
							parent
							
								
									f8213a8a85
								
							
						
					
					
						commit
						c53067a7cd
					
				
					 1 changed files with 12 additions and 0 deletions
				
			
		| 
						 | 
					@ -21,6 +21,7 @@ const MessageFilter = @import("MessageFilter.zig");
 | 
				
			||||||
const Menu = @import("Menu.zig");
 | 
					const Menu = @import("Menu.zig");
 | 
				
			||||||
const EventHandler = @import("EventHandler.zig");
 | 
					const EventHandler = @import("EventHandler.zig");
 | 
				
			||||||
const Button = @import("Button.zig");
 | 
					const Button = @import("Button.zig");
 | 
				
			||||||
 | 
					const scrollbar_v = @import("scrollbar_v.zig");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const escape = fmt.fmtSliceEscapeLower;
 | 
					const escape = fmt.fmtSliceEscapeLower;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,6 +69,7 @@ pub fn create(allocator: Allocator, parent: Plane) !Widget {
 | 
				
			||||||
            .on_click5 = mouse_click_button5,
 | 
					            .on_click5 = mouse_click_button5,
 | 
				
			||||||
        }),
 | 
					        }),
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					    self.menu.scrollbar.?.style_factory = scrollbar_style;
 | 
				
			||||||
    try self.commands.init(self);
 | 
					    try self.commands.init(self);
 | 
				
			||||||
    return Widget.to(self);
 | 
					    return Widget.to(self);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -78,6 +80,15 @@ pub fn deinit(self: *Self, a: Allocator) void {
 | 
				
			||||||
    a.destroy(self);
 | 
					    a.destroy(self);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fn scrollbar_style(sb: *scrollbar_v, theme: *const Widget.Theme) Widget.Theme.Style {
 | 
				
			||||||
 | 
					    return if (sb.active)
 | 
				
			||||||
 | 
					        .{ .fg = theme.scrollbar_active.fg, .bg = theme.panel.bg }
 | 
				
			||||||
 | 
					    else if (sb.hover)
 | 
				
			||||||
 | 
					        .{ .fg = theme.scrollbar_hover.fg, .bg = theme.panel.bg }
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        .{ .fg = theme.scrollbar.fg, .bg = theme.panel.bg };
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn handle_resize(self: *Self, pos: Widget.Box) void {
 | 
					pub fn handle_resize(self: *Self, pos: Widget.Box) void {
 | 
				
			||||||
    self.plane.move_yx(@intCast(pos.y), @intCast(pos.x)) catch return;
 | 
					    self.plane.move_yx(@intCast(pos.y), @intCast(pos.x)) catch return;
 | 
				
			||||||
    self.plane.resize_simple(@intCast(pos.h), @intCast(pos.w)) catch return;
 | 
					    self.plane.resize_simple(@intCast(pos.h), @intCast(pos.w)) catch return;
 | 
				
			||||||
| 
						 | 
					@ -195,6 +206,7 @@ fn mouse_click_button5(menu: **Menu.State(*Self), _: *Button.State(*Menu.State(*
 | 
				
			||||||
    if (self.view_pos < @max(self.entries.items.len, self.view_rows) - self.view_rows)
 | 
					    if (self.view_pos < @max(self.entries.items.len, self.view_rows) - self.view_rows)
 | 
				
			||||||
        self.view_pos += Menu.scroll_lines;
 | 
					        self.view_pos += Menu.scroll_lines;
 | 
				
			||||||
    self.update_selected();
 | 
					    self.update_selected();
 | 
				
			||||||
 | 
					    self.update_scrollbar();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn update_selected(self: *Self) void {
 | 
					fn update_selected(self: *Self) void {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue