Skip to content

Commit ead1d48

Browse files
author
Jay
committed
Make button custom text colour apply to icon
1 parent 6502ffa commit ead1d48

File tree

2 files changed

+11
-23
lines changed

2 files changed

+11
-23
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.7.5",
3+
.version = "0.7.6",
44
.fingerprint = 0xe8a81a8d0aa558d5,
55
.minimum_zig_version = "0.15.2",
66
.dependencies = .{

src/engine.zig

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -592,19 +592,13 @@ pub const Element = struct {
592592
return true;
593593
}
594594

595-
inline fn button_tint(self: *Element, theme: *Theme) Colour {
596-
if (self.type.button.style == .success) {
597-
return theme.success_text_colour;
598-
}
599-
if (self.type.button.style == .failed) {
600-
return theme.failed_text_colour;
601-
}
602-
if (self.pressed) {
603-
return theme.tinted_text_colour;
604-
}
605-
if (self.hovered) {
606-
return theme.tinted_text_colour;
607-
}
595+
inline fn button_text_tint(self: *Element, theme: *Theme) Colour {
596+
if (self.type.button.style == .success) return theme.success_text_colour;
597+
if (self.type.button.style == .failed) return theme.failed_text_colour;
598+
if (self.type.button.style == .custom) return self.colour;
599+
if (self.pressed) return theme.tinted_text_colour;
600+
if (self.hovered) return theme.tinted_text_colour;
601+
608602
return theme.text_colour;
609603
}
610604

@@ -624,7 +618,8 @@ pub const Element = struct {
624618
return;
625619
},
626620
.custom => {
627-
tint_texture(texture, self.background.colour);
621+
if (self.background.colour.a != engine.TRANSPARENT.a)
622+
tint_texture(texture, self.background.colour);
628623
return;
629624
},
630625
else => {
@@ -1610,13 +1605,6 @@ pub const Element = struct {
16101605
};
16111606
source.y = (image_height - source.h) / 2;
16121607
}
1613-
err("img={d}x{d} scale={d} src={d}x{d}", .{
1614-
image_width,
1615-
image_height,
1616-
dst_scale,
1617-
source.w,
1618-
source.h,
1619-
});
16201608
},
16211609
}
16221610

@@ -1770,7 +1758,7 @@ pub const Element = struct {
17701758
.end => element.rect.width - content_width,
17711759
};
17721760

1773-
const tint = element.button_tint(display.theme);
1761+
const tint = element.button_text_tint(display.theme);
17741762
var has_icon = false;
17751763
if (element.current_icon()) |icon_image| {
17761764
has_icon = true;

0 commit comments

Comments
 (0)