From 572f74d8bae1beb2c445f3a1624bdf7b529db3c9 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Mon, 18 Nov 2024 21:21:30 +0100 Subject: [PATCH] fix: alpha rendering in filelist_view --- src/tui/filelist_view.zig | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/tui/filelist_view.zig b/src/tui/filelist_view.zig index 8e392cf..e8096a7 100644 --- a/src/tui/filelist_view.zig +++ b/src/tui/filelist_view.zig @@ -130,13 +130,14 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool { } fn handle_render_menu(self: *Self, button: *Button.State(*Menu.State(*Self)), theme: *const Widget.Theme, selected: bool) bool { - const style_base = if (button.active) theme.editor_cursor else if (button.hover or selected) theme.editor_selection else theme.panel; - const style_hint: Widget.Theme.Style = .{ .fg = theme.editor_hint.fg, .fs = theme.editor_hint.fs, .bg = style_base.bg }; - const style_information: Widget.Theme.Style = .{ .fg = theme.editor_information.fg, .fs = theme.editor_information.fs, .bg = style_base.bg }; - const style_warning: Widget.Theme.Style = .{ .fg = theme.editor_warning.fg, .fs = theme.editor_warning.fs, .bg = style_base.bg }; - const style_error: Widget.Theme.Style = .{ .fg = theme.editor_error.fg, .fs = theme.editor_error.fs, .bg = style_base.bg }; - const style_separator: Widget.Theme.Style = .{ .fg = theme.editor_selection.bg, .bg = style_base.bg }; - // const style_error: Widget.Theme.Style = .{ .fg = theme.editor_error.fg, .fs = theme.editor_error.fs, .bg = style_base.bg }; + const style_base = theme.panel; + const style_label = if (button.active) theme.editor_cursor else if (button.hover or selected) theme.editor_selection else theme.panel; + const style_hint: Widget.Theme.Style = .{ .fg = theme.editor_hint.fg, .fs = theme.editor_hint.fs, .bg = style_label.bg }; + const style_information: Widget.Theme.Style = .{ .fg = theme.editor_information.fg, .fs = theme.editor_information.fs, .bg = style_label.bg }; + const style_warning: Widget.Theme.Style = .{ .fg = theme.editor_warning.fg, .fs = theme.editor_warning.fs, .bg = style_label.bg }; + const style_error: Widget.Theme.Style = .{ .fg = theme.editor_error.fg, .fs = theme.editor_error.fs, .bg = style_label.bg }; + const style_separator: Widget.Theme.Style = .{ .fg = theme.editor_selection.bg, .bg = style_label.bg }; + // const style_error: Widget.Theme.Style = .{ .fg = theme.editor_error.fg, .fs = theme.editor_error.fs, .bg = style_label.bg }; var idx: usize = undefined; var iter = button.opts.label; // label contains cbor, just the index if (!(cbor.matchValue(&iter, cbor.extract(&idx)) catch false)) { @@ -152,13 +153,17 @@ fn handle_render_menu(self: *Self, button: *Button.State(*Menu.State(*Self)), th button.plane.set_base_style(style_base); button.plane.erase(); button.plane.home(); + button.plane.set_style(style_label); + if (button.active or button.hover or selected) { + _ = button.plane.fill_width(" ", .{}) catch {}; + button.plane.home(); + } const entry = &self.entries.items[idx]; const pointer = if (selected) "⏵" else " "; _ = button.plane.print("{s} ", .{pointer}) catch {}; var buf: [std.fs.max_path_bytes]u8 = undefined; var removed_prefix: usize = 0; const max_len = self.view_cols / path_column_ratio; - button.plane.set_style(style_base); _ = button.plane.print("{s}:{d}", .{ root.shorten_path(&buf, entry.path, &removed_prefix, max_len - 7), entry.begin_line + 1 }) catch {}; button.plane.cursor_move_yx(0, @intCast(max_len)) catch return false; button.plane.set_style(style_separator);