Preserving and restoring pane sizes

It is possible to preserve the sizes of the individual panes, and restore their previous sizes the next time the application runs and opens its window. This is done by specifying a unique label for each pane container in the window and LibCXXW automatically saves the number of panes and their relative sizes when their main window gets destroyed.

The application code needs to check for the number of restored pane sizes, and create the same number of panes in the container's creator lambda:

x::w::new_panelayoutmanager npl{{10,50,100}};"main_pane";

     (const auto &pane_container)
          x::w::panelayoutmanager lm=pane_container->panelayout();

          size_t n=lm->restored_size();

          // Create 'n' panes here.

     }, npl);

Each container that uses the pane layout manager has a label. panelayoutmanager.C labels its sole pane container with main_pane. All pane containers' labels must be unique. This label gets used to preserve the size of the container's panes.


In order for the panes to get correctly restored to their original size, the creator lambda must create the same number of panes in the new container. panelayoutmanager.C is a demonstration program that creates random panes for demonstration purposes only. panelayoutmanager.C checks how many pane sizes got restore(), and automatically creates the same number of sample panes in its creator lambda.

It is not an error for the creator lambda to fail to create the number of restored pane container sizes, if so they get ignored.