diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-03-09 02:34:38 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-03-09 02:34:38 +0300 |
commit | d1bf196de1f4fb35921a383e15f2c87e3333f702 (patch) | |
tree | e2b94ea1dbb92d2d26548c193263c703e1444424 /release/scripts | |
parent | 754b22bd515790cd31b8e40f188b2e07196d76a8 (diff) |
improve brush size keys so they dont change by 20 each time (bad for small brushes), added wm.context_scale_int() operator.
Diffstat (limited to 'release/scripts')
-rw-r--r-- | release/scripts/op/wm.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/release/scripts/op/wm.py b/release/scripts/op/wm.py index 4deab93e6f1..a2c05562c65 100644 --- a/release/scripts/op/wm.py +++ b/release/scripts/op/wm.py @@ -100,6 +100,42 @@ class WM_OT_context_set_int(bpy.types.Operator): # same as enum execute = execute_context_assign +class WM_OT_context_scale_int(bpy.types.Operator): # same as enum + '''Scale an int context value.''' + bl_idname = "wm.context_scale_int" + bl_label = "Context Set" + bl_options = {'UNDO'} + + path = rna_path_prop + value = FloatProperty(name="Value", description="Assign value", default=1.0) + always_step = BoolProperty(name="Always Step", + description="Always adjust the value by a minimum of 1 when 'value' is not 1.0.", + default=True) + + def execute(self, context): + if context_path_validate(context, self.properties.path) is Ellipsis: + return {'PASS_THROUGH'} + + value = self.properties.value + path = self.properties.path + + if value == 1.0: # nothing to do + return {'CANCELLED'} + + if getattr(self.properties, "always_step", False): + if value > 1.0: + add = "1" + func = "max" + else: + add = "-1" + func = "min" + exec("context.%s = %s(round(context.%s * value), context.%s + %s)" % (path, func, path, path, add)) + else: + exec("context.%s *= value" % self.properties.path) + + return {'FINISHED'} + + class WM_OT_context_set_float(bpy.types.Operator): # same as enum '''Set a context value.''' bl_idname = "wm.context_set_float" @@ -510,6 +546,7 @@ classes = [ WM_OT_context_set_boolean, WM_OT_context_set_int, + WM_OT_context_scale_int, WM_OT_context_set_float, WM_OT_context_set_string, WM_OT_context_set_enum, |