Fix some RNA/scene issuess with unified paint settings.
authorNicholas Bishop <nicholasbishop@gmail.com>
Thu, 12 Jan 2012 21:48:08 +0000 (21:48 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Thu, 12 Jan 2012 21:48:08 +0000 (21:48 +0000)
Added RNA for the unified paint setting flags that matches the Brush
RNA. Fixed the getter/setter functions to avoid guessing which Scene's
UnifiedPaintSetting to use. The getter functions take a Scene pointer
now, the setter functions are removed in favor of a more explicit
approach through RNA:

Rather than RNA choosing whether a property's value is in the Brush or
in the UnifiedPaintSettings, there are now explicit properties for
both. The UI code has been modified accordingly to switch the toggle
buttons between affecting the Brush and the UnifiedPaintSettings.

release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/blenkernel/BKE_brush.h
source/blender/blenkernel/intern/brush.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/makesrna/intern/rna_brush.c
source/blender/makesrna/intern/rna_scene.c

index e89e2d9..a8ffb25 100644 (file)
@@ -475,6 +475,17 @@ class PaintPanel():
         parent.prop(ups, "use_unified_size", text="Size")
         parent.prop(ups, "use_unified_strength", text="Strength")
 
+    @staticmethod
+    def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text=""):
+        ups = context.tool_settings.unified_paint_settings
+        ptr = ups if ups.use_unified_size else brush
+        parent.prop(ptr, prop_name, icon=icon, text=text)
+
+    @staticmethod
+    def prop_unified_strength(parent, context, brush, prop_name, icon='NONE', text=""):
+        ups = context.tool_settings.unified_paint_settings
+        ptr = ups if ups.use_unified_strength else brush
+        parent.prop(ptr, prop_name, icon=icon, text=text)
 
 class VIEW3D_PT_tools_brush(PaintPanel, Panel):
     bl_label = "Brush"
@@ -530,14 +541,16 @@ class VIEW3D_PT_tools_brush(PaintPanel, Panel):
 
             row = col.row(align=True)
 
-            if brush.use_locked_size:
-                row.prop(brush, "use_locked_size", toggle=True, text="", icon='LOCKED')
+            ups = context.tool_settings.unified_paint_settings
+            if ((ups.use_unified_size and ups.use_locked_size) or
+                ((not ups.use_unified_size) and brush.use_locked_size)):
+                self.prop_unified_size(row, context, brush, "use_locked_size", icon='LOCKED')
                 row.prop(brush, "unprojected_radius", text="Radius", slider=True)
             else:
-                row.prop(brush, "use_locked_size", toggle=True, text="", icon='UNLOCKED')
+                self.prop_unified_size(row, context, brush, "use_locked_size", icon='UNLOCKED')
                 row.prop(brush, "size", slider=True)
 
-            row.prop(brush, "use_pressure_size", toggle=True, text="")
+            self.prop_unified_size(row, context, brush, "use_pressure_size")
 
             if tool not in {'SNAKE_HOOK', 'GRAB', 'ROTATE'}:
                 col.separator()
@@ -551,12 +564,12 @@ class VIEW3D_PT_tools_brush(PaintPanel, Panel):
                         row.prop(brush, "use_space_atten", toggle=True, text="", icon='UNLOCKED')
 
                 row.prop(brush, "strength", text="Strength", slider=True)
-                row.prop(brush, "use_pressure_strength", text="")
+                self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             if tool == 'ROTATE':
                 row = col.row(align=True)
                 row.prop(brush, "strength", text="Strength", slider=True)
-                row.prop(brush, "use_pressure_strength", text="")
+                self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             if tool != 'SMOOTH':
                 col.separator()
@@ -644,11 +657,11 @@ class VIEW3D_PT_tools_brush(PaintPanel, Panel):
 
             row = col.row(align=True)
             row.prop(brush, "size", slider=True)
