summaryrefslogtreecommitdiff
path: root/core/colors.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/colors.zig')
-rw-r--r--core/colors.zig23
1 files changed, 22 insertions, 1 deletions
diff --git a/core/colors.zig b/core/colors.zig
index 84595a30..f0b01c71 100644
--- a/core/colors.zig
+++ b/core/colors.zig
@@ -764,7 +764,8 @@ pub fn loadThemeFile(p: *Pardes, generation: u32, bytes: []const u8) bool {
}
pub fn finishThemeInitialization(p: *Pardes) void {
- p.chrome = ChromeTheme.fromTheme(p.theme());
+ // The session's own theme's: never one a view wears (`wear`).
+ p.chrome = ChromeTheme.fromTheme(if (p.custom_theme) |*custom| custom else &themes[p.settings.theme]);
}
/// Themes near `name`, a line of them, for a Theme given a name there is
@@ -832,6 +833,26 @@ pub fn themeIndex(name: []const u8) ?usize {
return null;
}
+/// The live view wears theme `index` while a state previews themes (`:theme
+/// `, a Themes picker): the whole window drawn in it, no pane dimmed; null,
+/// its own again. Nothing is loaded or set: `theme()` and `chromeTheme()`
+/// read what the view wears, and rest (TagState.toRest) takes it off.
+pub fn wear(p: *Pardes, index: ?usize) void {
+ const s = &p.view().tag_state;
+ s.worn = if (index) |i| (if (i < themes.len) @intCast(i) else null) else null;
+ s.previewing = if (s.worn != null) .full else .empty;
+ wornChrome(p);
+}
+
+/// The chrome of the theme the live view wears, worked out once a theme
+/// (its contrast searches take pow calls): `wear`'s, and a frame's first
+/// step's, for a view that wears another than the last one worked out.
+pub fn wornChrome(p: *Pardes) void {
+ const i = p.view().tag_state.worn orelse return;
+ if (p.worn_chrome) |w| if (w.index == i) return;
+ p.worn_chrome = .{ .index = i, .chrome = ChromeTheme.fromTheme(&themes[i]) };
+}
+
pub fn setThemeIndex(p: *Pardes, index: usize) void {
if (index >= themes.len or
(p.custom_theme == null and p.theme_file_path.get().len == 0 and