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:
authorAntonioya <blendergit@gmail.com>2018-11-02 19:30:09 +0300
committerAntonioya <blendergit@gmail.com>2018-11-02 21:28:36 +0300
commit982ca8c45ab6cf39cd059ed4ae0d6e60cd503bea (patch)
tree2cc65adbc22fcbeb992fe58bf93071b99a8b1a3d /source/blender/editors/interface
parentc63d133f4dc2b227c6a5e5dbb23bcceae2c2eb7f (diff)
Add hide_buttons option to template_ID_preview
When use the template in the topbar for only select an ID is very annoying to have the buttons after the name and only adds noise to the selector. This option hide the number of users, new and delete buttons to get a cleaner topbar selector. By default the parameter is disabled in order to keep all existing code/UI running.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_templates.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 0826ba3c5cd..92346e79d1e 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -649,7 +649,7 @@ static uiBut *template_id_def_new_but(
static void template_ID(
bContext *C, uiLayout *layout, TemplateID *template_ui, StructRNA *type, int flag,
const char *newop, const char *openop, const char *unlinkop,
- const bool live_icon)
+ const bool live_icon, const bool hide_buttons)
{
uiBut *but;
uiBlock *block;
@@ -722,7 +722,7 @@ static void template_ID(
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_OVERRIDE));
}
- if (ID_REAL_USERS(id) > 1) {
+ if ((ID_REAL_USERS(id) > 1) && (hide_buttons == false)) {
char numstr[32];
short numstr_len;
@@ -748,12 +748,14 @@ static void template_ID(
if (user_alert) UI_but_flag_enable(but, UI_BUT_REDALERT);
- if (id->lib == NULL && !(ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB, ID_WS))) {
+ if (id->lib == NULL && !(ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB, ID_WS)) &&
+ (hide_buttons == false))
+ {
uiDefIconButR(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_FAKE_USER_OFF, 0, 0, UI_UNIT_X, UI_UNIT_Y, &idptr, "use_fake_user", -1, 0, 0, -1, -1, NULL);
}
}
- if (flag & UI_ID_ADD_NEW) {
+ if ((flag & UI_ID_ADD_NEW) && (hide_buttons == false)) {
template_id_def_new_but(block, id, template_ui, type, newop, editable, flag & UI_ID_OPEN, false, UI_UNIT_X);
}
@@ -791,7 +793,7 @@ static void template_ID(
/* delete button */
/* don't use RNA_property_is_unlink here */
- if (id && (flag & UI_ID_DELETE)) {
+ if (id && (flag & UI_ID_DELETE) && (hide_buttons == false)) {
/* allow unlink if 'unlinkop' is passed, even when 'PROP_NEVER_UNLINK' is set */
but = NULL;
@@ -894,7 +896,7 @@ static void ui_template_id(
PointerRNA *ptr, const char *propname,
const char *newop, const char *openop, const char *unlinkop,
int flag, int prv_rows, int prv_cols, int filter, bool use_tabs,
- float scale, bool live_icon)
+ float scale, const bool live_icon, const bool hide_buttons)
{
TemplateID *template_ui;
PropertyRNA *prop;
@@ -942,7 +944,9 @@ static void ui_template_id(
}
else {
uiLayoutRow(layout, true);
- template_ID(C, layout, template_ui, type, flag, newop, openop, unlinkop, live_icon);
+ template_ID(
+ C, layout, template_ui, type, flag, newop, openop,
+ unlinkop, live_icon, hide_buttons);
}
}
@@ -958,7 +962,7 @@ void uiTemplateID(
layout, C, ptr, propname,
newop, openop, unlinkop,
UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE,
- 0, 0, filter, false, 1.0f, live_icon);
+ 0, 0, filter, false, 1.0f, live_icon, false);
}
void uiTemplateIDBrowse(
@@ -969,18 +973,19 @@ void uiTemplateIDBrowse(
layout, C, ptr, propname,
newop, openop, unlinkop,
UI_ID_BROWSE | UI_ID_RENAME,
- 0, 0, filter, false, 1.0f, false);
+ 0, 0, filter, false, 1.0f, false, false);
}
void uiTemplateIDPreview(
uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
- const char *openop, const char *unlinkop, int rows, int cols, int filter)
+ const char *openop, const char *unlinkop, int rows, int cols, int filter,
+ const bool hide_buttons)
{
ui_template_id(
layout, C, ptr, propname,
newop, openop, unlinkop,
UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS,
- rows, cols, filter, false, 1.0f, false);
+ rows, cols, filter, false, 1.0f, false, hide_buttons);
}
void uiTemplateGpencilColorPreview(
@@ -991,7 +996,7 @@ void uiTemplateGpencilColorPreview(
layout, C, ptr, propname,
NULL, NULL, NULL,
UI_ID_BROWSE | UI_ID_PREVIEWS | UI_ID_DELETE,
- rows, cols, filter, false, scale < 0.5f ? 0.5f : scale, false);
+ rows, cols, filter, false, scale < 0.5f ? 0.5f : scale, false, false);
}
/**
@@ -1007,7 +1012,7 @@ void uiTemplateIDTabs(
layout, C, ptr, propname,
newop, NULL, unlinkop,
UI_ID_BROWSE | UI_ID_RENAME,
- 0, 0, filter, true, 1.0f, false);
+ 0, 0, filter, true, 1.0f, false, false);
}
/************************ ID Chooser Template ***************************/