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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-08-21 16:27:29 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-08-30 17:10:03 +0300
commit9f78f471d7aeacd357349f0eb4b8f8bbc01db756 (patch)
treee6dd30928d9566ad86cf19658f691e3c78fe887c /source/blender
parentdf8a7ec3a81394fef4a21a6f1c1e4a43d5d44fba (diff)
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.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c20
-rw-r--r--source/blender/editors/screen/workspace_edit.c29
-rw-r--r--source/blender/makesdna/DNA_workspace_types.h4
-rw-r--r--source/blender/makesrna/RNA_enum_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_object.c17
-rw-r--r--source/blender/makesrna/intern/rna_workspace.c6
6 files changed, 60 insertions, 17 deletions
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index e6f8e70f70b..1fd82d01cf5 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -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) {
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 246d2fed1a1..77fc20a98a5 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -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);
+ if (screen_new == NULL) {
+ return false;
+ }
- /* 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);
+ BKE_workspace_hook_layout_for_workspace_set(win->workspace_hook, workspace_new, layout_new);
+ BKE_workspace_active_set(win->workspace_hook, workspace_new);
- BLI_assert(CTX_wm_workspace(C) == 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);
- WM_toolsystem_unlink_all(C, workspace_old);
- WM_toolsystem_reinit_all(C, win);
+ BLI_assert(CTX_wm_workspace(C) == workspace_new);
- return true;
+ 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 false;
+ return true;
}
/**
diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h
index 3eb40bfa523..fd56c246c96 100644
--- a/source/blender/makesdna/DNA_workspace_types.h
+++ b/source/blender/makesdna/DNA_workspace_types.h
@@ -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). */
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index 8d3d7f81deb..613454e2f33 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -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[];
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index ec5daa69d6d..6fbd7abaa39 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -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", ""},
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index db6a58fa85e..b9ca6412f7a 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -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);