[Bf-blender-cvs] [d7672ad0f7f] master: Fix tool settings showing in the top-bar
Campbell Barton
noreply at git.blender.org
Wed Apr 24 08:15:08 CEST 2019
Commit: d7672ad0f7f4f4bcf3cb13c72ff19425f3be9709
Author: Campbell Barton
Date: Wed Apr 24 16:11:16 2019 +1000
Branches: master
https://developer.blender.org/rBd7672ad0f7f4f4bcf3cb13c72ff19425f3be9709
Fix tool settings showing in the top-bar
Each spaces top-bar wasn't showing it's own active tool,
Remove RNA access to the workspaces tool since using it is error prone.
Eventually this should be completely removed.
===================================================================
M release/scripts/startup/bl_ui/space_toolsystem_common.py
M source/blender/makesrna/intern/rna_workspace.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index aa9e0bf979f..315efc6ecf7 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -543,13 +543,23 @@ class ToolSelectPanelHelper:
def draw(self, context):
self.draw_cls(self.layout, context)
+ @staticmethod
+ def _tool_key_from_context(context):
+ space_data = context.space_data
+ space_type = space_data.type
+ if space_type == 'VIEW_3D':
+ return space_type, context.mode
+ elif space_type == 'IMAGE_EDITOR':
+ return space_type, space_data.mode
+ elif space_type == 'NODE_EDITOR':
+ return space_type, None
+ else:
+ return None, None
+
@staticmethod
def tool_active_from_context(context):
- # BAD DESIGN WARNING: last used tool
- workspace = context.workspace
- space_type = workspace.tools_space_type
- mode = workspace.tools_mode
- return ToolSelectPanelHelper._tool_active_from_context(context, space_type, mode)
+ space_type = context.space_data.type
+ return ToolSelectPanelHelper._tool_active_from_context(context, space_type)
@staticmethod
def draw_active_tool_header(
@@ -557,10 +567,9 @@ class ToolSelectPanelHelper:
*,
show_tool_name=False,
):
- # BAD DESIGN WARNING: last used tool
- workspace = context.workspace
- space_type = workspace.tools_space_type
- mode = workspace.tools_mode
+ space_type, mode = ToolSelectPanelHelper._tool_key_from_context(context)
+ if space_type is None:
+ return None
item, tool, icon_value = ToolSelectPanelHelper._tool_get_active(context, space_type, mode, with_icon=True)
if item is None:
return None
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index 5e4791b8b7a..6349b5206d6 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -158,9 +158,8 @@ const EnumPropertyItem *rna_WorkSpace_tools_mode_itemf(bContext *UNUSED(C),
PropertyRNA *UNUSED(prop),
bool *UNUSED(r_free))
{
- WorkSpace *workspace = ptr->id.data;
-
- switch (workspace->tools_space_type) {
+ bToolRef *tref = ptr->data;
+ switch (tref->space_type) {
case SPACE_VIEW3D:
return rna_enum_context_mode_items;
case SPACE_IMAGE:
@@ -372,19 +371,6 @@ static void rna_def_workspace(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Tools", "");
rna_def_workspace_tools(brna, prop);
- prop = RNA_def_property(srna, "tools_space_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "tools_space_type");
- RNA_def_property_enum_items(prop, rna_enum_space_type_items);
- RNA_def_property_ui_text(prop, "Active Tool Space", "");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "tools_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "tools_mode");
- RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items);
- RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_WorkSpace_tools_mode_itemf");
- RNA_def_property_ui_text(prop, "Active Tool Mode", "");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_workspace_object_mode_items);
RNA_def_property_ui_text(
More information about the Bf-blender-cvs
mailing list