diff --git a/src/renderer/vaxis/Plane.zig b/src/renderer/vaxis/Plane.zig index fe5ad76..4ef18fb 100644 --- a/src/renderer/vaxis/Plane.zig +++ b/src/renderer/vaxis/Plane.zig @@ -286,7 +286,7 @@ pub inline fn set_base_style(self: *Plane, _: [*c]const u8, style_: Style) void pub fn set_base_style_transparent(self: *Plane, _: [*:0]const u8, style_: Style) void { self.style_base.fg = if (style_.fg) |color| vaxis.Cell.Color.rgbFromUint(@intCast(color)) else .default; - self.style.bg = .default; + self.style_base.bg = if (style_.bg) |color| vaxis.Cell.Color.rgbFromUint(@intCast(color)) else .default; if (style_.fs) |fs| set_font_style(&self.style, fs); self.set_style(style_); self.transparent = true; @@ -294,7 +294,7 @@ pub fn set_base_style_transparent(self: *Plane, _: [*:0]const u8, style_: Style) pub fn set_base_style_bg_transparent(self: *Plane, _: [*:0]const u8, style_: Style) void { self.style_base.fg = if (style_.fg) |color| vaxis.Cell.Color.rgbFromUint(@intCast(color)) else .default; - self.style.bg = .default; + self.style_base.bg = if (style_.bg) |color| vaxis.Cell.Color.rgbFromUint(@intCast(color)) else .default; if (style_.fs) |fs| set_font_style(&self.style, fs); self.set_style(style_); self.transparent = true; @@ -309,7 +309,7 @@ pub inline fn set_style(self: *Plane, style_: Style) void { pub inline fn set_style_bg_transparent(self: *Plane, style_: Style) void { if (style_.fg) |color| self.style.fg = vaxis.Cell.Color.rgbFromUint(@intCast(color)); - self.style.bg = .default; + if (style_.bg) |color| self.style.bg = vaxis.Cell.Color.rgbFromUint(@intCast(color)); if (style_.fs) |fs| set_font_style(&self.style, fs); self.transparent = true; } diff --git a/src/tui/home.zig b/src/tui/home.zig index 5ea374c..8593d06 100644 --- a/src/tui/home.zig +++ b/src/tui/home.zig @@ -78,6 +78,7 @@ fn menu_on_render(_: *Self, button: *Button.State(*Menu.State(*Self)), theme: *c const style_base = if (button.active) theme.editor_cursor else if (button.hover or selected) theme.editor_selection else theme.editor; if (button.active or button.hover or selected) { button.plane.set_base_style(" ", style_base); + button.plane.erase(); } else { button.plane.set_base_style_bg_transparent(" ", style_base); } @@ -85,10 +86,18 @@ fn menu_on_render(_: *Self, button: *Button.State(*Menu.State(*Self)), theme: *c const style_text = if (tui.find_scope_style(theme, "keyword")) |sty| sty.style else theme.editor; const style_keybind = if (tui.find_scope_style(theme, "entity.name")) |sty| sty.style else theme.editor; const sep = std.mem.indexOfScalar(u8, button.opts.label, ':') orelse button.opts.label.len; - button.plane.set_style_bg_transparent(style_text); + if (button.active or button.hover or selected) { + button.plane.set_style(style_text); + } else { + button.plane.set_style_bg_transparent(style_text); + } const pointer = if (selected) "⏵" else " "; _ = button.plane.print("{s}{s}", .{ pointer, button.opts.label[0..sep] }) catch {}; - button.plane.set_style_bg_transparent(style_keybind); + if (button.active or button.hover or selected) { + button.plane.set_style(style_keybind); + } else { + button.plane.set_style_bg_transparent(style_keybind); + } _ = button.plane.print("{s}", .{button.opts.label[sep + 1 ..]}) catch {}; return false; }