[Bf-blender-cvs] [cef6fb72c8f] userpref_redesign: Initial grouping/categorizing of settings sections
Julian Eisel
noreply at git.blender.org
Tue Feb 27 20:15:47 CET 2018
Commit: cef6fb72c8f8f21826da79873228f28129291732
Author: Julian Eisel
Date: Tue Feb 27 19:50:19 2018 +0100
Branches: userpref_redesign
https://developer.blender.org/rBcef6fb72c8f8f21826da79873228f28129291732
Initial grouping/categorizing of settings sections
Made this to work just like we define categories in menus: a enum item with only
the UI-name set starts a new category with given name. Also added another
uiLayout.prop option "group", not sure if thats such a nice way to do it though.
Will check during review.
===================================================================
M release/scripts/startup/bl_ui/space_userpref.py
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/interface_layout.c
M source/blender/makesrna/intern/rna_ui_api.c
M source/blender/makesrna/intern/rna_userdef.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 83925923fc3..e414c961316 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -89,7 +89,7 @@ class USERPREF_PT_navigation(Panel):
col = layout.column()
- col.prop(userpref, "active_section", expand=True)
+ col.prop(userpref, "active_section", expand=True, group=True)
class USERPREF_MT_interaction_presets(Menu):
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 6e09318314d..320477f541e 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -857,7 +857,8 @@ void UI_exit(void);
#define UI_ITEM_R_FULL_EVENT (1 << 6)
#define UI_ITEM_R_NO_BG (1 << 7)
#define UI_ITEM_R_IMMEDIATE (1 << 8)
-#define UI_ITEM_O_DEPRESS (1 << 9)
+#define UI_ITEM_R_GROUP (1 << 9)
+#define UI_ITEM_O_DEPRESS (1 << 10)
/* uiTemplateOperatorPropertyButs flags */
#define UI_TEMPLATE_OP_PROPS_SHOW_TITLE 1
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 30a18ddc8bc..9a150cec869 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -581,7 +581,7 @@ static void ui_item_enum_expand_handle(bContext *C, void *arg1, void *arg2)
}
static void ui_item_enum_expand(
uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop,
- const char *uiname, int h, bool icon_only)
+ const char *uiname, int h, bool icon_only, bool group)
{
/* XXX The way this function currently handles uiname parameter is insane and inconsistent with general UI API:
* * uiname is the *enum property* label.
@@ -625,8 +625,16 @@ static void ui_item_enum_expand(
}
for (item = item_array; item->identifier; item++) {
+ const bool is_first = item == item_array;
+
if (!item->identifier[0]) {
- if (radial && layout_radial) {
+ if (group && name) {
+ if (!is_first) {
+ uiItemS(block->curlayout);
+ }
+ uiItemL(block->curlayout, item->name, ICON_NONE);
+ }
+ else if (radial && layout_radial) {
uiItemS(layout_radial);
}
continue;
@@ -1382,7 +1390,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
PropertyType type;
char namestr[UI_MAX_NAME_STR];
int len, w, h;
- bool slider, toggle, expand, icon_only, no_bg;
+ bool slider, toggle, expand, icon_only, no_bg, group;
bool is_array;
UI_block_layout_set_current(block, layout);
@@ -1443,6 +1451,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
expand = (flag & UI_ITEM_R_EXPAND) != 0;
icon_only = (flag & UI_ITEM_R_ICON_ONLY) != 0;
no_bg = (flag & UI_ITEM_R_NO_BG) != 0;
+ group = expand && ((flag & UI_ITEM_R_GROUP) != 0);
/* get size */
ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, &w, &h);
@@ -1464,7 +1473,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
}
/* expanded enum */
else if (type == PROP_ENUM && (expand || RNA_property_flag(prop) & PROP_ENUM_FLAG))
- ui_item_enum_expand(layout, block, ptr, prop, name, h, icon_only);
+ ui_item_enum_expand(layout, block, ptr, prop, name, h, icon_only, group);
/* property with separate label */
else if (type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) {
but = ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag);
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 5fc263ae171..05cb680da3d 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -95,8 +95,10 @@ const char *rna_translate_ui_text(
return BLT_pgettext(BLT_I18NCONTEXT_DEFAULT, text);
}
-static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name, const char *text_ctxt,
- int translate, int icon, int expand, int slider, int toggle, int icon_only, int event,
+static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname,
+ const char *name, const char *text_ctxt,
+ int translate, int icon, int expand, int group,
+ int slider, int toggle, int icon_only, int event,
int full_event, int emboss, int index, int icon_value)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
@@ -116,6 +118,7 @@ static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname,
flag |= (slider) ? UI_ITEM_R_SLIDER : 0;
flag |= (expand) ? UI_ITEM_R_EXPAND : 0;
+ flag |= (group) ? UI_ITEM_R_GROUP : 0;
flag |= (toggle) ? UI_ITEM_R_TOGGLE : 0;
flag |= (icon_only) ? UI_ITEM_R_ICON_ONLY : 0;
flag |= (event) ? UI_ITEM_R_EVENT : 0;
@@ -550,6 +553,8 @@ void RNA_api_ui_layout(StructRNA *srna)
api_ui_item_rna_common(func);
api_ui_item_common(func);
RNA_def_boolean(func, "expand", false, "", "Expand button to show more detail");
+ RNA_def_boolean(func, "group", false, "", "Allow grouping together enum items if the enum allows it "
+ "(requires expand option to be enabled)");
RNA_def_boolean(func, "slider", false, "", "Use slider widget for numeric values");
RNA_def_boolean(func, "toggle", false, "", "Use toggle widget for boolean values");
RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in buttons, no text");
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 4b15a18ad63..5b595e02b3c 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -4697,6 +4697,7 @@ void RNA_def_userdef(BlenderRNA *brna)
PropertyRNA *prop;
static const EnumPropertyItem user_pref_sections[] = {
+ {0, "", 0, "User Preferences", ""},
{USER_SECTION_GENERAL, "GENERAL", 0, "General", ""},
{USER_SECTION_INTERFACE, "INTERFACE", 0, "Interface", ""},
{USER_SECTION_INPUT, "INPUT", 0, "Input", ""},
@@ -4704,9 +4705,10 @@ void RNA_def_userdef(BlenderRNA *brna)
{USER_SECTION_THEME, "THEMES", 0, "Themes", ""},
{USER_SECTION_FILE, "FILES", 0, "File", ""},
{0, "", 0, "Workspaces", ""},
- {USER_SECTION_WORKSPACE_CONFIG, "WORKSPACE_CONFIG", 0, "Workspace Configuration File", ""},
- {USER_SECTION_WORKSPACE_ADDONS, "WORKSPACE_ADDONS", 0, "Workspace Add-on Overrides", ""},
- {USER_SECTION_WORKSPACE_KEYMAPS, "WORKSPACE_KEYMAPS", 0, "Workspace Key-map Overrides", ""},
+ {USER_SECTION_WORKSPACE_CONFIG, "WORKSPACE_CONFIG", 0, "Configuration File", ""},
+ {USER_SECTION_WORKSPACE_ADDONS, "WORKSPACE_ADDONS", 0, "Add-on Overrides", ""},
+ {USER_SECTION_WORKSPACE_KEYMAPS, "WORKSPACE_KEYMAPS", 0, "Key-map Overrides", ""},
+ {0, "", 0, "System", ""},
{USER_SECTION_SYSTEM, "SYSTEM", 0, "System", ""},
{0, NULL, 0, NULL, NULL}
};
More information about the Bf-blender-cvs
mailing list