diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-09-04 20:16:52 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-09-04 20:25:55 +0300 |
commit | 1715d09d7c9506ed77af69571ab739a48a972514 (patch) | |
tree | c45f7b1d4c5efd75ecd7d9f37e9383488da70502 | |
parent | 933725ab4643ea9de268ca3be434f2ec0a797aff (diff) |
Cleanup: userpref UI options into their own struct
Mixing options for showing preferences with other flags was confusing.
-rw-r--r-- | release/datafiles/userdef/userdef_default.c | 17 | ||||
-rw-r--r-- | source/blender/editors/space_userpref/space_userpref.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_userdef_types.h | 47 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 2 |
5 files changed, 45 insertions, 29 deletions
diff --git a/release/datafiles/userdef/userdef_default.c b/release/datafiles/userdef/userdef_default.c index 4ad99993ada..da8d1884851 100644 --- a/release/datafiles/userdef/userdef_default.c +++ b/release/datafiles/userdef/userdef_default.c @@ -63,8 +63,6 @@ const UserDef U_default = { .gpu_flag = 0, .app_flag = 0, .language = 0, - .userpref = USER_SECTION_INTERFACE, - .userpref_flag = 0, .viewzoom = USER_ZOOM_DOLLY, .mixbufsize = 2048, .audiodevice = 0, @@ -182,6 +180,11 @@ const UserDef U_default = { .pie_menu_confirm = 0, .pie_menu_radius = 100, .pie_menu_threshold = 12, + .opensubdiv_compute_type = 0, + .gpencil_multisamples = 4, + .factor_display_type = USER_FACTOR_AS_FACTOR, + .viewport_aa = 8, + .walk_navigation = { .mouse_speed = 1, @@ -192,10 +195,12 @@ const UserDef U_default = { .teleport_time = 0.2, .flag = 0, }, - .opensubdiv_compute_type = 0, - .gpencil_multisamples = 4, - .factor_display_type = USER_FACTOR_AS_FACTOR, - .viewport_aa = 8, + + .space_data = + { + .section_active = USER_SECTION_INTERFACE, + }, + .runtime = { .is_dirty = 0, diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c index 4c6f2231cc1..a42ab048907 100644 --- a/source/blender/editors/space_userpref/space_userpref.c +++ b/source/blender/editors/space_userpref/space_userpref.c @@ -121,7 +121,7 @@ static void userpref_main_region_init(wmWindowManager *wm, ARegion *ar) static void userpref_main_region_draw(const bContext *C, ARegion *ar) { - ED_region_panels_ex(C, ar, NULL, U.userpref, true); + ED_region_panels_ex(C, ar, NULL, U.space_data.section_active, true); } static void userpref_operatortypes(void) diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index d19fb000c15..7d72eb41424 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -562,6 +562,17 @@ typedef struct UserDef_Runtime { char _pad0[7]; } UserDef_Runtime; +/** + * Store UI data here instead of the space + * since the space is typically a window which is freed. + */ +typedef struct UserDef_SpaceData { + char section_active; + /** #eUserPrefUI_Flag UI options. */ + char flag; + char _pad0[6]; +} UserDef_SpaceData; + typedef struct UserDef { /** UserDef has separate do-version handling, and can be read from other files. */ int versionfile, subversionfile; @@ -570,8 +581,7 @@ typedef struct UserDef { int flag; /** #eDupli_ID_Flags. */ short dupflag; - /** - * #eUserPref_PrefFlag preferences for the preferences. */ + /** #eUserPref_PrefFlag preferences for the preferences. */ char pref_flag; char savetime; char _pad4[4]; @@ -609,14 +619,12 @@ typedef struct UserDef { /** #eUserpref_UI_Flag2. */ char uiflag2; char gpu_flag; - char _pad8[2]; + char _pad8[6]; /* Experimental flag for app-templates to make changes to behavior * which are outside the scope of typical preferences. */ - short app_flag; - short language; - short userpref; - char userpref_flag; + char app_flag; char viewzoom; + short language; int mixbufsize; int audiodevice; @@ -774,7 +782,6 @@ typedef struct UserDef { /** Legacy, for backwards compatibility only. */ int compute_device_type; - char _pad6[4]; /** Opacity of inactive F-Curves in F-Curve Editor. */ float fcu_inactive_alpha; @@ -796,8 +803,6 @@ typedef struct UserDef { /** Pie menu distance from center before a direction is set. */ short pie_menu_threshold; - struct WalkNavigation walk_navigation; - short opensubdiv_compute_type; /** #eMultiSample_Type, amount of samples for Grease Pencil. */ short gpencil_multisamples; @@ -806,7 +811,12 @@ typedef struct UserDef { char viewport_aa; - char _pad5[2]; + char _pad5[6]; + + struct WalkNavigation walk_navigation; + + /** The UI for the user preferences. */ + UserDef_SpaceData space_data; /** Runtime data (keep last). */ UserDef_Runtime runtime; @@ -820,7 +830,7 @@ extern UserDef U; /* Toggles for unfinished 2.8 UserPref design. */ //#define WITH_USERDEF_WORKSPACES -/** #UserDef.userpref (UI active_section) */ +/** #UserDef_SpaceData.section_active (UI active_section) */ typedef enum eUserPref_Section { USER_SECTION_INTERFACE = 0, USER_SECTION_EDITING = 1, @@ -842,11 +852,12 @@ typedef enum eUserPref_Section { USER_SECTION_FILE_PATHS = 15, } eUserPref_Section; -/** UserDef.userpref_flag (State of the user preferences UI). */ -typedef enum eUserPref_SectionFlag { - /* Hide/expand keymap preferences. */ - USER_SECTION_INPUT_HIDE_UI_KEYCONFIG = (1 << 0), -} eUserPref_SectionFlag; +/** #UserDef_SpaceData.flag (State of the user preferences UI). */ +typedef enum eUserPrefUI_Flag { + /** Hide/expand key-map preferences. */ + USER_SPACEDATA_INPUT_HIDE_UI_KEYCONFIG = (1 << 0), + USER_SPACEDATA_ADDONS_SHOW_ONLY_ENABLED = (1 << 1), +} eUserPrefUI_Flag; /** #UserDef.flag */ typedef enum eUserPref_Flag { @@ -877,7 +888,7 @@ typedef enum eUserPref_Flag { USER_NONEGFRAMES = (1 << 24), USER_TXT_TABSTOSPACES_DISABLE = (1 << 25), USER_TOOLTIPS_PYTHON = (1 << 26), - USER_ADDONS_ENABLED_ONLY = (1 << 27), + USER_FLAG_UNUSED_27 = (1 << 27), /* dirty */ } eUserPref_Flag; typedef enum eUserPref_PrefFlag { diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 64ed284eb1f..7c6247180a3 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -4112,7 +4112,7 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "show_addons_enabled_only", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_ADDONS_ENABLED_ONLY); + RNA_def_property_boolean_sdna(prop, NULL, "space_data.flag", USER_SPACEDATA_ADDONS_SHOW_ONLY_ENABLED); RNA_def_property_ui_text(prop, "Enabled Add-ons Only", "Only show enabled add-ons. Un-check to see all installed add-ons"); @@ -5463,7 +5463,7 @@ static void rna_def_userdef_keymap(BlenderRNA *brna) prop = RNA_def_property(srna, "show_ui_keyconfig", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna( - prop, NULL, "userpref_flag", USER_SECTION_INPUT_HIDE_UI_KEYCONFIG); + prop, NULL, "space_data.flag", USER_SPACEDATA_INPUT_HIDE_UI_KEYCONFIG); RNA_def_property_ui_text(prop, "Show UI Key-Config", ""); prop = RNA_def_property(srna, "active_keyconfig", PROP_STRING, PROP_DIRPATH); @@ -5744,7 +5744,7 @@ void RNA_def_userdef(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Preferences", "Global preferences"); prop = RNA_def_property(srna, "active_section", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "userpref"); + RNA_def_property_enum_sdna(prop, NULL, "space_data.section_active"); RNA_def_property_enum_items(prop, preference_section_items); RNA_def_property_ui_text( prop, "Active Section", "Active section of the preferences shown in the user interface"); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index af841f20620..c7f38a7f53b 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1767,7 +1767,7 @@ static void wm_userpref_read_exceptions(UserDef *userdef_curr, const UserDef *us ((void)0) /* Current visible preferences category. */ - USERDEF_RESTORE(userpref); + USERDEF_RESTORE(space_data.section_active); #undef USERDEF_RESTORE } |