Adjust Human UI element size to UI window size

Hello.
I’m playing with Grasshopper and Human UI.
I have a bunch of elements (Expanders, 3D View) in my Human UI window, which I add and position via Create Grid.
Since the application will run side by side with other windows it would be nice to adjust the size of the window.
However, if I do that, the window changes, but the size of the elements in the window stays the same and I end up with stuff cut off or white space. See screenshot.

Is there a way to dynamically adjust the size of the elements with the window?
I am already using a static size variable with the Adjust Element Positioning Component to set the initial size, so I guess all I needed would be a way to feed the (current) size back to that. However, I seem to not be able to get window size. Any suggestions?

Thanks!

Rather than set an explicit size for your elements, you should use the Adjust Element Positioning component and right click the Horizontal Alignment input and select “Stretch”.

Cheers,
Marc

1 Like

Nice, that does it. Thanks for the quick reply, Mark!

1 Like

So Mark, I’ve been playing with your suggesting for a while. Works generally well, but I got stuck again at two points:

I am using a few value listeners upstream of the window generation and then update the window with the set functions from the UI output tab as recommended.
However, whenever the Value Listener updates, the elements on the Human UI window get moved out of their place.
Moreover, what is worse, a 3D Viewer to display my geometry is reset (seemingly to some internal value?), different from the settings I supplied through the Set 3D View Properties component (I have predefined views for the user to choose from the UI), and also different from the current view. How can I avoid that?

Second, and not so important: The Create 3D View component seems to require height and width data and hence doesn’t adjust to the window size. Any workaround that?

I guess these are three questions:

  1. how can I prevent Human UI elements to leave their desired positions when a upstream value listener updates?
  2. How can I make a 3D view keep its View Properties when a upstream value listener updates?
  3. How can I make a 3D View component adjust to variable window size (see previous question)?

I’ll be very grateful for any hints!

This is an indication that you have broken the cardinal rule of HumanUI – Use “Create” components only with static variables, and use “Set” with dynamic variables to update the created components. Look for places in your script where you are changing the values going into a Create HUI component, and remove those inputs and use a corresponding Set component instead.

Cheers,
Marc

you are right: there was a list that I created with dynamic data! Getting rid of that fixed (1) and (2). Only question (3) is still open. But I can live with that.
Thanks a lot!

Hello Marc. Is it also possible to turn the logic upside down? → can I define window size based on elements that I am creating? Following order on GH canvas, I first create elements, define their properties and finally use “AddElems” to put them into actual window. Based on that I presume, that it might be possible.

More details below

I am creating UI for grasshopper script that other people will use, planning to introduce “warning messages” for them when something goes bad.
I want to create universal cluster, where you input only warning message text, and it will just pop up in the middle of screen when triggered, with size dependent on length/layout of warning message.

image

Of course I could add two more inputs (window width+height) and always modify window size after I insert my text…
But I was wondering if you can retrieve real sizes of UI elements.

GetElementProperties indicates that these values are there (ActualWidth, ActualHeight), but I do not know how to read them. Other “T” output just describes variable type, no value published there :frowning:

The Launch Window component has an input for height that you can set to “Auto” using a string input that calculates the height of the window based on the elements that are visible in the window, this should be exactly what you’re looking for if I understand your question properly.

The location is trickier as you need to calculate the start point of the window based on the screen resolution minus the fixed width, and an assumption about height. It won’t always be perfectly centered vertically but still should be a comfortable user experience.

Marc

Thanks for an answer Marc. I managed to figure out the auto-centered window location quite easily, the “Auto” input however does not work, because window height input only seems to accept integers. Is there any workaround that I am missing?

But all in all, setting up the size manually is not that much of a hassle. Content of the message is pre-defined in most cases.
I was just wondering