diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-02-09 01:42:45 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-02-09 01:42:45 +0400 |
commit | 385c892418eec2851d2ab3c30c1ddee4b8ebb237 (patch) | |
tree | 7a8306832467f913ea89a2b181a8d2e984d09873 | |
parent | a8a567d28eb67f4b8403be4f4959e07d1dd8628e (diff) |
UI: use proportional option while dragging buttons
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 19 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_curve.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_linestyle.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_meta.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_pose.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_texture.c | 2 |
12 files changed, 42 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index f189af751b4..5c5db59fcd9 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -176,6 +176,8 @@ typedef struct uiHandleButtonMulti { LinkNode *mbuts; uiButStore *bs_mbuts; + bool is_proportional; + /* before activating, we need to check gesture direction * accumulate signed cursor movement here so we can tell if this is a vertical motion or not. */ float drag_dir[2]; @@ -937,12 +939,22 @@ static void ui_multibut_states_create(uiBut *but_active, uiHandleButtonData *dat ui_multibut_add(data, but); } } + + /* edit buttons proportionally to eachother + * note: if we mix buttons which are proportional and others which are not, + * this may work a bit strangely */ + if (but_active->rnaprop) { + if ((data->origvalue != 0.0) && (RNA_property_flag(but_active->rnaprop) & PROP_PROPORTIONAL)) { + data->multi_data.is_proportional = true; + } + } } static void ui_multibut_states_apply(bContext *C, uiHandleButtonData *data, uiBlock *block) { ARegion *ar = data->region; const double value_delta = data->value - data->origvalue; + const double value_scale = data->multi_data.is_proportional ? (data->value / data->origvalue) : 0.0; uiBut *but; BLI_assert(data->multi_data.init == BUTTON_MULTI_INIT_ENABLE); @@ -965,7 +977,12 @@ static void ui_multibut_states_apply(bContext *C, uiHandleButtonData *data, uiBl } else { /* dragging (use delta) */ - but->active->value = mbut_state->origvalue + value_delta; + if (data->multi_data.is_proportional) { + but->active->value = mbut_state->origvalue * value_scale; + } + else { + but->active->value = mbut_state->origvalue + value_delta; + } } ui_button_execute_end(C, ar, but, active_back); } diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 8bcd5888b2e..ff2d69ca05e 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -1465,6 +1465,7 @@ static void rna_def_curve(BlenderRNA *brna) prop = RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ); RNA_def_property_array(prop, 3); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size"); RNA_def_property_editable_func(prop, "rna_Curve_texspace_editable"); RNA_def_property_float_funcs(prop, "rna_Curve_texspace_size_get", "rna_Curve_texspace_size_set", NULL); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 407c5571b4c..99f427a9ab6 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -569,6 +569,7 @@ static void rna_def_image(BlenderRNA *brna) prop = RNA_def_property(srna, "generated_width", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gen_x"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_range(prop, 1, 65536); RNA_def_property_ui_text(prop, "Generated Width", "Generated image width"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update"); @@ -576,6 +577,7 @@ static void rna_def_image(BlenderRNA *brna) prop = RNA_def_property(srna, "generated_height", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gen_y"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_range(prop, 1, 65536); RNA_def_property_ui_text(prop, "Generated Height", "Generated image height"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update"); diff --git a/source/blender/makesrna/intern/rna_linestyle.c b/source/blender/makesrna/intern/rna_linestyle.c index 03319a9ccf8..e03a3352bac 100644 --- a/source/blender/makesrna/intern/rna_linestyle.c +++ b/source/blender/makesrna/intern/rna_linestyle.c @@ -848,11 +848,13 @@ static void rna_def_linestyle_modifiers(BlenderRNA *brna) prop = RNA_def_property(srna, "scale_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "scale_x"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_ui_text(prop, "Scale X", "Scaling factor that is applied along the X axis"); RNA_def_property_update(prop, NC_LINESTYLE, NULL); prop = RNA_def_property(srna, "scale_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "scale_y"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_ui_text(prop, "Scale Y", "Scaling factor that is applied along the Y axis"); RNA_def_property_update(prop, NC_LINESTYLE, NULL); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 6e1b39e9ea7..5d4f3e68d5b 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -2486,6 +2486,7 @@ void rna_def_texmat_common(StructRNA *srna, const char *texspace_editable) prop = RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size"); RNA_def_property_float_funcs(prop, "rna_Mesh_texspace_size_get", NULL, NULL); RNA_def_property_editable_func(prop, texspace_editable); diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 6bf7c8926e8..2627e628538 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -219,18 +219,21 @@ static void rna_def_metaelement(BlenderRNA *brna) prop = RNA_def_property(srna, "size_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "expx"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_range(prop, 0.0f, 20.0f); RNA_def_property_ui_text(prop, "Size X", "Size of element, use of components depends on element type"); RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); prop = RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "expy"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_range(prop, 0.0f, 20.0f); RNA_def_property_ui_text(prop, "Size Y", "Size of element, use of components depends on element type"); RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); prop = RNA_def_property(srna, "size_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "expz"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_range(prop, 0.0f, 20.0f); RNA_def_property_ui_text(prop, "Size Z", "Size of element, use of components depends on element type"); RNA_def_property_update(prop, 0, "rna_MetaBall_update_data"); @@ -353,6 +356,7 @@ static void rna_def_metaball(BlenderRNA *brna) prop = RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ); RNA_def_property_array(prop, 3); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size"); RNA_def_property_editable_func(prop, "rna_Meta_texspace_editable"); RNA_def_property_float_funcs(prop, "rna_Meta_texspace_size_get", "rna_Meta_texspace_size_set", NULL); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index f175d609026..91b522032ae 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1756,6 +1756,7 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) prop = RNA_def_property(srna, "aspect_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "aspectx"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_range(prop, 1, FLT_MAX); RNA_def_property_ui_range(prop, 1, 1000, 1, 3); RNA_def_property_ui_text(prop, "Horizontal Aspect Ratio", ""); @@ -1763,6 +1764,7 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) prop = RNA_def_property(srna, "aspect_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "aspecty"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_range(prop, 1, FLT_MAX); RNA_def_property_ui_range(prop, 1, 1000, 1, 3); RNA_def_property_ui_text(prop, "Vertical Aspect Ratio", ""); @@ -1770,6 +1772,7 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) prop = RNA_def_property(srna, "scale_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "scalex"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 1000, 1, 3); RNA_def_property_ui_text(prop, "Horizontal Scale", ""); @@ -1777,6 +1780,7 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) prop = RNA_def_property(srna, "scale_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "scaley"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 1000, 1, 3); RNA_def_property_ui_text(prop, "Vertical Scale", ""); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 63a51071c56..57713e7a037 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -3232,6 +3232,7 @@ static void def_sh_mapping(StructRNA *srna) prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_ui_text(prop, "Scale", ""); RNA_def_property_update(prop, 0, "rna_Mapping_Node_update"); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index c8ade9366fb..066b6f6654e 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -2300,6 +2300,7 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable"); RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); RNA_def_property_float_array_default(prop, default_scale); @@ -2346,6 +2347,7 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "dscale"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); RNA_def_property_float_array_default(prop, default_scale); RNA_def_property_ui_text(prop, "Delta Scale", "Extra scaling added to the scale of the object"); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 4ece8a25e73..4050b9b2df3 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -797,6 +797,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_editable_array_func(prop, "rna_PoseChannel_scale_editable"); RNA_def_property_float_array_default(prop, default_scale); RNA_def_property_ui_text(prop, "Scale", ""); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 07ab0d906fd..939eceed647 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -4152,6 +4152,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "xsch"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 4, 65536); RNA_def_property_ui_text(prop, "Resolution X", "Number of horizontal pixels in the rendered image"); @@ -4159,6 +4160,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "ysch"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 4, 65536); RNA_def_property_ui_text(prop, "Resolution Y", "Number of vertical pixels in the rendered image"); @@ -4188,6 +4190,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop = RNA_def_property(srna, "pixel_aspect_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xasp"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 1.0f, 200.0f); RNA_def_property_ui_text(prop, "Pixel Aspect X", @@ -4196,6 +4199,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop = RNA_def_property(srna, "pixel_aspect_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "yasp"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 1.0f, 200.0f); RNA_def_property_ui_text(prop, "Pixel Aspect Y", diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index b0e1ed04790..0d327d6da0a 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -538,6 +538,7 @@ static void rna_def_texmapping(BlenderRNA *brna) prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_ui_text(prop, "Scale", ""); RNA_def_property_update(prop, 0, "rna_Texture_mapping_update"); @@ -674,6 +675,7 @@ static void rna_def_mtex(BlenderRNA *brna) prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); + RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_ui_range(prop, -100, 100, 10, 2); RNA_def_property_ui_text(prop, "Size", "Set scaling for the texture's X, Y and Z sizes"); RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update"); |