Workspaces: switch object mode when switching workspaces.
In the workspace properties a mode can now be configured that is automatically enabled when switching to the workspace. This is a test to validate how well it works. The weak point is that if you don't have an appropriate object already select it will not switch modes. See T56475.
This commit is contained in:
parent
df8a7ec3a8
commit
9f78f471d7
|
@ -92,7 +92,7 @@ _modules = [
|
|||
"space_view3d_toolbar",
|
||||
|
||||
# XXX, keep last so panels show after all other tool options.
|
||||
"properties_data_workspace",
|
||||
"properties_workspace",
|
||||
]
|
||||
|
||||
import bpy
|
||||
|
|
|
@ -36,11 +36,15 @@ class WORKSPACE_PT_main(WorkSpaceButtonsPanel, Panel):
|
|||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
def draw(self, context):
|
||||
pass
|
||||
workspace = context.workspace
|
||||
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
layout.prop(workspace, "object_mode", text="Mode")
|
||||
|
||||
|
||||
class WORKSPACE_PT_owner_ids(WorkSpaceButtonsPanel, Panel):
|
||||
bl_label = "Workspace Add-ons"
|
||||
class WORKSPACE_PT_addons(WorkSpaceButtonsPanel, Panel):
|
||||
bl_label = "Filter Add-ons"
|
||||
bl_parent_id = "WORKSPACE_PT_main"
|
||||
|
||||
def draw_header(self, context):
|
||||
|
@ -102,7 +106,7 @@ class WORKSPACE_PT_custom_props(WorkSpaceButtonsPanel, PropertyPanel, Panel):
|
|||
|
||||
classes = (
|
||||
WORKSPACE_PT_main,
|
||||
WORKSPACE_PT_owner_ids,
|
||||
WORKSPACE_PT_addons,
|
||||
WORKSPACE_PT_custom_props,
|
||||
)
|
||||
|
|
@ -76,6 +76,26 @@ void BLO_update_defaults_userpref_blend(void)
|
|||
* This function can be emptied each time the startup.blend is updated. */
|
||||
void BLO_update_defaults_startup_blend(Main *bmain)
|
||||
{
|
||||
for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
|
||||
const char *name = workspace->id.name + 2;
|
||||
|
||||
if (STREQ(name, "2D Animation")) {
|
||||
workspace->object_mode = OB_MODE_GPENCIL_PAINT;
|
||||
}
|
||||
if (STREQ(name, "3D Animation")) {
|
||||
workspace->object_mode = OB_MODE_POSE;
|
||||
}
|
||||
else if (STREQ(name, "Texture Paint")) {
|
||||
workspace->object_mode = OB_MODE_TEXTURE_PAINT;
|
||||
}
|
||||
else if (STREQ(name, "Sculpting")) {
|
||||
workspace->object_mode = OB_MODE_SCULPT;
|
||||
}
|
||||
else if (STREQ(name, "UV Editing")) {
|
||||
workspace->object_mode = OB_MODE_EDIT;
|
||||
}
|
||||
}
|
||||
|
||||
for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
|
||||
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
|
||||
for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
|
||||
|
|
|
@ -172,24 +172,29 @@ bool ED_workspace_change(
|
|||
screen_new = screen_change_prepare(screen_old, screen_new, bmain, C, win);
|
||||
BLI_assert(BKE_workspace_layout_screen_get(layout_new) == screen_new);
|
||||
|
||||
if (screen_new) {
|
||||
BKE_workspace_hook_layout_for_workspace_set(win->workspace_hook, workspace_new, layout_new);
|
||||
BKE_workspace_active_set(win->workspace_hook, workspace_new);
|
||||
|
||||
/* update screen *after* changing workspace - which also causes the
|
||||
* actual screen change and updates context (including CTX_wm_workspace) */
|
||||
screen_change_update(C, win, screen_new);
|
||||
workspace_change_update(workspace_new, workspace_old, C, wm);
|
||||
|
||||
BLI_assert(CTX_wm_workspace(C) == workspace_new);
|
||||
|
||||
WM_toolsystem_unlink_all(C, workspace_old);
|
||||
WM_toolsystem_reinit_all(C, win);
|
||||
|
||||
return true;
|
||||
if (screen_new == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
BKE_workspace_hook_layout_for_workspace_set(win->workspace_hook, workspace_new, layout_new);
|
||||
BKE_workspace_active_set(win->workspace_hook, workspace_new);
|
||||
|
||||
/* update screen *after* changing workspace - which also causes the
|
||||
* actual screen change and updates context (including CTX_wm_workspace) */
|
||||
screen_change_update(C, win, screen_new);
|
||||
workspace_change_update(workspace_new, workspace_old, C, wm);
|
||||
|
||||
BLI_assert(CTX_wm_workspace(C) == workspace_new);
|
||||
|
||||
WM_toolsystem_unlink_all(C, workspace_old);
|
||||
WM_toolsystem_reinit_all(C, win);
|
||||
|
||||
/* Automatic mode switching. */
|
||||
if (workspace_new->object_mode != workspace_old->object_mode) {
|
||||
ED_object_mode_generic_enter(C, workspace_new->object_mode);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -144,8 +144,10 @@ typedef struct WorkSpace {
|
|||
char tools_space_type;
|
||||
/** Type is different for each space-type. */
|
||||
char tools_mode;
|
||||
char _pad[6];
|
||||
|
||||
int object_mode;
|
||||
|
||||
char _pad[2];
|
||||
int flags DNA_PRIVATE_WORKSPACE; /* enum eWorkSpaceFlags */
|
||||
|
||||
/* Info text from modal operators (runtime). */
|
||||
|
|
|
@ -43,6 +43,7 @@ extern const EnumPropertyItem DummyRNA_DEFAULT_items[];
|
|||
extern const EnumPropertyItem rna_enum_id_type_items[];
|
||||
|
||||
extern const EnumPropertyItem rna_enum_object_mode_items[];
|
||||
extern const EnumPropertyItem rna_enum_workspace_object_mode_items[];
|
||||
extern const EnumPropertyItem rna_enum_object_empty_drawtype_items[];
|
||||
extern const EnumPropertyItem rna_enum_object_gpencil_type_items[];
|
||||
extern const EnumPropertyItem rna_enum_metaelem_type_items[];
|
||||
|
|
|
@ -81,6 +81,23 @@ const EnumPropertyItem rna_enum_object_mode_items[] = {
|
|||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* Same as above, but with names that distinguish grease pencil. */
|
||||
const EnumPropertyItem rna_enum_workspace_object_mode_items[] = {
|
||||
{OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object Mode", ""},
|
||||
{OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit Mode", ""},
|
||||
{OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose Mode", ""},
|
||||
{OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""},
|
||||
{OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
|
||||
{OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
|
||||
{OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
|
||||
{OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""},
|
||||
{OB_MODE_GPENCIL_EDIT, "GPENCIL_EDIT", ICON_EDITMODE_HLT, "Grease Pencil Edit Mode", "Edit Grease Pencil Strokes"},
|
||||
{OB_MODE_GPENCIL_SCULPT, "GPENCIL_SCULPT", ICON_SCULPTMODE_HLT, "Grease Pencil Sculpt Mode", "Sculpt Grease Pencil Strokes"},
|
||||
{OB_MODE_GPENCIL_PAINT, "GPENCIL_PAINT", ICON_GREASEPENCIL, "Grease Pencil Draw", "Paint Grease Pencil Strokes"},
|
||||
{OB_MODE_GPENCIL_WEIGHT, "GPENCIL_WEIGHT", ICON_WPAINT_HLT, "Grease Pencil Weight Paint", "Grease Pencil Weight Paint Strokes" },
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
const EnumPropertyItem rna_enum_object_empty_drawtype_items[] = {
|
||||
{OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""},
|
||||
{OB_ARROWS, "ARROWS", 0, "Arrows", ""},
|
||||
|
|
|
@ -320,11 +320,9 @@ static void rna_def_workspace(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Active Tool Space", "Tool mode");
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
|
||||
#if 0
|
||||
prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, rna_enum_object_mode_items);
|
||||
RNA_def_property_ui_text(prop, "Mode", "Object interaction mode used in this window");
|
||||
#endif
|
||||
RNA_def_property_enum_items(prop, rna_enum_workspace_object_mode_items);
|
||||
RNA_def_property_ui_text(prop, "Object Mode", "Switch to this object mode when activating the workspace");
|
||||
|
||||
/* Flags */
|
||||
prop = RNA_def_property(srna, "use_filter_by_owner", PROP_BOOLEAN, PROP_NONE);
|
||||
|
|
Loading…
Reference in New Issue