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>2019-09-05 21:21:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-09-05 21:44:12 +0300
commit1efd857430459210f9656b15d4c8586a3fef7f70 (patch)
treef16e15c0f99648978f54e839b15dd34275da0a5e /source/blender/editors/mesh
parentc25c3f73c4670de0e1d3c9dbea5f46abf8dccd3e (diff)
Object: Mode switching operator
Remove unused OBJECT_OT_mode_set_or_submode, add OBJECT_OT_mode_set_with_submode which can switch to edit mode as well as a sub-mode - currently only mesh select mode is supported (others may be added later).
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r--source/blender/editors/mesh/editmesh_select.c60
1 files changed, 54 insertions, 6 deletions
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index ce8d26542d9..d11a223f455 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -1343,7 +1343,7 @@ static int edbm_select_mode_exec(bContext *C, wmOperator *op)
const bool use_extend = RNA_boolean_get(op->ptr, "use_extend");
const bool use_expand = RNA_boolean_get(op->ptr, "use_expand");
- if (EDBM_selectmode_toggle(C, type, action, use_extend, use_expand)) {
+ if (EDBM_selectmode_toggle_multi(C, type, action, use_extend, use_expand)) {
return OPERATOR_FINISHED;
}
else {
@@ -2346,11 +2346,11 @@ void EDBM_selectmode_convert(BMEditMesh *em,
}
/* user facing function, does notification */
-bool EDBM_selectmode_toggle(bContext *C,
- const short selectmode_new,
- const int action,
- const bool use_extend,
- const bool use_expand)
+bool EDBM_selectmode_toggle_multi(bContext *C,
+ const short selectmode_new,
+ const int action,
+ const bool use_extend,
+ const bool use_expand)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -2472,6 +2472,54 @@ bool EDBM_selectmode_toggle(bContext *C,
return ret;
}
+bool EDBM_selectmode_set_multi(bContext *C, const short selectmode)
+{
+ BLI_assert(selectmode != 0);
+ bool changed = false;
+
+ {
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = NULL;
+ if (obedit && obedit->type == OB_MESH) {
+ em = BKE_editmesh_from_object(obedit);
+ }
+ if (em == NULL) {
+ return changed;
+ }
+ }
+
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Scene *scene = CTX_data_scene(C);
+ ToolSettings *ts = scene->toolsettings;
+
+ if (ts->selectmode != selectmode) {
+ ts->selectmode = selectmode;
+ changed = true;
+ }
+
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
+ view_layer, CTX_wm_view3d(C), &objects_len);
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob_iter = objects[ob_index];
+ BMEditMesh *em_iter = BKE_editmesh_from_object(ob_iter);
+ if (em_iter->selectmode != ts->selectmode) {
+ em_iter->selectmode = ts->selectmode;
+ EDBM_selectmode_set(em_iter);
+ DEG_id_tag_update(ob_iter->data, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob_iter->data);
+ changed = true;
+ }
+ }
+
+ if (changed) {
+ WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
+ }
+ return changed;
+}
+
/**
* Use to disable a selectmode if its enabled, Using another mode as a fallback
* if the disabled mode is the only mode set.