From 910220be47729d6effffb7aa33bfe05d4caa5d3d Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Thu, 12 May 2011 01:57:47 +0000 Subject: == Radial control == Patch to make the radial control more generic with RNA. Patch was reviewed here: http://codereview.appspot.com/4280080/ Prior to this update, the radial control code in trunk had generic parts of the radial control implemented as an incomplete operator within WM. Then each different user of the radial control had to implement a separate operator to actually pass in specific brush data -- e.g. sculpt's brush size, vpaint's brush size, etc. This patch removes all the extra operators and makes the WM operator do everything. It now takes several RNA path strings as its properties -- the only required property is data_path, which specifies the data to be modified by the radial control. The other paths affect display in various ways, e.g. rotation, color, etc. In addition to decreasing some duplicate paint brush code, these updates make it pretty easy to enable radial control for other purposes (and it can be set up entirely though python or keymaps, no extra C code needed.) --- source/blender/makesrna/intern/rna_sculpt_paint.c | 4 ++-- source/blender/makesrna/intern/rna_space.c | 27 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index ce018fdfd6e..da536f95cba 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -481,12 +481,12 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_struct_sdna(srna, "ParticleBrushData"); RNA_def_struct_ui_text(srna, "Particle Brush", "Particle editing brush"); - prop= RNA_def_property(srna, "size", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE); RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 100, 10, 3); RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels"); - prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR); RNA_def_property_range(prop, 0.001, 1.0); RNA_def_property_ui_text(prop, "Strength", "Brush strength"); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 59824d6a752..5281e152d54 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -508,6 +508,27 @@ static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *C, P return item; } +static void rna_SpaceImageEditor_zoom_get(PointerRNA *ptr, float *values) +{ + SpaceImage *sima= (SpaceImage*)ptr->data; + ScrArea *sa; + ARegion *ar; + + values[0] = values[1] = 1; + + sa = rna_area_from_space(ptr); + if(!sa) return; + + /* find aregion */ + for(ar=sa->regionbase.first; ar; ar=ar->next) { + if(ar->regiontype == RGN_TYPE_WINDOW) + break; + } + if(!ar) return; + + ED_space_image_zoom(sima, ar, &values[0], &values[1]); +} + static void rna_SpaceImageEditor_cursor_location_get(PointerRNA *ptr, float *values) { SpaceImage *sima= (SpaceImage*)ptr->data; @@ -1556,6 +1577,12 @@ static void rna_def_space_image(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "sample_line_hist"); RNA_def_property_struct_type(prop, "Histogram"); RNA_def_property_ui_text(prop, "Line sample", "Sampled colors along line"); + + prop= RNA_def_property(srna, "zoom", PROP_FLOAT, PROP_NONE); + RNA_def_property_array(prop, 2); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_float_funcs(prop, "rna_SpaceImageEditor_zoom_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Zoom", "Zoom factor"); /* image draw */ prop= RNA_def_property(srna, "show_repeat", PROP_BOOLEAN, PROP_NONE); -- cgit v1.2.3