Skip to content

Commit 491f72b

Browse files
author
Jay
committed
button icon_size is width/height not x/y
1 parent 06b8d26 commit 491f72b

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
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.10",
3+
.version = "0.3.0",
44
.fingerprint = 0xe8a81a8d0aa558d5,
55
.minimum_zig_version = "0.14.1",
66
.dependencies = .{

src/engine.zig

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ pub const Element = struct {
358358
text: []const u8 = "",
359359
translated: []const u8 = "",
360360
text_texture: ?*sdl.SDL_Texture = null,
361-
icon_size: Vector = .{ .x = 0, .y = 0 },
361+
icon_size: Size = .{ .width = 0, .height = 0 },
362362
spacing: f32 = 0,
363363
icon_default_name: ?[]const u8 = null,
364364
icon_hover: ?*TextureInfo = null,
@@ -1106,7 +1106,7 @@ pub const Element = struct {
11061106
if (self.type.button.text_texture) |_| {
11071107
height = display.text_height * display.scale; // * text_height;
11081108
}
1109-
height = @max(self.type.button.icon_size.y, height);
1109+
height = @max(self.type.button.icon_size.height, height);
11101110
height += (self.pad.top + self.pad.bottom);
11111111
return @max(self.minimum.height, height);
11121112
},
@@ -1139,10 +1139,10 @@ pub const Element = struct {
11391139
.button => {
11401140
var width: f32 = self.pad.left + self.pad.right;
11411141

1142-
width += self.type.button.icon_size.x;
1142+
width += self.type.button.icon_size.width;
11431143

11441144
// Do we need to pad between icon and text?
1145-
if (self.type.button.icon_size.x > 0 and self.type.button.text.len > 0) {
1145+
if (self.type.button.icon_size.width > 0 and self.type.button.text.len > 0) {
11461146
width += self.type.button.spacing;
11471147
}
11481148

@@ -1654,7 +1654,7 @@ pub const Element = struct {
16541654
}
16551655

16561656
// The inner content can contain a button and/or text texture.
1657-
var content_width = element.type.button.icon_size.x;
1657+
var content_width = element.type.button.icon_size.width;
16581658
if (element.type.button.text_texture) |texture| {
16591659
const size = text_size(display, texture, .normal);
16601660

@@ -1681,8 +1681,8 @@ pub const Element = struct {
16811681
var dest: Rect = .{
16821682
.x = element.rect.x + element.pad.left + content_offset,
16831683
.y = element.rect.y + element.pad.top,
1684-
.width = element.type.button.icon_size.x,
1685-
.height = element.type.button.icon_size.y,
1684+
.width = element.type.button.icon_size.width,
1685+
.height = element.type.button.icon_size.height,
16861686
};
16871687
dest.x += scroll_offset.x;
16881688
dest.y += scroll_offset.y;
@@ -1703,13 +1703,13 @@ pub const Element = struct {
17031703
if (element.type.button.text_texture) |texture| {
17041704
const size = text_size(display, texture, .normal);
17051705
var dest: Rect = .{
1706-
.x = element.rect.x + element.type.button.icon_size.x + element.pad.left + content_offset,
1706+
.x = element.rect.x + element.type.button.icon_size.width + element.pad.left + content_offset,
17071707
.y = element.rect.y + (element.rect.height / 2.0) - (size.height / 2),
17081708
.width = size.width,
17091709
.height = size.height,
17101710
};
17111711
dest = dest.move(&scroll_offset);
1712-
if (has_icon or element.type.button.icon_size.x > 0) {
1712+
if (has_icon or element.type.button.icon_size.width > 0) {
17131713
dest.x += element.type.button.spacing;
17141714
}
17151715
_ = sdl.SDL_SetTextureColorMod(texture, tint.r, tint.g, tint.b);
@@ -4342,7 +4342,7 @@ pub const Display = struct {
43424342
.text = "",
43434343
.translated = "",
43444344
.on_click = close_fn,
4345-
.icon_size = .{ .x = 70, .y = 70 },
4345+
.icon_size = .{ .width = 70, .height = 70 },
43464346
} },
43474347
.on_resized = back_button_resize,
43484348
},
@@ -4868,7 +4868,7 @@ pub fn setup_button(
48684868
if (element.type.button.icon_default_name) |icon_default| {
48694869
if (try display.load_texture_resource(allocator, icon_default)) |texture| {
48704870
element.texture = texture;
4871-
if (element.type.button.icon_size.x == 0 or element.type.button.icon_size.y == 0)
4871+
if (element.type.button.icon_size.width == 0 or element.type.button.icon_size.height == 0)
48724872
warn("button `{s}` has icon `{s}`, but no icon size.", .{ element.name, icon_default });
48734873
}
48744874
}

0 commit comments

Comments
 (0)