diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-04-02 22:19:58 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-04-02 23:25:22 +0300 |
commit | 0faa065ed4aaa87e53bb574d950ebf8ac0cfd4a3 (patch) | |
tree | 5b281d48e9fc825c02074511ed4975439f193f45 /source/blender/editors | |
parent | 80e7a48f21e00c6ebd872cf53787687acce3511e (diff) |
Move to Collection: Popup for naming new collection
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index dab45a03b8a..c7aae4922e2 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -2082,7 +2082,9 @@ static int move_to_collection_exec(bContext *C, wmOperator *op) CTX_DATA_END; if (is_new) { - scene_collection = BKE_collection_add(&scene->id, scene_collection, COLLECTION_TYPE_NONE, NULL); + char new_collection_name[MAX_NAME]; + RNA_string_get(op->ptr, "new_collection_name", new_collection_name); + scene_collection = BKE_collection_add(&scene->id, scene_collection, COLLECTION_TYPE_NONE, new_collection_name); } if ((single_object != NULL) && @@ -2216,9 +2218,19 @@ static void move_to_collection_menus_items(uiLayout *layout, MoveToCollectionDat static int move_to_collection_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - PropertyRNA *prop = RNA_struct_find_property(op->ptr, "collection_index"); + PropertyRNA *prop; + + prop = RNA_struct_find_property(op->ptr, "collection_index"); if (RNA_property_is_set(op->ptr, prop)) { RNA_boolean_set(op->ptr, "is_add", event->ctrl); + + if (RNA_boolean_get(op->ptr, "is_new")) { + prop = RNA_struct_find_property(op->ptr, "new_collection_name"); + if (!RNA_property_is_set(op->ptr, prop)) { + RNA_property_string_set(op->ptr, prop, "New Collection"); + return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X, 5 * UI_UNIT_Y); + } + } return move_to_collection_exec(C, op); } @@ -2279,10 +2291,13 @@ void OBJECT_OT_move_to_collection(wmOperatorType *ot) prop = RNA_def_int(ot->srna, "collection_index", COLLECTION_INVALID_INDEX, COLLECTION_INVALID_INDEX, INT_MAX, "Collection Index", "Index of the collection to move to", 0, INT_MAX); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); + RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN); prop = RNA_def_boolean(ot->srna, "is_add", false, "Add", "Keep object in original collections as well"); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); + RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN); prop = RNA_def_boolean(ot->srna, "is_new", false, "New", "Move objects to a new collection"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN); + prop = RNA_def_string(ot->srna, "new_collection_name", NULL, MAX_NAME, "Name", + "Name of the newly added collection"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); } |