Commit: 3f5268959074dbbb1d15814803b38731b4a60878 Author: Nathan Craddock Date: Sat Jun 29 21:37:11 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rB3f5268959074dbbb1d15814803b38731b4a60878
Outliner: Move selection syncing functions to outliner_sync.c This is just for organization. Also fixes a small error when outliner select/deselect all still synced when selection syncing was disabled. =================================================================== M source/blender/editors/object/object_select.c 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 M source/blender/editors/space_outliner/outliner_sync.c =================================================================== diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index b96ccde8046..8908fd2da93 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -118,7 +118,7 @@ void ED_object_base_select(Base *base, eObjectSelect_Mode mode) BKE_scene_object_base_flag_sync_from_base(base); } - /* Using globals to sync selection for now */ + /* Set synced selection global declared in ED_outliner.h */ sync_select_dirty_flag = SYNC_SELECT_REPLACE; } diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index b513fc1d060..6bcee5c7ef4 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -3540,115 +3540,6 @@ static void outliner_update_viewable_area(ARegion *ar, UI_view2d_totRect_set(&ar->v2d, sizex, sizey); } -void outliners_mark_dirty(const bContext *C) -{ - Main *bmain = CTX_data_main(C); - for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { - for (SpaceLink *space = sa->spacedata.first; space; space = space->next) { - if (space->spacetype == SPACE_OUTLINER) { - SpaceOutliner *soutliner = (SpaceOutliner *)space; - - /* Mark selection state as dirty */ - soutliner->flag |= SO_IS_DIRTY; - } - } - } - } -} - -/* 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); - - if (base) { - if (tselem->flag & TSE_ACTIVE) { - ED_object_base_activate(C, base); - } - - if (tselem->flag & TSE_SELECTED) { - ED_object_base_select(base, BA_SELECT); - } - else { - ED_object_base_select(base, BA_DESELECT); - } - } - } - } - - 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 */ -static void outliner_sync_selection_from_view_layer(ViewLayer *view_layer, ListBase *tree) -{ - for (TreeElement *te = tree->first; te; te = te->next) { - TreeStoreElem *tselem = TREESTORE(te); - - tselem->flag &= ~TSE_ACTIVE; - - if (tselem->type == 0) { - if (te->idcode == ID_OB) { - Object *ob = (Object *)tselem->id; - Object *obact = OBACT(view_layer); - Base *base = (te->directdata) ? (Base *)te->directdata : - BKE_view_layer_base_find(view_layer, ob); - const bool is_selected = (base != NULL) && ((base->flag & BASE_SELECTED) != 0); - - if (base && (ob == obact)) { - tselem->flag |= TSE_ACTIVE; - } - - if (is_selected) { - tselem->flag |= TSE_SELECTED; - } - else { - tselem->flag &= ~TSE_SELECTED; - } - } - } - - outliner_sync_selection_from_view_layer(view_layer, &te->subtree); - } -} - -static void outliner_sync_selection(const bContext *C, SpaceOutliner *soops) -{ - ViewLayer *view_layer = CTX_data_view_layer(C); - - /* If 3D view selection occurred, mark outliners as dirty */ - if (sync_select_dirty_flag != SYNC_SELECT_NONE) { - printf("Marking outliners as dirty\n"); - - outliners_mark_dirty(C); - - sync_select_dirty_flag = SYNC_SELECT_NONE; - } - - /* 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); - - soops->flag &= ~SO_IS_DIRTY; - } -} - /* ****************************************************** */ /* Main Entrypoint - Draw contents of Outliner editor */ diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 82d6f5deaea..e6e15388e21 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1103,7 +1103,9 @@ static int outliner_select_all_exec(bContext *C, wmOperator *op) break; } - outliner_select_sync(C, soops); + if (soops->flag & SO_SYNC_SELECTION) { + 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); diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 73864397045..a0c0b63246d 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -261,12 +261,6 @@ void outliner_object_mode_toggle(struct bContext *C, ViewLayer *view_layer, Base *base); -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, struct ReportList *, @@ -474,4 +468,12 @@ float outliner_restrict_columns_width(const struct SpaceOutliner *soops); TreeElement *outliner_find_active_element(const ListBase *lb); bool outliner_is_element_visible(const ListBase *lb, const TreeElement *te); +/* outliner_sync.c ---------------------------------------------- */ + +void outliners_mark_dirty(const struct bContext *C); +void outliner_select_sync(struct bContext *C, struct SpaceOutliner *soops); +void outliner_sync_selection(const struct bContext *C, struct SpaceOutliner *soops); +void outliner_sync_selection_from_view_layer(struct ViewLayer *view_layer, struct ListBase *tree); +void outliner_sync_selection_to_view_layer(struct bContext *C, struct ListBase *tree); + #endif /* __OUTLINER_INTERN_H__ */ diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 7c727f6bd64..c031a045ff5 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -72,18 +72,6 @@ #include "outliner_intern.h" -/* Set clean outliner and mark other outliners for syncing */ -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); - sync_select_dirty_flag = SYNC_SELECT_NONE; - - /* 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) */ Base *ED_outliner_give_base_under_cursor(struct bContext *C, const int mval[2]) { diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c index 3aaf51b607f..09e3ac06e06 100644 --- a/source/blender/editors/space_outliner/outliner_sync.c +++ b/source/blender/editors/space_outliner/outliner_sync.c @@ -21,13 +21,147 @@ * \ingroup spoutliner */ +#include <stdio.h> + #include "DNA_layer_types.h" #include "DNA_outliner_types.h" +#include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "BKE_context.h" +#include "BKE_layer.h" +#include "BKE_main.h" + +#include "DEG_depsgraph.h" + +#include "ED_object.h" #include "ED_outliner.h" +#include "WM_api.h" +#include "WM_types.h" + #include "outliner_intern.h" /* Default value for sync selection state */ -short sync_select_dirty_flag = SYNC_SELECT_NONE; \ No newline at end of file +short sync_select_dirty_flag = SYNC_SELECT_NONE; + +/* Set clean outliner and mark other outliners for syncing */ +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); + sync_select_dirty_flag = SYNC_SELECT_NONE; + + /* Don't need to mark self as dirty here... */ + outliners_mark_dirty(C); + soops->flag &= ~SO_IS_DIRTY; +} + +void outliners_mark_dirty(const bContext *C) +{ + Main *bmain = CTX_data_main(C); + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (SpaceLink *space = sa->spacedata.first; space; space = space->next) { + if (space->spacetype == SPACE_OUTLINER) { + SpaceOutliner *soutliner = (SpaceOutliner *)space; + + /* Mark selection state as dirty */ + soutliner->flag |= SO_IS_DIRTY; + } + } + } + } +} + +/* 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); + + if (base) { + if (tselem->flag & TSE_ACTIVE) { + ED_object_base_activate(C, base); + } + + if (tselem->flag & TSE_SELECTED) { + ED_object_bas @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs