Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-04-27 17:43:36 +0300
committerJulian Eisel <julian@blender.org>2020-04-27 18:01:40 +0300
commitb0f207db15c5698f11db1168d2882f056583d6d5 (patch)
tree10449a797559e5395b38ecfe10c05d195a0a0c1f /source/blender/editors/interface/interface_layout.c
parent5559edf3c7b854186d2e6cd9c5a492c15df77072 (diff)
UI: (Internal) utility for more controllable property split layout
Adds a wrapper-struct to create and return the three layouts required for the propery split layout (i.e. `UILayout.use_property_split`). This gives more flexibility for special treatment. E.g. needed for adding the arrow icon buttons when there is a hierarchy of nodes to be represented in the material properties (needs inserting in the text column to not offset the split layout). This commit also makes use of the utility for `uiItemL_respect_property_split()`.
Diffstat (limited to 'source/blender/editors/interface/interface_layout.c')
-rw-r--r--source/blender/editors/interface/interface_layout.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 2ca4af32bc2..0609424fd61 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -3162,35 +3162,40 @@ void uiItemL(uiLayout *layout, const char *name, int icon)
}
/**
- * Helper to add a label, which handles logic for split property layout if needed.
- *
- * Normally, we handle the split layout in #uiItemFullR(), but there are other cases where we may
- * want to use the logic. For those this helper was added, although it will likely have to be
- * extended to support more cases.
- * Ideally, #uiItemFullR() could just call this, but it currently has too many special needs.
- *
- * \return A layout placed in the row after the split layout. Used to place decorator items.
+ * Normally, we handle the split layout in #uiItemFullR(), but there are other cases where the
+ * logic is needed. Ideally, #uiItemFullR() could just call this, but it currently has too many
+ * special needs.
*/
-uiLayout *uiItemL_respect_property_split(uiLayout *layout, const char *text, int icon)
+uiPropertySplitWrapper uiItemPropertySplitWrapperCreate(uiLayout *parent_layout)
{
- if (layout->item.flag & UI_ITEM_PROP_SEP) {
- uiBlock *block = uiLayoutGetBlock(layout);
+ uiPropertySplitWrapper split_wrapper = {NULL};
+
+ uiLayout *layout_row = uiLayoutRow(parent_layout, true);
+ uiLayout *layout_split = uiLayoutSplit(layout_row, UI_ITEM_PROP_SEP_DIVIDE, true);
- uiLayout *layout_row = uiLayoutRow(layout, true);
- uiLayout *layout_split = uiLayoutSplit(layout_row, UI_ITEM_PROP_SEP_DIVIDE, true);
- uiLayout *layout_sub = uiLayoutColumn(layout_split, true);
+ layout_split->space = 0;
+ split_wrapper.label_column = uiLayoutColumn(layout_split, true);
+ split_wrapper.label_column->alignment = UI_LAYOUT_ALIGN_RIGHT;
+ split_wrapper.property_row = ui_item_prop_split_layout_hack(parent_layout, layout_split);
+ split_wrapper.decorate_column = uiLayoutColumn(layout_row, true);
- layout_split->space = layout_sub->space = layout_row->space = 0;
- layout_sub->alignment = UI_LAYOUT_ALIGN_RIGHT;
+ return split_wrapper;
+}
- uiItemL_(layout_sub, text, icon);
+/*
+ * Helper to add a label and creates a property split layout if needed.
+ */
+uiLayout *uiItemL_respect_property_split(uiLayout *layout, const char *text, int icon)
+{
+ if (layout->item.flag & UI_ITEM_PROP_SEP) {
+ uiBlock *block = uiLayoutGetBlock(layout);
+ uiPropertySplitWrapper split_wrapper = uiItemPropertySplitWrapperCreate(layout);
+ /* Further items added to 'layout' will automatically be added to split_wrapper.property_row */
- layout_split = ui_item_prop_split_layout_hack(layout, layout_split);
- UI_block_layout_set_current(block, layout_split);
+ uiItemL_(split_wrapper.label_column, text, icon);
+ UI_block_layout_set_current(block, split_wrapper.property_row);
- /* The decorator layout uses the row the split layout was inserted to. */
- uiLayout *layout_decorator = layout_row;
- return layout_decorator;
+ return split_wrapper.decorate_column;
}
else {
char namestr[UI_MAX_NAME_STR];