[Fix] Wron size when fit constraint is used

This commit is contained in:
Frank 2022-08-16 22:29:00 +02:00
parent 883a7100a5
commit 8ef0d82ed6

View file

@ -42,7 +42,12 @@ public class Image extends CustomRenderComponent {
public Image setUvRect(int left, int top, int width, int height) { public Image setUvRect(int left, int top, int width, int height) {
uvRect = new Rectangle(left, top, width, height); setUvRect(new Rectangle(left, top, width, height));
return this;
}
public Image setUvRect(Rectangle rect) {
uvRect = rect;
return this; return this;
} }
@ -51,7 +56,11 @@ public class Image extends CustomRenderComponent {
} }
public Image setResourceSize(int width, int height) { public Image setResourceSize(int width, int height) {
resourceSize = new Size(width, height); return setResourceSize(new Size(width, height));
}
public Image setResourceSize(Size sz) {
resourceSize = sz;
return this; return this;
} }
@ -61,12 +70,12 @@ public class Image extends CustomRenderComponent {
@Override @Override
public int getContentWidth() { public int getContentWidth() {
return resourceSize.width(); return uvRect.width;
} }
@Override @Override
public int getContentHeight() { public int getContentHeight() {
return resourceSize.height(); return uvRect.height;
} }
@ -79,7 +88,7 @@ public class Image extends CustomRenderComponent {
Rectangle bounds, Rectangle bounds,
Rectangle clipRect Rectangle clipRect
) { ) {
RenderHelper.renderImage(stack, bounds.width, bounds.height, location, uvRect, resourceSize, alpha); RenderHelper.renderImage(stack, 0, 0, bounds.width, bounds.height, location, resourceSize, uvRect, alpha);
} }
@Override @Override