fix: alpha rendering in filelist_view

This commit is contained in:
CJ van den Berg 2024-11-18 21:21:30 +01:00
parent 031d57a54d
commit 572f74d8ba
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -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 { 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_base = theme.panel;
const style_hint: Widget.Theme.Style = .{ .fg = theme.editor_hint.fg, .fs = theme.editor_hint.fs, .bg = style_base.bg }; const style_label = if (button.active) theme.editor_cursor else if (button.hover or selected) theme.editor_selection else theme.panel;
const style_information: Widget.Theme.Style = .{ .fg = theme.editor_information.fg, .fs = theme.editor_information.fs, .bg = style_base.bg }; const style_hint: Widget.Theme.Style = .{ .fg = theme.editor_hint.fg, .fs = theme.editor_hint.fs, .bg = style_label.bg };
const style_warning: Widget.Theme.Style = .{ .fg = theme.editor_warning.fg, .fs = theme.editor_warning.fs, .bg = style_base.bg }; const style_information: Widget.Theme.Style = .{ .fg = theme.editor_information.fg, .fs = theme.editor_information.fs, .bg = style_label.bg };
const style_error: Widget.Theme.Style = .{ .fg = theme.editor_error.fg, .fs = theme.editor_error.fs, .bg = style_base.bg }; const style_warning: Widget.Theme.Style = .{ .fg = theme.editor_warning.fg, .fs = theme.editor_warning.fs, .bg = style_label.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_label.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_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 idx: usize = undefined;
var iter = button.opts.label; // label contains cbor, just the index var iter = button.opts.label; // label contains cbor, just the index
if (!(cbor.matchValue(&iter, cbor.extract(&idx)) catch false)) { 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.set_base_style(style_base);
button.plane.erase(); button.plane.erase();
button.plane.home(); 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 entry = &self.entries.items[idx];
const pointer = if (selected) "" else " "; const pointer = if (selected) "" else " ";
_ = button.plane.print("{s} ", .{pointer}) catch {}; _ = button.plane.print("{s} ", .{pointer}) catch {};
var buf: [std.fs.max_path_bytes]u8 = undefined; var buf: [std.fs.max_path_bytes]u8 = undefined;
var removed_prefix: usize = 0; var removed_prefix: usize = 0;
const max_len = self.view_cols / path_column_ratio; 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.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.cursor_move_yx(0, @intCast(max_len)) catch return false;
button.plane.set_style(style_separator); button.plane.set_style(style_separator);