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:
authorJulian Eisel <eiseljulian@gmail.com>2017-02-22 18:02:43 +0300
committerJulian Eisel <eiseljulian@gmail.com>2017-02-22 19:25:00 +0300
commit910b7dec8dca25473d98c23f7c4fd8e44fafd47d (patch)
treec4dba049c8670704a7d789cf6f16f0e711dd0ec3 /source/blender/editors/space_outliner/outliner_tree.c
parente003499f6ffed72f3a166cca4d59e855774767d2 (diff)
UI: Support drag & drop reordering of collections
This adds initial support for reordering collections from the Outliner using drag & drop. Although drag & drop support is limited to collections for now, this lays most foundations for general drag & drop reordering support in the Outliner. There are some design questions to be answered though: * Would reordering of other data types (like objects) be a purely visual change or would it affect the order in which they are stored? (Would that make a difference for the user?) * Should/can we allow mixing of different data types? (e.g. mixing render layers with objects) * How could we realize this technically? Notes: * "Sort Alphabetically" has to be disabled to use this ("View" menu). * Reordering only works with collections on the same hierarchy level. * Added some visual feedback that should work quite well, it's by far not a final design though: {F493806} * Modified collection orders are stored in .blends. * Reordering can be undone. * Did minor cleanups here and there.
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_tree.c')
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 62ab69ebda2..11b25f7fc87 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1377,6 +1377,15 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops)
}
}
+static void outliner_collections_reorder(const Scene *scene, TreeElement *insert_element, TreeElement *insert_after)
+{
+ SceneLayer *sl = BKE_scene_layer_render_active(scene);
+ LayerCollection *insert_coll = insert_element->directdata;
+ LayerCollection *insert_after_coll = insert_after ? insert_after->directdata : NULL;
+
+ BKE_layer_collection_reinsert_after(scene, sl, insert_coll, insert_after_coll);
+}
+
static void outliner_add_collections_recursive(SpaceOops *soops, ListBase *tree, Scene *scene,
ListBase *layer_collections, TreeElement *parent_ten)
{
@@ -1385,6 +1394,7 @@ static void outliner_add_collections_recursive(SpaceOops *soops, ListBase *tree,
ten->name = collection->scene_collection->name;
ten->directdata = collection;
+ ten->reinsert = outliner_collections_reorder;
for (LinkData *link = collection->object_bases.first; link; link = link->next) {
outliner_add_element(soops, &ten->subtree, ((Base *)link->data)->object, NULL, 0, 0);
@@ -1513,18 +1523,15 @@ static void outliner_sort(ListBase *lb)
{
TreeElement *te;
TreeStoreElem *tselem;
- int totelem = 0;
te = lb->last;
if (te == NULL) return;
tselem = TREESTORE(te);
-
+
/* sorting rules; only object lists, ID lists, or deformgroups */
- if ( ELEM(tselem->type, TSE_DEFGROUP, TSE_ID_BASE) || (tselem->type == 0 && te->idcode == ID_OB)) {
-
- /* count first */
- for (te = lb->first; te; te = te->next) totelem++;
-
+ if (ELEM(tselem->type, TSE_DEFGROUP, TSE_ID_BASE) || (tselem->type == 0 && te->idcode == ID_OB)) {
+ int totelem = BLI_listbase_count(lb);
+
if (totelem > 1) {
tTreeSort *tear = MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array");
tTreeSort *tp = tear;
@@ -1863,9 +1870,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SceneLayer *sl, SpaceOops
ten = outliner_add_element(soops, &soops->tree, OBACT_NEW, NULL, 0, 0);
}
- if ((soops->flag & SO_SKIP_SORT_ALPHA) == 0) {
- outliner_sort(&soops->tree);
- }
+ outliner_sort(&soops->tree);
outliner_filter_tree(soops, &soops->tree);
BKE_main_id_clear_newpoins(mainvar);