UI: simplify layout panels C++ API

This simplifies the C++ API for making layout panels. Now it is also more similar to the Python API.
`uiLayoutPanel` is like `layout.panel` and `uiLayoutPanelProp` is like `layout.panel_prop`.

Both, `uiLayoutPanel` and `uiLayoutPanelProp`, now exist in two variants. One that takes a label
parameter and one that does not. If the label is passed in, only the panel body layout is returned.
Otherwise, the header and body are returned for more customization.

Pull Request: https://projects.blender.org/blender/blender/pulls/117670
This commit is contained in:
Jacques Lucke
2024-01-30 17:44:56 +01:00
parent 78a0127356
commit f358843108
15 changed files with 108 additions and 57 deletions

View File

@@ -92,8 +92,8 @@ static void handle_node_declaration_items(bContext *C,
LayoutPanelState *state = BKE_panel_layout_panel_state_ensure(
root_panel, panel_idname.c_str(), panel_decl->default_collapsed);
PointerRNA state_ptr = RNA_pointer_create(nullptr, &RNA_LayoutPanelState, state);
uiLayout *panel_layout = uiLayoutPanel(
C, layout, IFACE_(panel_decl->name.c_str()), &state_ptr, "is_open");
uiLayout *panel_layout = uiLayoutPanelProp(
C, layout, &state_ptr, "is_open", IFACE_(panel_decl->name.c_str()));
/* Draw panel buttons at the top of each panel section. */
if (panel_layout && panel_decl->draw_buttons) {
panel_decl->draw_buttons(panel_layout, C, node_ptr);