[Bf-blender-cvs] [698cde93447] soc-2020-outliner: Merge branch 'master' into soc-2020-outliner
Nathan Craddock
noreply at git.blender.org
Fri Aug 7 23:36:21 CEST 2020
Commit: 698cde93447059c1c5db3bd7b98e6e9fd6f74607
Author: Nathan Craddock
Date: Fri Aug 7 15:36:04 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rB698cde93447059c1c5db3bd7b98e6e9fd6f74607
Merge branch 'master' into soc-2020-outliner
===================================================================
===================================================================
diff --cc source/blender/editors/space_outliner/outliner_collections.c
index 095cf6eb82d,efb91528e14..fbc6a8b18f1
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@@ -197,51 -208,48 +202,55 @@@ static Collection *find_parent_collecti
static int collection_new_exec(bContext *C, wmOperator *op)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
- ARegion *region = CTX_wm_region(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
+ Collection *collection;
+ const short type = RNA_enum_get(op->ptr, "type");
- struct CollectionNewData data = {
- .error = false,
- .collection = NULL,
- };
+ /* Make new collection a child of the active collection */
+ collection = CTX_data_layer_collection(C)->collection;
+ if (ID_IS_LINKED(collection)) {
+ collection = scene->master_collection;
+ }
- if (RNA_boolean_get(op->ptr, "nested")) {
- outliner_build_tree(bmain, scene, view_layer, space_outliner, region);
+ if (ID_IS_LINKED(scene)) {
+ BKE_report(op->reports, RPT_ERROR, "Can't add a new collection to linked scene/collection");
+ return OPERATOR_CANCELLED;
+ }
+ Collection *collection_new = BKE_collection_add(bmain, collection, NULL);
+
+ if (type != COLLECTION_NEW_EMPTY) {
+ /* Move selected objects into new collection */
+ struct IDsSelectedData data = {{NULL}};
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, outliner_find_selected_objects, &data);
+ outliner_tree_traverse(space_outliner,
+ &space_outliner->tree,
+ 0,
+ TSE_SELECTED,
- collection_find_selected_to_add,
++ outliner_find_selected_objects,
+ &data);
- if (data.error) {
- BKE_report(op->reports, RPT_ERROR, "More than one collection is selected");
- return OPERATOR_CANCELLED;
- }
- }
-
- if (data.collection == NULL || ID_IS_LINKED(data.collection)) {
- data.collection = scene->master_collection;
- }
+ LISTBASE_FOREACH (LinkData *, link, &data.selected_array) {
+ TreeElement *te = (TreeElement *)link->data;
+ TreeStoreElem *tselem = TREESTORE(te);
+ Collection *parent = find_parent_collection(te);
+ Object *ob = (Object *)tselem->id;
- if (ID_IS_LINKED(scene)) {
- BKE_report(op->reports, RPT_ERROR, "Can't add a new collection to linked scene/collection");
- return OPERATOR_CANCELLED;
+ if (type == COLLECTION_NEW_FROM_SELECTION) {
+ BKE_collection_object_move(bmain, scene, collection_new, parent, ob);
+ }
+ else {
+ BKE_collection_object_add(bmain, collection_new, ob);
+ }
+ }
+ BLI_freelistN(&data.selected_array);
}
- BKE_collection_add(bmain, data.collection, NULL);
-
- DEG_id_tag_update(&data.collection->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
- outliner_cleanup_tree(soops);
+ outliner_cleanup_tree(space_outliner);
WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
return OPERATOR_FINISHED;
}
@@@ -1502,62 -1529,3 +1547,66 @@@ void OUTLINER_OT_unhide_all(wmOperatorT
}
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Collection Color Tags
+ * \{ */
+
+static int outliner_color_tag_set_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene = CTX_data_scene(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
++ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
+ const short color_tag = RNA_enum_get(op->ptr, "color");
+
+ struct IDsSelectedData selected = {
+ .selected_array = {NULL, NULL},
+ };
+
- outliner_tree_traverse(
- soops, &soops->tree, 0, TSE_SELECTED, outliner_find_selected_collections, &selected);
++ outliner_tree_traverse(space_outliner,
++ &space_outliner->tree,
++ 0,
++ TSE_SELECTED,
++ outliner_find_selected_collections,
++ &selected);
+
+ LISTBASE_FOREACH (LinkData *, link, &selected.selected_array) {
+ TreeElement *te_selected = (TreeElement *)link->data;
+
+ Collection *collection = outliner_collection_from_tree_element(te_selected);
+ if (collection == scene->master_collection) {
+ continue;
+ }
+ if (ID_IS_LINKED(collection)) {
+ BKE_report(op->reports, RPT_WARNING, "Can't add a color tag to a linked collection");
+ continue;
+ }
+
+ collection->color = color_tag;
+ };
+
+ BLI_freelistN(&selected.selected_array);
+
+ WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_collection_color_tag_set(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Set Color Tag";
+ ot->idname = "OUTLINER_OT_collection_color_tag_set";
+ ot->description = "Set a color tag for the selected collections";
+
+ /* api callbacks */
+ ot->exec = outliner_color_tag_set_exec;
+ ot->poll = ED_outliner_collections_editor_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_enum(
+ ot->srna, "color", rna_enum_collection_color_items, COLLECTION_COLOR_NONE, "Color Tag", "");
+}
+
+/** \} */
diff --cc source/blender/editors/space_outliner/outliner_dragdrop.c
index 5a9b81c7e05,94052223e39..f2275ca1864
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@@ -186,8 -146,7 +186,8 @@@ static TreeElement *outliner_drop_inser
const float margin = UI_UNIT_Y * (1.0f / 4);
if (view_mval[1] < (te_hovered->ys + margin)) {
- if (TSELEM_OPEN(TREESTORE(te_hovered), soops) &&
- if (TSELEM_OPEN(TREESTORE(te_hovered), space_outliner)) {
++ if (TSELEM_OPEN(TREESTORE(te_hovered), space_outliner) &&
+ !BLI_listbase_is_empty(&te_hovered->subtree)) {
/* inserting after a open item means we insert into it, but as first child */
if (BLI_listbase_is_empty(&te_hovered->subtree)) {
*r_insert_type = TE_INSERT_INTO;
@@@ -253,11 -212,6 +253,11 @@@ static TreeElement *outliner_drop_inser
return NULL;
}
- SpaceOutliner *soutliner = CTX_wm_space_outliner(C);
- if (soutliner->sort_method != SO_SORT_FREE) {
++ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
++ if (space_outliner->sort_method != SO_SORT_FREE) {
+ *r_insert_type = TE_INSERT_INTO;
+ }
+
if (collection_te != te) {
*r_insert_type = TE_INSERT_INTO;
}
@@@ -378,11 -265,23 +378,11 @@@ static bool parent_drop_allowed(bContex
static bool parent_drop_poll(bContext *C,
wmDrag *drag,
const wmEvent *event,
- const char **UNUSED(r_tooltip))
+ const char **r_tooltip)
{
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
- bool changed = outliner_flag_set(&soops->tree, TSE_HIGHLIGHTED | TSE_DRAG_ANY, false);
- bool changed = outliner_flag_set(&space_outliner->tree, TSE_DRAG_ANY, false);
++ bool changed = outliner_flag_set(&space_outliner->tree, TSE_HIGHLIGHTED | TSE_DRAG_ANY, false);
if (changed) {
ED_region_tag_redraw_no_rebuild(CTX_wm_region(C));
}
@@@ -392,18 -291,14 +392,18 @@@
return false;
}
- if (!allow_parenting_without_modifier_key(space_outliner)) {
- if (!event->shift) {
- return false;
- }
+ TreeElementInsertType insert_type;
+ TreeElement *te = outliner_drop_insert_find(C, event, &insert_type);
+ if (!te) {
+ return false;
}
+ TreeStoreElem *tselem = TREESTORE(te);
- if (soops->sort_method != SO_SORT_FREE || soops->outlinevis != SO_VIEW_LAYER) {
- TreeElement *te = outliner_drop_find(C, event);
- if (!te) {
++ if (space_outliner->sort_method != SO_SORT_FREE || space_outliner->outlinevis != SO_VIEW_LAYER) {
+ insert_type = TE_INSERT_INTO;
+ }
+
+ if (!parent_drop_allowed(C, event, te, potential_child)) {
return false;
}
@@@ -547,17 -390,7 +547,17 @@@ static int parent_drop_invoke(bContext
ListBase *lb = event->customdata;
wmDrag *drag = lb->first;
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
- if (soops->sort_method != SO_SORT_FREE || soops->outlinevis != SO_VIEW_LAYER) {
- parent_drop_set_parents(C, op->reports, drag->ids.first, par, PAR_OBJECT, event->alt);
++ SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
++ if (space_outliner->sort_method != SO_SORT_FREE || space_outliner->outlinevis != SO_VIEW_LAYER) {
+ insert_type = TE_INSERT_INTO;
+ }
+
+ if (insert_type == TE_INSERT_INTO) {
+ parent_drop_set_parents(C, op->reports, drag->ids.first, par, PAR_OBJECT, event->alt);
+ }
+ else {
+ parent_drop_move_objects(C, drag->ids.first, te);
+ }
return OPERATOR_FINISHED;
}
@@@ -775,318 -616,6 +775,318 @@@ void OUTLINER_OT_material_drop(wmOperat
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
}
+/* ******************** UI Stack Drop Operator *********************** */
+
+/* A generic operator to allow drag and drop for modifiers, constraints,
+ * and shader effects which all share the same UI stack layout.
+ *
+ * The following operations are allowed:
+ * - Reordering within an object.
+ * - Copying a single modifier/constraint/effect to another object.
+ * - Copying (linking) an object's modifiers/constraints/effects to another. */
+
+enum eUIStackDropAction {
+ UI_STACK_DROP_REORDER,
+ UI_STACK_DROP_COPY,
+ UI_STACK_DROP_LINK,
+};
+
+static bool uistack_drop_poll(bContext *C,
+ wmDrag *drag,
+ const wmEvent *event,
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list