diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2019-11-25 21:41:30 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2019-11-25 21:50:34 +0300 |
commit | 5bcb0c9935033d9d9983838bd4f5ed226627c2e9 (patch) | |
tree | 4923d38f4ba23209dc07eab80562dd0bad59c0d5 /source/blender/editors/interface/interface_templates.c | |
parent | 03cdfc2ff6df61a247b90c4ad8bb1b26034b4505 (diff) |
UI: Allow label for Template-ID (respecting property split layout)
Adds a `text` parameter to `bpy.types.uiLayout.template_ID()` which
causes a label to be added, as usual. Adding the label also makes the
template respect the `bpy.types.uiLayout.use_property_split` option.
Also fixes wrong layout being used in the template-ID, although I think
that didn't cause issues in practice.
Sergey requested this for usage in the Movie Clip Editor.
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index a65e70d4109..5788b741108 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -780,6 +780,7 @@ static void template_ID(bContext *C, const char *newop, const char *openop, const char *unlinkop, + const char *text, const bool live_icon, const bool hide_buttons) { @@ -803,6 +804,11 @@ static void template_ID(bContext *C, type = idptr.type; } + if (text) { + /* Add label resepecting the seperated layout property split state. */ + layout = uiItemL_respect_property_split(layout, text, ICON_NONE); + } + if (flag & UI_ID_BROWSE) { template_add_button_search_menu(C, layout, @@ -1187,6 +1193,7 @@ static void ui_template_id(uiLayout *layout, const char *newop, const char *openop, const char *unlinkop, + const char *text, int flag, int prv_rows, int prv_cols, @@ -1239,13 +1246,22 @@ static void ui_template_id(uiLayout *layout, */ if (template_ui->idlb) { if (use_tabs) { - uiLayoutRow(layout, true); + layout = uiLayoutRow(layout, true); template_ID_tabs(C, layout, template_ui, type, flag, newop, unlinkop); } else { - uiLayoutRow(layout, true); - template_ID( - C, layout, template_ui, type, flag, newop, openop, unlinkop, live_icon, hide_buttons); + layout = uiLayoutRow(layout, true); + template_ID(C, + layout, + template_ui, + type, + flag, + newop, + openop, + unlinkop, + text, + live_icon, + hide_buttons); } } @@ -1260,7 +1276,8 @@ void uiTemplateID(uiLayout *layout, const char *openop, const char *unlinkop, int filter, - const bool live_icon) + const bool live_icon, + const char *text) { ui_template_id(layout, C, @@ -1269,6 +1286,7 @@ void uiTemplateID(uiLayout *layout, newop, openop, unlinkop, + text, UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE, 0, 0, @@ -1286,7 +1304,8 @@ void uiTemplateIDBrowse(uiLayout *layout, const char *newop, const char *openop, const char *unlinkop, - int filter) + int filter, + const char *text) { ui_template_id(layout, C, @@ -1295,6 +1314,7 @@ void uiTemplateIDBrowse(uiLayout *layout, newop, openop, unlinkop, + text, UI_ID_BROWSE | UI_ID_RENAME, 0, 0, @@ -1324,6 +1344,7 @@ void uiTemplateIDPreview(uiLayout *layout, newop, openop, unlinkop, + NULL, UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS, rows, cols, @@ -1350,6 +1371,7 @@ void uiTemplateGpencilColorPreview(uiLayout *layout, NULL, NULL, NULL, + NULL, UI_ID_BROWSE | UI_ID_PREVIEWS | UI_ID_DELETE, rows, cols, @@ -1378,6 +1400,7 @@ void uiTemplateIDTabs(uiLayout *layout, newop, NULL, unlinkop, + NULL, UI_ID_BROWSE | UI_ID_RENAME, 0, 0, @@ -7485,8 +7508,16 @@ void uiTemplateCacheFile(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiLayoutSetContextPointer(layout, "edit_cachefile", &fileptr); - uiTemplateID( - layout, C, ptr, propname, NULL, "CACHEFILE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false); + uiTemplateID(layout, + C, + ptr, + propname, + NULL, + "CACHEFILE_OT_open", + NULL, + UI_TEMPLATE_ID_FILTER_ALL, + false, + NULL); if (!file) { return; |