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

« back to all changes in this revision

Viewing changes to source/blender/windowmanager/intern/wm_gesture.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
113
113
                win->tweak = NULL;
114
114
        BLI_remlink(&win->gesture, gesture);
115
115
        MEM_freeN(gesture->customdata);
 
116
        if (gesture->userdata) {
 
117
                MEM_freeN(gesture->userdata);
 
118
        }
116
119
        MEM_freeN(gesture);
117
120
}
118
121
 
130
133
{
131
134
        if (gesture->type == WM_GESTURE_TWEAK) {
132
135
                rcti *rect = gesture->customdata;
133
 
                int dx = rect->xmax - rect->xmin;
134
 
                int dy = rect->ymax - rect->ymin;
 
136
                int dx = BLI_rcti_size_x(rect);
 
137
                int dy = BLI_rcti_size_y(rect);
135
138
                if (ABS(dx) + ABS(dy) > U.tweak_threshold) {
136
139
                        int theta = (int)floor(4.0f * atan2f((float)dy, (float)dx) / (float)M_PI + 0.5f);
137
140
                        int val = EVT_GESTURE_W;
154
157
                        if (val == 6) printf("tweak south-west\n");
155
158
                        if (val == 7) printf("tweak west\n");
156
159
                        if (val == 8) printf("tweak north-west\n");
157
 
#endif                  
 
160
#endif
158
161
                        return val;
159
162
                }
160
163
        }
224
227
        glutil_draw_lined_arc(0.0, M_PI * 2.0, rect->xmax, 40);
225
228
        
226
229
        glDisable(GL_LINE_STIPPLE);
227
 
        glTranslatef((float)-rect->xmin, (float)-rect->ymin, 0.0f);
 
230
        glTranslatef(-rect->xmin, -rect->ymin, 0.0f);
228
231
        
229
232
}
230
233
 
231
234
static void draw_filled_lasso(wmGesture *gt)
232
235
{
233
236
        ScanFillContext sf_ctx;
234
 
        ScanFillVert *v = NULL, *lastv = NULL, *firstv = NULL;
235
 
        ScanFillFace *efa;
 
237
        ScanFillVert *sf_vert = NULL, *sf_vert_last = NULL, *sf_vert_first = NULL;
 
238
        ScanFillFace *sf_tri;
236
239
        short *lasso = (short *)gt->customdata;
237
240
        int i;
238
241
        
239
 
        BLI_begin_edgefill(&sf_ctx);
 
242
        BLI_scanfill_begin(&sf_ctx);
240
243
        for (i = 0; i < gt->points; i++, lasso += 2) {
241
244
                float co[3];
242
245
 
244
247
                co[1] = (float)lasso[1];
245
248
                co[2] = 0.0f;
246
249
 
247
 
                v = BLI_addfillvert(&sf_ctx, co);
248
 
                if (lastv)
249
 
                        /* e = */ /* UNUSED */ BLI_addfilledge(&sf_ctx, lastv, v);
250
 
                lastv = v;
251
 
                if (firstv == NULL) firstv = v;
 
250
                sf_vert = BLI_scanfill_vert_add(&sf_ctx, co);
 
251
                if (sf_vert_last)
 
252
                        /* e = */ /* UNUSED */ BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert);
 
253
                sf_vert_last = sf_vert;
 
254
                if (sf_vert_first == NULL) sf_vert_first = sf_vert;
252
255
        }
253
256
        
254
257
        /* highly unlikely this will fail, but could crash if (gt->points == 0) */
