forked from bartvdbraak/blender
switching the active brush with Alt+Wheel would crash when going past the last, need rna to clamp the range.
This commit is contained in:
parent
efae4c8f21
commit
68f94765bd
@ -142,6 +142,21 @@ static int rna_ParticleEdit_hair_get(PointerRNA *ptr)
|
|||||||
|
|
||||||
return (edit && edit->psys);
|
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
|
#else
|
||||||
|
|
||||||
static void rna_def_paint(BlenderRNA *brna)
|
static void rna_def_paint(BlenderRNA *brna)
|
||||||
@ -162,6 +177,7 @@ static void rna_def_paint(BlenderRNA *brna)
|
|||||||
RNA_def_property_ui_text(prop, "Brushes", "Brushes selected for this paint mode.");
|
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);
|
prop= RNA_def_property(srna, "active_brush_index", PROP_INT, PROP_NONE);
|
||||||
|
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);
|
RNA_def_property_range(prop, 0, INT_MAX);
|
||||||
|
|
||||||
/* Fake property to get active brush directly, rather than integer index */
|
/* Fake property to get active brush directly, rather than integer index */
|
||||||
|
Loading…
Reference in New Issue
Block a user