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:
authorCampbell Barton <ideasman42@gmail.com>2009-11-17 18:10:19 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-17 18:10:19 +0300
commit68f94765bddb3770d2d786af947c587570d65d7e (patch)
tree4feaa501ccdaec52b51b7c4f8ca57e19ddbf11ed /source/blender/makesrna/intern/rna_sculpt_paint.c
parentefae4c8f21881f878c1a07e1039a5901d0863c30 (diff)
switching the active brush with Alt+Wheel would crash when going past the last, need rna to clamp the range.
Diffstat (limited to 'source/blender/makesrna/intern/rna_sculpt_paint.c')
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index e6d57a0be43..beb979dfa75 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -142,6 +142,21 @@ static int rna_ParticleEdit_hair_get(PointerRNA *ptr)
return (edit && edit->psys);
}
+
+static void rna_Paint_active_brush_index_set(PointerRNA *ptr, int value)
+{
+ Paint *p= ptr->data;
+ CLAMP(value, 0, p->brush_count-1);
+ p->active_brush_index= value;
+}
+
+static void rna_Paint_active_brush_index_range(PointerRNA *ptr, int *min, int *max)
+{
+ Paint *p= ptr->data;
+ *min= 0;
+ *max= MAX2(p->brush_count-1, 0);
+}
+
#else
static void rna_def_paint(BlenderRNA *brna)
@@ -162,7 +177,8 @@ static void rna_def_paint(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Brushes", "Brushes selected for this paint mode.");
prop= RNA_def_property(srna, "active_brush_index", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 0, INT_MAX);
+ RNA_def_property_int_funcs(prop, NULL, "rna_Paint_active_brush_index_set", "rna_Paint_active_brush_index_range");
+ RNA_def_property_range(prop, 0, INT_MAX);
/* Fake property to get active brush directly, rather than integer index */
prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);