Revision: 47712
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47712
Author:   aligorith
Date:     2012-06-11 01:09:25 +0000 (Mon, 11 Jun 2012)
Log Message:
-----------
Grease Pencil - Eraser is drawn with the circle/brush indicator again

Modified Paths:
--------------
    trunk/blender/source/blender/editors/gpencil/gpencil_paint.c

Modified: trunk/blender/source/blender/editors/gpencil/gpencil_paint.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/gpencil_paint.c        
2012-06-11 00:46:22 UTC (rev 47711)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_paint.c        
2012-06-11 01:09:25 UTC (rev 47712)
@@ -57,9 +57,12 @@
 #include "ED_screen.h"
 #include "ED_view3d.h"
 
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
 #include "RNA_access.h"
+#include "RNA_define.h"
 
-#include "RNA_define.h"
 #include "WM_api.h"
 #include "WM_types.h"
 
@@ -98,8 +101,10 @@
 
        float imat[4][4];   /* inverted transformation matrix applying when 
converting coords from screen-space
                             * to region space */
-
-       float custom_color[4]; /* custom color for (?) */
+       
+       float custom_color[4]; /* custom color - hack for enforcing a 
particular color for track/mask editing */
+       
+       void *erasercursor; /* radial cursor data for drawing eraser */
 } tGPsdata;
 
 /* values for tGPsdata->status */
@@ -1265,6 +1270,49 @@
 
 /* ------------------------------- */
 
+/* Helper callback for drawing the cursor itself */
+static void gpencil_draw_eraser(bContext *C, int x, int y, void *p_ptr)
+{
+       tGPsdata *p = (tGPsdata *)p_ptr;
+       
+       if (p->paintmode == GP_PAINTMODE_ERASER) {
+               glPushMatrix();
+               
+               glTranslatef((float)x, (float)y, 0.0f);
+               
+               glColor4ub(255, 255, 255, 128);
+               
+               glEnable(GL_LINE_SMOOTH);
+               glEnable(GL_BLEND);
+               
+               glutil_draw_lined_arc(0.0, M_PI*2.0, p->radius, 40);
+               
+               glDisable(GL_BLEND);
+               glDisable(GL_LINE_SMOOTH);
+               
+               glPopMatrix();
+       }
+}
+
+/* Turn brush cursor in 3D view on/off */
+static void gpencil_draw_toggle_eraser_cursor(bContext *C, tGPsdata *p, short 
enable)
+{
+       if (p->erasercursor && !enable) {
+               /* clear cursor */
+               WM_paint_cursor_end(CTX_wm_manager(C), p->erasercursor);
+               p->erasercursor = NULL;
+       }
+       else if (enable) {
+               /* enable cursor */
+               p->erasercursor = WM_paint_cursor_activate(CTX_wm_manager(C), 
+                                                               NULL, // XXX
+                                                               
gpencil_draw_eraser, p);
+       }
+}
+
+/* ------------------------------- */
+
+
 static void gpencil_draw_exit(bContext *C, wmOperator *op)
 {
        tGPsdata *p = op->customdata;
@@ -1279,8 +1327,8 @@
        if (p) {
                /* check size of buffer before cleanup, to determine if 
anything happened here */
                if (p->paintmode == GP_PAINTMODE_ERASER) {
-                       // TODO clear radial cursor thing
-                       // XXX draw_sel_circle(NULL, p.mvalo, 0, p.radius, 0);
+                       /* turn off radial brush cursor */
+                       gpencil_draw_toggle_eraser_cursor(C, p, FALSE);
                }
                
                /* cleanup */
@@ -1331,6 +1379,7 @@
        return 1;
 }
 
+
 /* ------------------------------- */
 
 /* update UI indicators of status, including cursor and header prints */
@@ -1576,7 +1625,7 @@
        
        /* if eraser is on, draw radial aid */
        if (p->paintmode == GP_PAINTMODE_ERASER) {
-               // TODO: this involves mucking around with radial control, so 
we leave this for now..
+               gpencil_draw_toggle_eraser_cursor(C, p, TRUE);
        }
        
        /* set cursor */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to