draw the brush size with pressure applied (when the tablet is used), nice to see...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 16 Jan 2013 19:22:15 +0000 (19:22 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 16 Jan 2013 19:22:15 +0000 (19:22 +0000)
source/blender/editors/sculpt_paint/paint_cursor.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_window.c

index 5f241f0d9cc18f4c02bb040e0cb330ed2cc69639..ec8d60ce62a8cca44aceef3afece198fcae5a2c3 100644 (file)
@@ -595,6 +595,18 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
 
        /* draw brush outline */
        glTranslatef(translation[0], translation[1], 0);
+
+       /* draw an inner brush */
+       if (BKE_brush_use_size_pressure(scene, brush)) {
+               const wmWindow *win = CTX_wm_window(C);
+               const float pressure = WM_cursor_pressure(win);
+               if (pressure != -1.0f && pressure != 0.0f) {
+                       /* inner at full alpha */
+                       glutil_draw_lined_arc(0.0, M_PI * 2.0, final_radius * pressure, 40);
+                       /* outer at half alpha */
+                       glColor4f(outline_col[0], outline_col[1], outline_col[2], outline_alpha * 0.5f);
+               }
+       }
        glutil_draw_lined_arc(0.0, M_PI * 2.0, final_radius, 40);
        glTranslatef(-translation[0], -translation[1], 0);
 
index eb1aad75a88552bbda192d20a6d8f4dbc862c94a..1b8bf29d92a839453188385d46c016a9a58c2c7d 100644 (file)
@@ -131,6 +131,7 @@ void                *WM_paint_cursor_activate(struct wmWindowManager *wm,
 void           WM_paint_cursor_end(struct wmWindowManager *wm, void *handle);
 
 void           WM_cursor_warp          (struct wmWindow *win, int x, int y);
+float          WM_cursor_pressure      (const struct wmWindow *win);
 
                        /* event map */
 int                    WM_userdef_event_map(int kmitype);
index d81aa74e138739191124ba44e67f169a9cc4f6d2..907a0a34f6056e5a8bb4926101c27be8b64a34bc 100644 (file)
@@ -2655,6 +2655,10 @@ static void update_tablet_data(wmWindow *win, wmEvent *event)
                event->custom = EVT_DATA_TABLET;
                event->customdata = wmtab;
                event->customdatafree = 1;
+               // printf("%s: using tablet %.5f\n", wmtab->Pressure, __func__);
+       }
+       else {
+               // printf("%s: not using tablet\n", __func__);
        }
 }
 
index e6a40187bfe3c9f61662b4b33be2a450c323a3e2..52024897f70616f629bcd4d301d39262c31008f9 100644 (file)
@@ -1318,6 +1318,21 @@ void WM_cursor_warp(wmWindow *win, int x, int y)
        }
 }
 
+/**
+ * Get the cursor pressure, in most cases you'll want to use wmTabletData from the event
+ */
+float WM_cursor_pressure(const struct wmWindow *win)
+{
+       const GHOST_TabletData *td = GHOST_GetTabletData(win->ghostwin);
+       /* if there's tablet data from an active tablet device then add it */
+       if ((td != NULL) && td->Active != GHOST_kTabletModeNone) {
+               return td->Pressure;
+       }
+       else {
+               return -1.0f;
+       }
+}
+
 /* support for native pixel size */
 /* mac retina opens window in size X, but it has up to 2 x more pixels */
 int WM_window_pixels_x(wmWindow *win)