255
 
        if (firstv) {
256
 
                float zvec[3] = {0.0f, 0.0f, 1.0f};
257
 
                BLI_addfilledge(&sf_ctx, firstv, v);
258
 
                BLI_edgefill_ex(&sf_ctx, FALSE, zvec);
 
258
        if (sf_vert_first) {
 
259
                const float zvec[3] = {0.0f, 0.0f, 1.0f};
 
260
                BLI_scanfill_edge_add(&sf_ctx, sf_vert_first, sf_vert);
 
261
                BLI_scanfill_calc_ex(&sf_ctx, BLI_SCANFILL_CALC_REMOVE_DOUBLES | BLI_SCANFILL_CALC_HOLES, zvec);
259
262
        
260
263
                glEnable(GL_BLEND);
261
264
                glColor4f(1.0, 1.0, 1.0, 0.05);
262
265
                glBegin(GL_TRIANGLES);
263
 
                for (efa = sf_ctx.fillfacebase.first; efa; efa = efa->next) {
264
 
                        glVertex2fv(efa->v1->co);
265
 
                        glVertex2fv(efa->v2->co);
266
 
                        glVertex2fv(efa->v3->co);
 
266
                for (sf_tri = sf_ctx.fillfacebase.first; sf_tri; sf_tri = sf_tri->next) {
 
267
                        glVertex2fv(sf_tri->v1->co);
 
268
                        glVertex2fv(sf_tri->v2->co);
 
269
                        glVertex2fv(sf_tri->v3->co);
267
270
                }
268
271
                glEnd();
269
272
                glDisable(GL_BLEND);
270
273
        
271
 
                BLI_end_edgefill(&sf_ctx);
 
274
                BLI_scanfill_end(&sf_ctx);
272
275
        }
273
276
}
274
277
 
306
309
static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
307
310
{
308
311
        rcti *rect = (rcti *)gt->customdata;
309
 
        
 
312
        int winsizex = WM_window_pixels_x(win);
 
313
        int winsizey = WM_window_pixels_y(win);
 
314
 
310
315
        glEnable(GL_LINE_STIPPLE);
311
316
        glColor3ub(96, 96, 96);
312
317
        glLineStipple(1, 0xCCCC);
313
 
        sdrawline(rect->xmin - win->sizex, rect->ymin, rect->xmin + win->sizex, rect->ymin);
314
 
        sdrawline(rect->xmin, rect->ymin - win->sizey, rect->xmin, rect->ymin + win->sizey);
 
318
        sdrawline(rect->xmin - winsizex, rect->ymin, rect->xmin + winsizex, rect->ymin);
 
319
        sdrawline(rect->xmin, rect->ymin - winsizey, rect->xmin, rect->ymin + winsizey);
315
320
        
316
321
        glColor3ub(255, 255, 255);
317
322
        glLineStipple(1, 0x3333);
318
 
        sdrawline(rect->xmin - win->sizex, rect->ymin, rect->xmin + win->sizex, rect->ymin);
319
 
        sdrawline(rect->xmin, rect->ymin - win->sizey, rect->xmin, rect->ymin + win->sizey);
 
323
        sdrawline(rect->xmin - winsizex, rect->ymin, rect->xmin + winsizex, rect->ymin);
 
324
        sdrawline(rect->xmin, rect->ymin - winsizey, rect->xmin, rect->ymin + winsizey);
320
325
        glDisable(GL_LINE_STIPPLE);
321
326
}
322
327
 
331
336
                
332
337
                if (gt->type == WM_GESTURE_RECT)
333
338
                        wm_gesture_draw_rect(gt);
334
 
//              else if (gt->type==WM_GESTURE_TWEAK)
 
339
//              else if (gt->type == WM_GESTURE_TWEAK)
335
340
//                      wm_gesture_draw_line(gt);
336
341
                else if (gt->type == WM_GESTURE_CIRCLE)
337
342
                        wm_gesture_draw_circle(gt);
357
362
        ARegion *ar = CTX_wm_region(C);
358
363
        
359
364
        if (screen)
360
 
                screen->do_draw_gesture = 1;
 
365
                screen->do_draw_gesture = TRUE;
361
366
 
362
367
        wm_tag_redraw_overlay(win, ar);
363
368
}