~ubuntu-branches/ubuntu/trusty/blender/trusty-proposed

« back to all changes in this revision

Viewing changes to source/blender/editors/space_outliner/space_outliner.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2013-08-14 10:43:49 UTC
  • mfrom: (14.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20130814104349-t1d5mtwkphp12dyj
Tags: 2.68a-3
* Upload to unstable
* debian/: python3.3 Depends simplified
  - debian/control: python3.3 Depends dropped
    for blender-data package
  - 0001-blender_thumbnailer.patch refreshed
* debian/control: libavcodec b-dep versioning dropped

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
#include "BLI_blenlib.h"
38
38
#include "BLI_math.h"
39
 
#include "BLI_rand.h"
40
39
#include "BLI_utildefines.h"
41
40
 
42
41
#include "BKE_context.h"
90
89
        WM_event_add_dropbox_handler(&ar->handlers, lb);
91
90
}
92
91
 
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)
94
93
{
95
94
        ARegion *ar = CTX_wm_region(C);
96
95
        SpaceOops *soops = CTX_wm_space_outliner(C);
97
 
        TreeElement *te = NULL;
98
96
        float fmval[2];
99
97
        UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
100
98
 
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);
109
 
                                if (te_valid) {
110
 
                                        /* check that parent/child are both in the same scene */
111
 
                                        Scene *scene = (Scene *)outliner_search_back(soops, te_valid, ID_SCE);
112
 
 
113
 
                                        if (!scene) {
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)
117
 
                                                 */
118
 
                                                return 1;
119
 
                                        }
120
 
 
121
 
                                        if (scene && BKE_scene_base_find(scene, (Object *)id)) {
122
 
                                                return 1;
123
 
                                        }
 
103
                        TreeElement *te = outliner_dropzone_find(soops, fmval, 1);
 
104
 
 
105
                        if (te && te->idcode == ID_OB && TREESTORE(te)->type == 0) {
 
106
                                Scene *scene;
 
107
                                ID *te_id = TREESTORE(te)->id;
 
108
 
 
109
                                /* check if dropping self or parent */
 
110
                                if (te_id == id || (Object *)te_id == ((Object *)id)->parent)
 
111
                                        return 0;
 
112
 
 
113
                                /* check that parent/child are both in the same scene */
 
114
                                scene = (Scene *)outliner_search_back(soops, te, ID_SCE);
 
115
 
 
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)
 
119
                                 */
 
120
                                if (!scene || BKE_scene_base_find(scene, (Object *)id)) {
 
121
                                        return 1;
124
122
                                }
125
123
                        }
126
124
                }
135
133
        RNA_string_set(drop->ptr, "child", id->name + 2);
136
134
}
137
135
 
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)
139
137
{
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) {
151
 
                                return 0;
152
 
                        }
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;
156
 
                        }
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;
161
 
                        }
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);
 
151
 
 
152
                                        switch (te->idcode) {
 
153
                                                case ID_SCE:
 
154
                                                        return (ELEM3(tselem->type, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS));
 
155
                                                case ID_OB:
 
156
                                                        return (ELEM(tselem->type, TSE_MODIFIER_BASE, TSE_CONSTRAINT_BASE));
 
157
                                                /* Other codes to ignore? */
 
158
                                        }
 
159
                                }
 
160
                                return (te == NULL);
 
161
                        }
163
162
                }
164
163
        }
165
164
        return 0;
176
175
        RNA_enum_set(drop->ptr, "type", 0);
177
176
}
178
177
 
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)
180
179
{
181
180
        ARegion *ar = CTX_wm_region(C);
182
181
        SpaceOops *soops = CTX_wm_space_outliner(C);
183
 
        TreeElement *te = NULL;
184
182
        float fmval[2];
185
183
        UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
186
184
 
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))
194
 
                                        return 1;
195
 
                        }
 
189
                        TreeElement *te = outliner_dropzone_find(soops, fmval, 0);
 
190
                        return (te && te->idcode == ID_SCE && TREESTORE(te)->type == 0);
196
191
                }
197
192
        }
198
193
        return 0;
205
200
        RNA_string_set(drop->ptr, "object", id->name + 2);
206
201
}
207
202
 
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)
209
204
{
210
205
        ARegion *ar = CTX_wm_region(C);
211
206
        SpaceOops *soops = CTX_wm_space_outliner(C);
212
 
        TreeElement *te = NULL;
213
207
        float fmval[2];
214
208
        UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
215
209
 
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))
223
 
                                        return 1;
224
 
                        }
 
214
                        TreeElement *te = outliner_dropzone_find(soops, fmval, 1);
 
215
                        return (te && te->idcode == ID_OB && TREESTORE(te)->type == 0);
225
216
                }
226
217
        }
227
218
        return 0;
271
262
        
272
263
}
273
264
 
274
 
static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn)
 
265
static void outliner_main_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
275
266
{
276
267
        /* context changes */
277
268
        switch (wmn->category) {
316
307
                                        /* all modifier actions now */
317
308
                                        ED_region_tag_redraw(ar);
318
309
                                        break;
 
310
                                default:
 
311
                                        /* Trigger update for NC_OBJECT itself */
 
312
                                        ED_region_tag_redraw(ar);
 
313
                                        break;
319
314
                        }
320
315
                        break;
321
316
                case NC_GROUP:
383
378
{
384
379
}
385
380
 
386
 
static void outliner_header_area_listener(ARegion *ar, wmNotifier *wmn)
 
381
static void outliner_header_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
387
382
{
388
383
        /* context changes */
389
384
        switch (wmn->category) {