-            row.prop(brush, "use_pressure_size", toggle=True, text="")
+            self.prop_unified_size(row, context, brush, "use_pressure_size")
 
             row = col.row(align=True)
             row.prop(brush, "strength", text="Strength", slider=True)
-            row.prop(brush, "use_pressure_strength", toggle=True, text="")
+            self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             row = col.row(align=True)
             row.prop(brush, "jitter", slider=True)
@@ -670,11 +683,11 @@ class VIEW3D_PT_tools_brush(PaintPanel, Panel):
 
             row = col.row(align=True)
             row.prop(brush, "size", slider=True)
-            row.prop(brush, "use_pressure_size", toggle=True, text="")
+            self.prop_unified_size(row, context, brush, "use_pressure_size")
 
             row = col.row(align=True)
             row.prop(brush, "strength", text="Strength", slider=True)
-            row.prop(brush, "use_pressure_strength", toggle=True, text="")
+            self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             row = col.row(align=True)
             row.prop(brush, "jitter", slider=True)
@@ -688,11 +701,11 @@ class VIEW3D_PT_tools_brush(PaintPanel, Panel):
 
             row = col.row(align=True)
             row.prop(brush, "size", slider=True)
-            row.prop(brush, "use_pressure_size", toggle=True, text="")
+            self.prop_unified_size(row, context, brush, "use_pressure_size")
 
             row = col.row(align=True)
             row.prop(brush, "strength", text="Strength", slider=True)
-            row.prop(brush, "use_pressure_strength", toggle=True, text="")
+            self.prop_unified_strength(row, context, brush, "use_pressure_strength")
 
             # XXX - TODO
             #row = col.row(align=True)
index 3241838..b69eabb 100644 (file)
@@ -76,7 +76,7 @@ struct BrushPainter;
 typedef struct BrushPainter BrushPainter;
 typedef int (*BrushFunc)(void *user, struct ImBuf *ibuf, float *lastpos, float *pos);
 
-BrushPainter *brush_painter_new(struct Brush *brush);
+BrushPainter *brush_painter_new(struct Scene *scene, struct Brush *brush);
 void brush_painter_require_imbuf(BrushPainter *painter, short flt,
        short texonly, int size);
 int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos,
@@ -95,14 +95,9 @@ struct ImBuf *brush_gen_radial_control_imbuf(struct Brush *br);
 int  brush_size(struct Brush *brush);
 void brush_set_size(struct Brush *brush, int value);
 
-int  brush_use_locked_size(struct Brush *brush);
-void brush_set_use_locked_size(struct Brush *brush, int value);
-
-int  brush_use_alpha_pressure(struct Brush *brush);
-void brush_set_use_alpha_pressure(struct Brush *brush, int value);
-
-int  brush_use_size_pressure(struct Brush *brush);
-void brush_set_use_size_pressure(struct Brush *brush, int value);
+int  brush_use_locked_size(const struct Scene *scene, struct Brush *brush);
+int  brush_use_alpha_pressure(const struct Scene *scene, struct Brush *brush);
+int  brush_use_size_pressure(const struct Scene *scene, struct Brush *brush);
 
 float brush_unprojected_radius(struct Brush *brush);
 void  brush_set_unprojected_radius(struct Brush *brush, float value);
