Skip to content

Commit 2cc885b

Browse files
committed
Element -> Entity
Bump to 0.12.0
1 parent ac4c88d commit 2cc885b

File tree

8 files changed

+17
-14
lines changed

8 files changed

+17
-14
lines changed

src/button.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ pub fn Button(comptime T: type) type {
104104
.width = self.icon_size.width,
105105
.height = self.icon_size.height,
106106
};
107-
dest = dest.move(&scroll_offset);
107+
dest = dest.move(scroll_offset);
108108
if (entity.flip.x) {
109109
dest.x += dest.width;
110110
dest.width = 0 - dest.width;
@@ -130,7 +130,7 @@ pub fn Button(comptime T: type) type {
130130
if (entity.type.button.icon_size.width == 0 or entity.type.button.icon_size.height == 0) {
131131
dest.x = entity.rect.x + entity.rect.width / 2 - size.width / 2;
132132
}
133-
dest = dest.move(&scroll_offset);
133+
dest = dest.move(scroll_offset);
134134
if (has_icon or entity.type.button.icon_size.width > 0) {
135135
dest.x += entity.type.button.spacing;
136136
}

src/checkbox.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn Checkbox(comptime T: type) type {
3737
.width = checkbox.width,
3838
.height = checkbox.height,
3939
};
40-
dest = dest.move(&scroll_offset);
40+
dest = dest.move(scroll_offset);
4141
if (self.checked) {
4242
if (self.on_texture) |texture| {
4343
_ = sdl.SDL_RenderTexture(display.renderer, texture.texture, null, @ptrCast(&dest));

src/engine.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,12 +3040,15 @@ pub const Clip = @import("entity.zig").Clip;
30403040
pub const Entity = @import("entity.zig").Entity;
30413041
pub const Fit = @import("entity.zig").Fit;
30423042
pub const LayoutSize = @import("entity.zig").LayoutSize;
3043+
pub const LayoutAlign = @import("entity.zig").LayoutAlign;
3044+
pub const LayoutMode = @import("entity.zig").LayoutMode;
30433045
pub const Rect = @import("entity.zig").Rect;
30443046
pub const Scale = @import("entity.zig").Scale;
30453047
pub const Size = @import("entity.zig").Size;
30463048
pub const TextElement = @import("entity.zig").TextElement;
30473049
pub const ToggleState = @import("entity.zig").ToggleState;
30483050
pub const Vector = @import("entity.zig").Vector;
3051+
pub const Visibility = @import("entity.zig").Visibility;
30493052

30503053
pub const Button = @import("button.zig").Button;
30513054
pub const Checkbox = @import("checkbox.zig").Checkbox;

src/entity.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ pub fn Entity(comptime T: type) type {
10251025
// Buttons do not use the background.image or backgroud.image_name
10261026
// field, so don't draw background image for buttons.
10271027
if (entity.type != .button) {
1028-
var dest = entity.rect.move(&scroll_offset);
1028+
var dest = entity.rect.move(scroll_offset);
10291029
if (entity.flip.x) {
10301030
dest.x += dest.width;
10311031
dest.width = 0 - dest.width;
@@ -1088,7 +1088,7 @@ pub fn Entity(comptime T: type) type {
10881088
display.renderer,
10891089
2,
10901090
colour,
1091-
entity.rect.move(&scroll_offset),
1091+
entity.rect.move(scroll_offset),
10921092
.{},
10931093
);
10941094
if (entity.type == .panel and (entity.type.panel.scrollable.scroll.x or entity.type.panel.scrollable.scroll.y)) {
@@ -1100,7 +1100,7 @@ pub fn Entity(comptime T: type) type {
11001100
.{},
11011101
);
11021102
} else if (entity.type == .label) {
1103-
var pad_line = entity.rect.move(&scroll_offset);
1103+
var pad_line = entity.rect.move(scroll_offset);
11041104
pad_line.x += entity.pad.left;
11051105
pad_line.y += entity.pad.top;
11061106
pad_line.width -= (entity.pad.left + entity.pad.right);
@@ -1122,7 +1122,7 @@ pub fn Entity(comptime T: type) type {
11221122
display.renderer,
11231123
entity.border_width,
11241124
entity.border_colour,
1125-
entity.rect.move(&scroll_offset),
1125+
entity.rect.move(scroll_offset),
11261126
.{},
11271127
);
11281128
}
@@ -1134,7 +1134,7 @@ pub fn Entity(comptime T: type) type {
11341134
draw_selection_marker(
11351135
display,
11361136
display.theme.cursor_colour,
1137-
entity.rect.move(&scroll_offset),
1137+
entity.rect.move(scroll_offset),
11381138
);
11391139
}
11401140
}
@@ -2132,7 +2132,7 @@ pub const Rect = extern struct {
21322132
height: f32 = 0,
21332133

21342134
/// Add the x and y value from the `other` vector to this vector.
2135-
pub fn move(self: *const Rect, offset: *const Vector) Rect {
2135+
pub fn move(self: *const Rect, offset: Vector) Rect {
21362136
return .{
21372137
.x = self.x + offset.x,
21382138
.y = self.y + offset.y,

src/label.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub fn draw_text_elements(
108108
parent_clip: ?Clip,
109109
) void {
110110
for (items) |*item| {
111-
const pos = item.location.move(&loc);
111+
const pos = item.location.move(loc);
112112
if (parent_clip) |clip| {
113113
if (pos.x + pos.width < clip.left) continue;
114114
if (pos.y + pos.height + 1 < clip.top) continue;
@@ -470,7 +470,7 @@ test "shrunk_label_in_panel" {
470470

471471
// Where would the draw function theoretically put this element
472472
const loc = Vector{ .x = child.rect.x, .y = child.rect.y };
473-
const would_draw_at = child.type.label.elements.items[0].location.move(&loc);
473+
const would_draw_at = child.type.label.elements.items[0].location.move(loc);
474474
try eq(74, would_draw_at.x);
475475
try eq(2, would_draw_at.y);
476476
}

src/progress_bar.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn ProgressBar(comptime T: type) type {
2020
.width = entity.rect.width - entity.pad.left - entity.pad.right,
2121
.height = entity.rect.height - entity.pad.top - entity.pad.bottom,
2222
};
23-
dest = dest.move(&scroll_offset);
23+
dest = dest.move(scroll_offset);
2424
var corner: f32 = entity.background.corner_radius;
2525
if (corner * 2 > dest.height) corner = dest.height / 2;
2626

src/rectangle.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn Rectangle(comptime T: type) type {
1919
colour.b,
2020
colour.a,
2121
);
22-
var dest = entity.rect.move(&scroll_offset);
22+
var dest = entity.rect.move(scroll_offset);
2323
_ = sdl.SDL_RenderFillRect(display.renderer, @ptrCast(&dest));
2424
}
2525
};

src/sprite.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn Sprite(comptime T: type) type {
2323
.width = entity.rect.width - entity.pad.left - entity.pad.right,
2424
.height = entity.rect.height - entity.pad.top - entity.pad.bottom,
2525
};
26-
dest = dest.move(&scroll_offset);
26+
dest = dest.move(scroll_offset);
2727

2828
if (dest.height <= 0 or dest.width <= 0) return;
2929

0 commit comments

Comments
 (0)