x::w::panelayoutmanager
's
append_panes()
,
insert_panes()
,
replace_panes()
, and
replace_all_panes()
return a
x::w::panefactory
,
which is a factory.
Every widget created by the factory becomes a new pane in the
pane layout manager's container.
Individual properties related to each new pane come from the pane factory's appearance object:
f->appearance=f->appearance->modify ([] (const auto &appearance) { appearance->size=20.0; });
The size
sets the
new widget's initial size. This is just a suggestion, since the
pane container, with all of its elements, always gets constrained by
its specified size.
x::w::new_panelayoutmanager npl{ x::w::dim_axis_arg{40} // 40 millimeter-long container }; factory->create_focusable_container( [&] (const x::w::container &new_container) { x::w::panelayoutmanager plm=new_container->get_layoutmanager(); x::w::panefactory f=plm->append_panes(); auto custom=f->appearance->modify ([] (const auto &appearance) { custom->size=20.0; // 20 millimeters (almost) }); f->appearance=custom; f->create_label("Lorem Ipsum")->show(); // The pane factory automatically resets itself to the default // pane appearance for each new pane, so we simply reinstall // the custom appearance requesting a 20mm pane: f->appearance=custom; f->create_label("Lorem Ipsum")->show(); }, npl);
This example creates a 40 millimeter-long container, with two initial panes. A custom pane appearance object specifies a 20 millimeter size, so the pane container's alloted 40 millimeter size gets evenly divided between them.
The actual size of each widget in this container is slightly less than 20 millimeters. The draggable divider between the two panes takes up some space too, and it has to fit within its container's 40 millimeter size. The two new panes' sizes get slightly adjusted, in order to leave sufficient space for the dividers (and the drawn borders).
The sizes set in the appearance objects, in this manner, are just guidelines, or hints, and the actual size of each new widget gets proportionately adjusted, together with the sizes of any existing panes, so that the entire container stays within its bounds. It is also possible to preserve the previous size of panes when creating them the next time the application runs.