RNA
[blender-staging.git] / source / blender / makesrna / intern / rna_brush.c
index 04c36fd496511f24187b57a535c256c53df55906..90617d0183368edabb9cbf54f3dfb872e58bd87c 100644 (file)
@@ -40,10 +40,24 @@ static void rna_Brush_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *p
        rna_iterator_array_begin(iter, (void*)brush->mtex, sizeof(MTex*), MAX_MTEX, NULL);
 }
 
-static void *rna_Brush_active_texture_get(PointerRNA *ptr)
+static PointerRNA rna_Brush_active_texture_get(PointerRNA *ptr)
 {
        Brush *brush= (Brush*)ptr->data;
-       return brush->mtex[(int)brush->texact];
+       return rna_pointer_inherit_refine(ptr, &RNA_TextureSlot, brush->mtex[(int)brush->texact]);
+}
+
+static float rna_Brush_rotation_get(PointerRNA *ptr)
+{
+       Brush *brush= (Brush*)ptr->data;
+       const float conv = 57.295779506;
+       return brush->rot * conv;
+}
+
+static void rna_Brush_rotation_set(PointerRNA *ptr, float v)
+{
+       Brush *brush= (Brush*)ptr->data;
+       const float conv = 0.017453293;
+       brush->rot = v * conv;
 }
 
 #else
@@ -53,32 +67,33 @@ void rna_def_brush(BlenderRNA *brna)
        StructRNA *srna;
        PropertyRNA *prop;
        static EnumPropertyItem prop_blend_items[] = {
-               {BRUSH_BLEND_MIX, "MIX", "Mix", "Use mix blending mode while painting."},
-               {BRUSH_BLEND_ADD, "ADD", "Add", "Use add blending mode while painting."},
-               {BRUSH_BLEND_SUB, "SUB", "Subtract", "Use subtract blending mode while painting."},
-               {BRUSH_BLEND_MUL, "MUL", "Multiply", "Use multiply blending mode while painting."},
-               {BRUSH_BLEND_LIGHTEN, "LIGHTEN", "Lighten", "Use lighten blending mode while painting."},
-               {BRUSH_BLEND_DARKEN, "DARKEN", "Darken", "Use darken blending mode while painting."},
-               {BRUSH_BLEND_ERASE_ALPHA, "ERASE_ALPHA", "Erase Alpha", "Erase alpha while painting."},
-               {BRUSH_BLEND_ADD_ALPHA, "ADD_ALPHA", "Add Alpha", "Add alpha while painting."},
-               {0, NULL, NULL, NULL}};
+               {BRUSH_BLEND_MIX, "MIX", 0, "Mix", "Use mix blending mode while painting."},
+               {BRUSH_BLEND_ADD, "ADD", 0, "Add", "Use add blending mode while painting."},
+               {BRUSH_BLEND_SUB, "SUB", 0, "Subtract", "Use subtract blending mode while painting."},
+               {BRUSH_BLEND_MUL, "MUL", 0, "Multiply", "Use multiply blending mode while painting."},
+               {BRUSH_BLEND_LIGHTEN, "LIGHTEN", 0, "Lighten", "Use lighten blending mode while painting."},
+               {BRUSH_BLEND_DARKEN, "DARKEN", 0, "Darken", "Use darken blending mode while painting."},
+               {BRUSH_BLEND_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting."},
+               {BRUSH_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting."},
+               {0, NULL, 0, NULL, NULL}};
        static EnumPropertyItem prop_texture_mode_items[] = {
-               {BRUSH_TEX_DRAG, "TEX_DRAG", "Drag", ""},
-               {BRUSH_TEX_TILE, "TEX_TILE", "Tile", ""},
-               {BRUSH_TEX_3D, "TEX_3D", "3D", ""},
-               {0, NULL, NULL, NULL}};
+               {BRUSH_TEX_DRAG, "TEX_DRAG", 0, "Drag", ""},
+               {BRUSH_TEX_TILE, "TEX_TILE", 0, "Tile", ""},
+               {BRUSH_TEX_3D, "TEX_3D", 0, "3D", ""},
+               {0, NULL, 0, NULL, NULL}};
        static EnumPropertyItem prop_sculpt_tool_items[] = {
-               {SCULPT_TOOL_DRAW, "DRAW", "Draw", ""},
-               {SCULPT_TOOL_SMOOTH, "SMOOTH", "Smooth", ""},
-               {SCULPT_TOOL_PINCH, "PINCH", "Pinch", ""},
-               {SCULPT_TOOL_INFLATE, "INFLATE", "Inflate", ""},
-               {SCULPT_TOOL_GRAB, "GRAB", "Grab", ""},
-               {SCULPT_TOOL_LAYER, "LAYER", "Layer", ""},
-               {SCULPT_TOOL_FLATTEN, "FLATTEN", "Flatten", ""},
-               {0, NULL, NULL, NULL}};
+               {SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""},
+               {SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""},
+               {SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", ""},
+               {SCULPT_TOOL_INFLATE, "INFLATE", 0, "Inflate", ""},
+               {SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", ""},
+               {SCULPT_TOOL_LAYER, "LAYER", 0, "Layer", ""},
+               {SCULPT_TOOL_FLATTEN, "FLATTEN", 0, "Flatten", ""},
+               {0, NULL, 0, NULL, NULL}};
        
        srna= RNA_def_struct(brna, "Brush", "ID");
        RNA_def_struct_ui_text(srna, "Brush", "Brush datablock for storing brush settings for painting and sculpting.");
+       RNA_def_struct_ui_icon(srna, ICON_BRUSH_DATA);
        
        /* enums */
        prop= RNA_def_property(srna, "blend", PROP_ENUM, PROP_NONE);
@@ -122,6 +137,12 @@ void rna_def_brush(BlenderRNA *brna)
        RNA_def_property_float_sdna(prop, NULL, "alpha");
        RNA_def_property_range(prop, 0.0f, 1.0f);
        RNA_def_property_ui_text(prop, "Strength", "The amount of pressure on the brush.");
+
+       prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "rot");
+       RNA_def_property_range(prop, 0, 360);
+       RNA_def_property_float_funcs(prop, "rna_Brush_rotation_get", "rna_Brush_rotation_set", NULL);
+       RNA_def_property_ui_text(prop, "Rotation", "Angle of the brush texture.");
        
        /* flag */
        prop= RNA_def_property(srna, "airbrush", PROP_BOOLEAN, PROP_NONE);
