Best way of fitting an embedded view to an object?

I may be missing something entirely here.

Embedded views are fixed sizes when you drag them onto the view canvas. But if you set an embedded view's path to a view that is smaller than the embedded view, the embedded view remains the same, original size.

Is there anyway to autosize an embedded view to the extents of the object that it is displaying? Or is this always going to be a manual operation?

Maybe you're missing the useDefaultViewWidth and useDefaultViewHeight properties? If they are checked, the object view will be made to fit the size of the view as it is defined, otherwise the contents of that view will be sized to fit the embedded view object.

I myself tend to use "auto" position basis and flex layouts instead of fixed pixel sizes and coordinate containers. I'm not sure how a coordinate container acts with regard to those "useDefaultView" properties when used as an embedded view. A coordinate container will resize nicely to fit within an embedded view, but only when set to "percent" mode.

I'm not missing those properties. Nothing happens when I set them.

The object I've set the path to has a default width of 100 and a height of 170. The embedded view is keeping its 320x320 default size.

Oh, I misunderstood--you want the embedded view itself to resize to fit the view it's embedding, not the other way 'round. In that case I believe the size of it is determined by its context. If it's inside a flex container, try using a basis of "auto," although that probably adjusts to its surrounding elements as well as taking into account the size of its contents.

...or you could simply set its basis to match the size of the view it is containing, though that will only apply along one axis (row vs. column layout). You can then explicitly set the other axis (width/height) using the style property.

I'm building this inside a Coordinate Container and not a flex (or any other sort of container like that).

I would have hoped that there was an easy way to fit the embedded view to its contents.

That's one of the reasons I avoid Coordinate Containers--you have to explicitly set element positions and sizes, rather than letting them adjust to the context surrounding them.

In this use case I think a coordinate container makes more sense, as I am replicating physical operator control panels, and want the overall view to look as close as possible to the real system. So no fancy automatic setting of positions and sizes. But I've always had to manually set the embedded view size. I've finally got annoyed enough of doing that. Hence my question.

It maybe that I should be using different style of base view. But that's a different question.

Seems like a reasonable request you could make for an improvement to the Designer.

You can set coordinate container to percentage
Or if you keep it fixed you can set the x/y to use "100%"
Or something more advanced with calcs...
There is also "auto" or "fit-content" though those sometimes have issues with svgs

1 Like