How to maximize a panel to occupy the entire surface of some parent container

In some apps it’s possible to press a key (such as backtick) to maximize the panel hovered by the mouse cursor. The panel is resized such that it occupies the entire surface of the toplevel container. Pressing again the key restores the UI to the previous state.

What would be an easy way to implement this using GTK containers? I’m interested in the resizing part, not in how it can be triggered.

Hi @aleb, do you have any existing app to reference the behavior you’re describing?

Meanwhile, can you explain why setting expand property on and off, on your panel, wouldn’t do what you describe? Also, have you considered implementing gtk_widget_get_request_mode and gtk_widget_get_preferred_* methods to explicitly control the widget geometry?

This feature is explained here:

The following video demonstrates pressing Shift+backtick to maximize the current panel, and pressing backtick to maximize the hovered panel:

Using the expand property does not work because then the widget only takes the available space, when it should take all the space including the space occupied by neighbor widgets.

The size of the widget would be toggled between the one calculated with the gtk_widget_get_request_mode & gtk_widget_get_preferred_* methods and full-size (of the parent container).

I guess the logic would have to go in the parent container class.

Judging from the video, you can do it with expands, but, you also need need to set visibility of other panels to false.

If I were to implement this, the first thing I would try is to simply create a container, where all children are expanded by default. And when one of the containers is selected to expand to whole parent container space, it would simply set visibility to false to all other children.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.