Blender V5.3
outliner_select.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2004 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "DNA_armature_types.h"
14#include "DNA_modifier_types.h"
15#include "DNA_object_types.h"
16#include "DNA_scene_types.h"
17#include "DNA_sequence_types.h"
18#include "DNA_shader_fx_types.h"
19
20#include "BLI_listbase.hh"
21#include "BLI_utildefines.hh"
22
23#include "BKE_annotations.h"
24#include "BKE_armature.hh"
25#include "BKE_collection.hh"
26#include "BKE_constraint.h"
27#include "BKE_context.hh"
28#include "BKE_deform.hh"
29#include "BKE_grease_pencil.hh"
30#include "BKE_layer.hh"
31#include "BKE_lib_id.hh"
32#include "BKE_main.hh"
33#include "BKE_modifier.hh"
34#include "BKE_object.hh"
35#include "BKE_particle.h"
36#include "BKE_report.hh"
37#include "BKE_shader_fx.hh"
38
39#include "DEG_depsgraph.hh"
41
42#include "ED_armature.hh"
43#include "ED_buttons.hh"
44#include "ED_object.hh"
45#include "ED_outliner.hh"
46#include "ED_screen.hh"
47#include "ED_select_utils.hh"
48#include "ED_sequencer.hh"
49#include "ED_text.hh"
50#include "ED_undo.hh"
51
52#include "SEQ_select.hh"
53#include "SEQ_sequencer.hh"
54
55#include "WM_api.hh"
56#include "WM_message.hh"
57#include "WM_types.hh"
58
59#include "UI_interface.hh"
60#include "UI_view2d.hh"
61
62#include "RNA_access.hh"
63#include "RNA_define.hh"
64#include "RNA_prototypes.hh"
65
66#include "ANIM_armature.hh"
68
69#include "outliner_intern.hh"
72#include "tree/tree_iterator.hh"
73
74namespace blender::ed::outliner {
75
76/* -------------------------------------------------------------------- */
79
86{
87 Main *bmain = CTX_data_main(C);
88 Object *ob = base->object;
89
90 bool changed = false;
92 changed = object::editmode_exit_ex(bmain, scene, ob, object::EM_FREEDATA);
93 if (changed) {
96 }
97 }
98 else {
100 if (changed) {
103 }
104 }
105
106 if (changed) {
109 ED_undo_push(C, "Outliner Edit Mode Toggle");
110 }
111}
112
119{
120 Main *bmain = CTX_data_main(C);
121 Object *ob = base->object;
122
123 if (!BKE_id_is_editable(CTX_data_main(C), &ob->id)) {
124 BKE_report(CTX_wm_reports(C), RPT_WARNING, "Cannot pose non-editable data");
125 return;
126 }
127
128 bool changed = false;
129 if (ob->mode & OB_MODE_POSE) {
130 changed = ED_object_posemode_exit_ex(bmain, ob);
131 if (changed) {
134 }
135 }
136 else {
137 changed = ED_object_posemode_enter_ex(bmain, ob);
138 if (changed) {
141 }
142 }
143
144 if (changed) {
147 ED_undo_push(C, "Outliner Pose Mode Toggle");
148 }
149}
150
163 const TreeViewContext &tvc,
164 Base *base)
165{
166 const eObjectMode active_mode = tvc.obact->mode;
168
170 const Main *bmain = CTX_data_main(C);
172 Base *base_active = BKE_view_layer_base_find(tvc.view_layer, tvc.obact);
173 if (base_active != base) {
177 ED_undo_push(C, "Change Active");
178
179 /* Operator call does undo push. */
180 object::mode_set(C, active_mode);
182 }
183 }
185}
186
188 const TreeViewContext &tvc,
189 TreeElement *te,
190 const bool do_extend)
191{
192 TreeStoreElem *tselem = TREESTORE(te);
193
194 if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
195 Object *ob = id_cast<Object *>(tselem->id);
198
199 /* Hidden objects can be removed from the mode. */
200 if (!base || (!(base->flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT) &&
201 (ob->mode != tvc.obact->mode)))
202 {
203 return;
204 }
205
206 if (!do_extend) {
208 }
209 else if (tvc.ob_edit && OB_TYPE_SUPPORT_EDITMODE(ob->type)) {
210 /* Grease Pencil does not support multi-object editing yet. */
211 if (ob->type != OB_GREASE_PENCIL) {
213 }
214 }
215 else if (tvc.ob_pose && ob->type == OB_ARMATURE) {
217 }
218 }
219}
220
222
223/* -------------------------------------------------------------------- */
226
228{
229 /* paranoia check */
230 if (te->store_elem->type != TSE_R_LAYER) {
231 return;
232 }
233
234 ViewLayer *view_layer = static_cast<ViewLayer *>(te->directdata);
235 wmWindow *win = CTX_wm_window(C);
236 Scene *scene = WM_window_get_active_scene(win);
237
238 if (BLI_findindex(&scene->view_layers, view_layer) != -1) {
239 WM_window_set_active_view_layer(win, view_layer);
241 }
242}
243
248 const Main &bmain, const Scene *scene, ViewLayer *view_layer, Object *ob_parent, bool select)
249{
250 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
251 for (Base &base : *BKE_view_layer_object_bases_get(view_layer)) {
252 Object *ob = base.object;
253 if (((base.flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT) != 0) &&
254 BKE_object_is_child_recursive(ob_parent, ob))
255 {
257 }
258 }
259}
260
261static void do_outliner_bone_select_recursive(bArmature *arm, Bone *bone_parent, bool select)
262{
263 for (Bone &bone : bone_parent->childbase) {
264 if (select && animrig::bone_is_selectable(arm, &bone)) {
265 bone.flag |= BONE_SELECTED;
266 }
267 else {
269 }
271 }
272}
273
274static void do_outliner_ebone_select_recursive(bArmature *arm, EditBone *ebone_parent, bool select)
275{
276 EditBone *ebone;
277 for (ebone = ebone_parent->next; ebone; ebone = ebone->next) {
278 if (ED_armature_ebone_is_child_recursive(ebone_parent, ebone)) {
279 if (select && EBONE_SELECTABLE(arm, ebone)) {
281 }
282 else {
284 }
285 }
286 }
287}
288
290 Main &bmain,
291 Scene *scene,
292 ViewLayer *view_layer,
293 TreeElement *te,
294 const eOLSetState set,
295 bool recursive)
296{
297 TreeStoreElem *tselem = TREESTORE(te);
298 TreeStoreElem *parent_tselem = nullptr;
299 TreeElement *parent_te = nullptr;
300 Scene *sce;
301 Base *base;
302 Object *ob = nullptr;
303
304 /* if id is not object, we search back */
305 if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
306 ob = id_cast<Object *>(tselem->id);
307 }
308 else {
309 parent_te = outliner_search_back_te(te, ID_OB);
310 if (parent_te) {
311 parent_tselem = TREESTORE(parent_te);
312 ob = id_cast<Object *>(parent_tselem->id);
313
314 /* Don't return when activating children of the previous active object. */
315 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
316 if (ob == BKE_view_layer_active_object_get(view_layer) && set == OL_SETSEL_NONE) {
317 return;
318 }
319 }
320 }
321 if (ob == nullptr) {
322 return;
323 }
324
325 sce = id_cast<Scene *>(outliner_search_back(te, ID_SCE));
326 if (sce && scene != sce) {
329 scene = sce;
330 }
331
332 /* find associated base in current scene */
333 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
334 base = BKE_view_layer_base_find(view_layer, ob);
335
337 if (base != nullptr) {
338 Object *obact = BKE_view_layer_active_object_get(view_layer);
339 const eObjectMode object_mode = obact ? obact->mode : OB_MODE_OBJECT;
340 if (base && !BKE_object_is_mode_compat(base->object, object_mode)) {
341 if (object_mode == OB_MODE_OBJECT) {
342 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
343 object::mode_generic_exit(&bmain, depsgraph, scene, base->object);
344 }
345 if (!BKE_object_is_mode_compat(base->object, object_mode)) {
346 base = nullptr;
347 }
348 }
349 }
350 }
351
352 if (base) {
353 if (set == OL_SETSEL_EXTEND) {
354 /* swap select */
355 if (base->flag & BASE_SELECTED) {
357 if (parent_tselem) {
358 parent_tselem->flag &= ~TSE_SELECTED;
359 }
360 }
361 else {
363 if (parent_tselem) {
364 parent_tselem->flag |= TSE_SELECTED;
365 }
366 }
367 }
368 else if (recursive) {
369 /* Pass */
370 }
371 else {
372 /* De-select all. */
373
374 /* Only in object mode so we can switch the active object,
375 * keeping all objects in the current 'mode' selected, useful for multi-pose/edit mode.
376 * This keeps the convention that all objects in the current mode are also selected.
377 * see #55246. */
379 (ob->mode == OB_MODE_OBJECT) :
380 true)
381 {
382 BKE_view_layer_base_deselect_all(bmain, scene, view_layer);
383 }
385 if (parent_tselem) {
386 parent_tselem->flag |= TSE_SELECTED;
387 }
388 }
389
390 if (recursive) {
391 /* Recursive select/deselect for Object hierarchies */
393 bmain, scene, view_layer, ob, (base->flag & BASE_SELECTED) != 0);
394 }
395
396 if (set != OL_SETSEL_NONE) {
397 if (!recursive) {
398 object::base_activate_with_mode_exit_if_needed(C, base); /* adds notifier */
399 }
402 }
403 }
404}
405
407 bContext *C, const Main &bmain, const Scene *scene, ViewLayer *view_layer, TreeElement *te)
408{
409 /* we search for the object parent */
410 Object *ob = id_cast<Object *>(outliner_search_back(te, ID_OB));
411 /* NOTE: `ob->matbits` can be nullptr when a local object points to a library mesh. */
412 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
413 if (ob == nullptr || ob != BKE_view_layer_active_object_get(view_layer) ||
414 ob->matbits == nullptr)
415 {
416 return; /* just paranoia */
417 }
418
419 /* In ob mat array? */
420 TreeElement *tes = te->parent;
421 if (tes->idcode == ID_OB) {
422 ob->actcol = te->index + 1;
423 ob->matbits[te->index] = 1; /* Make ob material active too. */
424 }
425 else {
426 /* or in obdata material */
427 ob->actcol = te->index + 1;
428 ob->matbits[te->index] = 0; /* Make obdata material active too. */
429 }
430
431 /* Tagging object for update seems a bit stupid here, but looks like we have to do it
432 * for render views to update. See #42973.
433 * Note that RNA material update does it too, see e.g. rna_MaterialSlot_update(). */
434 DEG_id_tag_update(id_cast<ID *>(ob), ID_RECALC_TRANSFORM);
436}
437
439{
440 Object *ob = id_cast<Object *>(outliner_search_back(te, ID_OB));
441
442 if (ob == nullptr) {
443 /* Happens in "Blender File" view (there is simply no object up in the hierarchy in this case).
444 */
445 return;
446 }
447
448 scene->camera = ob;
449
450 Main *bmain = CTX_data_main(C);
451 wmWindowManager *wm = bmain->wm.first();
452
453 WM_windows_scene_data_sync(&wm->windows, scene);
457}
458
460{
461 Scene *sce = nullptr;
462
463 TreeElement *tep = te->parent;
464 if (tep) {
465 TreeStoreElem *tselem = TREESTORE(tep);
466 if (tselem->type == TSE_SOME_ID) {
467 sce = id_cast<Scene *>(tselem->id);
468 }
469 }
470
471 /* make new scene active */
472 if (sce && scene != sce) {
474 }
475}
476
478{
479 /* id in tselem is object */
480 Object *ob = id_cast<Object *>(tselem->id);
481 BLI_assert(te->index + 1 >= 0);
483
486}
487
489{
490 bGPdata *gpd = id_cast<bGPdata *>(tselem->id);
491 bGPDlayer *gpl = static_cast<bGPDlayer *>(te->directdata);
492
493 /* We can only have a single "active" layer at a time
494 * and there must always be an active layer... */
495 if (gpl) {
499 }
500}
501
503 TreeElement *te,
504 TreeStoreElem *tselem)
505{
506 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(tselem->id);
508
509 if (node.is_layer()) {
510 if (grease_pencil.has_active_group()) {
512 &grease_pencil.id,
514 GreasePencilv3LayerGroup,
515 active);
516 }
518 CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3Layers, active);
519 }
520 if (node.is_group()) {
521 if (grease_pencil.has_active_layer()) {
523 CTX_wm_message_bus(C), &grease_pencil.id, &grease_pencil, GreasePencilv3Layers, active);
524 }
526 &grease_pencil.id,
528 GreasePencilv3LayerGroup,
529 active);
530 }
531
532 grease_pencil.set_active_node(&node);
533
536}
537
539 TreeElement *te,
540 TreeStoreElem *tselem)
541{
542 bArmature *arm = reinterpret_cast<bArmature *>(tselem->id);
543 BoneCollection *bcoll = reinterpret_cast<BoneCollection *>(te->directdata);
546}
547
549 const Scene *scene,
550 ViewLayer *view_layer,
551 TreeElement *te,
552 TreeStoreElem *tselem,
553 const eOLSetState set,
554 bool recursive)
555{
556 const Main *bmain = CTX_data_main(C);
557 Object *ob = id_cast<Object *>(tselem->id);
558 bArmature *arm = id_cast<bArmature *>(ob->data);
559 bPoseChannel *pchan = static_cast<bPoseChannel *>(te->directdata);
560
561 if (set != OL_SETSEL_EXTEND) {
562 /* Single select forces all other bones to get unselected. */
564 *bmain, scene, view_layer, nullptr);
565
566 for (Object *ob : objects) {
568
569 /* Sanity checks. */
570 if (ELEM(nullptr, ob_iter, ob_iter->pose, ob_iter->data)) {
571 continue;
572 }
573
574 for (bPoseChannel &pchannel : ob_iter->pose->chanbase) {
575 animrig::bone_deselect(&pchannel);
576 }
577
578 if (ob != ob_iter) {
580 }
581 }
582 }
583
584 Bone *bone = pchan->bone_get(*ob);
585 if ((set == OL_SETSEL_EXTEND) && (pchan->flag & POSE_SELECTED)) {
587 }
588 else {
589 if (animrig::bone_is_visible(arm, {pchan, bone})) {
591 }
592 arm->act_bone = bone;
593 }
594
595 if (recursive) {
596 /* Recursive select/deselect */
597 do_outliner_bone_select_recursive(arm, bone, (pchan->flag & POSE_SELECTED) != 0);
598 }
599
602}
603
605 const Main &bmain,
606 const Scene *scene,
607 ViewLayer *view_layer,
608 TreeElement *te,
609 TreeStoreElem *tselem,
610 const eOLSetState set,
611 bool recursive)
612{
613 bArmature *arm = id_cast<bArmature *>(tselem->id);
614 Bone *bone = static_cast<Bone *>(te->directdata);
615
616 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
618 if (ob) {
619 if (set != OL_SETSEL_EXTEND) {
620 /* single select forces all other bones to get unselected */
621 for (Bone *bone_iter = arm->bonebase.first(); bone_iter != nullptr;
622 bone_iter = bone_iter->next)
623 {
624 bone_iter->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
625 do_outliner_bone_select_recursive(arm, bone_iter, false);
626 }
627 }
628 }
629
630 if (set == OL_SETSEL_EXTEND && (bone->flag & BONE_SELECTED)) {
631 bone->flag &= ~BONE_SELECTED;
632 }
633 else {
634 if (animrig::bone_is_visible(arm, bone) && ((bone->flag & BONE_UNSELECTABLE) == 0)) {
635 bone->flag |= BONE_SELECTED;
636 }
637 arm->act_bone = bone;
638 }
639
640 if (recursive) {
641 /* Recursive select/deselect */
642 do_outliner_bone_select_recursive(arm, bone, (bone->flag & BONE_SELECTED) != 0);
643 }
644
646}
647
649static void tree_element_active_ebone__sel(bContext *C, bArmature *arm, EditBone *ebone, short sel)
650{
651 if (sel) {
652 arm->act_edbone = ebone;
653 }
654 if (EBONE_SELECTABLE(arm, ebone)) {
656 }
658}
659
661 const Scene *scene,
662 ViewLayer *view_layer,
663 TreeElement *te,
664 TreeStoreElem *tselem,
665 const eOLSetState set,
666 bool recursive)
667{
668 bArmature *arm = id_cast<bArmature *>(tselem->id);
669 EditBone *ebone = static_cast<EditBone *>(te->directdata);
670
671 if (set == OL_SETSEL_NORMAL) {
672 ObjectsInModeParams ob_params{};
673 ob_params.object_mode = OB_MODE_EDIT;
674 ob_params.no_dup_data = true;
675
676 const Main *bmain = CTX_data_main(C);
678 *bmain, scene, view_layer, nullptr, &ob_params);
680
681 tree_element_active_ebone__sel(C, arm, ebone, true);
682 }
683 else if (set == OL_SETSEL_EXTEND) {
684 if (!(ebone->flag & BONE_SELECTED)) {
685 tree_element_active_ebone__sel(C, arm, ebone, true);
686 }
687 else {
688 /* entirely selected, so de-select */
689 tree_element_active_ebone__sel(C, arm, ebone, false);
690 }
691 }
692
693 if (recursive) {
694 /* Recursive select/deselect */
695 do_outliner_ebone_select_recursive(arm, ebone, (ebone->flag & BONE_SELECTED) != 0);
696 }
697}
698
700 TreeElement *te,
701 TreeStoreElem *tselem,
702 const eOLSetState set)
703{
704 Object *ob = id_cast<Object *>(tselem->id);
705 ModifierData *md = static_cast<ModifierData *>(te->directdata);
706
707 if (set == OL_SETSEL_NORMAL) {
710 }
711}
712
714{
715 Object *ob = id_cast<Object *>(tselem->id);
716
718}
719
721 const Scene *scene,
722 ViewLayer *view_layer,
723 TreeElement *te,
724 TreeStoreElem *tselem,
725 const eOLSetState set)
726{
727 Object *ob = id_cast<Object *>(tselem->id);
728
729 /* Activate the parent bone if this is a bone constraint. */
730 te = te->parent;
731 while (te) {
732 tselem = TREESTORE(te);
733 if (tselem->type == TSE_POSE_CHANNEL) {
734 tree_element_posechannel_activate(C, scene, view_layer, te, tselem, set, false);
735 return;
736 }
737 te = te->parent;
738 }
739
741}
742
744 WorkSpace *workspace,
745 TreeElement *te,
746 const eOLSetState set)
747{
748 Scene *sequencer_scene = workspace->sequencer_scene;
749 if (!sequencer_scene) {
750 return;
751 }
753 Strip *strip = &te_strip->get_strip();
754 Editing *ed = seq::editing_get(sequencer_scene);
755
756 if (BLI_findindex(ed->current_strips(), strip) != -1) {
757 if (set == OL_SETSEL_EXTEND) {
758 seq::select_active_set(sequencer_scene, nullptr);
759 }
760 vse::deselect_all_strips(sequencer_scene);
761
762 if ((set == OL_SETSEL_EXTEND) && strip->flag & SEQ_SELECT) {
763 strip->flag &= ~SEQ_SELECT;
764 }
765 else {
766 strip->flag |= SEQ_SELECT;
767 seq::select_active_set(sequencer_scene, strip);
768 }
769 }
770
772}
773
775{
776 Scene *sequencer_scene = workspace->sequencer_scene;
777 if (!sequencer_scene) {
778 return;
779 }
780 Editing *ed = seq::editing_get(sequencer_scene);
781
782#if 0
783 select_single_seq(strip, 1);
784#endif
785 Strip *p = ed->current_strips()->first();
786 while (p) {
787 if ((!p->data) || (!p->data->stripdata) || (p->data->stripdata->filename[0] == '\0')) {
788 p = p->next;
789 continue;
790 }
791
792#if 0
793 if (STREQ(p->strip->stripdata->filename, strip->data->stripdata->filename)) {
794 select_single_seq(p, 0);
795 }
796#endif
797 p = p->next;
798 }
799}
800
802{
803 ViewLayer *view_layer = CTX_data_view_layer(C);
804 LayerCollection *layer_collection = static_cast<LayerCollection *>(
805 view_layer->layer_collections.first_);
806 BKE_layer_collection_activate(view_layer, layer_collection);
807 /* A very precise notifier - ND_LAYER alone is quite vague, we want to avoid unnecessary work
808 * when only the active collection changes. */
810}
811
813{
814 Scene *scene = CTX_data_scene(C);
815 LayerCollection *layer_collection = static_cast<LayerCollection *>(te->directdata);
816 ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, layer_collection);
817 BKE_layer_collection_activate(view_layer, layer_collection);
818 /* A very precise notifier - ND_LAYER alone is quite vague, we want to avoid unnecessary work
819 * when only the active collection changes. */
821}
822
824{
825 Text *text = reinterpret_cast<Text *>(te->store_elem->id);
827}
828
830 const TreeViewContext &tvc,
831 TreeElement *te,
832 const eOLSetState set,
833 const bool handle_all_types)
834{
835 switch (te->idcode) {
839 case ID_OB:
840 if (handle_all_types) {
841 tree_element_object_activate(C, *tvc.bmain, tvc.scene, tvc.view_layer, te, set, false);
842 }
843 break;
844 case ID_MA:
846 break;
847 case ID_WO:
849 break;
850 case ID_CA:
852 break;
853 case ID_TXT:
855 break;
856 }
857}
858
860{
861 if (TreeElement *parent_te = outliner_search_back_te(te, ID_OB)) {
862 TreeStoreElem *parent_tselem = TREESTORE(parent_te);
863 Object *ob = id_cast<Object *>(parent_tselem->id);
864
865 if (ob) {
866 PointerRNA object_ptr = RNA_pointer_create_discrete(&ob->id, RNA_Object, ob);
867 PropertyRNA *prop = RNA_struct_find_property(&object_ptr, "active_shape_key_index");
868 RNA_property_int_set(&object_ptr, prop, te->index);
869 RNA_property_update(C, &object_ptr, prop);
870 }
871 }
872}
873
875 const TreeViewContext &tvc,
876 TreeElement *te,
877 TreeStoreElem *tselem,
878 const eOLSetState set,
879 bool recursive)
880{
882 switch (tselem->type) {
883 case TSE_DEFGROUP:
885 break;
886 case TSE_BONE:
888 C, *tvc.bmain, tvc.scene, tvc.view_layer, te, tselem, set, recursive);
889 break;
890 case TSE_EBONE:
891 tree_element_ebone_activate(C, tvc.scene, tvc.view_layer, te, tselem, set, recursive);
892 break;
893 case TSE_MODIFIER:
894 tree_element_modifier_activate(C, te, tselem, set);
895 break;
896 case TSE_LINKED_OB:
897 tree_element_object_activate(C, *tvc.bmain, tvc.scene, tvc.view_layer, te, set, false);
898 break;
899 case TSE_LINKED_PSYS:
901 break;
902 case TSE_POSE_BASE:
903 return;
904 case TSE_POSE_CHANNEL:
905 tree_element_posechannel_activate(C, tvc.scene, tvc.view_layer, te, tselem, set, recursive);
906 break;
908 case TSE_CONSTRAINT:
909 tree_element_constraint_activate(C, tvc.scene, tvc.view_layer, te, tselem, set);
910 break;
911 case TSE_R_LAYER:
913 break;
916 break;
917 case TSE_STRIP:
919 break;
920 case TSE_STRIP_DUP:
922 break;
923 case TSE_GP_LAYER:
924 tree_element_gplayer_activate(C, te, tselem);
925 break;
928 break;
931 break;
934 break;
937 break;
938 default:
939 break;
940 }
941}
942
944
945/* -------------------------------------------------------------------- */
948
950 const Scene *scene,
951 ViewLayer *view_layer,
952 const TreeElement *te,
953 const TreeStoreElem *tselem)
954{
955 const Object *ob = id_cast<const Object *>(tselem->id);
956 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
957 if (ob == BKE_view_layer_active_object_get(view_layer)) {
958 if (BKE_object_defgroup_active_index_get(ob) == te->index + 1) {
959 return OL_DRAWSEL_NORMAL;
960 }
961 }
962 return OL_DRAWSEL_NONE;
963}
964
966 const Scene *scene,
967 ViewLayer *view_layer,
968 const TreeElement *te,
969 const TreeStoreElem *tselem)
970{
971 const bArmature *arm = id_cast<const bArmature *>(tselem->id);
972 const Bone *bone = static_cast<Bone *>(te->directdata);
973 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
974 const Object *ob = BKE_view_layer_active_object_get(view_layer);
975 if (ob && ob->data == id_cast<const ID *>(arm)) {
976 if (bone->flag & BONE_SELECTED) {
977 return OL_DRAWSEL_NORMAL;
978 }
979 }
980 return OL_DRAWSEL_NONE;
981}
982
984{
985 const EditBone *ebone = static_cast<EditBone *>(te->directdata);
986 if (ebone->flag & BONE_SELECTED) {
987 return OL_DRAWSEL_NORMAL;
988 }
989 return OL_DRAWSEL_NONE;
990}
991
993 const TreeStoreElem *tselem)
994{
995 const Object *ob = id_cast<const Object *>(tselem->id);
996 const ModifierData *md = static_cast<const ModifierData *>(te->directdata);
997
999}
1000
1002 const TreeStoreElem *tselem)
1003{
1004 return (tselem->id == id_cast<const ID *>(tvc.obact)) ? OL_DRAWSEL_NORMAL : OL_DRAWSEL_NONE;
1005}
1006
1008 const Scene *scene,
1009 const ViewLayer *view_layer,
1010 const TreeStoreElem *tselem)
1011{
1012 const Object *ob = id_cast<const Object *>(tselem->id);
1013 /* This will just lookup in a cache, it will not change the arguments. */
1014 BKE_view_layer_synced_ensure(bmain, scene, const_cast<ViewLayer *>(view_layer));
1015 const Base *base = BKE_view_layer_base_find(const_cast<ViewLayer *>(view_layer),
1016 const_cast<Object *>(ob));
1017 if (base == nullptr) {
1018 /* Armature not instantiated in current scene (e.g. inside an appended group). */
1019 return OL_DRAWSEL_NONE;
1020 }
1021
1022 if (ob->mode & OB_MODE_POSE) {
1023 return OL_DRAWSEL_NORMAL;
1024 }
1025 return OL_DRAWSEL_NONE;
1026}
1027
1029 const TreeElement *te,
1030 const TreeStoreElem *tselem)
1031{
1032 const Object *ob = id_cast<const Object *>(tselem->id);
1033 const bPoseChannel *pchan = static_cast<bPoseChannel *>(te->directdata);
1034 if (ob == ob_pose && ob->pose) {
1035 if (pchan->flag & POSE_SELECTED) {
1036 return OL_DRAWSEL_NORMAL;
1037 }
1038 }
1039 return OL_DRAWSEL_NONE;
1040}
1041
1043 const TreeElement *te)
1044{
1045 const ViewLayer *te_view_layer = static_cast<ViewLayer *>(te->directdata);
1046
1047 if (view_layer == te_view_layer) {
1048 return OL_DRAWSEL_NORMAL;
1049 }
1050 return OL_DRAWSEL_NONE;
1051}
1052
1054 const TreeStoreElem *tselem)
1055{
1056 const bArmature *arm = reinterpret_cast<const bArmature *>(tselem->id);
1057 const BoneCollection *bcoll = reinterpret_cast<const BoneCollection *>(te->directdata);
1058
1059 if (arm->runtime->active_collection == bcoll) {
1060 return OL_DRAWSEL_ACTIVE;
1061 }
1062 return OL_DRAWSEL_NONE;
1063}
1064
1066{
1067 const Scene *sequencer_scene = workspace->sequencer_scene;
1068 if (!sequencer_scene) {
1069 return OL_DRAWSEL_NONE;
1070 }
1072 const Strip *strip = &te_strip->get_strip();
1073 const Editing *ed = seq::editing_get(sequencer_scene);
1074
1075 if (ed && ed->act_strip == strip && strip->flag & SEQ_SELECT) {
1076 return OL_DRAWSEL_NORMAL;
1077 }
1078 return OL_DRAWSEL_NONE;
1079}
1080
1082{
1084 const Strip *strip = &te_dup->get_strip();
1085 if (strip->flag & SEQ_SELECT) {
1086 return OL_DRAWSEL_NORMAL;
1087 }
1088 return OL_DRAWSEL_NONE;
1089}
1090
1092{
1093 if ((static_cast<const bGPDlayer *>(te->directdata))->flag & GP_LAYER_ACTIVE) {
1094 return OL_DRAWSEL_NORMAL;
1095 }
1096 return OL_DRAWSEL_NONE;
1097}
1098
1100{
1101 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(te->store_elem->id);
1103 if (node.is_layer() && grease_pencil.is_layer_active(&node.as_layer())) {
1104 return OL_DRAWSEL_NORMAL;
1105 }
1106 return OL_DRAWSEL_NONE;
1107}
1108
1110 const ViewLayer *view_layer, const LayerCollection *layer_collection)
1111{
1112 if (layer_collection == view_layer->layer_collections.first_) {
1113 return OL_DRAWSEL_NORMAL;
1114 }
1115 return OL_DRAWSEL_NONE;
1116}
1117
1119 const LayerCollection *layer_collection, const TreeElement *te)
1120{
1121 if (layer_collection == te->directdata) {
1122 return OL_DRAWSEL_NORMAL;
1123 }
1124 return OL_DRAWSEL_NONE;
1125}
1126
1128 const Scene *scene,
1129 ViewLayer *view_layer,
1130 const TreeElement *te)
1131{
1132 /* we search for the object parent */
1133 const Object *ob = id_cast<const Object *>(
1134 outliner_search_back(const_cast<TreeElement *>(te), ID_OB));
1135 /* NOTE: `ob->matbits` can be nullptr when a local object points to a library mesh. */
1136 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
1137 if (ob == nullptr || ob != BKE_view_layer_active_object_get(view_layer) ||
1138 ob->matbits == nullptr)
1139 {
1140 return OL_DRAWSEL_NONE; /* just paranoia */
1141 }
1142
1143 /* searching in ob mat array? */
1144 const TreeElement *tes = te->parent;
1145 if (tes->idcode == ID_OB) {
1146 if (ob->actcol == te->index + 1) {
1147 if (ob->matbits[te->index]) {
1148 return OL_DRAWSEL_NORMAL;
1149 }
1150 }
1151 }
1152 /* or we search for obdata material */
1153 else {
1154 if (ob->actcol == te->index + 1) {
1155 if (ob->matbits[te->index] == 0) {
1156 return OL_DRAWSEL_NORMAL;
1157 }
1158 }
1159 }
1160 return OL_DRAWSEL_NONE;
1161}
1162
1164 const TreeElement *te,
1165 const TreeStoreElem *tselem)
1166{
1167 if (te->idcode == ID_SCE) {
1168 if (tselem->id == id_cast<ID *>(tvc.scene)) {
1169 return OL_DRAWSEL_NORMAL;
1170 }
1171 }
1172 return OL_DRAWSEL_NONE;
1173}
1174
1176{
1177 const TreeElement *tep = te->parent;
1178 if (tep == nullptr) {
1179 return OL_DRAWSEL_NORMAL;
1180 }
1181
1182 const TreeStoreElem *tselem = TREESTORE(tep);
1183 if (tselem->id == id_cast<const ID *>(scene)) {
1184 return OL_DRAWSEL_NORMAL;
1185 }
1186 return OL_DRAWSEL_NONE;
1187}
1188
1190{
1191 const Object *ob = id_cast<const Object *>(
1192 outliner_search_back(const_cast<TreeElement *>(te), ID_OB));
1193
1194 return (scene->camera == ob) ? OL_DRAWSEL_NORMAL : OL_DRAWSEL_NONE;
1195}
1196
1198 const TreeElement *te,
1199 const TreeStoreElem *tselem)
1200{
1201 switch (te->idcode) {
1202 case ID_SCE:
1203 return tree_element_active_scene_get(tvc, te, tselem);
1204 case ID_OB:
1205 /* Objects are currently handled by the caller in order to also change text color. */
1206 return OL_DRAWSEL_NONE;
1207 break;
1208 case ID_MA:
1209 return tree_element_active_material_get(*tvc.bmain, tvc.scene, tvc.view_layer, te);
1210 case ID_WO:
1211 return tree_element_active_world_get(tvc.scene, te);
1212 case ID_CA:
1213 return tree_element_active_camera_get(tvc.scene, te);
1214 }
1215 return OL_DRAWSEL_NONE;
1216}
1217
1219{
1220 if (const Object *ob = id_cast<Object *>(
1221 outliner_search_back(const_cast<TreeElement *>(te), ID_OB)))
1222 {
1223 if (ob->shapenr == te->index + 1) {
1224 return OL_DRAWSEL_NORMAL;
1225 }
1226 }
1227 return OL_DRAWSEL_NONE;
1228}
1229
1231 const TreeElement *te,
1232 const TreeStoreElem *tselem)
1233{
1234 switch (tselem->type) {
1235 case TSE_DEFGROUP:
1236 return tree_element_defgroup_state_get(*tvc.bmain, tvc.scene, tvc.view_layer, te, tselem);
1237 case TSE_BONE:
1238 return tree_element_bone_state_get(*tvc.bmain, tvc.scene, tvc.view_layer, te, tselem);
1239 case TSE_EBONE:
1241 case TSE_MODIFIER:
1242 return tree_element_modifier_state_get(te, tselem);
1244 return OL_DRAWSEL_NONE;
1245 case TSE_LINKED_OB:
1246 return tree_element_object_state_get(tvc, tselem);
1247 case TSE_LINKED_PSYS:
1248 return OL_DRAWSEL_NONE;
1249 case TSE_POSE_BASE:
1250 return tree_element_pose_state_get(*tvc.bmain, tvc.scene, tvc.view_layer, tselem);
1251 case TSE_POSE_CHANNEL:
1252 return tree_element_posechannel_state_get(tvc.ob_pose, te, tselem);
1254 case TSE_CONSTRAINT:
1255 return OL_DRAWSEL_NONE;
1256 case TSE_R_LAYER:
1258 case TSE_STRIP:
1260 case TSE_STRIP_DUP:
1262 case TSE_GP_LAYER:
1271 return tree_element_bone_collection_state_get(te, tselem);
1274 default:
1275 break;
1276 }
1277 return OL_DRAWSEL_NONE;
1278}
1279
1281{
1282 TreeStoreElem *tselem;
1283
1284 te = te->parent;
1285 while (te) {
1286 tselem = TREESTORE(te);
1287 if (tselem->type == TSE_POSE_CHANNEL) {
1288 *r_bone_te = te;
1289 return static_cast<bPoseChannel *>(te->directdata);
1290 }
1291 te = te->parent;
1292 }
1293
1294 return nullptr;
1295}
1296
1298
1299/* -------------------------------------------------------------------- */
1302
1304 PointerRNA *ptr,
1305 const eSpaceButtons_Context context)
1306{
1307 bScreen *screen = CTX_wm_screen(C);
1308
1309 for (ScrArea &area : screen->areabase) {
1310 if (area.spacetype != SPACE_PROPERTIES) {
1311 continue;
1312 }
1313
1314 SpaceProperties *sbuts = area.spacedata.first_as<SpaceProperties>();
1315 if (ED_buttons_should_sync_with_outliner(C, sbuts, &area)) {
1316 ED_buttons_set_context(C, sbuts, ptr, context);
1317 }
1318 }
1319}
1320
1322{
1323 PointerRNA ptr = {};
1325
1326 /* ID Types */
1327 if (tselem->type == TSE_SOME_ID) {
1328 ptr = RNA_id_pointer_create(tselem->id);
1329
1330 switch (te->idcode) {
1331 case ID_SCE:
1332 context = BCONTEXT_SCENE;
1333 break;
1334 case ID_OB:
1335 context = BCONTEXT_OBJECT;
1336 break;
1337 case ID_ME:
1338 case ID_CU_LEGACY:
1339 case ID_MB:
1340 case ID_IM:
1341 case ID_LT:
1342 case ID_LA:
1343 case ID_CA:
1344 case ID_SPK:
1345 case ID_AR:
1346 case ID_GD_LEGACY:
1347 case ID_GP:
1348 case ID_LP:
1349 case ID_CV:
1350 case ID_PT:
1351 case ID_VO:
1352 context = BCONTEXT_DATA;
1353 break;
1354 case ID_MA:
1355 context = BCONTEXT_MATERIAL;
1356 break;
1357 case ID_WO:
1358 context = BCONTEXT_WORLD;
1359 break;
1360 }
1361 }
1362 else {
1363 switch (tselem->type) {
1364 case TSE_SHAPE_KEY_BASE:
1366 if (TreeElement *parent_te = outliner_search_back_te(te, ID_OB)) {
1367 TreeStoreElem *parent_tselem = TREESTORE(parent_te);
1368 Object *ob = id_cast<Object *>(parent_tselem->id);
1369 ptr = RNA_id_pointer_create(static_cast<ID *>(ob->data));
1370 context = BCONTEXT_DATA;
1371 }
1372 break;
1373 case TSE_DEFGROUP_BASE:
1374 case TSE_DEFGROUP:
1375 ptr = RNA_id_pointer_create(tselem->id);
1376 context = BCONTEXT_DATA;
1377 break;
1379 case TSE_CONSTRAINT: {
1380 TreeElement *bone_te = nullptr;
1381 bPoseChannel *pchan = outliner_find_parent_bone(te, &bone_te);
1382
1383 if (pchan) {
1384 ptr = RNA_pointer_create_discrete(TREESTORE(bone_te)->id, RNA_PoseBone, pchan);
1385 context = BCONTEXT_BONE_CONSTRAINT;
1386 }
1387 else {
1388 ptr = RNA_id_pointer_create(tselem->id);
1389 context = BCONTEXT_CONSTRAINT;
1390 }
1391
1392 /* Expand the selected constraint in the properties editor. */
1393 if (tselem->type != TSE_CONSTRAINT_BASE) {
1395 }
1396 break;
1397 }
1398 case TSE_MODIFIER_BASE:
1399 case TSE_MODIFIER:
1400 ptr = RNA_id_pointer_create(tselem->id);
1401 context = BCONTEXT_MODIFIER;
1402
1403 if (tselem->type != TSE_MODIFIER_BASE) {
1404 ModifierData *md = static_cast<ModifierData *>(te->directdata);
1405
1406 switch (md->type) {
1408 context = BCONTEXT_PARTICLE;
1409 break;
1416 context = BCONTEXT_PHYSICS;
1417 break;
1418 default:
1419 break;
1420 }
1421
1422 if (context == BCONTEXT_MODIFIER) {
1424 }
1425 }
1426 break;
1428 break;
1430 case TSE_GPENCIL_EFFECT:
1431 ptr = RNA_id_pointer_create(tselem->id);
1432 context = BCONTEXT_SHADERFX;
1433
1434 if (tselem->type != TSE_GPENCIL_EFFECT_BASE) {
1436 }
1437 break;
1438 case TSE_BONE: {
1439 bArmature *arm = id_cast<bArmature *>(tselem->id);
1440 Bone *bone = static_cast<Bone *>(te->directdata);
1441
1442 ptr = RNA_pointer_create_discrete(&arm->id, RNA_Bone, bone);
1443 context = BCONTEXT_BONE;
1444 break;
1445 }
1446 case TSE_EBONE: {
1447 bArmature *arm = id_cast<bArmature *>(tselem->id);
1448 EditBone *ebone = static_cast<EditBone *>(te->directdata);
1449
1450 ptr = RNA_pointer_create_discrete(&arm->id, RNA_EditBone, ebone);
1451 context = BCONTEXT_BONE;
1452 break;
1453 }
1454 case TSE_POSE_CHANNEL: {
1455 Object *ob = id_cast<Object *>(tselem->id);
1456 bArmature *arm = id_cast<bArmature *>(ob->data);
1457 bPoseChannel *pchan = static_cast<bPoseChannel *>(te->directdata);
1458
1459 ptr = RNA_pointer_create_discrete(&arm->id, RNA_PoseBone, pchan);
1460 context = BCONTEXT_BONE;
1461 break;
1462 }
1463 case TSE_POSE_BASE: {
1464 Object *ob = id_cast<Object *>(tselem->id);
1465 bArmature *arm = id_cast<bArmature *>(ob->data);
1466
1467 ptr = RNA_pointer_create_discrete(&arm->id, RNA_Armature, arm);
1468 context = BCONTEXT_DATA;
1469 break;
1470 }
1471 case TSE_R_LAYER: {
1472 ViewLayer *view_layer = static_cast<ViewLayer *>(te->directdata);
1473
1474 ptr = RNA_pointer_create_discrete(tselem->id, RNA_ViewLayer, view_layer);
1475 context = BCONTEXT_VIEW_LAYER;
1476 break;
1477 }
1478 case TSE_LINKED_PSYS: {
1479 Object *ob = id_cast<Object *>(tselem->id);
1480 ParticleSystem *psys = psys_get_current(ob);
1481
1482 ptr = RNA_pointer_create_discrete(&ob->id, RNA_ParticleSystem, psys);
1483 context = BCONTEXT_PARTICLE;
1484 break;
1485 }
1486 case TSE_GP_LAYER:
1488 ptr = RNA_id_pointer_create(tselem->id);
1489 context = BCONTEXT_DATA;
1490 break;
1492 ptr = RNA_pointer_create_discrete(tselem->id, RNA_Armature, tselem->id);
1493 context = BCONTEXT_DATA;
1494 break;
1496 ptr = RNA_pointer_create_discrete(tselem->id, RNA_BoneCollection, te->directdata);
1497 context = BCONTEXT_DATA;
1498 break;
1500 ptr = RNA_pointer_create_discrete(tselem->id, RNA_Collection, te->directdata);
1501 context = BCONTEXT_COLLECTION;
1502 break;
1503 default:
1504 break;
1505 }
1506 }
1507
1508 if (ptr) {
1509 outliner_sync_to_properties_editors(C, &ptr, context);
1510 }
1511}
1512
1514
1515/* -------------------------------------------------------------------- */
1518
1526 const TreeViewContext &tvc,
1527 SpaceOutliner *space_outliner,
1528 TreeElement *te,
1529 TreeStoreElem *tselem,
1530 const bool extend,
1531 const bool recursive,
1532 const bool do_activate_data)
1533{
1534 Main *bmain = CTX_data_main(C);
1535 /* Always makes active object, except for some specific types. */
1536 if (ELEM(tselem->type,
1537 TSE_STRIP,
1540 TSE_EBONE,
1543 {
1544 /* Note about TSE_EBONE: In case of a same ID_AR datablock shared among several
1545 * objects, we do not want to switch out of edit mode (see #48328 for details). */
1546 }
1547 else if (do_activate_data) {
1549 *tvc.bmain,
1550 tvc.scene,
1551 tvc.view_layer,
1552 te,
1553 (extend && tselem->type == TSE_SOME_ID) ? OL_SETSEL_EXTEND :
1555 recursive && tselem->type == TSE_SOME_ID);
1556 }
1557 else if (recursive && !(space_outliner->flag & SO_SYNC_SELECT)) {
1558 /* Selection of child objects in hierarchy when sync-selection is OFF. */
1559 tree_iterator::all(te->subtree, [&](TreeElement *te) {
1560 TreeStoreElem *tselem = TREESTORE(te);
1561 if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
1562 tselem->flag |= TSE_SELECTED;
1563 }
1564 });
1565 }
1566
1567 if (tselem->type == TSE_SOME_ID) { /* The lib blocks. */
1568 if (do_activate_data == false) {
1569 /* Only select in outliner. */
1570 }
1571 else if (te->idcode == ID_SCE) {
1572 if (tvc.scene != id_cast<Scene *>(tselem->id)) {
1573 WM_window_set_active_scene(bmain, C, CTX_wm_window(C), id_cast<Scene *>(tselem->id));
1574 }
1575 }
1576 else if ((te->idcode == ID_GR) && (space_outliner->outlinevis != SO_VIEW_LAYER)) {
1577 Collection *gr = id_cast<Collection *>(tselem->id);
1578 BKE_view_layer_synced_ensure(*bmain, tvc.scene, tvc.view_layer);
1579
1580 if (extend) {
1583 Base *base = BKE_view_layer_base_find(tvc.view_layer, object);
1584 if (base && (base->flag & BASE_SELECTED)) {
1585 sel = object::BA_DESELECT;
1586 break;
1587 }
1588 }
1590
1592 Base *base = BKE_view_layer_base_find(tvc.view_layer, object);
1593 if (base) {
1594 object::base_select(base, sel);
1595 }
1596 }
1598 }
1599 else {
1600 BKE_view_layer_base_deselect_all(*bmain, tvc.scene, tvc.view_layer);
1601
1603 Base *base = BKE_view_layer_base_find(tvc.view_layer, object);
1604 /* Object may not be in this scene */
1605 if (base != nullptr) {
1606 if ((base->flag & BASE_SELECTED) == 0) {
1608 }
1609 }
1610 }
1612 }
1613
1614 DEG_id_tag_update(&tvc.scene->id, ID_RECALC_SELECT);
1616 }
1617 else { /* Rest of types. */
1618 tree_element_activate(C, tvc, te, OL_SETSEL_NORMAL, false);
1619 }
1620 }
1621 else if (do_activate_data) {
1623 C, tvc, te, tselem, extend ? OL_SETSEL_EXTEND : OL_SETSEL_NORMAL, recursive);
1624 }
1625}
1626
1628 SpaceOutliner *space_outliner,
1629 TreeElement *te,
1630 const short select_flag)
1631{
1632 TreeStoreElem *tselem = TREESTORE(te);
1633 const bool activate = select_flag & OL_ITEM_ACTIVATE;
1634 const bool extend = select_flag & OL_ITEM_EXTEND;
1635 const bool activate_data = select_flag & OL_ITEM_SELECT_DATA;
1636 const bool recursive = select_flag & OL_ITEM_RECURSIVE;
1637
1638 /* Clear previous active when activating and clear selection when not extending selection */
1639 const eTreeStoreElem_Flag clear_flag = (activate ? TSE_ACTIVE : eTreeStoreElem_Flag{}) |
1640 (extend ? eTreeStoreElem_Flag{} : TSE_SELECTED);
1641
1642 /* Do not clear the active and select flag when selecting hierarchies. */
1643 if (clear_flag && !recursive) {
1644 outliner_flag_set(*space_outliner, clear_flag, false);
1645 }
1646
1647 if (select_flag & OL_ITEM_SELECT) {
1648 tselem->flag |= TSE_SELECTED;
1649 }
1650 else {
1651 tselem->flag &= ~TSE_SELECTED;
1652 }
1653
1654 if (activate) {
1655 TreeViewContext tvc;
1657
1658 if (!recursive) {
1659 tselem->flag |= TSE_ACTIVE;
1660 }
1661
1663 tvc,
1664 space_outliner,
1665 te,
1666 tselem,
1667 extend,
1668 select_flag & OL_ITEM_RECURSIVE,
1669 activate_data || space_outliner->flag & SO_SYNC_SELECT);
1670 }
1671}
1672
1674{
1675 /* If we're recursing, we need to know the collection of the selected item in order
1676 * to prevent selecting across collection boundaries. (Object hierarchies might cross
1677 * collection boundaries, i.e., children may be in different collections from their
1678 * parents.) */
1679 Collection *parent_collection = nullptr;
1680 if (te->store_elem->type == TSE_LAYER_COLLECTION) {
1681 parent_collection = static_cast<LayerCollection *>(te->directdata)->collection;
1682 }
1683 else if (te->store_elem->type == TSE_SOME_ID && te->idcode == ID_OB) {
1684 parent_collection = BKE_collection_object_find(CTX_data_main(C),
1686 nullptr,
1687 reinterpret_cast<Object *>(te->store_elem->id));
1688 }
1689 return parent_collection;
1690}
1691
1692static bool can_select_recursive(TreeElement *te, Collection *in_collection)
1693{
1694 if (te->store_elem->type == TSE_LAYER_COLLECTION) {
1695 return true;
1696 }
1697
1698 if (te->store_elem->type == TSE_SOME_ID && te->idcode == ID_OB) {
1699 /* Only actually select the object if
1700 * 1. We are not restricted to any collection, or
1701 * 2. The object is in fact in the given collection. */
1702 if (!in_collection || BKE_collection_has_object_recursive(
1703 in_collection, reinterpret_cast<Object *>(te->store_elem->id)))
1704 {
1705 return true;
1706 }
1707 }
1708
1709 return false;
1710}
1711
1712static void do_outliner_select_recursive(ListBaseT<TreeElement> *lb,
1713 bool selecting,
1714 Collection *in_collection)
1715{
1716 for (TreeElement &te : *lb) {
1717 TreeStoreElem *tselem = TREESTORE(&te);
1718 /* Recursive selection only on collections or objects. */
1719 if (can_select_recursive(&te, in_collection)) {
1720 tselem->flag = selecting ? (tselem->flag | TSE_SELECTED) : (tselem->flag & ~TSE_SELECTED);
1721 if (tselem->type == TSE_LAYER_COLLECTION) {
1722 /* Restrict sub-tree selections to this collection. This prevents undesirable behavior in
1723 * the edge-case where there is an object which is part of this collection, but which has
1724 * children that are part of another collection. */
1726 &te.subtree, selecting, static_cast<LayerCollection *>(te.directdata)->collection);
1727 }
1728 else {
1729 do_outliner_select_recursive(&te.subtree, selecting, in_collection);
1730 }
1731 }
1732 else {
1733 tselem->flag &= ~TSE_SELECTED;
1734 }
1735 }
1736}
1737
1738static bool do_outliner_range_select_recursive(ListBaseT<TreeElement> *lb,
1739 TreeElement *active,
1740 TreeElement *cursor,
1741 bool selecting,
1742 const bool recurse,
1743 Collection *in_collection)
1744{
1745 for (TreeElement &te : *lb) {
1746 TreeStoreElem *tselem = TREESTORE(&te);
1747
1748 bool can_select = !recurse || can_select_recursive(&te, in_collection);
1749
1750 /* Remember if we are selecting before we potentially change the selecting state. */
1751 bool selecting_before = selecting;
1752
1753 /* Set state for selection */
1754 if (ELEM(&te, active, cursor)) {
1755 selecting = !selecting;
1756 }
1757
1758 if (can_select && (selecting_before || selecting)) {
1759 tselem->flag |= TSE_SELECTED;
1760 }
1761
1762 /* Don't look inside closed elements, unless we're forcing the recursion all the way down. */
1763 if (!(tselem->flag & TSE_CLOSED) || recurse) {
1764 /* If this tree element is a collection, then it sets
1765 * the precedent for inclusion of its sub-objects. */
1766 Collection *child_collection = in_collection;
1767 if (tselem->type == TSE_LAYER_COLLECTION) {
1768 child_collection = static_cast<LayerCollection *>(te.directdata)->collection;
1769 }
1771 &te.subtree, active, cursor, selecting, recurse, child_collection);
1772 }
1773 }
1774
1775 return selecting;
1776}
1777
1778/* Select a range of items between cursor and active element */
1780 SpaceOutliner *space_outliner,
1781 TreeElement *cursor,
1782 const bool extend,
1783 const bool recurse,
1784 Collection *in_collection)
1785{
1786 TreeElement *active = outliner_find_element_with_flag(&space_outliner->runtime->tree,
1787 TSE_ACTIVE);
1788
1789 /* If no active element exists, activate the element under the cursor */
1790 if (!active) {
1791 outliner_item_select(C, space_outliner, cursor, OL_ITEM_SELECT | OL_ITEM_ACTIVATE);
1792 return;
1793 }
1794
1795 TreeStoreElem *tselem = TREESTORE(active);
1796 const bool active_selected = (tselem->flag & TSE_SELECTED);
1797
1798 if (!extend) {
1799 outliner_flag_set(*space_outliner, TSE_SELECTED, false);
1800 }
1801
1802 /* Select active if under cursor */
1803 if (active == cursor) {
1804 outliner_item_select(C, space_outliner, cursor, OL_ITEM_SELECT);
1805 if (recurse) {
1806 do_outliner_select_recursive(&cursor->subtree, true, in_collection);
1807 }
1808 return;
1809 }
1810
1811 /* If active is not selected or visible, select and activate the element under the cursor */
1812 if (!active_selected || !outliner_is_element_visible(active)) {
1813 outliner_item_select(C, space_outliner, cursor, OL_ITEM_SELECT | OL_ITEM_ACTIVATE);
1814 return;
1815 }
1816
1818 &space_outliner->runtime->tree, active, cursor, false, recurse, in_collection);
1819
1820 if (recurse) {
1821 do_outliner_select_recursive(&cursor->subtree, true, in_collection);
1822 /* Select children of active tree element. This is required when
1823 * range selecting from bottom to top, see #117224. */
1824 in_collection = outliner_collection_get_for_recursive(C, active);
1825 do_outliner_select_recursive(&active->subtree, true, in_collection);
1826 }
1827}
1828
1830 const ARegion *region,
1831 float view_co_x)
1832{
1833 return (view_co_x > region->v2d.cur.xmax - outliner_right_columns_width(space_outliner));
1834}
1835
1836bool outliner_is_co_within_mode_column(SpaceOutliner *space_outliner, const float view_mval[2])
1837{
1838 if (!outliner_shows_mode_column(*space_outliner)) {
1839 return false;
1840 }
1841
1842 return view_mval[0] < UI_UNIT_X;
1843}
1844
1846 SpaceOutliner *space_outliner,
1847 const float view_mval[2])
1848{
1849 const Main *bmain = CTX_data_main(C);
1850 const Scene *scene = CTX_data_scene(C);
1851 ViewLayer *view_layer = CTX_data_view_layer(C);
1852 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
1853 Object *obact = BKE_view_layer_active_object_get(view_layer);
1854
1855 return outliner_is_co_within_mode_column(space_outliner, view_mval) && obact &&
1856 obact->mode != OB_MODE_OBJECT;
1857}
1858
1865 const int mval[2],
1866 const bool extend,
1867 const bool use_range,
1868 const bool deselect_all,
1869 const bool recurse)
1870{
1871 ARegion *region = CTX_wm_region(C);
1872 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1873 TreeElement *te;
1874 float view_mval[2];
1875 bool changed = false, rebuild_tree = false;
1876
1877 ui::view2d_region_to_view(&region->v2d, mval[0], mval[1], &view_mval[0], &view_mval[1]);
1878
1879 if (outliner_is_co_within_restrict_columns(space_outliner, region, view_mval[0])) {
1880 return OPERATOR_CANCELLED;
1881 }
1882 if (outliner_is_co_within_active_mode_column(C, space_outliner, view_mval)) {
1883 return OPERATOR_CANCELLED;
1884 }
1885
1886 if (!(te = outliner_find_item_at_y(
1887 space_outliner, &space_outliner->runtime->tree, view_mval[1])))
1888 {
1889 if (deselect_all) {
1890 changed |= outliner_flag_set(*space_outliner, TSE_SELECTED, false);
1891 }
1892 }
1893 /* Don't allow toggle on scene collection */
1894 else if ((TREESTORE(te)->type != TSE_VIEW_COLLECTION_BASE) &&
1896 {
1898 }
1899 else {
1900 /* The row may also contain children, if one is hovered we want this instead of current te. */
1901 bool merged_elements = false;
1902 bool is_over_icon = false;
1904 space_outliner, te, view_mval[0], &merged_elements, &is_over_icon);
1905
1906 /* If the selected icon was an aggregate of multiple elements, run the search popup */
1907 if (merged_elements) {
1908 merged_element_search_menu_invoke(C, te, activate_te);
1909 return OPERATOR_CANCELLED;
1910 }
1911
1912 TreeStoreElem *activate_tselem = TREESTORE(activate_te);
1913
1914 Collection *parent_collection = nullptr;
1915 if (recurse) {
1916 parent_collection = outliner_collection_get_for_recursive(C, activate_te);
1917 }
1918
1919 /* If we're not recursing (not double clicking), and we are extending or range selecting by
1920 * holding CTRL or SHIFT, ignore events when the cursor is over the icon. This disambiguates
1921 * the case where we are recursing *and* holding CTRL or SHIFT in order to extend or range
1922 * select recursively. */
1923 if (!recurse && (extend || use_range) && is_over_icon) {
1924 return OPERATOR_CANCELLED;
1925 }
1926
1927 if (use_range) {
1929 C, space_outliner, activate_te, extend, (recurse && is_over_icon), parent_collection);
1930 }
1931 else {
1932 const bool is_over_name_icons = outliner_item_is_co_over_name_icons(activate_te,
1933 view_mval[0]);
1934 /* Always select unless already active and selected. */
1935 bool select = !extend || !(activate_tselem->flag & TSE_ACTIVE) ||
1936 !(activate_tselem->flag & TSE_SELECTED);
1937
1938 /* If we're CTRL+double-clicking and the element is already
1939 * selected, skip the activation and go straight to deselection. */
1940 if (extend && recurse && activate_tselem->flag & TSE_SELECTED) {
1941 select = false;
1942 }
1943
1944 const short select_flag = OL_ITEM_ACTIVATE | (select ? OL_ITEM_SELECT : OL_ITEM_DESELECT) |
1945 (is_over_name_icons ? OL_ITEM_SELECT_DATA : 0) |
1946 (extend ? OL_ITEM_EXTEND : 0);
1947
1948 /* The recurse flag is set when the user double-clicks
1949 * to select everything in a collection or hierarchy. */
1950 if (recurse) {
1951 if (is_over_icon) {
1952 /* Select or deselect object hierarchy recursively. */
1953 outliner_item_select(C, space_outliner, activate_te, select_flag);
1954 do_outliner_select_recursive(&activate_te->subtree, select, parent_collection);
1955 }
1956 else {
1957 /* Double-clicked, but it wasn't on the icon. */
1959 }
1960 }
1961 else {
1962 outliner_item_select(C, space_outliner, activate_te, select_flag);
1963 }
1964
1965 /* Only switch properties editor tabs when icons are selected. */
1966 if (is_over_icon) {
1967 outliner_set_properties_tab(C, activate_te, activate_tselem);
1968 }
1969 }
1970
1971 changed = true;
1972 }
1973
1974 if (!changed) {
1975 return OPERATOR_CANCELLED;
1976 }
1977
1978 if (rebuild_tree) {
1979 ED_region_tag_redraw(region);
1980 }
1981 else {
1983 }
1984
1986
1987 return OPERATOR_FINISHED;
1988}
1989
1990/* Event can enter-key, then it opens/closes. */
1992 wmOperator *op,
1993 const wmEvent *event)
1994{
1995 ARegion *region = CTX_wm_region(C);
1996
1997 const bool extend = RNA_boolean_get(op->ptr, "extend");
1998 const bool use_range = RNA_boolean_get(op->ptr, "extend_range");
1999 const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
2000 const bool recurse = RNA_boolean_get(op->ptr, "recurse");
2001
2002 int mval[2];
2003 WM_event_drag_start_mval(event, region, mval);
2004 return outliner_item_do_activate_from_cursor(C, mval, extend, use_range, deselect_all, recurse);
2005}
2006
2008{
2009 ot->name = "Select";
2010 ot->idname = "OUTLINER_OT_item_activate";
2011 ot->description = "Handle mouse clicks to select and activate items";
2012
2014
2016
2018
2019 PropertyRNA *prop;
2020 prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection for activation");
2022 prop = RNA_def_boolean(
2023 ot->srna, "extend_range", false, "Extend Range", "Select a range from active element");
2025
2026 prop = RNA_def_boolean(ot->srna,
2027 "deselect_all",
2028 false,
2029 "Deselect On Nothing",
2030 "Deselect all when nothing under the cursor");
2032
2033 prop = RNA_def_boolean(
2034 ot->srna, "recurse", false, "Recurse", "Select objects recursively from active element");
2036}
2037
2039
2040/* -------------------------------------------------------------------- */
2043
2045 SpaceOutliner *space_outliner,
2046 const rctf *rectf,
2047 const bool select)
2048{
2049 tree_iterator::all_open(*space_outliner, [&](TreeElement *te) {
2050 if (te->ys <= rectf->ymax && te->ys + UI_UNIT_Y >= rectf->ymin) {
2052 C, space_outliner, te, (select ? OL_ITEM_SELECT : OL_ITEM_DESELECT) | OL_ITEM_EXTEND);
2053 }
2054 });
2055}
2056
2058{
2059 Scene *scene = CTX_data_scene(C);
2060 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
2061 ARegion *region = CTX_wm_region(C);
2062 rctf rectf;
2063
2064 const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
2065 const bool select = (sel_op != SEL_OP_SUB);
2066 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
2067 outliner_flag_set(*space_outliner, TSE_SELECTED, 0);
2068 }
2069
2071 ui::view2d_region_to_view_rctf(&region->v2d, &rectf, &rectf);
2072
2073 outliner_box_select(C, space_outliner, &rectf, select);
2074
2078
2080
2081 return OPERATOR_FINISHED;
2082}
2083
2085 wmOperator *op,
2086 const wmEvent *event)
2087{
2088 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
2089 ARegion *region = CTX_wm_region(C);
2090 float view_mval[2];
2091 const bool tweak = RNA_boolean_get(op->ptr, "tweak");
2092
2093 int mval[2];
2094 WM_event_drag_start_mval(event, region, mval);
2095 ui::view2d_region_to_view(&region->v2d, mval[0], mval[1], &view_mval[0], &view_mval[1]);
2096
2097 /* Find element clicked on */
2099 space_outliner, &space_outliner->runtime->tree, view_mval[1]);
2100
2101 /* Pass through if click is over name or icons, or not tweak event */
2102 if (te && tweak && outliner_item_is_co_over_name_icons(te, view_mval[0])) {
2104 }
2105
2106 if (outliner_is_co_within_active_mode_column(C, space_outliner, view_mval)) {
2108 }
2109
2110 return WM_gesture_box_invoke(C, op, event);
2111}
2112
2114{
2115 /* identifiers */
2116 ot->name = "Box Select";
2117 ot->idname = "OUTLINER_OT_select_box";
2118 ot->description = "Use box selection to select tree elements";
2119
2120 /* API callbacks. */
2125
2127
2128 /* flags */
2130
2131 /* properties */
2132 PropertyRNA *prop;
2133
2134 prop = RNA_def_boolean(
2135 ot->srna, "tweak", false, "Tweak", "Tweak gesture from empty space for box selection");
2137
2140}
2141
2143
2144/* -------------------------------------------------------------------- */
2147
2148/* Given a tree element return the rightmost child that is visible in the outliner */
2150 TreeElement *te)
2151{
2152 while (te->subtree.last()) {
2153 if (TSELEM_OPEN(TREESTORE(te), space_outliner)) {
2154 te = te->subtree.last();
2155 }
2156 else {
2157 break;
2158 }
2159 }
2160 return te;
2161}
2162
2163/* Find previous visible element in the tree. */
2165{
2166 if (te->prev) {
2167 te = outliner_find_rightmost_visible_child(space_outliner, te->prev);
2168 }
2169 else if (te->parent) {
2170 /* Use parent if at beginning of list */
2171 te = te->parent;
2172 }
2173
2174 return te;
2175}
2176
2177/* Recursively search up the tree until a successor to a given element is found */
2179{
2180 TreeElement *successor = te;
2181 while (successor->parent) {
2182 if (successor->parent->next) {
2183 te = successor->parent->next;
2184 break;
2185 }
2186 successor = successor->parent;
2187 }
2188
2189 return te;
2190}
2191
2192/* Find next visible element in the tree */
2194{
2195 TreeStoreElem *tselem = TREESTORE(te);
2196
2197 if (TSELEM_OPEN(tselem, space_outliner) && te->subtree.first()) {
2198 te = te->subtree.first();
2199 }
2200 else if (te->next) {
2201 te = te->next;
2202 }
2203 else {
2205 }
2206
2207 return te;
2208}
2209
2211 TreeElement *te,
2212 bool toggle_all)
2213{
2214 TreeStoreElem *tselem = TREESTORE(te);
2215
2216 if (TSELEM_OPEN(tselem, space_outliner)) {
2217 outliner_item_openclose(te, false, toggle_all);
2218 }
2219 /* Only walk up a level if the element is closed and not toggling expand */
2220 else if (!toggle_all && te->parent) {
2221 te = te->parent;
2222 }
2223
2224 return te;
2225}
2226
2228 TreeElement *te,
2229 bool toggle_all)
2230{
2231 TreeStoreElem *tselem = TREESTORE(te);
2232
2233 /* Only walk down a level if the element is open and not toggling expand */
2234 if (!toggle_all && TSELEM_OPEN(tselem, space_outliner) && !te->subtree.is_empty()) {
2235 te = te->subtree.first();
2236 }
2237 else {
2238 outliner_item_openclose(te, true, toggle_all);
2239 }
2240
2241 return te;
2242}
2243
2245 TreeElement *te,
2246 const int direction,
2247 const bool extend,
2248 const bool toggle_all)
2249{
2250 TreeStoreElem *tselem = TREESTORE(te);
2251
2252 switch (direction) {
2253 case UI_SELECT_WALK_UP:
2254 te = outliner_find_previous_element(space_outliner, te);
2255 break;
2257 te = outliner_find_next_element(space_outliner, te);
2258 break;
2260 te = outliner_walk_left(space_outliner, te, toggle_all);
2261 break;
2263 te = outliner_walk_right(space_outliner, te, toggle_all);
2264 break;
2265 }
2266
2267 /* If new element is already selected, deselect the previous element */
2268 TreeStoreElem *tselem_new = TREESTORE(te);
2269 if (extend) {
2270 tselem->flag = (tselem_new->flag & TSE_SELECTED) ? (tselem->flag & ~TSE_SELECTED) :
2271 (tselem->flag | TSE_SELECTED);
2272 }
2273
2274 return te;
2275}
2276
2277/* Find the active element to walk from, or set one if none exists.
2278 * Changed is set to true if the active element is found, or false if it was set */
2279static TreeElement *find_walk_select_start_element(SpaceOutliner *space_outliner, bool *r_changed)
2280{
2281 TreeElement *active_te = outliner_find_element_with_flag(&space_outliner->runtime->tree,
2282 TSE_ACTIVE);
2283 *r_changed = false;
2284
2285 /* If no active element exists, use the first element in the tree */
2286 if (!active_te) {
2287 active_te = space_outliner->runtime->tree.first();
2288 *r_changed = true;
2289 }
2290
2291 /* If the active element is not visible, activate the first visible parent element */
2292 if (!outliner_is_element_visible(active_te)) {
2293 while (!outliner_is_element_visible(active_te)) {
2294 active_te = active_te->parent;
2295 }
2296 *r_changed = true;
2297 }
2298
2299 return active_te;
2300}
2301
2302/* Scroll the outliner when the walk element reaches the top or bottom boundary */
2303static void outliner_walk_scroll(SpaceOutliner *space_outliner, ARegion *region, TreeElement *te)
2304{
2305 /* Account for the header height */
2306 int y_max = region->v2d.cur.ymax - UI_UNIT_Y;
2307 int y_min = region->v2d.cur.ymin;
2308
2309 /* Scroll if walked position is beyond the border */
2310 if (te->ys > y_max) {
2311 outliner_scroll_view(space_outliner, region, te->ys - y_max);
2312 }
2313 else if (te->ys < y_min) {
2314 outliner_scroll_view(space_outliner, region, -(y_min - te->ys));
2315 }
2316}
2317
2319 wmOperator *op,
2320 const wmEvent * /*event*/)
2321{
2322 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
2323 ARegion *region = CTX_wm_region(C);
2324
2325 const short direction = RNA_enum_get(op->ptr, "direction");
2326 const bool extend = RNA_boolean_get(op->ptr, "extend");
2327 const bool toggle_all = RNA_boolean_get(op->ptr, "toggle_all");
2328
2329 bool changed;
2330 TreeElement *active_te = find_walk_select_start_element(space_outliner, &changed);
2331
2332 /* If finding the active element did not modify the selection, proceed to walk */
2333 if (!changed) {
2334 active_te = do_outliner_select_walk(space_outliner, active_te, direction, extend, toggle_all);
2335 }
2336
2338 space_outliner,
2339 active_te,
2341
2342 /* Scroll outliner to focus on walk element */
2343 outliner_walk_scroll(space_outliner, region, active_te);
2344
2347
2348 return OPERATOR_FINISHED;
2349}
2350
2352{
2353 /* identifiers */
2354 ot->name = "Walk Select";
2355 ot->idname = "OUTLINER_OT_select_walk";
2356 ot->description = "Use walk navigation to select tree elements";
2357
2358 /* API callbacks. */
2361
2363
2364 /* properties */
2365 PropertyRNA *prop;
2367 prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection on walk");
2369 prop = RNA_def_boolean(
2370 ot->srna, "toggle_all", false, "Toggle All", "Toggle open/close hierarchy");
2372}
2373
2375
2376} // namespace blender::ed::outliner
Functions to deal with Armatures.
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_END
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(_collection, _object)
support for deformation groups and hooks.
Low-level operations for grease pencil.
General operations, lookup, etc. for blender objects.
Object is a sort of wrapper for general info.
#define OB_TYPE_SUPPORT_EDITMODE(_type)
#define EBONE_SELECTABLE(arm, ebone)
#define SEL_OP_USE_PRE_DESELECT(sel_op)
#define C
Definition RandGen.cpp:29
#define UI_UNIT_Y
#define UI_UNIT_X
#define ND_SEQUENCER
Definition WM_types.hh:456
#define NA_ACTIVATED
Definition WM_types.hh:640
#define ND_DATA
Definition WM_types.hh:552
#define NC_SCREEN
Definition WM_types.hh:390
#define ND_MODE
Definition WM_types.hh:464
#define ND_OB_SELECT
Definition WM_types.hh:461
#define NC_SCENE
Definition WM_types.hh:391
#define ND_MODIFIER
Definition WM_types.hh:503
#define NA_EDITED
Definition WM_types.hh:634
#define ND_PARTICLE
Definition WM_types.hh:506
#define NS_MODE_OBJECT
Definition WM_types.hh:610
#define NC_MATERIAL
Definition WM_types.hh:393
#define ND_CONSTRAINT
Definition WM_types.hh:505
#define NC_GPENCIL
Definition WM_types.hh:412
#define ND_BONE_ACTIVE
Definition WM_types.hh:483
#define ND_TRANSFORM
Definition WM_types.hh:475
#define ND_LAYER
Definition WM_types.hh:469
#define ND_BONE_COLLECTION
Definition WM_types.hh:515
#define NS_MODE_POSE
Definition WM_types.hh:619
#define NC_OBJECT
Definition WM_types.hh:392
#define ND_SHADING_LINKS
Definition WM_types.hh:522
#define NS_LAYER_COLLECTION
Definition WM_types.hh:630
#define NA_SELECTED
Definition WM_types.hh:639
#define ELEM(...)
#define STREQ(a, b)
void activate(bool forceActivation=false) const
const T & data(const Action &owning_action) const
void bone_deselect(bPoseChannel *pchan)
bool bone_is_visible(const bArmature *armature, const Bone *bone)
bool bone_is_selectable(const bArmature *armature, const bke::PChanBoneConst pchanbone)
void bone_select(bPoseChannel *pchan)
void base_select(Base *base, eObjectSelect_Mode mode)
void mode_generic_exit(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob)
bool editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag)
void base_activate_with_mode_exit_if_needed(bContext *C, Base *base)
bool mode_set(bContext *C, eObjectMode mode)
bool editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int flag)
void all_open(const SpaceOutliner &space_outliner, const ConstVisitorFn visitor)
void all(const SpaceOutliner &space_outliner, const ConstVisitorFn visitor)
static void tree_element_bone_activate(bContext *C, const Main &bmain, const Scene *scene, ViewLayer *view_layer, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive)
bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float view_co_x)
static void tree_element_defgroup_activate(bContext *C, TreeElement *te, TreeStoreElem *tselem)
static void tree_element_constraint_activate(bContext *C, const Scene *scene, ViewLayer *view_layer, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set)
TreeElement * outliner_find_item_at_y(const SpaceOutliner *space_outliner, const ListBaseT< TreeElement > *tree, float view_co_y)
void outliner_tag_redraw_avoid_rebuild_on_open_change(const SpaceOutliner *space_outliner, ARegion *region)
static void tree_element_master_collection_activate(const bContext *C)
static void do_outliner_range_select(bContext *C, SpaceOutliner *space_outliner, TreeElement *cursor, const bool extend, const bool recurse, Collection *in_collection)
static void tree_element_world_activate(bContext *C, Scene *scene, TreeElement *te)
static void do_outliner_item_activate_tree_element(bContext *C, const TreeViewContext &tvc, SpaceOutliner *space_outliner, TreeElement *te, TreeStoreElem *tselem, const bool extend, const bool recursive, const bool do_activate_data)
static void tree_element_gplayer_activate(bContext *C, TreeElement *te, TreeStoreElem *tselem)
static void do_outliner_ebone_select_recursive(bArmature *arm, EditBone *ebone_parent, bool select)
static eOLDrawState tree_element_active_camera_get(const Scene *scene, const TreeElement *te)
eOLDrawState tree_element_type_active_state_get(const TreeViewContext &tvc, const TreeElement *te, const TreeStoreElem *tselem)
static wmOperatorStatus outliner_item_activate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static eOLDrawState tree_element_bone_collection_state_get(const TreeElement *te, const TreeStoreElem *tselem)
static void outliner_sync_to_properties_editors(const bContext *C, PointerRNA *ptr, const eSpaceButtons_Context context)
static eOLDrawState tree_element_pose_state_get(const Main &bmain, const Scene *scene, const ViewLayer *view_layer, const TreeStoreElem *tselem)
static void tree_elemment_shapekey_active_set(bContext *C, TreeElement *te)
static void outliner_box_select(bContext *C, SpaceOutliner *space_outliner, const rctf *rectf, const bool select)
static void do_outliner_bone_select_recursive(bArmature *arm, Bone *bone_parent, bool select)
TreeElement * outliner_find_item_at_x_in_row(const SpaceOutliner *space_outliner, TreeElement *parent_te, float view_co_x, bool *r_is_merged_icon, bool *r_is_over_icon)
static eOLDrawState tree_element_active_material_get(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const TreeElement *te)
static void do_outliner_item_posemode_toggle(bContext *C, Scene *scene, Base *base)
static eOLDrawState tree_element_defgroup_state_get(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const TreeElement *te, const TreeStoreElem *tselem)
static eOLDrawState tree_element_viewlayer_state_get(const ViewLayer *view_layer, const TreeElement *te)
static bool outliner_is_co_within_active_mode_column(bContext *C, SpaceOutliner *space_outliner, const float view_mval[2])
static TreeElement * outliner_walk_left(SpaceOutliner *space_outliner, TreeElement *te, bool toggle_all)
float outliner_right_columns_width(const SpaceOutliner *space_outliner)
static eOLDrawState tree_element_posechannel_state_get(const Object *ob_pose, const TreeElement *te, const TreeStoreElem *tselem)
static TreeElement * outliner_find_next_element(SpaceOutliner *space_outliner, TreeElement *te)
static eOLDrawState tree_element_ebone_state_get(const TreeElement *te)
static void do_outliner_item_editmode_toggle(bContext *C, Scene *scene, Base *base)
static void tree_element_bonecollection_activate(bContext *C, TreeElement *te, TreeStoreElem *tselem)
TreeElement * outliner_search_back_te(TreeElement *te, short idcode)
static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreElem *tselem)
static Collection * outliner_collection_get_for_recursive(bContext *C, TreeElement *te)
static void tree_element_object_activate(bContext *C, Main &bmain, Scene *scene, ViewLayer *view_layer, TreeElement *te, const eOLSetState set, bool recursive)
void tree_element_activate(bContext *C, const TreeViewContext &tvc, TreeElement *te, eOLSetState set, bool handle_all_types)
static eOLDrawState tree_element_shapekey_state_get(const TreeElement *te)
static void tree_element_posechannel_activate(bContext *C, const Scene *scene, ViewLayer *view_layer, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive)
void OUTLINER_OT_item_activate(wmOperatorType *ot)
static void tree_element_camera_activate(bContext *C, Scene *scene, TreeElement *te)
static wmOperatorStatus outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEvent *)
static eOLDrawState tree_element_gplayer_state_get(const TreeElement *te)
bPoseChannel * outliner_find_parent_bone(TreeElement *te, TreeElement **r_bone_te)
bool outliner_flag_set(SpaceOutliner &space_outliner, const eTreeStoreElem_Flag flag, const short set)
static eOLDrawState tree_element_master_collection_state_get(const ViewLayer *view_layer, const LayerCollection *layer_collection)
static TreeElement * outliner_find_previous_element(SpaceOutliner *space_outliner, TreeElement *te)
static wmOperatorStatus outliner_item_do_activate_from_cursor(bContext *C, const int mval[2], const bool extend, const bool use_range, const bool deselect_all, const bool recurse)
static TreeElement * do_outliner_select_walk(SpaceOutliner *space_outliner, TreeElement *te, const int direction, const bool extend, const bool toggle_all)
static void outliner_walk_scroll(SpaceOutliner *space_outliner, ARegion *region, TreeElement *te)
static TreeElement * outliner_walk_right(SpaceOutliner *space_outliner, TreeElement *te, bool toggle_all)
void outliner_item_mode_toggle(bContext *C, const TreeViewContext &tvc, TreeElement *te, bool do_extend)
void outliner_viewcontext_init(const bContext *C, TreeViewContext *tvc)
void OUTLINER_OT_select_walk(wmOperatorType *ot)
static void tree_element_viewlayer_activate(bContext *C, TreeElement *te)
static TreeElement * find_walk_select_start_element(SpaceOutliner *space_outliner, bool *r_changed)
static void do_outliner_object_select_recursive(const Main &bmain, const Scene *scene, ViewLayer *view_layer, Object *ob_parent, bool select)
static void tree_element_material_activate(bContext *C, const Main &bmain, const Scene *scene, ViewLayer *view_layer, TreeElement *te)
void outliner_scroll_view(SpaceOutliner *space_outliner, ARegion *region, int delta_y)
static void tree_element_modifier_activate(bContext *C, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set)
bool outliner_is_element_visible(const TreeElement *te)
bool outliner_is_co_within_mode_column(SpaceOutliner *space_outliner, const float view_mval[2])
void outliner_item_openclose(TreeElement *te, bool open, bool toggle_all)
static void tree_element_ebone_activate(bContext *C, const Scene *scene, ViewLayer *view_layer, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set, bool recursive)
static eOLDrawState tree_element_active_world_get(const Scene *scene, const TreeElement *te)
static void do_outliner_select_recursive(ListBaseT< TreeElement > *lb, bool selecting, Collection *in_collection)
TreeElementT * tree_element_cast(const TreeElement *te)
ID * outliner_search_back(TreeElement *te, short idcode)
static bool outliner_is_co_within_restrict_columns(const SpaceOutliner *space_outliner, const ARegion *region, float view_co_x)
void merged_element_search_menu_invoke(bContext *C, TreeElement *parent_te, TreeElement *activate_te)
static void tree_element_psys_activate(bContext *C, TreeStoreElem *tselem)
static eOLDrawState tree_element_grease_pencil_node_state_get(const TreeElement *te)
static void do_outliner_item_mode_toggle_generic(bContext *C, const TreeViewContext &tvc, Base *base)
static eOLDrawState tree_element_object_state_get(const TreeViewContext &tvc, const TreeStoreElem *tselem)
static void tree_element_strip_activate(bContext *C, WorkSpace *workspace, TreeElement *te, const eOLSetState set)
static eOLDrawState tree_element_bone_state_get(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const TreeElement *te, const TreeStoreElem *tselem)
static TreeElement * outliner_find_rightmost_visible_child(SpaceOutliner *space_outliner, TreeElement *te)
static eOLDrawState tree_element_strip_state_get(const WorkSpace *workspace, const TreeElement *te)
bool outliner_item_is_co_over_name_icons(const TreeElement *te, float view_co_x)
static void tree_element_strip_dup_activate(WorkSpace *workspace, TreeElement *)
static void tree_element_active_ebone__sel(bContext *C, bArmature *arm, EditBone *ebone, short sel)
void tree_element_type_active_set(bContext *C, const TreeViewContext &tvc, TreeElement *te, TreeStoreElem *tselem, eOLSetState set, bool recursive)
static wmOperatorStatus outliner_box_select_exec(bContext *C, wmOperator *op)
static TreeElement * outliner_element_find_successor_in_parents(TreeElement *te)
static void tree_element_layer_collection_activate(bContext *C, TreeElement *te)
bool outliner_shows_mode_column(const SpaceOutliner &space_outliner)
eOLDrawState tree_element_active_state_get(const TreeViewContext &tvc, const TreeElement *te, const TreeStoreElem *tselem)
static wmOperatorStatus outliner_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static eOLDrawState tree_element_modifier_state_get(const TreeElement *te, const TreeStoreElem *tselem)
static eOLDrawState tree_element_layer_collection_state_get(const LayerCollection *layer_collection, const TreeElement *te)
static void tree_element_text_activate(bContext *C, TreeElement *te)
void OUTLINER_OT_select_box(wmOperatorType *ot)
static eOLDrawState tree_element_strip_dup_state_get(const TreeElement *te)
static bool do_outliner_range_select_recursive(ListBaseT< TreeElement > *lb, TreeElement *active, TreeElement *cursor, bool selecting, const bool recurse, Collection *in_collection)
static eOLDrawState tree_element_active_scene_get(const TreeViewContext &tvc, const TreeElement *te, const TreeStoreElem *tselem)
static bool can_select_recursive(TreeElement *te, Collection *in_collection)
static void tree_element_grease_pencil_node_activate(bContext *C, TreeElement *te, TreeStoreElem *tselem)
void outliner_item_select(bContext *C, SpaceOutliner *space_outliner, TreeElement *te, short select_flag)
TreeElement * outliner_find_element_with_flag(const ListBaseT< TreeElement > *lb, short flag)
bool deselect_all_strips(const Scene *scene)
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:304
void select_active_set(Scene *scene, Strip *strip)
void view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
Definition view2d.cc:1651
void view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst) ATTR_NONNULL()
Definition view2d.cc:1657
void WM_main_add_notifier(uint type, void *reference)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void WM_window_set_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene *scene)
void BKE_annotations_layer_active_set(struct bGPdata *gpd, struct bGPDlayer *active)
bool ED_buttons_should_sync_with_outliner(const bContext *C, const SpaceProperties *sbuts, ScrArea *area)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void ED_buttons_set_context(const bContext *C, SpaceProperties *sbuts, PointerRNA *ptr, eSpaceButtons_Context context)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
void BKE_view_layer_base_select_and_set_active(ViewLayer *view_layer, Base *selbase)
@ RPT_WARNING
Definition BKE_report.hh:40
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool BKE_layer_collection_activate(ViewLayer *view_layer, LayerCollection *lc)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
wmOperatorStatus WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
SpaceOutliner * CTX_wm_space_outliner(const bContext *C)
struct ParticleSystem * psys_get_current(struct Object *ob)
Definition particle.cc:571
PointerRNA RNA_id_pointer_create(ID *id)
@ BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT
bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child)
void ED_outliner_select_sync_from_outliner(bContext *C, SpaceOutliner *space_outliner)
Vector< Base * > BKE_view_layer_array_from_bases_in_mode_params(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d, const ObjectsInModeParams *params)
@ eModifierType_ParticleSystem
@ eModifierType_DynamicPaint
wmWindow * CTX_wm_window(const bContext *C)
bool ED_operator_outliner_active(bContext *C)
void BKE_object_defgroup_active_index_set(Object *ob, int new_index)
Definition deform.cc:618
ViewLayer * WM_window_get_active_view_layer(const wmWindow *win)
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
bool ED_text_activate_in_screen(bContext *C, Text *text)
void BKE_modifier_panel_expand(ModifierData *md)
ViewLayer * CTX_data_view_layer(const bContext *C)
void ED_outliner_select_sync_from_object_tag(bContext *C)
ModifierData * BKE_object_active_modifier(const Object *ob)
Definition object.cc:1427
void WM_operator_properties_select_walk_direction(wmOperatorType *ot)
Collection * BKE_collection_object_find(Main *bmain, Scene *scene, Collection *collection, Object *ob)
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
void WM_operator_properties_border_to_rctf(wmOperator *op, rctf *r_rect)
Vector< Object * > BKE_object_pose_array_get_unique(const Main &bmain, const Scene *scene, ViewLayer *view_layer, View3D *v3d)
Definition object.cc:2587
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
Scene * WM_window_get_active_scene(const wmWindow *win)
bool ED_object_posemode_exit_ex(Main *bmain, Object *ob)
Definition pose_edit.cc:117
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
Object * BKE_object_pose_armature_get(Object *ob)
Definition object.cc:2507
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
Object * CTX_data_edit_object(const bContext *C)
void ED_undo_push(bContext *C, const char *str, UndoEncodeHints hints=UndoEncodeHints(0))
Definition ed_undo.cc:103
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
@ BCONTEXT_BONE_CONSTRAINT
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void WM_operator_properties_gesture_box(wmOperatorType *ot)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
ViewLayer * BKE_view_layer_find_from_collection(const Scene *scene, LayerCollection *lc)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_event_drag_start_mval(const wmEvent *event, const ARegion *region, int r_mval[2])
wmMsgBus * CTX_wm_message_bus(const bContext *C)
void ED_undo_group_begin(bContext *C)
Definition ed_undo.cc:91
void BKE_view_layer_base_deselect_all(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
bool BKE_object_is_in_editmode(const Object *ob)
Definition object.cc:1898
void WM_windows_scene_data_sync(const ListBaseT< wmWindow > *win_lb, Scene *scene)
wmOperatorStatus WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void BKE_shaderfx_panel_expand(ShaderFxData *fx)
Definition shader_fx.cc:156
Main * CTX_data_main(const bContext *C)
void ANIM_armature_bonecoll_active_set(bArmature *armature, BoneCollection *bcoll)
@ ID_RECALC_SELECT
Definition DNA_ID.h:1101
@ ID_RECALC_TRANSFORM
Definition DNA_ID.h:1054
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
bool ED_object_posemode_enter_ex(Main *bmain, Object *ob)
Definition pose_edit.cc:81
void WM_gesture_box_cancel(bContext *C, wmOperator *op)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
bool BKE_object_is_child_recursive(const Object *ob_parent, const Object *ob_child)
Definition object.cc:4922
void WM_operator_properties_select_operation_simple(wmOperatorType *ot)
void DEG_relations_tag_update(Main *bmain)
Scene * CTX_data_scene(const bContext *C)
bScreen * CTX_wm_screen(const bContext *C)
bool BKE_collection_has_object_recursive(Collection *collection, Object *ob)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
void BKE_constraint_panel_expand(struct bConstraint *con)
void ED_undo_group_end(bContext *C)
Definition ed_undo.cc:97
void BKE_object_modifier_set_active(Object *ob, ModifierData *md)
Definition object.cc:1415
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
ReportList * CTX_wm_reports(const bContext *C)
bool ED_operator_region_outliner_active(bContext *C)
bool ED_armature_edit_deselect_all_multi_ex(const Span< Base * > bases)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
Definition lib_id.cc:2782
bool BKE_object_is_mode_compat(const Object *ob, eObjectMode object_mode)
Definition object.cc:2058
ARegion * CTX_wm_region(const bContext *C)
void ED_armature_ebone_select_set(EditBone *ebone, bool select)
void ED_region_tag_redraw_no_rebuild(ARegion *region)
Definition area.cc:727
ListBaseT< Base > * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
void WM_window_set_active_view_layer(wmWindow *win, ViewLayer *view_layer)
int BKE_object_defgroup_active_index_get(const Object *ob)
Definition deform.cc:613
#define TREESTORE(a)
#define TSELEM_OPEN(telm, sv)
struct Object * object
ListBaseT< Bone > childbase
struct Collection * collection
ListBaseT< wmWindowManager > wm
Definition BKE_main.hh:415
struct bPose * pose
ListBaseT< ViewLayer > view_layers
struct Object * camera
struct ToolSettings * toolsettings
ListBaseT< SpaceLink > spacedata
ed::outliner::SpaceOutliner_Runtime * runtime
eSpaceOutliner_Flag flag
eTreeStoreElem_Flag flag
ListBaseT< LayerCollection > layer_collections
struct Scene * sequencer_scene
struct EditBone * act_edbone
bke::bArmature_Runtime * runtime
ListBaseT< Bone > bonebase
ListBaseT< bPoseChannel > chanbase
ListBaseT< struct ScrArea > areabase
ListBaseT< ed::outliner::TreeElement > tree
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_)