Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_dragdrop.c
| Show First 20 Lines • Show All 841 Lines • ▼ Show 20 Lines | static bool datastack_drop_are_types_valid(StackDropData *drop_data) | ||||
| return true; | return true; | ||||
| } | } | ||||
| static bool datastack_drop_poll(bContext *C, | static bool datastack_drop_poll(bContext *C, | ||||
| wmDrag *drag, | wmDrag *drag, | ||||
| const wmEvent *event, | const wmEvent *event, | ||||
| const char **r_tooltip) | const char **r_tooltip) | ||||
| { | { | ||||
| if (drag->type != WM_DRAG_DATASTACK) { | |||||
| return false; | |||||
| } | |||||
| SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); | SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| bool changed = outliner_flag_set(&space_outliner->tree, TSE_HIGHLIGHTED | TSE_DRAG_ANY, false); | bool changed = outliner_flag_set(&space_outliner->tree, TSE_HIGHLIGHTED | TSE_DRAG_ANY, false); | ||||
| StackDropData *drop_data = drag->poin; | StackDropData *drop_data = drag->poin; | ||||
| if (!drop_data) { | if (!drop_data) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 500 Lines • ▼ Show 20 Lines | * when the drag goes too far outside the region. */ | ||||
| wmOperatorType *ot = WM_operatortype_find("VIEW2D_OT_edge_pan", true); | wmOperatorType *ot = WM_operatortype_find("VIEW2D_OT_edge_pan", true); | ||||
| PointerRNA op_ptr; | PointerRNA op_ptr; | ||||
| WM_operator_properties_create_ptr(&op_ptr, ot); | WM_operator_properties_create_ptr(&op_ptr, ot); | ||||
| RNA_int_set(&op_ptr, "outside_padding", OUTLINER_DRAG_SCOLL_OUTSIDE_PAD); | RNA_int_set(&op_ptr, "outside_padding", OUTLINER_DRAG_SCOLL_OUTSIDE_PAD); | ||||
| WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &op_ptr); | WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &op_ptr); | ||||
| WM_operator_properties_free(&op_ptr); | WM_operator_properties_free(&op_ptr); | ||||
| } | } | ||||
| wmDrag *drag = WM_event_start_drag(C, data.icon, WM_DRAG_ID, NULL, 0.0, WM_DRAG_NOP); | const bool use_datastack_drag = ELEM(tselem->type, | ||||
| if (ELEM(tselem->type, | |||||
| TSE_MODIFIER, | TSE_MODIFIER, | ||||
| TSE_MODIFIER_BASE, | TSE_MODIFIER_BASE, | ||||
| TSE_CONSTRAINT, | TSE_CONSTRAINT, | ||||
| TSE_CONSTRAINT_BASE, | TSE_CONSTRAINT_BASE, | ||||
| TSE_GPENCIL_EFFECT, | TSE_GPENCIL_EFFECT, | ||||
| TSE_GPENCIL_EFFECT_BASE)) { | TSE_GPENCIL_EFFECT_BASE); | ||||
Severin: This will break now for the cases where an actual ID is dragged. So for the latter of the two… | |||||
Done Inline ActionsYou're completely right, I missed that. I've put the evaluation before the if-cases as you've suggested. rjg: You're completely right, I missed that. I've put the evaluation before the `if`-cases as you've… | |||||
| const int wm_drag_type = use_datastack_drag ? WM_DRAG_DATASTACK : WM_DRAG_ID; | |||||
| wmDrag *drag = WM_event_start_drag(C, data.icon, wm_drag_type, NULL, 0.0, WM_DRAG_NOP); | |||||
| if (use_datastack_drag) { | |||||
| TreeElement *te_bone = NULL; | TreeElement *te_bone = NULL; | ||||
| bPoseChannel *pchan = outliner_find_parent_bone(te, &te_bone); | bPoseChannel *pchan = outliner_find_parent_bone(te, &te_bone); | ||||
| datastack_drop_data_init(drag, (Object *)tselem->id, pchan, te, tselem, te->directdata); | datastack_drop_data_init(drag, (Object *)tselem->id, pchan, te, tselem, te->directdata); | ||||
| } | } | ||||
| else if (ELEM(GS(data.drag_id->name), ID_OB, ID_GR)) { | else if (ELEM(GS(data.drag_id->name), ID_OB, ID_GR)) { | ||||
| /* For collections and objects we cheat and drag all selected. */ | /* For collections and objects we cheat and drag all selected. */ | ||||
| /* Only drag element under mouse if it was not selected before. */ | /* Only drag element under mouse if it was not selected before. */ | ||||
| ▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines | |||||
This will break now for the cases where an actual ID is dragged. So for the latter of the two ifs, it still has to be WM_DRAG_ID.
You could change the drag type in the if-block if needed, but that seems ugly and can fail easily.
Instead I'd suggest adding a const bool use_datastack_drag = ELEM(...) and setting the type based on that. And then just checking if (use_datastack_drag) below.