Revision: 30142
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30142
Author:   jwilkins
Date:     2010-07-09 10:08:28 +0200 (Fri, 09 Jul 2010)

Log Message:
-----------
* enabled roll out icon menu for other paint modes

Modified Paths:
--------------
    branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
    branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c

Modified: branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py       
2010-07-09 07:53:06 UTC (rev 30141)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py       
2010-07-09 08:08:28 UTC (rev 30142)
@@ -504,19 +504,26 @@
 
         if not context.particle_edit_object:
             col = layout.split().column()
-            row = col.row()
 
-            if context.sculpt_object and brush:
-                defaultbrushes = 8
-            elif context.texture_paint_object and brush:
-                defaultbrushes = 4
+            if context.sculpt_object and context.tool_settings.sculpt:
+                col.template_ID_preview(settings, "brush", new="brush.add", 
filter="is_sculpt_brush", rows=3, cols=8)
+            elif context.texture_paint_object and 
context.tool_settings.image_paint:
+                col.template_ID_preview(settings, "brush", new="brush.add", 
filter="is_imapaint_brush", rows=3, cols=8)
+            elif context.vertex_paint_object and 
context.tool_settings.vertex_paint:
+                col.template_ID_preview(settings, "brush", new="brush.add", 
filter="is_vpaint_brush", rows=3, cols=8)
+            elif context.weight_paint_object and 
context.tool_settings.weight_paint:
+                col.template_ID_preview(settings, "brush", new="brush.add", 
filter="is_wpaint_brush", rows=3, cols=8)
             else:
-                defaultbrushes = 7
+                row = col.row()
 
-            if not context.sculpt_object:
+                if context.sculpt_object and brush:
+                    defaultbrushes = 8
+                elif context.texture_paint_object and brush:
+                    defaultbrushes = 4
+                else:
+                    defaultbrushes = 7
+
                 row.template_list(settings, "brushes", settings, 
"active_brush_index", rows=2, maxrows=defaultbrushes)
-            else:
-                col.template_ID_preview(settings, "brush", new="brush.add", 
filter="is_sculpt_brush", rows=3, cols=8)
 
         # Particle Mode #
 
@@ -1037,7 +1044,7 @@
     bl_label = "Appearance"
 
     def poll(self, context):
-        return (context.sculpt_object and context.tool_settings.sculpt)
+        return (context.sculpt_object and context.tool_settings.sculpt) or 
(context.vertex_paint_object and context.tool_settings.vertex_paint) or 
(context.weight_paint_object and context.tool_settings.weight_paint) or 
(context.texture_paint_object and context.tool_settings.image_paint)
 
     def draw(self, context):
         layout = self.layout
@@ -1048,11 +1055,12 @@
 
         col = layout.column();
 
-        if brush.sculpt_tool in ('DRAW', 'INFLATE', 'CLAY', 'WAX', 'PINCH', 
'CREASE', 'BLOB', 'FLATTEN'):
-            col.prop(brush, "add_col", text="Add Color")
-            col.prop(brush, "sub_col", text="Substract Color")
-        else:
-            col.prop(brush, "add_col", text="Color")
+        if context.sculpt_object and context.tool_settings.sculpt:
+            if brush.sculpt_tool in ('DRAW', 'INFLATE', 'CLAY', 'WAX', 
'PINCH', 'CREASE', 'BLOB', 'FLATTEN'):
+                col.prop(brush, "add_col", text="Add Color")
+                col.prop(brush, "sub_col", text="Substract Color")
+            else:
+                col.prop(brush, "add_col", text="Color")
 
         col.separator()
 

Modified: branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c       
2010-07-09 07:53:06 UTC (rev 30141)
+++ branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c       
2010-07-09 08:08:28 UTC (rev 30142)
@@ -30,6 +30,7 @@
 
 #include "DNA_brush_types.h"
 #include "DNA_texture_types.h"
+#include "DNA_scene_types.h"
 
 #include "BLI_math.h"
 
@@ -64,6 +65,45 @@
        return 0;
 }
 
+static int rna_Brush_is_vpaint_brush(Brush *me, bContext *C)
+{
+       VPaint *vp = CTX_data_tool_settings(C)->vpaint;
+       int i;
+
+       for (i= 0; i < vp->paint.brush_count; i++) {
+               if (strcmp(me->id.name+2, vp->paint.brushes[i]->id.name+2) == 
0) 
+                       return 1;
+       }
+
+       return 0;
+}
+
+static int rna_Brush_is_wpaint_brush(Brush *me, bContext *C)
+{
+       VPaint *vp = CTX_data_tool_settings(C)->wpaint;
+       int i;
+
+       for (i= 0; i < vp->paint.brush_count; i++) {
+               if (strcmp(me->id.name+2, vp->paint.brushes[i]->id.name+2) == 
0) 
+                       return 1;
+       }
+
+       return 0;
+}
+
+static int rna_Brush_is_imapaint_brush(Brush *me, bContext *C)
+{
+       ImagePaintSettings *data = &(CTX_data_tool_settings(C)->imapaint);
+       int i;
+
+       for (i= 0; i < data->paint.brush_count; i++) {
+               if (strcmp(me->id.name+2, data->paint.brushes[i]->id.name+2) == 
0) 
+                       return 1;
+       }
+
+       return 0;
+}
+
 #else
 
 static void rna_def_brush_texture_slot(BlenderRNA *brna)
@@ -202,12 +242,33 @@
 
        /* functions */
        func= RNA_def_function(srna, "is_sculpt_brush", 
"rna_Brush_is_sculpt_brush");
-       RNA_def_function_ui_description(func, "Returns true if Brush can be 
used for sculpting.");
+       RNA_def_function_ui_description(func, "Returns true if Brush can be 
used for sculpting");
        parm= RNA_def_pointer(func, "context", "Context", "", "");
        RNA_def_property_flag(parm, PROP_REQUIRED);
        parm= RNA_def_boolean(func, "ret", 0, "", "");
        RNA_def_function_return(func, parm);
 
+       func= RNA_def_function(srna, "is_vpaint_brush", 
"rna_Brush_is_vpaint_brush");
+       RNA_def_function_ui_description(func, "Returns true if Brush can be 
used for vertex painting");
+       parm= RNA_def_pointer(func, "context", "Context", "", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       parm= RNA_def_boolean(func, "ret", 0, "", "");
+       RNA_def_function_return(func, parm);
+
+       func= RNA_def_function(srna, "is_wpaint_brush", 
"rna_Brush_is_wpaint_brush");
+       RNA_def_function_ui_description(func, "Returns true if Brush can be 
used for weight painting");
+       parm= RNA_def_pointer(func, "context", "Context", "", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       parm= RNA_def_boolean(func, "ret", 0, "", "");
+       RNA_def_function_return(func, parm);
+
+       func= RNA_def_function(srna, "is_imapaint_brush", 
"rna_Brush_is_imapaint_brush");
+       RNA_def_function_ui_description(func, "Returns true if Brush can be 
used for image painting");
+       parm= RNA_def_pointer(func, "context", "Context", "", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       parm= RNA_def_boolean(func, "ret", 0, "", "");
+       RNA_def_function_return(func, parm);
+
        /* enums */
        prop= RNA_def_property(srna, "blend", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_items(prop, prop_blend_items);


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

Reply via email to