diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2019-11-07 18:31:33 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2019-11-08 07:31:01 +0300 |
commit | a7fcd78d2d690f0fa57cc65d04ee20d9d26b08e4 (patch) | |
tree | 8be8bae245abdf96638eeaacecbea12c9df1e841 /source/blender/makesrna | |
parent | 3ecb1056c9d8b83d2c025411c4f443b840902d66 (diff) |
User Preference Experimental Tab
Experimental tab in User Preferences for experimental features.
The tab option is only visible when "Developer Extras" is on.
Included here is a (commented out) example panel to be used as a
template for the new experimental panels. Since these panels will come
and go it is nice to have a reference in the code.
Differential Revision: https://developer.blender.org/D6203
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 115 |
1 files changed, 89 insertions, 26 deletions
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 9ecfc7f675f..1b73c1e78db 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -69,6 +69,32 @@ static const EnumPropertyItem opensubdiv_compute_type_items[] = { }; #endif +static const EnumPropertyItem preference_section_items[] = { + {USER_SECTION_INTERFACE, "INTERFACE", 0, "Interface", ""}, + {USER_SECTION_THEME, "THEMES", 0, "Themes", ""}, + {USER_SECTION_VIEWPORT, "VIEWPORT", 0, "Viewport", ""}, + {USER_SECTION_LIGHT, "LIGHTS", 0, "Lights", ""}, + {USER_SECTION_EDITING, "EDITING", 0, "Editing", ""}, + {USER_SECTION_ANIMATION, "ANIMATION", 0, "Animation", ""}, + {0, "", 0, NULL, NULL}, + {USER_SECTION_ADDONS, "ADDONS", 0, "Add-ons", ""}, +#if 0 // def WITH_USERDEF_WORKSPACES + {0, "", 0, NULL, NULL}, + {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, "Keymap Overrides", ""}, +#endif + {0, "", 0, NULL, NULL}, + {USER_SECTION_INPUT, "INPUT", 0, "Input", ""}, + {USER_SECTION_NAVIGATION, "NAVIGATION", 0, "Navigation", ""}, + {USER_SECTION_KEYMAP, "KEYMAP", 0, "Keymap", ""}, + {0, "", 0, NULL, NULL}, + {USER_SECTION_SYSTEM, "SYSTEM", 0, "System", ""}, + {USER_SECTION_SAVE_LOAD, "SAVE_LOAD", 0, "Save & Load", ""}, + {USER_SECTION_FILE_PATHS, "FILE_PATHS", 0, "File Paths", ""}, + {0, NULL, 0, NULL, NULL}, +}; + static const EnumPropertyItem audio_device_items[] = { {0, "Null", 0, "None", "Null device - there will be no audio output"}, {0, NULL, 0, NULL, NULL}, @@ -435,6 +461,39 @@ static int rna_UserDef_mouse_emulate_3_button_modifier_get(PointerRNA *ptr) # endif } +static const EnumPropertyItem *rna_UseDef_active_section_itemf(bContext *UNUSED(C), + PointerRNA *ptr, + PropertyRNA *UNUSED(prop), + bool *r_free) +{ + UserDef *userdef = ptr->data; + + if ((userdef->flag & USER_DEVELOPER_UI) == 0) { + *r_free = false; + return preference_section_items; + } + + EnumPropertyItem *items = NULL; + int totitem = 0; + + RNA_enum_items_add(&items, &totitem, preference_section_items); + RNA_enum_item_add_separator(&items, &totitem); + + EnumPropertyItem item = { + .value = USER_SECTION_EXPERIMENTAL, + .name = "Experimental", + .identifier = "EXPERIMENTAL", + .icon = 0, + .description = "", + }; + + RNA_enum_item_add(&items, &totitem, &item); + RNA_enum_item_end(&items, &totitem); + + *r_free = true; + return items; +} + static PointerRNA rna_UserDef_view_get(PointerRNA *ptr) { return rna_pointer_inherit_refine(ptr, &RNA_PreferencesView, ptr->data); @@ -4162,6 +4221,7 @@ static void rna_def_userdef_view(BlenderRNA *brna) prop, "Developer Extras", "Show options for developers (edit source in context menu, geometry indices)"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "show_object_info", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_DRAWVIEWINFO); @@ -5756,6 +5816,25 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna) "Enables automatic saving of preview images in the .blend file"); } +static void rna_def_userdef_experimental(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "PreferencesExperimental", NULL); + RNA_def_struct_sdna(srna, "UserDef_Experimental"); + RNA_def_struct_nested(brna, srna, "Preferences"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); + RNA_def_struct_ui_text(srna, "Experimental", "Experimental features"); + + prop = RNA_def_property(srna, "use_experimental_all", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_EXPERIMENTAL_ALL); + RNA_def_property_ui_text(prop, + "All Experimental Features", + "Expose all the experimental features in the user interface"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); +} + static void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; @@ -5815,32 +5894,6 @@ void RNA_def_userdef(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem preference_section_items[] = { - {USER_SECTION_INTERFACE, "INTERFACE", 0, "Interface", ""}, - {USER_SECTION_THEME, "THEMES", 0, "Themes", ""}, - {USER_SECTION_VIEWPORT, "VIEWPORT", 0, "Viewport", ""}, - {USER_SECTION_LIGHT, "LIGHTS", 0, "Lights", ""}, - {USER_SECTION_EDITING, "EDITING", 0, "Editing", ""}, - {USER_SECTION_ANIMATION, "ANIMATION", 0, "Animation", ""}, - {0, "", 0, NULL, NULL}, - {USER_SECTION_ADDONS, "ADDONS", 0, "Add-ons", ""}, -# if 0 // def WITH_USERDEF_WORKSPACES - {0, "", 0, NULL, NULL}, - {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, "Keymap Overrides", ""}, -# endif - {0, "", 0, NULL, NULL}, - {USER_SECTION_INPUT, "INPUT", 0, "Input", ""}, - {USER_SECTION_NAVIGATION, "NAVIGATION", 0, "Navigation", ""}, - {USER_SECTION_KEYMAP, "KEYMAP", 0, "Keymap", ""}, - {0, "", 0, NULL, NULL}, - {USER_SECTION_SYSTEM, "SYSTEM", 0, "System", ""}, - {USER_SECTION_SAVE_LOAD, "SAVE_LOAD", 0, "Save & Load", ""}, - {USER_SECTION_FILE_PATHS, "FILE_PATHS", 0, "File Paths", ""}, - {0, NULL, 0, NULL, NULL}, - }; - rna_def_userdef_dothemes(brna); rna_def_userdef_solidlight(brna); rna_def_userdef_walk_navigation(brna); @@ -5853,6 +5906,7 @@ void RNA_def_userdef(BlenderRNA *brna) prop = RNA_def_property(srna, "active_section", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "space_data.section_active"); RNA_def_property_enum_items(prop, preference_section_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_UseDef_active_section_itemf"); RNA_def_property_ui_text( prop, "Active Section", "Active section of the preferences shown in the user interface"); RNA_def_property_update(prop, 0, "rna_userdef_ui_update"); @@ -5922,6 +5976,14 @@ void RNA_def_userdef(BlenderRNA *brna) RNA_def_property_ui_text( prop, "System & OpenGL", "Graphics driver and operating system settings"); + prop = RNA_def_property(srna, "experimental", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "PreferencesExperimental"); + RNA_def_property_ui_text( + prop, + "Experimental", + "Settings for features that are still early in their development stage"); + prop = RNA_def_int_vector(srna, "version", 3, @@ -5975,6 +6037,7 @@ void RNA_def_userdef(BlenderRNA *brna) rna_def_userdef_studiolights(brna); rna_def_userdef_studiolight(brna); rna_def_userdef_pathcompare(brna); + rna_def_userdef_experimental(brna); USERDEF_TAG_DIRTY_PROPERTY_UPDATE_DISABLE; } |