diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-01-03 04:26:36 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-01-03 04:34:55 +0300 |
commit | a8ce9a143abbb51eae28e5d0cae1fb310bd0c24c (patch) | |
tree | b883f6e266a4e89693be856ee2fae0efd9f120d4 /source | |
parent | a854840e76ae3e0724531524e8b1d7a4cd63ea1d (diff) |
Tool System: store the fallback tool for re-use
The fallback tool was run-time only data,
now it's stored in the blend file.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesdna/DNA_workspace_types.h | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_workspace.c | 24 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_workspace_api.c | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_toolsystem.c | 2 |
4 files changed, 12 insertions, 24 deletions
diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h index 573b076542e..d2461657480 100644 --- a/source/blender/makesdna/DNA_workspace_types.h +++ b/source/blender/makesdna/DNA_workspace_types.h @@ -35,8 +35,7 @@ typedef struct bToolRef_Runtime { char gizmo_group[64]; char data_block[64]; - /** Optionally use these when not interacting directly with the primary tools gizmo. */ - char idname_fallback[64]; + /** Keymap for #bToolRef.idname_fallback, if set. */ char keymap_fallback[64]; /** Use to infer primary operator to use when setting accelerator keys. */ @@ -51,6 +50,9 @@ typedef struct bToolRef { struct bToolRef *next, *prev; char idname[64]; + /** Optionally use these when not interacting directly with the primary tools gizmo. */ + char idname_fallback[64]; + /** Use to avoid initializing the same tool multiple times. */ short tag; diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c index 7c6e3c2730b..4d4ab64abb9 100644 --- a/source/blender/makesrna/intern/rna_workspace.c +++ b/source/blender/makesrna/intern/rna_workspace.c @@ -192,18 +192,6 @@ static int rna_WorkSpaceTool_widget_length(PointerRNA *ptr) return tref->runtime ? strlen(tref->runtime->gizmo_group) : 0; } -static void rna_WorkSpaceTool_tool_fallback_get(PointerRNA *ptr, char *value) -{ - bToolRef *tref = ptr->data; - strcpy(value, tref->runtime ? tref->runtime->idname_fallback : ""); -} - -static int rna_WorkSpaceTool_tool_fallback_length(PointerRNA *ptr) -{ - bToolRef *tref = ptr->data; - return tref->runtime ? strlen(tref->runtime->idname_fallback) : 0; -} - #else /* RNA_RUNTIME */ static void rna_def_workspace_owner(BlenderRNA *brna) @@ -270,6 +258,10 @@ static void rna_def_workspace_tool(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Identifier", ""); RNA_def_struct_name_property(srna, prop); + prop = RNA_def_property(srna, "idname_fallback", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Identifier Fallback", ""); + RNA_def_struct_name_property(srna, prop); + prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Index", ""); @@ -300,14 +292,6 @@ static void rna_def_workspace_tool(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Widget", ""); RNA_def_property_string_funcs( prop, "rna_WorkSpaceTool_widget_get", "rna_WorkSpaceTool_widget_length", NULL); - RNA_define_verify_sdna(1); - - prop = RNA_def_property(srna, "tool_fallback", PROP_STRING, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Fallback", ""); - RNA_def_property_string_funcs( - prop, "rna_WorkSpaceTool_tool_fallback_get", "rna_WorkSpaceTool_tool_fallback_length", NULL); - RNA_define_verify_sdna(1); RNA_api_workspace_tool(srna); } diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c index 5cc55bfad8a..4fb6677199f 100644 --- a/source/blender/makesrna/intern/rna_workspace_api.c +++ b/source/blender/makesrna/intern/rna_workspace_api.c @@ -63,7 +63,9 @@ static void rna_WorkSpaceTool_setup(ID *id, STRNCPY(tref_rt.op, op_idname); tref_rt.index = index; - STRNCPY(tref_rt.idname_fallback, idname_fallback); + /* While it's logical to assign both these values from setup, + * it's useful to stored this in DNA for re-use, exceptional case: write to the 'tref'. */ + STRNCPY(tref->idname_fallback, idname_fallback); STRNCPY(tref_rt.keymap_fallback, keymap_fallback); WM_toolsystem_ref_set_from_runtime(C, (WorkSpace *)id, tref, &tref_rt, idname); diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index c79f75b5b21..45836604109 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -366,7 +366,7 @@ void WM_toolsystem_ref_set_from_runtime(struct bContext *C, } } if (use_fallback_keymap == false) { - tref->runtime->idname_fallback[0] = '\0'; + tref->idname_fallback[0] = '\0'; tref->runtime->keymap_fallback[0] = '\0'; } |