[Bf-blender-cvs] [883399072fa] soc-2019-outliner: Synced Selection: Sync outliner selections to view layer
Nathan Craddock
noreply at git.blender.org
Wed Jun 26 03:50:15 CEST 2019
Commit: 883399072fa5a37fbd86f1fd804c6ad7f8988220
Author: Nathan Craddock
Date: Tue Jun 25 19:47:12 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rB883399072fa5a37fbd86f1fd804c6ad7f8988220
Synced Selection: Sync outliner selections to view layer
Outliner select operators now flush their selections to the
active view layer when synced selection is enabled.
===================================================================
M source/blender/editors/space_outliner/outliner_draw.c
M source/blender/editors/space_outliner/outliner_edit.c
M source/blender/editors/space_outliner/outliner_intern.h
M source/blender/editors/space_outliner/outliner_select.c
===================================================================
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 6b414abd566..113592c3a71 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -3539,7 +3539,7 @@ static void outliner_update_viewable_area(ARegion *ar,
UI_view2d_totRect_set(&ar->v2d, sizex, sizey);
}
-void outliners_mark_dirty(const bContext *C, SpaceOutliner *soops)
+void outliners_mark_dirty(const bContext *C)
{
Main *bmain = CTX_data_main(C);
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
@@ -3549,36 +3549,45 @@ void outliners_mark_dirty(const bContext *C, SpaceOutliner *soops)
SpaceOutliner *soutliner = (SpaceOutliner *)space;
/* Mark selection state as dirty */
- if (soutliner != soops) {
- soutliner->flag |= SO_IS_DIRTY;
- }
+ soutliner->flag |= SO_IS_DIRTY;
}
}
}
}
}
-/* Sync selection flags with other outliner */
-static void outliner_sync_selection_with_outliner(SpaceOutliner *soops, ListBase *tree)
+/* Sync selection flags to active view layer */
+void outliner_sync_selection_to_view_layer(bContext *C, ListBase *tree)
{
+ Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+
for (TreeElement *te = tree->first; te; te = te->next) {
TreeStoreElem *tselem = TREESTORE(te);
+ if (tselem->type == 0) {
+ if (te->idcode == ID_OB) {
+ Object *ob = (Object *)tselem->id;
+ Base *base = (te->directdata) ? (Base *)te->directdata :
+ BKE_view_layer_base_find(view_layer, ob);
- TreeElement *ten = outliner_find_id(soops, &soops->tree, tselem->id);
- if (ten) {
- TreeStoreElem *this_tselem = TREESTORE(ten);
- /* If is selected in other outliner */
- if (tselem->flag & TSE_SELECTED) {
+ if (base) {
+ const bool is_selected = ((tselem->flag & TSE_SELECTED) != 0);
- this_tselem->flag |= TSE_SELECTED;
- }
- else {
- this_tselem->flag &= ~TSE_SELECTED;
+ if (is_selected) {
+ ED_object_base_select(base, BA_SELECT);
+ }
+ else {
+ ED_object_base_select(base, BA_DESELECT);
+ }
+ }
}
}
- outliner_sync_selection_with_outliner(soops, &te->subtree);
+ outliner_sync_selection_to_view_layer(C, &te->subtree);
}
+
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
/* Sync selection flags from active view layer */
@@ -3596,7 +3605,7 @@ static void outliner_sync_selection_from_view_layer(ViewLayer *view_layer, ListB
if (is_selected) {
tselem->flag |= TSE_SELECTED;
}
- else if (G_MAIN->sync_select_dirty_flag != SYNC_SELECT_EXTEND) {
+ else {
tselem->flag &= ~TSE_SELECTED;
}
}
@@ -3608,29 +3617,24 @@ static void outliner_sync_selection_from_view_layer(ViewLayer *view_layer, ListB
static void outliner_sync_selection(const bContext *C, SpaceOutliner *soops)
{
- /* Sync from clean outliner */
- if (soops->flag & SO_IS_DIRTY) {
- puts("\tSyncing from clean outliner");
- if (G_MAIN->clean_outliner) {
- outliner_sync_selection_with_outliner(soops, &G_MAIN->clean_outliner->tree);
- }
+ ViewLayer *view_layer = CTX_data_view_layer(C);
- soops->flag &= ~SO_IS_DIRTY;
+ /* If 3D view selection occurred, mark outliners as dirty */
+ if (G_MAIN->sync_select_dirty_flag != SYNC_SELECT_NONE) {
+ printf("Marking outliners as dirty\n");
+
+ outliners_mark_dirty(C);
+
+ G_MAIN->sync_select_dirty_flag = SYNC_SELECT_NONE;
}
- /* Sync from view layer */
- else if (G_MAIN->sync_select_dirty_flag != SYNC_SELECT_NONE) {
- printf("View3D select... Syncing from view layer... ");
- ViewLayer *view_layer = CTX_data_view_layer(C);
+ /* If dirty, sync from view layer */
+ if (soops->flag & SO_IS_DIRTY) {
+ printf("\tSyncing dirty outliner...\n");
outliner_sync_selection_from_view_layer(view_layer, &soops->tree);
- /* Mark other outliners as dirty */
- outliners_mark_dirty(C, soops);
-
- G_MAIN->clean_outliner = soops;
- G_MAIN->sync_select_dirty_flag = SYNC_SELECT_NONE;
- printf("set clean outliner\n");
+ soops->flag &= ~SO_IS_DIRTY;
}
}
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index e2fddd149c5..82d6f5deaea 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -1103,6 +1103,8 @@ static int outliner_select_all_exec(bContext *C, wmOperator *op)
break;
}
+ outliner_select_sync(C, soops);
+
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
ED_region_tag_redraw_no_rebuild(ar);
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index debf2934a92..73864397045 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -261,7 +261,11 @@ void outliner_object_mode_toggle(struct bContext *C,
ViewLayer *view_layer,
Base *base);
-void outliners_mark_dirty(const struct bContext *C, struct SpaceOutliner *soops);
+void outliners_mark_dirty(const struct bContext *C);
+
+void outliner_sync_selection_to_view_layer(struct bContext *C, struct ListBase *tree);
+
+void outliner_select_sync(struct bContext *C, struct SpaceOutliner *soops);
/* outliner_edit.c ---------------------------------------------- */
typedef void (*outliner_operation_cb)(struct bContext *C,
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 7235d92a6c8..570bca6a7d6 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -74,12 +74,15 @@
#include "outliner_intern.h"
/* Set clean outliner and mark other outliners for syncing */
-static void outliner_select_sync(const bContext *C, SpaceOutliner *soops)
+void outliner_select_sync(bContext *C, SpaceOutliner *soops)
{
puts("Outliner select... Mark other outliners as dirty for syncing");
+ outliner_sync_selection_to_view_layer(C, &soops->tree);
G_MAIN->sync_select_dirty_flag = SYNC_SELECT_NONE;
- G_MAIN->clean_outliner = soops;
- outliners_mark_dirty(C, soops);
+
+ /* Don't need to mark self as dirty here... */
+ outliners_mark_dirty(C);
+ soops->flag &= ~SO_IS_DIRTY;
}
/* Get base of object under cursor (for eyedropper) */
@@ -1373,7 +1376,6 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
if (!(te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]))) {
if (deselect_all) {
outliner_flag_set(&soops->tree, TSE_SELECTED, false);
- WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
changed = true;
}
}
@@ -1683,6 +1685,9 @@ static int outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEven
do_outliner_select_walk(soops, active, direction);
}
+ if (soops->flag & SO_SYNC_SELECTION) {
+ outliner_select_sync(C, soops);
+ }
ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
More information about the Bf-blender-cvs
mailing list