@@ -159,13 +180,17 @@ void rna_def_brush(BlenderRNA *brna)
        prop= RNA_def_property(srna, "flip_direction", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_DIR_IN);
        RNA_def_property_ui_text(prop, "Flip Direction", "Move vertices in the opposite direction.");
+
+       prop= RNA_def_property(srna, "space", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SPACE);
+       RNA_def_property_ui_text(prop, "Space", "Limit brush application to the distance specified by spacing.");
        
        /* not exposed in the interface yet
        prop= RNA_def_property(srna, "fixed_tex", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_FIXED_TEX);
        RNA_def_property_ui_text(prop, "Fixed Texture", "Keep texture origin in fixed position.");*/
 
-       prop= RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
+       prop= RNA_def_property(srna, "curve", PROP_POINTER, PROP_NEVER_NULL);
        RNA_def_property_ui_text(prop, "Curve", "Editable falloff curve.");
 
        /* texture */
@@ -174,7 +199,7 @@ void rna_def_brush(BlenderRNA *brna)
        /* clone tool */
        prop= RNA_def_property(srna, "clone_image", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "clone.image");
-       RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+       RNA_def_property_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "Clone Image", "Image for clone tool.");
        
        prop= RNA_def_property(srna, "clone_opacity", PROP_FLOAT, PROP_NONE);
@@ -217,10 +242,14 @@ static void rna_def_operator_stroke_element(BlenderRNA *brna)
        RNA_def_property_array(prop, 2);
        RNA_def_property_ui_text(prop, "Mouse", "");
 
-       /*prop= RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_NONE);
+       prop= RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_NONE);
        RNA_def_property_flag(prop, PROP_IDPROPERTY);
-       RNA_def_property_range(prop, 0, 1);
-       RNA_def_property_ui_text(prop, "Pressure", "");*/
+       RNA_def_property_range(prop, 0.0f, 1.0f);
+       RNA_def_property_ui_text(prop, "Pressure", "Tablet pressure.");
+
+       prop= RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED);
+       RNA_def_property_flag(prop, PROP_IDPROPERTY);
+       RNA_def_property_ui_text(prop, "Time", "");
 
        prop= RNA_def_property(srna, "flip", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_flag(prop, PROP_IDPROPERTY);
@@ -228,8 +257,6 @@ static void rna_def_operator_stroke_element(BlenderRNA *brna)
 
        /* XXX: Tool (this will be for pressing a modifier key for a different brush,
                e.g. switching to a Smooth brush in the middle of the stroke */
-
-       /* XXX: Time (should be useful for airbrush mode) */
 }
 
 void RNA_def_brush(BlenderRNA *brna)