UI: add active tool panel to tool settings
This commit is contained in:
@@ -513,16 +513,21 @@ class ToolSelectPanelHelper:
|
|||||||
self.draw_cls(self.layout, context)
|
self.draw_cls(self.layout, context)
|
||||||
|
|
||||||
@staticmethod
|
@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
|
# BAD DESIGN WARNING: last used tool
|
||||||
workspace = context.workspace
|
workspace = context.workspace
|
||||||
space_type = workspace.tools_space_type
|
space_type = workspace.tools_space_type
|
||||||
mode = workspace.tools_mode
|
mode = workspace.tools_mode
|
||||||
item, tool, icon_value = ToolSelectPanelHelper._tool_get_active(context, space_type, mode, with_icon=True)
|
item, tool, icon_value = ToolSelectPanelHelper._tool_get_active(context, space_type, mode, with_icon=True)
|
||||||
if item is None:
|
if item is None:
|
||||||
return
|
return None
|
||||||
# Note: we could show 'item.text' here but it makes the layout jitter when switcuing tools.
|
# Note: we could show 'item.text' here but it makes the layout jitter when switching tools.
|
||||||
layout.label(text=" ", icon_value=icon_value)
|
# 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
|
draw_settings = item.draw_settings
|
||||||
if draw_settings is not None:
|
if draw_settings is not None:
|
||||||
draw_settings(context, layout, tool)
|
draw_settings(context, layout, tool)
|
||||||
|
|||||||
@@ -614,6 +614,26 @@ class TOPBAR_MT_workspace_menu(Menu):
|
|||||||
layout.operator("workspace.delete", text="Delete")
|
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 = (
|
classes = (
|
||||||
TOPBAR_HT_upper_bar,
|
TOPBAR_HT_upper_bar,
|
||||||
TOPBAR_HT_lower_bar,
|
TOPBAR_HT_lower_bar,
|
||||||
@@ -630,6 +650,7 @@ classes = (
|
|||||||
TOPBAR_MT_render,
|
TOPBAR_MT_render,
|
||||||
TOPBAR_MT_window,
|
TOPBAR_MT_window,
|
||||||
TOPBAR_MT_help,
|
TOPBAR_MT_help,
|
||||||
|
TOPBAR_PT_active_tool,
|
||||||
)
|
)
|
||||||
|
|
||||||
if __name__ == "__main__": # only for live edit.
|
if __name__ == "__main__": # only for live edit.
|
||||||
|
|||||||
@@ -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)
|
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 WorkSpace *workspace = CTX_wm_workspace(C);
|
||||||
const int mode = CTX_data_mode_enum(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) {
|
if (workspace->tools_space_type == SPACE_VIEW3D) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case CTX_MODE_EDIT_MESH:
|
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;
|
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)
|
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)) {
|
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);
|
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
|
/* draw a certain button set only if properties area is currently
|
||||||
|
|||||||
Reference in New Issue
Block a user