diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_paint.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/icons.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 12 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 12 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 34 |
6 files changed, 38 insertions, 31 deletions
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index f9954b3d55d..95293f16d9d 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -60,6 +60,8 @@ void paint_brush_slot_remove(struct Paint *p); * however hiding faces is useful */ int paint_facesel_test(struct Object *ob); +int paint_has_brush(struct Paint *p, struct Brush *brush); + /* Session data (mode-specific) */ typedef struct SculptSession { diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index c1e00e091e8..78306705d6b 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -178,7 +178,7 @@ void BKE_previewimg_free_id(ID *id) Image *img = (Image*)id; BKE_previewimg_free(&img->preview); } else if (GS(id->name) == ID_BR) { - Brush *br = (Brush*)br; + Brush *br = (Brush*)id; BKE_previewimg_free(&br->preview); } } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index cf5deb95258..fcbe8d65d64 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -192,3 +192,15 @@ void copy_paint(Paint *orig, Paint *new) id_us_plus((ID *)new->brushes[i]); } } + +int paint_has_brush(Paint *p, Brush *brush) +{ + int i; + + for (i= 0; i < p->brush_count; i++) { + if (strcmp(brush->id.name+2, p->brushes[i]->id.name+2) == 0) + return 1; + } + + return 0; +} diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 30cbc512f5a..8498d5b22a1 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -822,9 +822,10 @@ void RNA_enum_set(PointerRNA *ptr, const char *name, int value); void RNA_enum_set_identifier(PointerRNA *ptr, const char *name, const char *id); int RNA_enum_is_equal(struct bContext *C, PointerRNA *ptr, const char *name, const char *enumname); -/* lower level functions that donr use a PointerRNA */ -int RNA_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value); -int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **identifier); +/* lower level functions that don't use a PointerRNA */ +int RNA_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value); +int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **identifier); +int RNA_enum_icon_from_value(EnumPropertyItem *item, int value, int *icon); void RNA_string_get(PointerRNA *ptr, const char *name, char *value); char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 36c8764b3f4..62dd14b2ffa 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -3424,6 +3424,18 @@ int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **ident return 0; } +int RNA_enum_icon_from_value(EnumPropertyItem *item, int value, int *icon) +{ + for( ; item->identifier; item++) { + if(item->value==value) { + *icon = item->icon; + return 1; + } + } + + return 0; +} + void RNA_string_get(PointerRNA *ptr, const char *name, char *value) { PropertyRNA *prop= RNA_struct_find_property(ptr, name); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 2226a37b0ff..44bca3b2324 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -45,6 +45,7 @@ #include "BKE_texture.h" #include "BKE_brush.h" #include "BKE_icons.h" +#include "BKE_paint.h" #include "WM_api.h" @@ -55,43 +56,22 @@ static void rna_Brush_update(Main *bmain, Scene *scene, PointerRNA *ptr) //WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); } -static int rna_Brush_is_sculpt_brush(Brush *me, bContext *C) +static int rna_Brush_is_sculpt_brush(Brush *br, bContext *C) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - int i; - - for (i= 0; i < sd->paint.brush_count; i++) { - if (strcmp(me->id.name+2, sd->paint.brushes[i]->id.name+2) == 0) - return 1; - } - - return 0; + return paint_has_brush(&sd->paint, br); } -static int rna_Brush_is_vpaint_brush(Brush *me, bContext *C) +static int rna_Brush_is_vpaint_brush(Brush *br, 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; + return paint_has_brush(&vp->paint, br); } -static int rna_Brush_is_wpaint_brush(Brush *me, bContext *C) +static int rna_Brush_is_wpaint_brush(Brush *br, 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; + return paint_has_brush(&vp->paint, br); } static int rna_Brush_is_imapaint_brush(Brush *me, bContext *C) |