diff options
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_select.c')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_select.c | 208 |
1 files changed, 195 insertions, 13 deletions
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 688f6d646ff..703624f5735 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -27,12 +27,16 @@ #include "DNA_armature_types.h" #include "DNA_collection_types.h" +#include "DNA_constraint_types.h" +#include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_types.h" #include "DNA_light_types.h" #include "DNA_material_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_sequence_types.h" +#include "DNA_shader_fx_types.h" #include "DNA_world_types.h" #include "BLI_listbase.h" @@ -40,21 +44,26 @@ #include "BKE_armature.h" #include "BKE_collection.h" +#include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_gpencil.h" +#include "BKE_gpencil_modifier.h" #include "BKE_layer.h" #include "BKE_main.h" +#include "BKE_modifier.h" #include "BKE_object.h" #include "BKE_paint.h" +#include "BKE_particle.h" #include "BKE_report.h" #include "BKE_scene.h" -#include "BKE_sequencer.h" +#include "BKE_shader_fx.h" #include "BKE_workspace.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" #include "ED_armature.h" +#include "ED_buttons.h" #include "ED_gpencil.h" #include "ED_object.h" #include "ED_outliner.h" @@ -63,6 +72,8 @@ #include "ED_sequencer.h" #include "ED_undo.h" +#include "SEQ_sequencer.h" + #include "WM_api.h" #include "WM_toolsystem.h" #include "WM_types.h" @@ -801,15 +812,26 @@ static eOLDrawState tree_element_active_psys(bContext *C, } static int tree_element_active_constraint(bContext *C, - Scene *UNUSED(scene), - ViewLayer *UNUSED(sl), - TreeElement *UNUSED(te), + Scene *scene, + ViewLayer *view_layer, + TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) { if (set != OL_SETSEL_NONE) { Object *ob = (Object *)tselem->id; + /* Activate the parent bone if this is a bone constraint. */ + te = te->parent; + while (te) { + tselem = TREESTORE(te); + if (tselem->type == TSE_POSE_CHANNEL) { + tree_element_active_posechannel(C, scene, view_layer, ob, te, tselem, set, false); + return OL_DRAWSEL_NONE; + } + te = te->parent; + } + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); } @@ -1041,6 +1063,7 @@ eOLDrawState tree_element_type_active(bContext *C, case TSE_POSE_CHANNEL: return tree_element_active_posechannel( C, tvc->scene, tvc->view_layer, tvc->ob_pose, te, tselem, set, recursive); + case TSE_CONSTRAINT_BASE: case TSE_CONSTRAINT: return tree_element_active_constraint(C, tvc->scene, tvc->view_layer, te, tselem, set); case TSE_R_LAYER: @@ -1081,6 +1104,169 @@ bPoseChannel *outliner_find_parent_bone(TreeElement *te, TreeElement **r_bone_te return NULL; } +static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreElem *tselem) +{ + PointerRNA ptr = {0}; + int context = 0; + + /* ID Types */ + if (tselem->type == 0) { + RNA_id_pointer_create(tselem->id, &ptr); + + switch (te->idcode) { + case ID_SCE: + context = BCONTEXT_SCENE; + break; + case ID_OB: + context = BCONTEXT_OBJECT; + break; + case ID_ME: + case ID_CU: + case ID_MB: + case ID_IM: + case ID_LT: + case ID_LA: + case ID_CA: + case ID_KE: + case ID_SPK: + case ID_AR: + case ID_GD: + case ID_LP: + case ID_HA: + case ID_PT: + case ID_VO: + context = BCONTEXT_DATA; + break; + case ID_MA: + context = BCONTEXT_MATERIAL; + break; + case ID_WO: + context = BCONTEXT_WORLD; + break; + } + } + else { + switch (tselem->type) { + case TSE_DEFGROUP_BASE: + case TSE_DEFGROUP: + RNA_id_pointer_create(tselem->id, &ptr); + context = BCONTEXT_DATA; + break; + case TSE_CONSTRAINT_BASE: + case TSE_CONSTRAINT: { + TreeElement *bone_te = NULL; + bPoseChannel *pchan = outliner_find_parent_bone(te, &bone_te); + + if (pchan) { + RNA_pointer_create(TREESTORE(bone_te)->id, &RNA_PoseBone, pchan, &ptr); + context = BCONTEXT_BONE_CONSTRAINT; + } + else { + RNA_id_pointer_create(tselem->id, &ptr); + context = BCONTEXT_CONSTRAINT; + } + + /* Expand the selected constraint in the properties editor. */ + if (tselem->type != TSE_CONSTRAINT_BASE) { + BKE_constraint_panel_expand(te->directdata); + } + break; + } + case TSE_MODIFIER_BASE: + case TSE_MODIFIER: + RNA_id_pointer_create(tselem->id, &ptr); + context = BCONTEXT_MODIFIER; + + if (tselem->type != TSE_MODIFIER_BASE) { + Object *ob = (Object *)tselem->id; + + if (ob->type == OB_GPENCIL) { + BKE_gpencil_modifier_panel_expand(te->directdata); + } + else { + BKE_modifier_panel_expand(te->directdata); + } + } + break; + case TSE_GPENCIL_EFFECT_BASE: + case TSE_GPENCIL_EFFECT: + RNA_id_pointer_create(tselem->id, &ptr); + context = BCONTEXT_SHADERFX; + + if (tselem->type != TSE_GPENCIL_EFFECT_BASE) { + BKE_shaderfx_panel_expand(te->directdata); + } + break; + case TSE_BONE: { + bArmature *arm = (bArmature *)tselem->id; + Bone *bone = te->directdata; + + RNA_pointer_create(&arm->id, &RNA_Bone, bone, &ptr); + context = BCONTEXT_BONE; + break; + } + case TSE_EBONE: { + bArmature *arm = (bArmature *)tselem->id; + EditBone *ebone = te->directdata; + + RNA_pointer_create(&arm->id, &RNA_EditBone, ebone, &ptr); + context = BCONTEXT_BONE; + break; + } + case TSE_POSE_CHANNEL: { + Object *ob = (Object *)tselem->id; + bArmature *arm = ob->data; + bPoseChannel *pchan = te->directdata; + + RNA_pointer_create(&arm->id, &RNA_PoseBone, pchan, &ptr); + context = BCONTEXT_BONE; + break; + } + case TSE_POSE_BASE: { + Object *ob = (Object *)tselem->id; + bArmature *arm = ob->data; + + RNA_pointer_create(&arm->id, &RNA_Armature, arm, &ptr); + context = BCONTEXT_DATA; + break; + } + case TSE_R_LAYER_BASE: + case TSE_R_LAYER: { + ViewLayer *view_layer = te->directdata; + + RNA_pointer_create(tselem->id, &RNA_ViewLayer, view_layer, &ptr); + context = BCONTEXT_VIEW_LAYER; + break; + } + case TSE_POSEGRP_BASE: + case TSE_POSEGRP: { + Object *ob = (Object *)tselem->id; + bArmature *arm = ob->data; + + RNA_pointer_create(&arm->id, &RNA_Armature, arm, &ptr); + context = BCONTEXT_DATA; + break; + } + case TSE_LINKED_PSYS: { + Object *ob = (Object *)tselem->id; + ParticleSystem *psys = psys_get_current(ob); + + RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &ptr); + context = BCONTEXT_PARTICLE; + break; + } + case TSE_GP_LAYER: + RNA_id_pointer_create(tselem->id, &ptr); + context = BCONTEXT_DATA; + break; + } + } + + if (ptr.data) { + ED_buttons_set_context(C, &ptr, context); + } +} + /* ================================================ */ /** @@ -1105,14 +1291,8 @@ static void do_outliner_item_activate_tree_element(bContext *C, TSE_SEQUENCE_DUP, TSE_EBONE, TSE_LAYER_COLLECTION)) { - /* Note about TSE_EBONE: In case of a same ID_AR datablock shared among several objects, - * we do not want to switch out of edit mode (see T48328 for details). */ - } - else if (tselem->id && OB_DATA_SUPPORT_EDITMODE(te->idcode)) { - /* Support edit-mode toggle, keeping the active object as is. */ - } - else if (tselem->type == TSE_POSE_BASE) { - /* Support pose mode toggle, keeping the active object as is. */ + /* Note about TSE_EBONE: In case of a same ID_AR datablock shared among several + * objects, we do not want to switch out of edit mode (see T48328 for details). */ } else if (do_activate_data) { tree_element_set_active_object(C, @@ -1187,6 +1367,8 @@ static void do_outliner_item_activate_tree_element(bContext *C, extend ? OL_SETSEL_EXTEND : OL_SETSEL_NORMAL, recursive); } + + outliner_set_properties_tab(C, te, tselem); } /* Select the item using the set flags */ @@ -1242,7 +1424,7 @@ static bool do_outliner_range_select_recursive(ListBase *lb, } /* Set state for selection */ - if (te == active || te == cursor) { + if (ELEM(te, active, cursor)) { selecting = !selecting; } |