From 71eb65328078d3b3ca440a9a23a7aa08238a6710 Mon Sep 17 00:00:00 2001 From: Nathan Craddock Date: Wed, 7 Aug 2019 22:27:07 -0600 Subject: Outliner: Synced selection and active element highlighting Adds a toggle to the filter menu for outliner synced selection. Enabled by default, this ensures selection is synced between objects, bones, and sequences. An active outliner element theme color is added to indicate which element is active. Synced selection is controlled on the operator level. Each operator that modifies selection for objects, bones, sequences, or outliner elements needs to call the respective ED_outliner_select_sync_from.. function to tag outliners to be synced. Syncing is done lazily on outliner draw. --- .../blender/editors/space_outliner/outliner_draw.c | 36 +++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/space_outliner/outliner_draw.c') diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index e4881a6f13d..cab8e45b827 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -60,6 +60,7 @@ #include "ED_armature.h" #include "ED_keyframing.h" #include "ED_object.h" +#include "ED_outliner.h" #include "ED_screen.h" #include "WM_api.h" @@ -3193,6 +3194,7 @@ static void outliner_draw_highlights_recursive(unsigned pos, const SpaceOutliner *soops, const ListBase *lb, const float col_selection[4], + const float col_active[4], const float col_highlight[4], const float col_searchmatch[4], int start_x, @@ -3206,7 +3208,11 @@ static void outliner_draw_highlights_recursive(unsigned pos, const int start_y = *io_start_y; /* selection status */ - if (tselem->flag & TSE_SELECTED) { + if ((tselem->flag & TSE_ACTIVE) && (tselem->flag & TSE_SELECTED)) { + immUniformColor4fv(col_active); + immRecti(pos, 0, start_y, (int)ar->v2d.cur.xmax, start_y + UI_UNIT_Y); + } + else if (tselem->flag & TSE_SELECTED) { immUniformColor4fv(col_selection); immRecti(pos, 0, start_y, (int)ar->v2d.cur.xmax, start_y + UI_UNIT_Y); } @@ -3260,6 +3266,7 @@ static void outliner_draw_highlights_recursive(unsigned pos, soops, &te->subtree, col_selection, + col_active, col_highlight, col_searchmatch, start_x + UI_UNIT_X, @@ -3271,10 +3278,12 @@ static void outliner_draw_highlights_recursive(unsigned pos, static void outliner_draw_highlights(ARegion *ar, SpaceOutliner *soops, int startx, int *starty) { const float col_highlight[4] = {1.0f, 1.0f, 1.0f, 0.13f}; - float col_selection[4], col_searchmatch[4]; + float col_selection[4], col_active[4], col_searchmatch[4]; UI_GetThemeColor3fv(TH_SELECT_HIGHLIGHT, col_selection); col_selection[3] = 1.0f; /* no alpha */ + UI_GetThemeColor3fv(TH_SELECT_ACTIVE, col_active); + col_active[3] = 1.0f; /* no alpha */ UI_GetThemeColor4fv(TH_MATCH, col_searchmatch); col_searchmatch[3] = 0.5f; @@ -3282,8 +3291,16 @@ static void outliner_draw_highlights(ARegion *ar, SpaceOutliner *soops, int star GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - outliner_draw_highlights_recursive( - pos, ar, soops, &soops->tree, col_selection, col_highlight, col_searchmatch, startx, starty); + outliner_draw_highlights_recursive(pos, + ar, + soops, + &soops->tree, + col_selection, + col_active, + col_highlight, + col_searchmatch, + startx, + starty); immUnbindProgram(); GPU_blend(false); } @@ -3439,6 +3456,17 @@ void draw_outliner(const bContext *C) outliner_build_tree(mainvar, scene, view_layer, soops, ar); // always + /* If global sync select is dirty, flag other outliners */ + if (ED_outliner_select_sync_is_dirty(C)) { + ED_outliner_select_sync_flag_outliners(C); + } + + /* Sync selection state from view layer */ + if (!ELEM(soops->outlinevis, SO_LIBRARIES, SO_DATA_API, SO_ID_ORPHANS) && + soops->flag & SO_SYNC_SELECT) { + outliner_sync_selection(C, soops); + } + /* force display to pixel coords */ v2d->flag |= (V2D_PIXELOFS_X | V2D_PIXELOFS_Y); /* set matrix for 2d-view controls */ -- cgit v1.2.3