refactor: render unfocused tabs with style from theme
This commit is contained in:
parent
18f4d9cef3
commit
95cb63c42a
1 changed files with 74 additions and 2 deletions
|
|
@ -610,8 +610,14 @@ const Tab = struct {
|
||||||
const mode: Mode = if (btn.hover) .selected else if (active) .active else .inactive;
|
const mode: Mode = if (btn.hover) .selected else if (active) .active else .inactive;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
.selected => self.render_selected(&btn.plane, btn.opts.label, btn.hover, theme, active),
|
.selected => self.render_selected(&btn.plane, btn.opts.label, btn.hover, theme, active),
|
||||||
.active => self.render_active(&btn.plane, btn.opts.label, btn.hover, theme),
|
.active => if (self.is_focused())
|
||||||
.inactive => self.render_inactive(&btn.plane, btn.opts.label, btn.hover, theme),
|
self.render_active(&btn.plane, btn.opts.label, btn.hover, theme)
|
||||||
|
else
|
||||||
|
self.render_unfocused_active(&btn.plane, btn.opts.label, btn.hover, theme),
|
||||||
|
.inactive => if (self.is_focused())
|
||||||
|
self.render_inactive(&btn.plane, btn.opts.label, btn.hover, theme)
|
||||||
|
else
|
||||||
|
self.render_unfocused_inactive(&btn.plane, btn.opts.label, btn.hover, theme),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -733,6 +739,72 @@ const Tab = struct {
|
||||||
plane.home();
|
plane.home();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn render_unfocused_active(self: *@This(), plane: *Plane, label: []const u8, hover: bool, theme: *const Widget.Theme) void {
|
||||||
|
plane.set_base_style(theme.editor);
|
||||||
|
plane.erase();
|
||||||
|
plane.home();
|
||||||
|
plane.set_style(.{
|
||||||
|
.fg = self.tab_style.inactive_fg.from_theme(theme),
|
||||||
|
.bg = self.tab_style.inactive_bg.from_theme(theme),
|
||||||
|
});
|
||||||
|
plane.fill(" ");
|
||||||
|
plane.home();
|
||||||
|
plane.set_style(.{
|
||||||
|
.fg = self.tab_style.active_fg.from_theme(theme),
|
||||||
|
.bg = self.tab_style.active_bg.from_theme(theme),
|
||||||
|
});
|
||||||
|
plane.fill(" ");
|
||||||
|
plane.home();
|
||||||
|
|
||||||
|
plane.set_style(.{
|
||||||
|
.fg = self.tab_style.active_left_fg.from_theme(theme),
|
||||||
|
.bg = self.tab_style.active_left_bg.from_theme(theme),
|
||||||
|
});
|
||||||
|
_ = plane.putstr(self.tab_style.unfocused_active_left) catch {};
|
||||||
|
|
||||||
|
plane.set_style(.{
|
||||||
|
.fg = self.tab_style.unfocused_active_fg.from_theme(theme),
|
||||||
|
.bg = self.tab_style.active_bg.from_theme(theme),
|
||||||
|
});
|
||||||
|
self.render_content(plane, label, hover, self.tab_style.unfocused_active_fg.from_theme(theme), theme);
|
||||||
|
|
||||||
|
plane.set_style(.{
|
||||||
|
.fg = self.tab_style.active_right_fg.from_theme(theme),
|
||||||
|
.bg = self.tab_style.active_right_bg.from_theme(theme),
|
||||||
|
});
|
||||||
|
_ = plane.putstr(self.tab_style.unfocused_active_right) catch {};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render_unfocused_inactive(self: *@This(), plane: *Plane, label: []const u8, hover: bool, theme: *const Widget.Theme) void {
|
||||||
|
plane.set_base_style(theme.editor);
|
||||||
|
plane.erase();
|
||||||
|
plane.home();
|
||||||
|
plane.set_style(.{
|
||||||
|
.fg = self.tab_style.inactive_fg.from_theme(theme),
|
||||||
|
.bg = self.tab_style.inactive_bg.from_theme(theme),
|
||||||
|
});
|
||||||
|
plane.fill(" ");
|
||||||
|
plane.home();
|
||||||
|
|
||||||
|
plane.set_style(.{
|
||||||
|
.fg = self.tab_style.inactive_left_fg.from_theme(theme),
|
||||||
|
.bg = self.tab_style.inactive_left_bg.from_theme(theme),
|
||||||
|
});
|
||||||
|
_ = plane.putstr(self.tab_style.unfocused_inactive_left) catch {};
|
||||||
|
|
||||||
|
plane.set_style(.{
|
||||||
|
.fg = self.tab_style.inactive_fg.from_theme(theme),
|
||||||
|
.bg = self.tab_style.inactive_bg.from_theme(theme),
|
||||||
|
});
|
||||||
|
self.render_content(plane, label, hover, self.tab_style.unfocused_inactive_fg.from_theme(theme), theme);
|
||||||
|
|
||||||
|
plane.set_style(.{
|
||||||
|
.fg = self.tab_style.inactive_right_fg.from_theme(theme),
|
||||||
|
.bg = self.tab_style.inactive_right_bg.from_theme(theme),
|
||||||
|
});
|
||||||
|
_ = plane.putstr(self.tab_style.unfocused_inactive_right) catch {};
|
||||||
|
}
|
||||||
|
|
||||||
fn render_content(self: *@This(), plane: *Plane, label: []const u8, hover: bool, fg: ?Widget.Theme.Color, theme: *const Widget.Theme) void {
|
fn render_content(self: *@This(), plane: *Plane, label: []const u8, hover: bool, fg: ?Widget.Theme.Color, theme: *const Widget.Theme) void {
|
||||||
const buffer_manager = tui.get_buffer_manager() orelse @panic("tabs no buffer manager");
|
const buffer_manager = tui.get_buffer_manager() orelse @panic("tabs no buffer manager");
|
||||||
const buffer_ = buffer_manager.buffer_from_ref(self.buffer_ref);
|
const buffer_ = buffer_manager.buffer_from_ref(self.buffer_ref);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue