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:
authorCampbell Barton <ideasman42@gmail.com>2018-03-02 06:46:21 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-03-02 06:46:21 +0300
commitda2d0fe43af030b5fe6e11226e7e691242f001aa (patch)
tree2f701d643bad9a51616a1a47d96a3d36acc43c26
parent4913e47aa0107cbe1daf06e8020a60916ea883a3 (diff)
parentff74357da09d5060d61d247f75dbb01e91ca3bb9 (diff)
Merge branch 'master' into blender2.8
-rw-r--r--source/blender/editors/animation/keyframing.c4
-rw-r--r--source/blender/editors/armature/pose_edit.c2
-rw-r--r--source/blender/editors/include/ED_object.h7
-rw-r--r--source/blender/editors/object/CMakeLists.txt1
-rw-r--r--source/blender/editors/object/object_edit.c107
-rw-r--r--source/blender/editors/object/object_modes.c140
-rw-r--r--source/blender/editors/util/ed_util.c2
7 files changed, 154 insertions, 109 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 6df0a1cd302..4ed5c49c1e3 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1358,7 +1358,7 @@ static int insert_key_exec(bContext *C, wmOperator *op)
* updated since the last switching to the edit mode will be keyframed correctly
*/
if (obedit && ANIM_keyingset_find_id(ks, (ID *)obedit->data)) {
- ED_object_toggle_modes(C, OB_MODE_EDIT);
+ ED_object_mode_toggle(C, OB_MODE_EDIT);
ob_edit_mode = true;
}
@@ -1369,7 +1369,7 @@ static int insert_key_exec(bContext *C, wmOperator *op)
/* restore the edit mode if necessary */
if (ob_edit_mode) {
- ED_object_toggle_modes(C, OB_MODE_EDIT);
+ ED_object_mode_toggle(C, OB_MODE_EDIT);
}
/* report failure or do updates? */
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 83eb1225c4c..3f2cf6f5853 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -109,7 +109,7 @@ void ED_armature_enter_posemode(bContext *C, Base *base)
}
/* XXX: disabled as this would otherwise cause a nasty loop... */
- //ED_object_toggle_modes(C, ob->mode);
+ //ED_object_mode_toggle(C, ob->mode);
}
void ED_armature_exit_posemode(bContext *C, Base *base)
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 3e04c8ccc8e..6c53d24ef8c 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -118,9 +118,6 @@ struct Base *ED_object_add_duplicate(struct Main *bmain, struct Scene *scene, st
void ED_object_parent(struct Object *ob, struct Object *parent, const int type, const char *substr);
-bool ED_object_mode_compat_set(struct bContext *C, struct WorkSpace *workspace, eObjectMode mode, struct ReportList *reports);
-void ED_object_toggle_modes(struct bContext *C, eObjectMode mode);
-
/* bitflags for enter/exit editmode */
#define EM_FREEDATA 1
#define EM_FREEUNDO 2
@@ -217,6 +214,10 @@ void undo_push_lattice(struct bContext *C, const char *name);
void ED_lattice_flags_set(struct Object *obedit, int flag);
+bool ED_object_mode_compat_test(const struct Object *ob, eObjectMode mode);
+bool ED_object_mode_compat_set(struct bContext *C, struct WorkSpace *workspace, eObjectMode mode, struct ReportList *reports);
+void ED_object_mode_toggle(struct bContext *C, eObjectMode mode);
+
/* object_modifier.c */
enum {
MODIFIER_APPLY_DATA = 1,
diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt
index 8050508983b..3c75f08bd00 100644
--- a/source/blender/editors/object/CMakeLists.txt
+++ b/source/blender/editors/object/CMakeLists.txt
@@ -52,6 +52,7 @@ set(SRC
object_hook.c
object_lattice.c
object_lod.c
+ object_modes.c
object_modifier.c
object_ops.c
object_random.c
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index ec81cdfdf69..db646472af5 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -366,7 +366,7 @@ void ED_object_editmode_enter(bContext *C, int flag)
/* note, when switching scenes the object can have editmode data but
* not be scene->obedit: bug 22954, this avoids calling self eternally */
if ((workspace->object_mode_restore & OB_MODE_EDIT) == 0)
- ED_object_toggle_modes(C, workspace->object_mode);
+ ED_object_mode_toggle(C, workspace->object_mode);
workspace->object_mode = OB_MODE_EDIT;
@@ -1491,92 +1491,6 @@ static const EnumPropertyItem *object_mode_set_itemsf(
return item;
}
-static const char *object_mode_op_string(eObjectMode mode)
-{
- if (mode & OB_MODE_EDIT)
- return "OBJECT_OT_editmode_toggle";
- if (mode == OB_MODE_SCULPT)
- return "SCULPT_OT_sculptmode_toggle";
- if (mode == OB_MODE_VERTEX_PAINT)
- return "PAINT_OT_vertex_paint_toggle";
- if (mode == OB_MODE_WEIGHT_PAINT)
- return "PAINT_OT_weight_paint_toggle";
- if (mode == OB_MODE_TEXTURE_PAINT)
- return "PAINT_OT_texture_paint_toggle";
- if (mode == OB_MODE_PARTICLE_EDIT)
- return "PARTICLE_OT_particle_edit_toggle";
- if (mode == OB_MODE_POSE)
- return "OBJECT_OT_posemode_toggle";
- if (mode == OB_MODE_GPENCIL)
- return "GPENCIL_OT_editmode_toggle";
- return NULL;
-}
-
-/* checks the mode to be set is compatible with the object
- * should be made into a generic function
- */
-static bool object_mode_compat_test(Object *ob, eObjectMode mode)
-{
- if (ob) {
- if (mode == OB_MODE_OBJECT)
- return true;
- else if (mode == OB_MODE_GPENCIL)
- return true; /* XXX: assume this is the case for now... */
-
- switch (ob->type) {
- case OB_MESH:
- if (mode & (OB_MODE_EDIT | OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT |
- OB_MODE_TEXTURE_PAINT | OB_MODE_PARTICLE_EDIT))
- {
- return true;
- }
- break;
- case OB_CURVE:
- case OB_SURF:
- case OB_FONT:
- case OB_MBALL:
- if (mode & (OB_MODE_EDIT))
- return true;
- break;
- case OB_LATTICE:
- if (mode & (OB_MODE_EDIT | OB_MODE_WEIGHT_PAINT))
- return true;
- break;
- case OB_ARMATURE:
- if (mode & (OB_MODE_EDIT | OB_MODE_POSE))
- return true;
- break;
- }
- }
-
- return false;
-}
-
-/**
- * Sets the mode to a compatible state (use before entering the mode).
- *
- * This is so each mode's exec function can call
- */
-bool ED_object_mode_compat_set(bContext *C, WorkSpace *workspace, eObjectMode mode, ReportList *reports)
-{
- bool ok;
- if (!ELEM(workspace->object_mode, mode, OB_MODE_OBJECT)) {
- const char *opstring = object_mode_op_string(workspace->object_mode);
-
- WM_operator_name_call(C, opstring, WM_OP_EXEC_REGION_WIN, NULL);
- ok = ELEM(workspace->object_mode, mode, OB_MODE_OBJECT);
- if (!ok) {
- wmOperatorType *ot = WM_operatortype_find(opstring, false);
- BKE_reportf(reports, RPT_ERROR, "Unable to execute '%s', error changing modes", ot->name);
- }
- }
- else {
- ok = true;
- }
-
- return ok;
-}
-
static int object_mode_set_poll(bContext *C)
{
/* Since Grease Pencil editmode is also handled here,
@@ -1617,7 +1531,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
}
}
- if (!ob || !object_mode_compat_test(ob, mode))
+ if (!ob || !ED_object_mode_compat_test(ob, mode))
return OPERATOR_PASS_THROUGH;
if (workspace->object_mode != mode) {
@@ -1628,7 +1542,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
/* Exit current mode if it's not the mode we're setting */
if (mode != OB_MODE_OBJECT && (workspace->object_mode != mode || toggle)) {
/* Enter new mode */
- ED_object_toggle_modes(C, mode);
+ ED_object_mode_toggle(C, mode);
}
if (toggle) {
@@ -1637,14 +1551,14 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
(restore_mode == OB_MODE_OBJECT) &&
(workspace->object_mode_restore != OB_MODE_OBJECT))
{
- ED_object_toggle_modes(C, workspace->object_mode_restore);
+ ED_object_mode_toggle(C, workspace->object_mode_restore);
}
else if (workspace->object_mode == mode) {
/* For toggling, store old mode so we know what to go back to */
workspace->object_mode_restore = restore_mode;
}
else if (!ELEM(workspace->object_mode_restore, mode, OB_MODE_OBJECT)) {
- ED_object_toggle_modes(C, workspace->object_mode_restore);
+ ED_object_mode_toggle(C, workspace->object_mode_restore);
}
}
@@ -1676,17 +1590,6 @@ void OBJECT_OT_mode_set(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
-void ED_object_toggle_modes(bContext *C, eObjectMode mode)
-{
- if (mode != OB_MODE_OBJECT) {
- const char *opstring = object_mode_op_string(mode);
-
- if (opstring) {
- WM_operator_name_call(C, opstring, WM_OP_EXEC_REGION_WIN, NULL);
- }
- }
-}
-
/************************ Game Properties ***********************/
static int game_property_new_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c
new file mode 100644
index 00000000000..3dd496336ce
--- /dev/null
+++ b/source/blender/editors/object/object_modes.c
@@ -0,0 +1,140 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Foundation, 2002-2008 full recode
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/object/object_modes.c
+ * \ingroup edobj
+ *
+ * General utils to handle mode switching,
+ * actual mode switching logic is per-object type.
+ */
+
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_workspace_types.h"
+
+#include "BLI_utildefines.h"
+
+#include "BKE_context.h"
+#include "BKE_report.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_object.h"
+
+static const char *object_mode_op_string(eObjectMode mode)
+{
+ if (mode & OB_MODE_EDIT)
+ return "OBJECT_OT_editmode_toggle";
+ if (mode == OB_MODE_SCULPT)
+ return "SCULPT_OT_sculptmode_toggle";
+ if (mode == OB_MODE_VERTEX_PAINT)
+ return "PAINT_OT_vertex_paint_toggle";
+ if (mode == OB_MODE_WEIGHT_PAINT)
+ return "PAINT_OT_weight_paint_toggle";
+ if (mode == OB_MODE_TEXTURE_PAINT)
+ return "PAINT_OT_texture_paint_toggle";
+ if (mode == OB_MODE_PARTICLE_EDIT)
+ return "PARTICLE_OT_particle_edit_toggle";
+ if (mode == OB_MODE_POSE)
+ return "OBJECT_OT_posemode_toggle";
+ if (mode == OB_MODE_GPENCIL)
+ return "GPENCIL_OT_editmode_toggle";
+ return NULL;
+}
+
+/**
+ * Checks the mode to be set is compatible with the object
+ * should be made into a generic function
+ */
+bool ED_object_mode_compat_test(const Object *ob, eObjectMode mode)
+{
+ if (ob) {
+ if (mode == OB_MODE_OBJECT)
+ return true;
+ else if (mode == OB_MODE_GPENCIL)
+ return true; /* XXX: assume this is the case for now... */
+
+ switch (ob->type) {
+ case OB_MESH:
+ if (mode & (OB_MODE_EDIT | OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT |
+ OB_MODE_TEXTURE_PAINT | OB_MODE_PARTICLE_EDIT))
+ {
+ return true;
+ }
+ break;
+ case OB_CURVE:
+ case OB_SURF:
+ case OB_FONT:
+ case OB_MBALL:
+ if (mode & (OB_MODE_EDIT))
+ return true;
+ break;
+ case OB_LATTICE:
+ if (mode & (OB_MODE_EDIT | OB_MODE_WEIGHT_PAINT))
+ return true;
+ break;
+ case OB_ARMATURE:
+ if (mode & (OB_MODE_EDIT | OB_MODE_POSE))
+ return true;
+ break;
+ }
+ }
+
+ return false;
+}
+
+/**
+ * Sets the mode to a compatible state (use before entering the mode).
+ *
+ * This is so each mode's exec function can call
+ */
+bool ED_object_mode_compat_set(bContext *C, WorkSpace *workspace, eObjectMode mode, ReportList *reports)
+{
+ bool ok;
+ if (!ELEM(workspace->object_mode, mode, OB_MODE_OBJECT)) {
+ const char *opstring = object_mode_op_string(workspace->object_mode);
+
+ WM_operator_name_call(C, opstring, WM_OP_EXEC_REGION_WIN, NULL);
+ ok = ELEM(workspace->object_mode, mode, OB_MODE_OBJECT);
+ if (!ok) {
+ wmOperatorType *ot = WM_operatortype_find(opstring, false);
+ BKE_reportf(reports, RPT_ERROR, "Unable to execute '%s', error changing modes", ot->name);
+ }
+ }
+ else {
+ ok = true;
+ }
+
+ return ok;
+}
+
+void ED_object_mode_toggle(bContext *C, eObjectMode mode)
+{
+ if (mode != OB_MODE_OBJECT) {
+ const char *opstring = object_mode_op_string(mode);
+
+ if (opstring) {
+ WM_operator_name_call(C, opstring, WM_OP_EXEC_REGION_WIN, NULL);
+ }
+ }
+}
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 562ba2c42b3..7a5b8bfbda1 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -118,7 +118,7 @@ void ED_editors_init(bContext *C)
if (!ELEM(object_mode, OB_MODE_OBJECT, OB_MODE_POSE)) {
if (!ID_IS_LINKED(obact) && !(data && ID_IS_LINKED(data))) {
CTX_wm_window_set(C, win);
- ED_object_toggle_modes(C, object_mode);
+ ED_object_mode_toggle(C, object_mode);
CTX_wm_window_set(C, NULL);
}
}