dotfiles/scripts/playtwitch/src/theme.zig

48 lines
1.7 KiB
Zig
Raw Normal View History

2022-11-02 22:35:51 +01:00
const std = @import("std");
2022-10-29 21:49:44 +02:00
const c = @import("ffi.zig").c;
2022-11-02 22:35:51 +01:00
const log = std.log.scoped(.theme);
2022-10-29 21:49:44 +02:00
pub fn loadTheme(colors: [*]c.ImVec4) void {
2022-11-02 22:35:51 +01:00
log.info("loading theme", .{});
colors[c.ImGuiCol_ButtonHovered] = c.ImVec4{ .x = 0.7, .y = 0.49, .z = 0.9, .w = 1.0 };
colors[c.ImGuiCol_Button] = c.ImVec4{ .x = 0.33, .y = 0.14, .z = 0.51, .w = 1.0 };
2022-10-29 21:49:44 +02:00
colors[c.ImGuiCol_ChildBg] = c.ImVec4{ .x = 0.1, .y = 0.0, .z = 0.2, .w = 0.85 };
colors[c.ImGuiCol_FrameBg] = c.ImVec4{ .x = 0.45, .y = 0.2, .z = 0.69, .w = 1.0 };
colors[c.ImGuiCol_HeaderHovered] = c.ImVec4{ .x = 0.45, .y = 0.2, .z = 0.69, .w = 1.0 };
2022-11-02 22:35:51 +01:00
colors[c.ImGuiCol_Header] = c.ImVec4{ .x = 0.26, .y = 0.1, .z = 0.43, .w = 1.0 };
colors[c.ImGuiCol_TableHeaderBg] = c.ImVec4{ .x = 0.45, .y = 0.2, .z = 0.69, .w = 0.8 };
colors[c.ImGuiCol_TitleBgActive] = c.ImVec4{ .x = 0.33, .y = 0.14, .z = 0.51, .w = 1.0 };
colors[c.ImGuiCol_WindowBg] = c.ImVec4{ .x = 0.12, .y = 0.0, .z = 0.23, .w = 0.8 };
2022-10-29 21:49:44 +02:00
}
pub fn loadFont() !?*c.ImFont {
log.info("loading fonts", .{});
const fonts = [_][:0]const u8{
2023-05-02 16:54:34 +02:00
"/usr/share/fonts/TTF/IosevkaNerdFont-Regular.ttf",
"/usr/share/fonts/noto/NotoSans-Regular.ttf",
};
for (fonts) |font| {
const found = if (std.fs.accessAbsolute(font, .{})) |_|
true
else |e| if (e == error.FileNotFound)
2023-05-02 16:54:34 +02:00
false
else
return e;
if (found) {
log.info("using font {s}", .{font});
return c.ImFontAtlas_AddFontFromFileTTF(
c.igGetIO().*.Fonts,
font.ptr,
16,
null,
null,
);
}
}
return null;
}