Jump to content

Pro tip for snappy resizing speed of detailed interfaces


Josh
 Share

Recommended Posts

If you have a panel with a lot of sub-objects, like the object properties panel in Leadwerks, which has a ton of detailed controls for different entity properties, it can slow down the speed of your redraws when the window or side panel is resized. This is because when a widget is resized, all of its children have to be adjusted, even if they are hidden.

image.thumb.png.58ef0176fa7372bfcd00df8e5c7ab1de.png

An easy way to improve this is to set the widget layout of the panel to (1,0,1,0) when it is hidden:

panel->SetHidden(true);
panel->SetLayout(1,0,1,0);

This locks it to the top-right so it doesn't get resized when the parent resizes, and all of its children can safely be skipped in the layout update routine, since its size does not get modified when the parent resizes.

When you show the panel, do it like this:

auto parent = panel->GetParent();
auto sz = parent->ClientSize();
panel->SetShape(0,0,sz.x,sz.y);
panel->SetLayout(1,1,1,1);
panel->SetHidden(false);

When I did this with the Ultra Engine editor side tabber panels, the side panel resizing got noticeably faster.

Another trick is to set a panel's background alpha to 0 if it's the same color as the underlying surface, and background rendering for that widget will be skipped:

panel->SetColor(0,0,0,0);

This can make redrawing a little bit faster, especially if you have a lot of overlapping panels.

  • Like 1
  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...