Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@gmail.com>2010-07-26 08:00:09 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2010-07-26 08:00:09 +0400
commitec19c7dffca92119c964dc18ef3af6efd1d8c0c9 (patch)
tree549f8b92d3badebd2a0e25710a86b639df9502c5 /source/blender/makesrna/intern/rna_brush.c
parent6561da03ae1f0bd90b257c096f38c8432f413076 (diff)
== Sculpt ==
Fixed brush icons loading slowly * Changed brush icon property from an enum to a flag that toggles whether a custom file is used for the brush icon * Changed get_brush_icon to only handle loading external icons, built-ins are handled through the regular icon system * Modified preview icon drawing to allow built-in icons * When not using a custom icon, a default icon is selected based on the current tool TODO: * Allowing preview to show built-in icons makes the brush texture selector look ugly when nothing is selected. As discussed on IRC though, the nothing-selected state needs to be clarified anyway; I'll address this in another commit * Use image browser when selecting a custom icon * Selecting the default icon is ugly (uses the active object's mode), this can be fixed by making brushes know which paint mode they are part of
Diffstat (limited to 'source/blender/makesrna/intern/rna_brush.c')
-rw-r--r--source/blender/makesrna/intern/rna_brush.c172
1 files changed, 94 insertions, 78 deletions
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 44bca3b2324..e970c79989e 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -36,19 +36,77 @@
#include "IMB_imbuf.h"
+
#include "WM_types.h"
+EnumPropertyItem brush_sculpt_tool_items[] = {
+ {SCULPT_TOOL_BLOB, "BLOB", ICON_BRUSH_BLOB, "Blob", ""},
+ {SCULPT_TOOL_CLAY, "CLAY", ICON_BRUSH_CLAY, "Clay", ""},
+ {SCULPT_TOOL_CREASE, "CREASE",ICON_BRUSH_CREASE, "Crease", ""},
+ {SCULPT_TOOL_DRAW, "DRAW", ICON_BRUSH_SCULPT_DRAW, "Draw", ""},
+ {SCULPT_TOOL_FILL, "FILL", ICON_BRUSH_FILL, "Fill", ""},
+ {SCULPT_TOOL_FLATTEN, "FLATTEN", ICON_BRUSH_FLATTEN, "Flatten", ""},
+ {SCULPT_TOOL_GRAB, "GRAB", ICON_BRUSH_GRAB, "Grab", ""},
+ {SCULPT_TOOL_INFLATE, "INFLATE", ICON_BRUSH_INFLATE, "Inflate", ""},
+ {SCULPT_TOOL_LAYER, "LAYER", ICON_BRUSH_LAYER, "Layer", ""},
+ {SCULPT_TOOL_NUDGE, "NUDGE", ICON_BRUSH_NUDGE, "Nudge", ""},
+ {SCULPT_TOOL_PINCH, "PINCH", ICON_BRUSH_PINCH, "Pinch", ""},
+ {SCULPT_TOOL_ROTATE, "ROTATE", ICON_BRUSH_ROTATE, "Rotate", ""},
+ {SCULPT_TOOL_SCRAPE, "SCRAPE", ICON_BRUSH_SCRAPE, "Scrape", ""},
+ {SCULPT_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_SMOOTH, "Smooth", ""},
+ {SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", ICON_BRUSH_SNAKE_HOOK, "Snake Hook", ""},
+ {SCULPT_TOOL_THUMB, "THUMB", ICON_BRUSH_THUMB, "Thumb", ""},
+ {0, NULL, 0, NULL, NULL}};
+
+
+EnumPropertyItem brush_vertexpaint_tool_items[] = {
+ {0, "MIX", ICON_BRUSH_MIX, "Mix", "Use mix blending mode while painting"},
+ {1, "ADD", ICON_BRUSH_ADD, "Add", "Use add blending mode while painting"},
+ {2, "SUB", ICON_BRUSH_SUBTRACT, "Subtract", "Use subtract blending mode while painting"},
+ {3, "MUL", ICON_BRUSH_MULTIPLY, "Multiply", "Use multiply blending mode while painting"},
+ {4, "BLUR", ICON_BRUSH_BLUR, "Blur", "Blur the color with surrounding values"},
+ {5, "LIGHTEN", ICON_BRUSH_LIGHTEN, "Lighten", "Use lighten blending mode while painting"},
+ {6, "DARKEN", ICON_BRUSH_DARKEN, "Darken", "Use darken blending mode while painting"},
+ {0, NULL, 0, NULL, NULL}};
+
+EnumPropertyItem brush_imagepaint_tool_items[] = {
+ {PAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_TEXDRAW, "Draw", ""},
+ {PAINT_TOOL_SOFTEN, "SOFTEN", ICON_BRUSH_SOFTEN, "Soften", ""},
+ {PAINT_TOOL_SMEAR, "SMEAR", ICON_BRUSH_SMEAR, "Smear", ""},
+ {PAINT_TOOL_CLONE, "CLONE", ICON_BRUSH_CLONE, "Clone", ""},
+ {0, NULL, 0, NULL, NULL}};
+
#ifdef RNA_RUNTIME
#include "MEM_guardedalloc.h"
+#include "DNA_object_types.h"
+
+#include "RNA_access.h"
+
#include "BKE_texture.h"
#include "BKE_brush.h"
#include "BKE_icons.h"
+
#include "BKE_paint.h"
#include "WM_api.h"
+static void rna_Brush_reset_icon(Brush *br, char *type)
+{
+ ID *id = &br->id;
+
+ if(br->flag & BRUSH_CUSTOM_ICON)
+ return;
+
+ if(id->icon_id >= BIFICONID_LAST) {
+ BKE_icon_delete(id);
+ BKE_previewimg_free_id(id);
+ }
+
+ id->icon_id = 0;
+}
+
static void rna_Brush_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Brush *br= (Brush*)ptr->data;
@@ -56,6 +114,27 @@ static void rna_Brush_update(Main *bmain, Scene *scene, PointerRNA *ptr)
//WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL);
}
+static void rna_Brush_sculpt_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ Brush *br= (Brush*)ptr->data;
+ rna_Brush_reset_icon(br, "sculpt");
+ rna_Brush_update(bmain, scene, ptr);
+}
+
+static void rna_Brush_vertexpaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ Brush *br= (Brush*)ptr->data;
+ rna_Brush_reset_icon(br, "vertex_paint");
+ rna_Brush_update(bmain, scene, ptr);
+}
+
+static void rna_Brush_imagepaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ Brush *br= (Brush*)ptr->data;
+ rna_Brush_reset_icon(br, "texture_paint");
+ rna_Brush_update(bmain, scene, ptr);
+}
+
static int rna_Brush_is_sculpt_brush(Brush *br, bContext *C)
{
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
@@ -91,12 +170,17 @@ static void rna_Brush_icon_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Brush *br= (Brush*)ptr->data;
- if (br->icon_imbuf) {
+ if(br->icon_imbuf) {
IMB_freeImBuf(br->icon_imbuf);
br->icon_imbuf= NULL;
}
- BKE_icon_changed(BKE_icon_getid(&(br->id)));
+ br->id.icon_id = 0;
+
+ if(br->flag & BRUSH_CUSTOM_ICON) {
+ BKE_previewimg_get(&br->id);
+ BKE_icon_changed(BKE_icon_getid(&br->id));
+ }
WM_main_add_notifier(NC_BRUSH|NA_EDITED, br);
}
@@ -219,25 +303,6 @@ static void rna_def_brush(BlenderRNA *brna)
{IMB_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting"},
{0, NULL, 0, NULL, NULL}};
- static EnumPropertyItem brush_sculpt_tool_items[] = {
- {SCULPT_TOOL_BLOB, "BLOB", ICON_BRUSH_BLOB, "Blob", ""},
- {SCULPT_TOOL_CLAY, "CLAY", ICON_BRUSH_CLAY, "Clay", ""},
- {SCULPT_TOOL_CREASE, "CREASE",ICON_BRUSH_CREASE, "Crease", ""},
- {SCULPT_TOOL_DRAW, "DRAW", ICON_BRUSH_SCULPT_DRAW, "Draw", ""},
- {SCULPT_TOOL_FILL, "FILL", ICON_BRUSH_FILL, "Fill", ""},
- {SCULPT_TOOL_FLATTEN, "FLATTEN", ICON_BRUSH_FLATTEN, "Flatten", ""},
- {SCULPT_TOOL_GRAB, "GRAB", ICON_BRUSH_GRAB, "Grab", ""},
- {SCULPT_TOOL_INFLATE, "INFLATE", ICON_BRUSH_INFLATE, "Inflate", ""},
- {SCULPT_TOOL_LAYER, "LAYER", ICON_BRUSH_LAYER, "Layer", ""},
- {SCULPT_TOOL_NUDGE, "NUDGE", ICON_BRUSH_NUDGE, "Nudge", ""},
- {SCULPT_TOOL_PINCH, "PINCH", ICON_BRUSH_PINCH, "Pinch", ""},
- {SCULPT_TOOL_ROTATE, "ROTATE", ICON_BRUSH_ROTATE, "Rotate", ""},
- {SCULPT_TOOL_SCRAPE, "SCRAPE", ICON_BRUSH_SCRAPE, "Scrape", ""},
- {SCULPT_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_SMOOTH, "Smooth", ""},
- {SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", ICON_BRUSH_SNAKE_HOOK, "Snake Hook", ""},
- {SCULPT_TOOL_THUMB, "THUMB", ICON_BRUSH_THUMB, "Thumb", ""},
- {0, NULL, 0, NULL, NULL}};
-
static EnumPropertyItem brush_stroke_method_items[] = {
{0, "DOTS", 0, "Dots", ""},
{BRUSH_RESTORE_MESH, "DRAG_DOT", 0, "Drag Dot", ""},
@@ -257,23 +322,6 @@ static void rna_def_brush(BlenderRNA *brna)
{BRUSH_RAKE, "RAKE", 0, "Rake", ""},
{0, NULL, 0, NULL, NULL}};
- static EnumPropertyItem brush_vertexpaint_tool_items[] = {
- {0, "MIX", ICON_BRUSH_MIX, "Mix", "Use mix blending mode while painting"},
- {1, "ADD", ICON_BRUSH_ADD, "Add", "Use add blending mode while painting"},
- {2, "SUB", ICON_BRUSH_SUBTRACT, "Subtract", "Use subtract blending mode while painting"},
- {3, "MUL", ICON_BRUSH_MULTIPLY, "Multiply", "Use multiply blending mode while painting"},
- {4, "BLUR", ICON_BRUSH_BLUR, "Blur", "Blur the color with surrounding values"},
- {5, "LIGHTEN", ICON_BRUSH_LIGHTEN, "Lighten", "Use lighten blending mode while painting"},
- {6, "DARKEN", ICON_BRUSH_DARKEN, "Darken", "Use darken blending mode while painting"},
- {0, NULL, 0, NULL, NULL}};
-
- static EnumPropertyItem brush_imagepaint_tool_items[] = {
- {PAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_TEXDRAW, "Draw", ""},
- {PAINT_TOOL_SOFTEN, "SOFTEN", ICON_BRUSH_SOFTEN, "Soften", ""},
- {PAINT_TOOL_SMEAR, "SMEAR", ICON_BRUSH_SMEAR, "Smear", ""},
- {PAINT_TOOL_CLONE, "CLONE", ICON_BRUSH_CLONE, "Clone", ""},
- {0, NULL, 0, NULL, NULL}};
-
static const EnumPropertyItem prop_flip_direction_items[]= {
{0, "ADD", 0, "Add", "Add effect of brush"},
{BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"},
@@ -312,38 +360,6 @@ static void rna_def_brush(BlenderRNA *brna)
{SCULPT_DISP_DIR_Z, "Z", 0, "Z Plane", ""},
{0, NULL, 0, NULL, NULL}};
- static EnumPropertyItem brush_icon_items[] = {
- {BRUSH_ICON_FILE, "FILE", 0, "Use An Image File", ""},
- {BRUSH_ICON_BLOB, "BLOB", 0, "Blob", ""},
- {BRUSH_ICON_CREASE, "CREASE", 0, "Crease", ""},
- {BRUSH_ICON_CLAY, "CLAY", 0, "Clay", ""},
- {BRUSH_ICON_SCULPTDRAW, "SCULPTDRAW", 0, "Sculpt Draw", ""},
- {BRUSH_ICON_FILL, "FILL", 0, "Fill", ""},
- {BRUSH_ICON_FLATTEN, "FLATTEN", 0, "Flatten", ""},
- {BRUSH_ICON_GRAB, "GRAB", 0, "Grab", ""},
- {BRUSH_ICON_INFLATE, "INFLATE", 0, "Inflate", ""},
- {BRUSH_ICON_LAYER, "LAYER", 0, "Layer", ""},
- {BRUSH_ICON_NUDGE, "NUDGE", 0, "Nudge", ""},
- {BRUSH_ICON_PINCH, "PINCH", 0, "Pinch", ""},
- {BRUSH_ICON_TWIST, "TWIST", 0, "Twist", ""},
- {BRUSH_ICON_SCRAPE, "SCRAPE", 0, "Scrape", ""},
- {BRUSH_ICON_SMOOTH, "SMOOTH", 0, "Smooth", ""},
- {BRUSH_ICON_SNAKE_HOOK, "SNAKE_HOOK", 0, "Snake Hook", ""},
- {BRUSH_ICON_THUMB, "THUMB", 0, "Thumb", ""},
- {BRUSH_ICON_ADD, "ADD", 0, "Add", ""},
- {BRUSH_ICON_BLUR, "BLUR", 0, "Blur", ""},
- {BRUSH_ICON_CLONE, "CLONE", 0, "Clone", ""},
- {BRUSH_ICON_DARKEN, "DARKEN", 0, "Darken", ""},
- {BRUSH_ICON_LIGHTEN, "LIGHTEN", 0, "Lighten", ""},
- {BRUSH_ICON_MIX, "MIX", 0, "Mix", ""},
- {BRUSH_ICON_MULTIPLY, "MULTIPLY", 0, "Multiply", ""},
- {BRUSH_ICON_SMEAR, "SMEAR", 0, "Smear", ""},
- {BRUSH_ICON_SOFTEN, "SOFTEN", 0, "Soften", ""},
- {BRUSH_ICON_SUBTRACT, "SUBTRACT", 0, "Subtract", ""},
- {BRUSH_ICON_TEXDRAW, "TEXDRAW", 0, "Texture Draw", ""},
- {BRUSH_ICON_VERTEXDRAW, "VERTEXDRAW", 0, "Vertex Draw", ""},
- {0, NULL, 0, NULL, NULL}};
-
FunctionRNA *func;
PropertyRNA *parm;
@@ -389,17 +405,17 @@ static void rna_def_brush(BlenderRNA *brna)
prop= RNA_def_property(srna, "sculpt_tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, brush_sculpt_tool_items);
RNA_def_property_ui_text(prop, "Sculpt Tool", "");
- RNA_def_property_update(prop, 0, "rna_Brush_update");
+ RNA_def_property_update(prop, 0, "rna_Brush_sculpt_tool_update");
prop= RNA_def_property(srna, "vertexpaint_tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, brush_vertexpaint_tool_items);
RNA_def_property_ui_text(prop, "Vertex/Weight Paint Tool", "");
- RNA_def_property_update(prop, 0, "rna_Brush_update");
+ RNA_def_property_update(prop, 0, "rna_Brush_vertexpaint_tool_update");
prop= RNA_def_property(srna, "imagepaint_tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, brush_imagepaint_tool_items);
RNA_def_property_ui_text(prop, "Image Paint Tool", "");
- RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_update");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_imagepaint_tool_update");
prop= RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
@@ -407,11 +423,6 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Direction", "");
RNA_def_property_update(prop, 0, "rna_Brush_update");
- prop= RNA_def_property(srna, "icon", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, brush_icon_items);
- RNA_def_property_ui_text(prop, "Brush Icon", "");
- RNA_def_property_update(prop, 0, "rna_Brush_icon_update");
-
prop= RNA_def_property(srna, "stroke_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, brush_stroke_method_items);
@@ -748,6 +759,11 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Subract Color", "Color of cursor when subtracting");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop= RNA_def_property(srna, "use_custom_icon", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_CUSTOM_ICON);
+ RNA_def_property_ui_text(prop, "Custom Icon", "Set the brush icon from an image file");
+ RNA_def_property_update(prop, 0, "rna_Brush_icon_update");
+
prop= RNA_def_property(srna, "icon_filepath", PROP_STRING, PROP_FILEPATH);
RNA_def_property_string_sdna(prop, NULL, "icon_filepath");
RNA_def_property_ui_text(prop, "Brush Icon Filepath", "File path to brush icon");