Skip to content

Commit 775712a

Browse files
author
Jay
committed
Separate faded text and background
1 parent 6198b48 commit 775712a

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.{
22
.name = .engine,
3-
.version = "0.2.5",
3+
.version = "0.2.6",
44
.fingerprint = 0xe8a81a8d0aa558d5,
55
.minimum_zig_version = "0.14.1",
66
.dependencies = .{

src/csv_reader.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ test "reader" {
164164
try expectEqual(Token.field, i.next());
165165
try expectEqualStrings("b\n1", i.value);
166166
try expectEqual(Token.field, i.next());
167-
std.log.err("remaining '{s}'", .{i.data});
168167
try expectEqualStrings("c1", i.value);
169168
try expectEqual(Token.field, i.next());
170169
try expectEqualStrings("d,1", i.value);

src/engine.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ pub const Element = struct {
13381338
_: ?Clip,
13391339
scroll_offset: Vector,
13401340
) void {
1341-
const colour = element.type.rectangle.style.from(display.theme, element.background_colour);
1341+
const colour = element.type.rectangle.style.panel(display.theme, element.background_colour);
13421342
_ = sdl.SDL_SetRenderDrawColor(
13431343
display.renderer,
13441344
colour.r,
@@ -2094,14 +2094,15 @@ inline fn draw_text_elements(
20942094
}
20952095
}
20962096

2097-
// Only do rendering if display parameter is provided
2098-
const current_colour = text_colour.from(display.theme, element.colour);
2097+
// Only render text if display parameter is provided
2098+
const current_colour = text_colour.text(display.theme, element.colour);
20992099
_ = sdl.SDL_SetTextureColorMod(
21002100
item.texture,
21012101
current_colour.r,
21022102
current_colour.g,
21032103
current_colour.b,
21042104
);
2105+
_ = sdl.SDL_SetTextureAlphaMod(item.texture, current_colour.a);
21052106
_ = sdl.SDL_RenderTexture(
21062107
display.renderer,
21072108
item.texture,

src/theme.zig

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub const ThemeColour = enum {
5151
background,
5252
custom,
5353

54-
pub fn from(self: ThemeColour, theme: *Theme, custom: Colour) Colour {
54+
pub fn text(self: ThemeColour, theme: *Theme, custom: Colour) Colour {
5555
return switch (self) {
5656
.normal => theme.text_colour,
5757
.faded => theme.faded_panel_colour,
@@ -63,6 +63,19 @@ pub const ThemeColour = enum {
6363
.custom => custom,
6464
};
6565
}
66+
67+
pub fn panel(self: ThemeColour, theme: *Theme, custom: Colour) Colour {
68+
return switch (self) {
69+
.normal => theme.text_colour,
70+
.background => theme.background_colour,
71+
.tinted => theme.tinted_text_colour,
72+
.faded => theme.faded_panel_colour,
73+
.emphasised => theme.emphasised_panel_colour,
74+
.success => theme.success_panel_colour,
75+
.failed => theme.failed_panel_colour,
76+
.custom => custom,
77+
};
78+
}
6679
};
6780

6881
/// The `Display` is prefilled with this usable set of default themes on

src/translation.zig

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ pub const Translation = struct {
5959
err("load_translation_data has invalid languge code: '{s}'", .{i.value});
6060
return;
6161
}
62-
err("saw {s}, {s}", .{ i.value, @tagName(lr) });
6362
try self.maps.put(allocator, lr, .empty);
6463
try headers.append(allocator, self.maps.getPtr(lr).?);
6564
},
@@ -81,20 +80,12 @@ pub const Translation = struct {
8180
continue;
8281
},
8382
.field => {
84-
// read the key from the first column
8583
const key = i.value;
86-
//try headers.items[0].*.put(allocator, key, key);
87-
// read the translations in the next columns
88-
//if (i.next() != .field) {
89-
// err("load_translation_data expecting a translation field on line {d}.", .{line});
90-
// return;
91-
//}
9284
col = 0;
9385
var n: Token = .eof;
9486
while (col < headers.items.len) : (col += 1) {
9587
n = i.next();
9688
if (n == .field) {
97-
err("saw {d}, {s}={s}", .{ col, key, i.value });
9889
try headers.items[col].*.put(allocator, key, i.value);
9990
} else if (n == .eol or n == .eof) {
10091
// Handle case where last column(s) are empty

0 commit comments

Comments
 (0)