90
89
WM_event_add_dropbox_handler(&ar->handlers, lb);
93
static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
92
static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
95
94
ARegion *ar = CTX_wm_region(C);
96
95
SpaceOops *soops = CTX_wm_space_outliner(C);
97
TreeElement *te = NULL;
99
97
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
102
100
ID *id = (ID *)drag->poin;
103
101
if (GS(id->name) == ID_OB) {
104
102
/* Ensure item under cursor is valid drop target */
105
/* Find object hovered over */
106
for (te = soops->tree.first; te; te = te->next) {
107
TreeElement *te_valid;
108
te_valid = outliner_dropzone_parent(C, event, te, fmval);
110
/* check that parent/child are both in the same scene */
111
Scene *scene = (Scene *)outliner_search_back(soops, te_valid, ID_SCE);
114
/* currently outlier organized in a way, that if there's no parent scene
115
* element for object it means that all displayed objects belong to
116
* active scene and parenting them is allowed (sergey)
121
if (scene && BKE_scene_base_find(scene, (Object *)id)) {
103
TreeElement *te = outliner_dropzone_find(soops, fmval, 1);
105
if (te && te->idcode == ID_OB && TREESTORE(te)->type == 0) {
107
ID *te_id = TREESTORE(te)->id;
109
/* check if dropping self or parent */
110
if (te_id == id || (Object *)te_id == ((Object *)id)->parent)
113
/* check that parent/child are both in the same scene */
114
scene = (Scene *)outliner_search_back(soops, te, ID_SCE);
116
/* currently outliner organized in a way that if there's no parent scene
117
* element for object it means that all displayed objects belong to
118
* active scene and parenting them is allowed (sergey)
120
if (!scene || BKE_scene_base_find(scene, (Object *)id)) {
135
133
RNA_string_set(drop->ptr, "child", id->name + 2);
138
static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, wmEvent *event)
136
static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event)
140
138
ARegion *ar = CTX_wm_region(C);
141
139
SpaceOops *soops = CTX_wm_space_outliner(C);
147
145
if (drag->type == WM_DRAG_ID) {
148
146
ID *id = (ID *)drag->poin;
149
147
if (GS(id->name) == ID_OB) {
150
if (((Object *)id)->parent == NULL) {
153
/* Ensure location under cursor is valid dropzone */
154
for (te = soops->tree.first; te; te = te->next) {
155
if (outliner_dropzone_parent_clear(C, event, te, fmval)) return 1;
157
/* Check if mouse cursor is below the tree */
158
te = soops->tree.last;
159
while (((te->flag & TE_LAZY_CLOSED) == 0) && (te->subtree.last)) {
160
te = te->subtree.last;
162
if (fmval[1] < te->ys) return 1;
148
if (((Object *)id)->parent) {
149
if ((te = outliner_dropzone_find(soops, fmval, 1))) {
150
TreeStoreElem *tselem = TREESTORE(te);
152
switch (te->idcode) {
154
return (ELEM3(tselem->type, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS));
156
return (ELEM(tselem->type, TSE_MODIFIER_BASE, TSE_CONSTRAINT_BASE));
157
/* Other codes to ignore? */
176
175
RNA_enum_set(drop->ptr, "type", 0);
179
static int outliner_scene_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
178
static int outliner_scene_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
181
180
ARegion *ar = CTX_wm_region(C);
182
181
SpaceOops *soops = CTX_wm_space_outliner(C);
183
TreeElement *te = NULL;
185
183
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
188
186
ID *id = (ID *)drag->poin;
189
187
if (GS(id->name) == ID_OB) {
190
188
/* Ensure item under cursor is valid drop target */
191
/* Find object hovered over */
192
for (te = soops->tree.first; te; te = te->next) {
193
if (outliner_dropzone_scene(C, event, te, fmval))
189
TreeElement *te = outliner_dropzone_find(soops, fmval, 0);
190
return (te && te->idcode == ID_SCE && TREESTORE(te)->type == 0);
205
200
RNA_string_set(drop->ptr, "object", id->name + 2);
208
static int outliner_material_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
203
static int outliner_material_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
210
205
ARegion *ar = CTX_wm_region(C);
211
206
SpaceOops *soops = CTX_wm_space_outliner(C);
212
TreeElement *te = NULL;
214
208
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
217
211
ID *id = (ID *)drag->poin;
218
212
if (GS(id->name) == ID_MA) {
219
213
/* Ensure item under cursor is valid drop target */
220
/* Find object hovered over */
221
for (te = soops->tree.first; te; te = te->next) {
222
if (outliner_dropzone_parent(C, event, te, fmval))
214
TreeElement *te = outliner_dropzone_find(soops, fmval, 1);
215
return (te && te->idcode == ID_OB && TREESTORE(te)->type == 0);