Skip to content

Commit 2a46db9

Browse files
author
Jay
committed
Fix sprite fit scaling. Fix panel wrap padding bug
1 parent 335b3a9 commit 2a46db9

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/engine.zig

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ pub const Element = struct {
16171617
const src_scale: f32 = image_width / image_height;
16181618
if (src_scale >= dst_scale) {
16191619
// image too wide, hight will have blank space
1620-
dest.height = dest.width * src_scale;
1620+
dest.height = dest.width / src_scale;
16211621
// sprite is drawn at top of its rect, unless a
16221622
// different child alignment is chosen.
16231623
switch (element.child_align.y) {
@@ -1664,13 +1664,8 @@ pub const Element = struct {
16641664
},
16651665
}
16661666

1667-
//const source: Rect = .{
1668-
// .x = 0,
1669-
// .y = 0,
1670-
// .width = @as(f32, @floatFromInt(texture.texture.w)),
1671-
// .height = @as(f32, @floatFromInt(texture.texture.h)),
1672-
//};
1673-
//_ = sdl.SDL_RenderTexture(display.renderer, texture.texture, &source, @ptrCast(&dest));
1667+
if (element.style == .custom)
1668+
tint_texture(texture.texture, element.colour);
16741669

16751670
_ = sdl.SDL_RenderTexture(display.renderer, texture.texture, @ptrCast(&source), @ptrCast(&dest));
16761671
}
@@ -3622,9 +3617,7 @@ pub const Display = struct {
36223617
if (child.layout.position == .float) continue;
36233618
if (child.type == .expander) continue;
36243619

3625-
// Spacing is inserted before all items except the first item in a line/row
3626-
if (i > 0)
3627-
current.x += parent.type.panel.spacing;
3620+
current.x += parent.type.panel.spacing;
36283621
i += 1;
36293622

36303623
if (current.x + child.rect.width > line_end) {

0 commit comments

Comments
 (0)