index b1aeea9..daa4144 100644 (file)
@@ -642,6 +642,7 @@ typedef struct BrushPainterCache {
 } BrushPainterCache;
 
 struct BrushPainter {
+       Scene *scene;
        Brush *brush;
 
        float lastmousepos[2];  /* mouse position of last paint call */
@@ -665,11 +666,12 @@ struct BrushPainter {
        BrushPainterCache cache;
 };
 
-BrushPainter *brush_painter_new(Brush *brush)
+BrushPainter *brush_painter_new(Scene *scene, Brush *brush)
 {
        BrushPainter *painter= MEM_callocN(sizeof(BrushPainter), "BrushPainter");
 
        painter->brush= brush;
+       painter->scene= scene;
        painter->firsttouch= 1;
        painter->cache.lastsize= -1; /* force ibuf create in refresh */
 
@@ -917,9 +919,9 @@ void brush_painter_break_stroke(BrushPainter *painter)
 
 static void brush_apply_pressure(BrushPainter *painter, Brush *brush, float pressure)
 {
-       if (brush_use_alpha_pressure(brush)) 
+       if (brush_use_alpha_pressure(painter->scene, brush)) 
                brush_set_alpha(brush, MAX2(0.0f, painter->startalpha*pressure));
-       if (brush_use_size_pressure(brush))
+       if (brush_use_size_pressure(painter->scene, brush))
                brush_set_size(brush, MAX2(1.0f, painter->startsize*pressure));
        if (brush->flag & BRUSH_JITTER_PRESSURE)
                brush->jitter = MAX2(0.0f, painter->startjitter*pressure);
@@ -1219,25 +1221,6 @@ struct ImBuf *brush_gen_radial_control_imbuf(Brush *br)
 /* XXX, wouldnt it be better to only pass the active scene?
  * this can return any old scene! - campbell*/
 
-static void set_unified_settings(Brush *brush, short flag, int value)
-{
-       Scene *sce;
-       for (sce= G.main->scene.first; sce; sce= sce->id.next) {
-               if (sce->toolsettings && 
-                       ELEM4(brush,
-                           paint_brush(&(sce->toolsettings->imapaint.paint)),
-                           paint_brush(&(sce->toolsettings->vpaint->paint)),
-                           paint_brush(&(sce->toolsettings->wpaint->paint)),
-                           paint_brush(&(sce->toolsettings->sculpt->paint))))
-               {
-                       if (value)
-                               sce->toolsettings->unified_paint_settings.flag |= flag;
-                       else
-                               sce->toolsettings->unified_paint_settings.flag &= ~flag;
-               }
-       }
-}
-
 static short unified_settings(Brush *brush)
 {
        Scene *sce;
@@ -1389,78 +1372,27 @@ int brush_size(Brush *brush)
        return (us_flag & UNIFIED_PAINT_SIZE) ? unified_size(brush) : brush->size;
 }
 
-void brush_set_use_locked_size(Brush *brush, int value)
-{
-       const short us_flag = unified_settings(brush);
-
-       if (us_flag & UNIFIED_PAINT_SIZE) {
-               set_unified_settings(brush, UNIFIED_PAINT_BRUSH_LOCK_SIZE, value);
-       }
-       else {
-               if (value)
-                       brush->flag |= BRUSH_LOCK_SIZE;
-               else
-                       brush->flag &= ~BRUSH_LOCK_SIZE;
-       }
-
-       //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush);
-}
-
-int brush_use_locked_size(Brush *brush)
+int brush_use_locked_size(const Scene *scene, Brush *brush)
 {
-       const short us_flag = unified_settings(brush);
+       const short us_flag = scene->toolsettings->unified_paint_settings.flag;
 
        return (us_flag & UNIFIED_PAINT_SIZE) ?
                (us_flag & UNIFIED_PAINT_BRUSH_LOCK_SIZE) :
                (brush->flag & BRUSH_LOCK_SIZE);
 }
 
-void brush_set_use_size_pressure(Brush *brush, int value)
-{
-       const short us_flag = unified_settings(brush);
-
-       if (us_flag & UNIFIED_PAINT_SIZE) {
-               set_unified_settings(brush, UNIFIED_PAINT_BRUSH_SIZE_PRESSURE, value);
-       }
-       else {
-               if (value)
-                       brush->flag |= BRUSH_SIZE_PRESSURE;
-               else
-                       brush->flag &= ~BRUSH_SIZE_PRESSURE;
-       }
-
-       //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush);
-}
-
-int brush_use_size_pressure(Brush *brush)
+int brush_use_size_pressure(const Scene *scene, Brush *brush)
 {
-       const short us_flag = unified_settings(brush);
+       const short us_flag = scene->toolsettings->unified_paint_settings.flag;
 
        return (us_flag & UNIFIED_PAINT_SIZE) ?
                (us_flag & UNIFIED_PAINT_BRUSH_SIZE_PRESSURE) :
                (brush->flag & BRUSH_SIZE_PRESSURE);
 }
 
-void brush_set_use_alpha_pressure(Brush *brush, int value)
+int brush_use_alpha_pressure(const Scene *scene, Brush *brush)
 {
-       const short us_flag = unified_settings(brush);
-
-       if (us_flag & UNIFIED_PAINT_ALPHA) {
-               set_unified_settings(brush, UNIFIED_PAINT_BRUSH_ALPHA_PRESSURE, value);
-       }
-       else {
-               if (value)
-                       brush->flag |= BRUSH_ALPHA_PRESSURE;
-               else
-                       brush->flag &= ~BRUSH_ALPHA_PRESSURE;
-       }
-
-       //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush);
-}
-
-int brush_use_alpha_pressure(Brush *brush)
-{
-       const short us_flag = unified_settings(brush);
+       const short us_flag = scene->toolsettings->unified_paint_settings.flag;
 
        return (us_flag & UNIFIED_PAINT_ALPHA) ?
                (us_flag & UNIFIED_PAINT_BRUSH_ALPHA_PRESSURE) :
index 8a4cb8a..2b75b32 100644 (file)
@@ -4862,7 +4862,7 @@ static int texture_paint_init(bContext *C, wmOperator *op)
                image_undo_restore, image_undo_free);
 
        /* create painter */
-       pop->painter= brush_painter_new(pop->s.brush);
+       pop->painter= brush_painter_new(scene, pop->s.brush);
 
        return 1;
 }
@@ -4968,6 +4968,7 @@ static int paint_exec(bContext *C, wmOperator *op)
 
 static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event)
 {
+       const Scene *scene = CTX_data_scene(C);
        PaintOperation *pop= op->customdata;
        wmTabletData *wmtab;
        PointerRNA itemptr;
@@ -4999,13 +5000,13 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event)
 
                /* special exception here for too high pressure values on first touch in
                   windows for some tablets, then we just skip first touch ..  */
-               if (tablet && (pressure >= 0.99f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || brush_use_alpha_pressure(pop->s.brush) || brush_use_size_pressure(pop->s.brush)))
+               if (tablet && (pressure >= 0.99f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || brush_use_alpha_pressure(scene, pop->s.brush) || brush_use_size_pressure(scene, pop->s.brush)))
                        return;
 
                /* This can be removed once fixed properly in
                 brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user) 
                 at zero pressure we should do nothing 1/2^12 is .0002 which is the sensitivity of the most sensitive pen tablet available*/
-               if (tablet && (pressure < .0002f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || brush_use_alpha_pressure(pop->s.brush) || brush_use_size_pressure(pop->s.brush)))
+               if (tablet && (pressure < .0002f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || brush_use_alpha_pressure(scene, pop->s.brush) || brush_use_size_pressure(scene, pop->s.brush)))
                        return;
        
        }
