OdraEncoded
OdraEncoded

Reputation: 3134

How to auto resize a GTK# window while it's hidden?

In my application, I have two toggle buttons which can change the layout of a window. They will remove or add buttons to it effectively changing the total requested size. Since the Resizeable property of that window is set to false, normally the window would automatically resize to fit it's contents, whether they are larger than before or smaller.

However if I change the layout while the window is hidden, after I make it visible the dimensions of the window won't have changed to fit the layout. It will auto resize after I move it around though.

//Code example
Window.Hide();
ChangeLayout(Window);
Window.Show();

I assume GTK skips to check for size changes while a container is invisible. Is there a way to force it to recalculate it's size?

Thank you.

P.S: It seems that only happens in Windows. Perhaps this is OS related?

Upvotes: 2

Views: 984

Answers (1)

Geoff Reedy
Geoff Reedy

Reputation: 36011

I don't have a windows machine to test it on, but try this as a workaround:

Window.Hide();
ChangeLayout(Window);
Window.Unrealize();
Window.Show();

You might also try setting the window resizable before changing the layout and then setting it unresizable:

Window.Hide();
Window.Resizable = true;
ChangeLayout(Window);
Window.Resizable = false;
Window.Show();

Upvotes: 1

Related Questions