[Bf-blender-cvs] [c90bc0175cf] soc-2019-outliner: Outliner: Fix setting of active element from the outliner
Nathan Craddock
noreply at git.blender.org
Thu Jul 11 19:58:58 CEST 2019
Commit: c90bc0175cf307d691e7d9ab887948730aa6df02
Author: Nathan Craddock
Date: Thu Jul 11 11:56:42 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rBc90bc0175cf307d691e7d9ab887948730aa6df02
Outliner: Fix setting of active element from the outliner
The active element was being synced, which incorrectly failed
when clicking on object data and other non-base elements in the
outliner. Now it leaves activation to operators in the outliner
rather than syncing to avoid code duplication.
===================================================================
M source/blender/editors/space_outliner/outliner_draw.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/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 0b83271b741..142925b5b5c 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -3346,8 +3346,7 @@ static void outliner_draw_highlights_recursive(unsigned pos,
const int start_y = *io_start_y;
/* selection status */
- if ((soops->flag & SO_SYNC_SELECTION) && (tselem->flag & TSE_ACTIVE) &&
- (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);
}
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index a9e9185e7f6..fd0489c13cc 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -261,6 +261,8 @@ void outliner_object_mode_toggle(struct bContext *C,
ViewLayer *view_layer,
Base *base);
+void outliner_element_activate(struct SpaceOutliner *soops, struct TreeStoreElem *tselem);
+
/* outliner_edit.c ---------------------------------------------- */
typedef void (*outliner_operation_cb)(struct bContext *C,
struct ReportList *,
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 9202b8f87a7..27fae072b1f 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1108,6 +1108,12 @@ eOLDrawState tree_element_type_active(bContext *C,
/* ================================================ */
+void outliner_element_activate(SpaceOutliner *soops, TreeStoreElem *tselem)
+{
+ outliner_flag_set(&soops->tree, TSE_ACTIVE | TSE_WALK, false);
+ tselem->flag |= TSE_ACTIVE | TSE_WALK;
+}
+
/**
* Action when clicking to activate an item (typically under the mouse cursor),
* but don't do any cursor intersection checks.
@@ -1158,8 +1164,7 @@ static void do_outliner_item_activate_tree_element(bContext *C,
}
/* Mark as active in the outliner */
- outliner_flag_set(&soops->tree, TSE_ACTIVE, false);
- tselem->flag |= TSE_ACTIVE;
+ outliner_element_activate(soops, tselem);
if (tselem->type == 0) { // the lib blocks
/* editmode? */
@@ -1247,7 +1252,8 @@ void outliner_item_select(SpaceOutliner *soops,
const bool toggle)
{
TreeStoreElem *tselem = TREESTORE(te);
- const short new_flag = toggle ? (tselem->flag ^ TSE_SELECTED) : (tselem->flag | TSE_SELECTED);
+ const short new_flag = (toggle && (tselem->flag & TSE_ACTIVE)) ? (tselem->flag ^ TSE_SELECTED) :
+ (tselem->flag | TSE_SELECTED);
if (extend == false) {
outliner_flag_set(&soops->tree, TSE_SELECTED, false);
@@ -1274,7 +1280,7 @@ static void do_outliner_range_select_recursive(ListBase *lb,
TREESTORE(te)->flag |= TSE_SELECTED;
}
- /* Don't look at closed elements */
+ /* Don't look inside closed elements */
if (!(TREESTORE(te)->flag & TSE_CLOSED)) {
do_outliner_range_select_recursive(&te->subtree, active, cursor, selecting);
}
@@ -1296,9 +1302,9 @@ static void do_outliner_range_select(SpaceOutliner *soops, TreeElement *cursor)
outliner_flag_set(&soops->tree, TSE_SELECTED, false);
- /* Only select active if under cursor */
+ /* Select active if under cursor */
if (active == cursor) {
- TREESTORE(cursor)->flag |= TSE_SELECTED | TSE_ACTIVE;
+ TREESTORE(cursor)->flag |= TSE_SELECTED;
return;
}
@@ -1721,6 +1727,8 @@ static TreeElement *find_walk_select_start_element(SpaceOutliner *soops, bool *c
/* If walk element is not visible, set that element's first visible parent as walk element */
if (!outliner_is_element_visible(walk_element)) {
+ TREESTORE(walk_element)->flag &= ~TSE_WALK;
+
while (!outliner_is_element_visible(walk_element)) {
walk_element = walk_element->parent;
}
diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c
index 096ebc5a649..e82d88cd5c9 100644
--- a/source/blender/editors/space_outliner/outliner_sync.c
+++ b/source/blender/editors/space_outliner/outliner_sync.c
@@ -81,11 +81,9 @@ static void outliner_sync_selection_from_outliner(bContext *C, ListBase *tree)
Base *base = (te->directdata) ? (Base *)te->directdata :
BKE_view_layer_base_find(view_layer, ob);
+ /* Don't sync active state from outliner because activation is handled by selection
+ * operators */
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);
}
@@ -146,6 +144,7 @@ static void outliner_sync_selection_from_outliner(bContext *C, ListBase *tree)
/* Sync selection and active flags from active view layer, bones, and sequences to the outliner */
static void outliner_sync_selection_to_outliner(const bContext *C,
ViewLayer *view_layer,
+ SpaceOutliner *soops,
ListBase *tree)
{
Scene *scene = CTX_data_scene(C);
@@ -154,8 +153,6 @@ static void outliner_sync_selection_to_outliner(const bContext *C,
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;
@@ -164,7 +161,7 @@ static void outliner_sync_selection_to_outliner(const bContext *C,
const bool is_selected = (base != NULL) && ((base->flag & BASE_SELECTED) != 0);
if (base && (ob == obact)) {
- tselem->flag |= TSE_ACTIVE;
+ outliner_element_activate(soops, tselem);
}
if (is_selected) {
@@ -203,7 +200,7 @@ static void outliner_sync_selection_to_outliner(const bContext *C,
Sequence *seq = (Sequence *)tselem->id;
if (seq == seq_act) {
- tselem->flag |= TSE_ACTIVE;
+ outliner_element_activate(soops, tselem);
}
if (seq->flag & SELECT) {
@@ -214,7 +211,7 @@ static void outliner_sync_selection_to_outliner(const bContext *C,
}
}
- outliner_sync_selection_to_outliner(C, view_layer, &te->subtree);
+ outliner_sync_selection_to_outliner(C, view_layer, soops, &te->subtree);
}
}
@@ -256,7 +253,7 @@ void outliner_sync_selection(const bContext *C, SpaceOutliner *soops)
if (soops->flag & SO_IS_DIRTY) {
printf("\tSyncing dirty outliner...\n");
- outliner_sync_selection_to_outliner(C, view_layer, &soops->tree);
+ outliner_sync_selection_to_outliner(C, view_layer, soops, &soops->tree);
// if (soops->outlinevis == SO_SEQUENCE) {
// printf("\tSyncing sequences...\n");
More information about the Bf-blender-cvs
mailing list