index 7cff37e..ca5abc1 100644 (file)
@@ -453,7 +453,7 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
                        glTranslatef(-0.5f, -0.5f, 0);
 
                        /* scale based on tablet pressure */
-                       if(sd->draw_pressure && brush_use_size_pressure(brush)) {
+                       if(sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) {
                                glTranslatef(0.5f, 0.5f, 0);
                                glScalef(1.0f/sd->pressure_value, 1.0f/sd->pressure_value, 1);
                                glTranslatef(-0.5f, -0.5f, 0);
@@ -515,7 +515,7 @@ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc,
 
        /* TODO: check whether this should really only be done when
           brush is over mesh? */
-       if(sd->draw_pressure && brush_use_alpha_pressure(brush))
+       if(sd->draw_pressure && brush_use_alpha_pressure(vc->scene, brush))
                (*visual_strength) *= sd->pressure_value;
 
        if(sd->draw_anchored)
@@ -529,16 +529,17 @@ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc,
        unprojected_radius = paint_calc_object_space_radius(vc, location,
                                                            projected_radius);
 
-       if(sd->draw_pressure && brush_use_size_pressure(brush))
+       if(sd->draw_pressure && brush_use_size_pressure(vc->scene, brush))
                unprojected_radius *= sd->pressure_value;
 
-       if(!brush_use_locked_size(brush))
+       if(!brush_use_locked_size(vc->scene, brush))
                brush_set_unprojected_radius(brush, unprojected_radius);
 }
 
 static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
 {
-       Paint *paint = paint_get_active(CTX_data_scene(C));
+       Scene *scene = CTX_data_scene(C);
+       Paint *paint = paint_get_active(scene);
        Brush *brush = paint_brush(paint);
        ViewContext vc;
        float final_radius;
@@ -597,7 +598,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
                /* draw overlay */
                paint_draw_alpha_overlay(sd, brush, &vc, x, y);
 
-               if(brush_use_locked_size(brush))
+               if(brush_use_locked_size(scene, brush))
                        brush_set_size(brush, pixel_radius);
 
                /* check if brush is subtracting, use different color then */
@@ -764,12 +765,13 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const
                length = len_v2(vec);
 
                if(length > FLT_EPSILON) {
+                       const Scene *scene = CTX_data_scene(C);
                        int steps;
                        int i;
                        float pressure= 1.0f;
 
                        /* XXX mysterious :) what has 'use size' do with this here... if you don't check for it, pressure fails */
-                       if(brush_use_size_pressure(stroke->brush))
+                       if(brush_use_size_pressure(scene, stroke->brush))
                                pressure = event_tablet_data(event, NULL);
                        
                        if(pressure > FLT_EPSILON) {
index 76185d7..6871298 100644 (file)
@@ -1974,6 +1974,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED
 
 static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
 {
+       const Scene *scene= CTX_data_scene(C);
        ToolSettings *ts= CTX_data_tool_settings(C);
        VPaint *wp= ts->wpaint;
        Brush *brush = paint_brush(&wp->paint);
@@ -1992,8 +1993,8 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        char *defbase_sel;
 
        const float pressure = RNA_float_get(itemptr, "pressure");
-       const float brush_size_final = brush_size(brush) * (brush_use_size_pressure(brush) ? pressure : 1.0f);
-       const float brush_alpha_final = brush_alpha(brush) * (brush_use_alpha_pressure(brush) ? pressure : 1.0f);
+       const float brush_size_final = brush_size(brush) * (brush_use_size_pressure(scene, brush) ? pressure : 1.0f);
+       const float brush_alpha_final = brush_alpha(brush) * (brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f);
 
        /* intentionally dont initialize as NULL, make sure we initialize all members below */
        WeightPaintInfo wpi;
@@ -2445,6 +2446,7 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob,
 
 static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
 {
+       const Scene *scene= CTX_data_scene(C);
        ToolSettings *ts= CTX_data_tool_settings(C);
        struct VPaintData *vpd = paint_stroke_mode_data(stroke);
        VPaint *vp= ts->vpaint;
@@ -2458,8 +2460,8 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        float mval[2];
 
        const float pressure = RNA_float_get(itemptr, "pressure");
-       const float brush_size_final = brush_size(brush) * (brush_use_size_pressure(brush) ? pressure : 1.0f);
-       const float brush_alpha_final = brush_alpha(brush) * (brush_use_alpha_pressure(brush) ? pressure : 1.0f);
+       const float brush_size_final = brush_size(brush) * (brush_use_size_pressure(scene, brush) ? pressure : 1.0f);
+       const float brush_alpha_final = brush_alpha(brush) * (brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f);
 
        RNA_float_get_array(itemptr, "mouse", mval);
        flip = RNA_boolean_get(itemptr, "pen_flip");
index 841b269..7712a07 100644 (file)
@@ -549,7 +549,7 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather)
        const float root_alpha = brush_alpha(brush);
        float alpha        = root_alpha*root_alpha;
        float dir          = brush->flag & BRUSH_DIR_IN ? -1 : 1;
-       float pressure     = brush_use_alpha_pressure(brush) ? cache->pressure : 1;
+       float pressure     = brush_use_alpha_pressure(cache->vc->scene, brush) ? cache->pressure : 1;
        float pen_flip     = cache->pen_flip ? -1 : 1;
        float invert       = cache->invert ? -1 : 1;
        float accum        = integrate_overlap(brush);
@@ -3017,6 +3017,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
                                                                                 struct PaintStroke *stroke,
                                                                                 PointerRNA *ptr)
 {
+       const Scene *scene = CTX_data_scene(C);
        SculptSession *ss = ob->sculpt;
        StrokeCache *cache = ss->cache;
        Brush *brush = paint_brush(&sd->paint);
@@ -3054,7 +3055,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
        cache->pixel_radius = brush_size(brush);
 
        if(cache->first_time) {
-               if (!brush_use_locked_size(brush)) {
+               if (!brush_use_locked_size(scene, brush)) {
                        cache->initial_radius= paint_calc_object_space_radius(cache->vc, cache->true_location, brush_size(brush));
                        brush_set_unprojected_radius(brush, cache->initial_radius);
                }
@@ -3063,7 +3064,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
                }
        }
 
-       if(brush_use_size_pressure(brush)) {
+       if(brush_use_size_pressure(scene, brush)) {
                cache->pixel_radius *= cache->pressure;
                cache->radius= cache->initial_radius * cache->pressure;
        }
@@ -3287,7 +3288,8 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss)
 
        /* Restore the mesh before continuing with anchored stroke */
        if((brush->flag & BRUSH_ANCHORED) ||
-          (brush->sculpt_tool == SCULPT_TOOL_GRAB && brush_use_size_pressure(brush)) ||
+          (brush->sculpt_tool == SCULPT_TOOL_GRAB &&
+               brush_use_size_pressure(ss->cache->vc->scene, brush)) ||
           (brush->flag & BRUSH_RESTORE_MESH))
        {
                StrokeCache *cache = ss->cache;
index 4fb672f..63009e0 100644 (file)
@@ -185,42 +185,6 @@ static int rna_Brush_get_size(PointerRNA *ptr)
        return brush_size(me);
 }
 
-static void rna_Brush_set_use_locked_size(PointerRNA *ptr, int value)
-{
-       Brush* me = (Brush*)(ptr->data);
-       brush_set_use_locked_size(me, value);
-}
-
-static int rna_Brush_get_use_locked_size(PointerRNA *ptr)
-{
-       Brush* me = (Brush*)(ptr->data);
-       return brush_use_locked_size(me);
-}
-
-static void rna_Brush_set_use_size_pressure(PointerRNA *ptr, int value)
-{
-       Brush* me = (Brush*)(ptr->data);
-       brush_set_use_size_pressure(me, value);
-}
-
-static int rna_Brush_get_use_size_pressure(PointerRNA *ptr)
-{
-       Brush* me = (Brush*)(ptr->data);
-       return brush_use_size_pressure(me);
-}
-
-static void rna_Brush_set_use_alpha_pressure(PointerRNA *ptr, int value)
-{
-       Brush* me = (Brush*)(ptr->data);
-       brush_set_use_alpha_pressure(me, value);
-}
-
-static int rna_Brush_get_use_alpha_pressure(PointerRNA *ptr)
-{
-       Brush* me = (Brush*)(ptr->data);
-       return brush_use_alpha_pressure(me);
-}
-
 static void rna_Brush_set_unprojected_radius(PointerRNA *ptr, float value)
 {
        Brush* me = (Brush*)(ptr->data);
@@ -575,7 +539,6 @@ static void rna_def_brush(BlenderRNA *brna)
        
        prop= RNA_def_property(srna, "use_pressure_strength", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ALPHA_PRESSURE);
-       RNA_def_property_boolean_funcs(prop, "rna_Brush_get_use_alpha_pressure", "rna_Brush_set_use_alpha_pressure");
        RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
        RNA_def_property_ui_text(prop, "Strength Pressure", "Enable tablet pressure sensitivity for strength");
        RNA_def_property_update(prop, 0, "rna_Brush_update");
@@ -588,7 +551,6 @@ static void rna_def_brush(BlenderRNA *brna)
 
        prop= RNA_def_property(srna, "use_pressure_size", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SIZE_PRESSURE);
-       RNA_def_property_boolean_funcs(prop, "rna_Brush_get_use_size_pressure", "rna_Brush_set_use_size_pressure");
        RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
        RNA_def_property_ui_text(prop, "Size Pressure", "Enable tablet pressure sensitivity for size");
        RNA_def_property_update(prop, 0, "rna_Brush_update");
@@ -668,7 +630,6 @@ static void rna_def_brush(BlenderRNA *brna)
        RNA_def_property_update(prop, 0, "rna_Brush_update");
 
        prop= RNA_def_property(srna, "use_locked_size", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_funcs(prop, "rna_Brush_get_use_locked_size", "rna_Brush_set_use_locked_size");
        RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_LOCK_SIZE);
        RNA_def_property_ui_text(prop, "Use Blender Units", "When locked brush stays same size relative to object; when unlocked brush size is given in pixels");
        RNA_def_property_update(prop, 0, "rna_Brush_update");
index af0e8d5..fab272e 100644 (file)
@@ -1627,6 +1627,7 @@ static void rna_def_unified_paint_settings(BlenderRNA  *brna)
        srna= RNA_def_struct(brna, "UnifiedPaintSettings", NULL);
        RNA_def_struct_ui_text(srna, "Unified Paint Settings", "Overrides for some of the active brush's settings");
 
+       /* high-level flags to enable or disable unified paint settings */
        prop= RNA_def_property(srna, "use_unified_size", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", UNIFIED_PAINT_SIZE);
        RNA_def_property_ui_text(prop, "Use Unified Radius",
@@ -1637,11 +1638,13 @@ static void rna_def_unified_paint_settings(BlenderRNA  *brna)
        RNA_def_property_ui_text(prop, "Use Unified Strength",
                                 "Instead of per-brush strength, the strength is shared across brushes");
 
+       /* unified paint settings that override the equivalent settings
+          from the active brush */
        prop= RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE);
        RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS*10);
        RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, 0);
        RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels");
-       
+
        prop= RNA_def_property(srna, "unprojected_radius", PROP_FLOAT, PROP_DISTANCE);
        RNA_def_property_range(prop, 0.001, FLT_MAX);
        RNA_def_property_ui_range(prop, 0.001, 1, 0, 0);
@@ -1653,6 +1656,20 @@ static void rna_def_unified_paint_settings(BlenderRNA  *brna)
        RNA_def_property_range(prop, 0.0f, 10.0f);
        RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 0.001);
        RNA_def_property_ui_text(prop, "Strength", "How powerful the effect of the brush is when applied");
+
+       prop= RNA_def_property(srna, "use_pressure_size", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", UNIFIED_PAINT_BRUSH_SIZE_PRESSURE);
+       RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
+       RNA_def_property_ui_text(prop, "Size Pressure", "Enable tablet pressure sensitivity for size");
+
+       prop= RNA_def_property(srna, "use_pressure_strength", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", UNIFIED_PAINT_BRUSH_ALPHA_PRESSURE);
+       RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
+       RNA_def_property_ui_text(prop, "Strength Pressure", "Enable tablet pressure sensitivity for strength");
+
+       prop= RNA_def_property(srna, "use_locked_size", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", UNIFIED_PAINT_BRUSH_LOCK_SIZE);
+       RNA_def_property_ui_text(prop, "Use Blender Units", "When locked brush stays same size relative to object; when unlocked brush size is given in pixels");
 }
 
 static void rna_def_unit_settings(BlenderRNA  *brna)