Respect custom Widget dimensions between Widgets

Hi I’m working on a card game and am having some issues with dimensions in the widgets.
My CardView widget is a 1440x2560 widget (The full res illustration dimension):

When I try to add the CardView to another Screen Size Widget, the Card view dimension ratio are the same as the screen (16:9 for example).

To get around this I made a canvas of dimensions 144x256 to put my CardView inside.

But if I drop the card view inside I get the wrong anchor points and dimensions.

I have to change the anchors by hand and set the Offsets to 0 to get the wanted result

I know that I can automatize those steps of setting the Anchor and the points in the BP but I was wondering if there was a way to have my Widget have the right dimensions when it’s created? Without the need for a Canvas.
Or at least to make the canvas have it’s children Anchors and offsets properly setup by default?

Actually just setting the size of the widget to the desired size (144x256) is MUCH easier that going through canvas and anchors.

Still I would like to not have to do that since I’m not agnostic of my card dimension anymore.
If there is a way to at least get the original Widget dimension?

For what I’m getting it is not possible to get a widget original dimension. I ended up getting the original 2DTexture dimensions and set a CardDimensions Attribute
That’s the cleanest solution I could think about but I’m susceptible to one of my illustration not being of the exact dimension. Will probably end up setting CardDimensions defaults to my wants

Hi brolock,

The key word you are after is Desired Size, there is GetDesiredSize() if you want to check it programmatically, or you can preview it as a screen size drop option.

335850-desiredsizepreview.png

Also note that anything you do here acts only as a preview, it does not set the widgets’ dimensions to that size.

335851-screensize.png

Widget Desired Size = Max bounds created by DesiredSizes/positions of Widget contents

A widget won’t render at its desired size if:

-It has insufficient space in its slot

-It’s overridden by the parent of the slot (e.g. as you pointed out, canvas panels, unless you tick SizeToContent)

-It’s alignment/anchors are set to fill

To manually control desired size I use a SizeBox where necessary. I see you already have a sizebox as the root of your CardView widget, so you can use that to control it.

TL;DR There is no one place where you set the dimensions of a widget, since there are plenty of places where they are determined and can be set/overridden.

Hope this helps :slight_smile:

Yeah helps me understand, I ended up having some settings about my UI dimensions stored in a singleton to make sure everything has the same constant size (important for me as I’m moving my Widget from canvas to canvas and have to resize it every time).