Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_common.py13
-rw-r--r--release/scripts/startup/bl_ui/space_topbar.py21
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c12
3 files changed, 39 insertions, 7 deletions
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index e03b3eb585d..b8e3d81c1d4 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -513,16 +513,21 @@ class ToolSelectPanelHelper:
self.draw_cls(self.layout, context)
@staticmethod
- def draw_active_tool_header(context, layout):
+ def draw_active_tool_header(
+ context, layout,
+ *,
+ show_tool_name=False,
+ ):
# BAD DESIGN WARNING: last used tool
workspace = context.workspace
space_type = workspace.tools_space_type
mode = workspace.tools_mode
item, tool, icon_value = ToolSelectPanelHelper._tool_get_active(context, space_type, mode, with_icon=True)
if item is None:
- return
- # Note: we could show 'item.text' here but it makes the layout jitter when switcuing tools.
- layout.label(text=" ", icon_value=icon_value)
+ return None
+ # Note: we could show 'item.text' here but it makes the layout jitter when switching tools.
+ # Add some spacing since the icon is currently assuming regular small icon size.
+ layout.label(text=" " + item.text if show_tool_name else " ", icon_value=icon_value)
draw_settings = item.draw_settings
if draw_settings is not None:
draw_settings(context, layout, tool)
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index b6a68f06785..3395889cf82 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -614,6 +614,26 @@ class TOPBAR_MT_workspace_menu(Menu):
layout.operator("workspace.delete", text="Delete")
+class TOPBAR_PT_active_tool(Panel):
+ bl_space_type = 'PROPERTIES'
+ bl_region_type = 'WINDOW'
+ bl_category = ""
+ bl_context = ".active_tool" # dot on purpose (access from tool settings)
+ bl_label = "Active Tool"
+
+ def draw(self, context):
+ layout = self.layout
+
+ # Panel display of topbar tool settings.
+ # currently displays in tool settings, keep here since the same functionality is used for the topbar.
+
+ layout.use_property_split = True
+ layout.use_property_decorate = False
+
+ from .space_toolsystem_common import ToolSelectPanelHelper
+ ToolSelectPanelHelper.draw_active_tool_header(context, layout, show_tool_name=True)
+
+
classes = (
TOPBAR_HT_upper_bar,
TOPBAR_HT_lower_bar,
@@ -630,6 +650,7 @@ classes = (
TOPBAR_MT_render,
TOPBAR_MT_window,
TOPBAR_MT_help,
+ TOPBAR_PT_active_tool,
)
if __name__ == "__main__": # only for live edit.
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 0350e3fcd14..fe10eee0536 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -200,11 +200,13 @@ static void buttons_main_region_layout_properties(const bContext *C, SpaceButs *
static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
{
- const char *contexts[3] = {NULL};
-
const WorkSpace *workspace = CTX_wm_workspace(C);
const int mode = CTX_data_mode_enum(C);
+ const char *contexts_base[4] = {NULL};
+ contexts_base[0] = ".active_tool";
+ const char **contexts = &contexts_base[1];
+
if (workspace->tools_space_type == SPACE_VIEW3D) {
switch (mode) {
case CTX_MODE_EDIT_MESH:
@@ -283,7 +285,7 @@ static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
}
const bool vertical = true;
- ED_region_panels_layout_ex(C, ar, contexts, -1, vertical);
+ ED_region_panels_layout_ex(C, ar, contexts_base, -1, vertical);
}
static void buttons_main_region_layout(const bContext *C, ARegion *ar)
@@ -365,6 +367,10 @@ static void buttons_header_region_message_subscribe(
if (!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_WORLD)) {
WM_msg_subscribe_rna_anon_prop(mbus, ViewLayer, name, &msg_sub_value_region_tag_redraw);
}
+
+ if (sbuts->mainb == BCONTEXT_TOOL) {
+ WM_msg_subscribe_rna_anon_prop(mbus, WorkSpace, tools, &msg_sub_value_region_tag_redraw);
+ }
}
/* draw a certain button set only if properties area is currently