diff options
Diffstat (limited to 'release/scripts/startup/bl_operators/wm.py')
-rw-r--r-- | release/scripts/startup/bl_operators/wm.py | 106 |
1 files changed, 89 insertions, 17 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 53c8d562297..af33e45668c 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -19,7 +19,9 @@ # <pep8 compliant> import bpy -from bpy.props import StringProperty, BoolProperty, IntProperty, FloatProperty +from bpy.props import StringProperty, BoolProperty, IntProperty, \ + FloatProperty, EnumProperty + from rna_prop_ui import rna_idprop_ui_prop_get, rna_idprop_ui_prop_clear @@ -106,7 +108,7 @@ class WM_OT_context_set_boolean(bpy.types.Operator): '''Set a context value.''' bl_idname = "wm.context_set_boolean" bl_label = "Context Set Boolean" - bl_options = {'UNDO'} + bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop value = BoolProperty(name="Value", @@ -119,7 +121,7 @@ class WM_OT_context_set_int(bpy.types.Operator): # same as enum '''Set a context value.''' bl_idname = "wm.context_set_int" bl_label = "Context Set" - bl_options = {'UNDO'} + bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop value = IntProperty(name="Value", description="Assign value", default=0) @@ -132,7 +134,7 @@ class WM_OT_context_scale_int(bpy.types.Operator): '''Scale an int context value.''' bl_idname = "wm.context_scale_int" bl_label = "Context Set" - bl_options = {'UNDO'} + bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop value = FloatProperty(name="Value", description="Assign value", default=1.0) @@ -168,7 +170,7 @@ class WM_OT_context_set_float(bpy.types.Operator): # same as enum '''Set a context value.''' bl_idname = "wm.context_set_float" bl_label = "Context Set Float" - bl_options = {'UNDO'} + bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop value = FloatProperty(name="Value", @@ -182,7 +184,7 @@ class WM_OT_context_set_string(bpy.types.Operator): # same as enum '''Set a context value.''' bl_idname = "wm.context_set_string" bl_label = "Context Set String" - bl_options = {'UNDO'} + bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop value = StringProperty(name="Value", @@ -195,7 +197,7 @@ class WM_OT_context_set_enum(bpy.types.Operator): '''Set a context value.''' bl_idname = "wm.context_set_enum" bl_label = "Context Set Enum" - bl_options = {'UNDO'} + bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop value = StringProperty(name="Value", @@ -209,7 +211,7 @@ class WM_OT_context_set_value(bpy.types.Operator): '''Set a context value.''' bl_idname = "wm.context_set_value" bl_label = "Context Set Value" - bl_options = {'UNDO'} + bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop value = StringProperty(name="Value", @@ -227,7 +229,7 @@ class WM_OT_context_toggle(bpy.types.Operator): '''Toggle a context value.''' bl_idname = "wm.context_toggle" bl_label = "Context Toggle" - bl_options = {'UNDO'} + bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop @@ -246,7 +248,7 @@ class WM_OT_context_toggle_enum(bpy.types.Operator): '''Toggle a context value.''' bl_idname = "wm.context_toggle_enum" bl_label = "Context Toggle Values" - bl_options = {'UNDO'} + bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop value_1 = StringProperty(name="Value", \ @@ -273,7 +275,7 @@ class WM_OT_context_cycle_int(bpy.types.Operator): '''vertex keys, groups' etc.''' bl_idname = "wm.context_cycle_int" bl_label = "Context Int Cycle" - bl_options = {'UNDO'} + bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop reverse = rna_reverse_prop @@ -307,7 +309,7 @@ class WM_OT_context_cycle_enum(bpy.types.Operator): '''Toggle a context value.''' bl_idname = "wm.context_cycle_enum" bl_label = "Context Enum Cycle" - bl_options = {'UNDO'} + bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop reverse = rna_reverse_prop @@ -360,7 +362,7 @@ class WM_OT_context_cycle_array(bpy.types.Operator): Useful for cycling the active mesh edit mode.''' bl_idname = "wm.context_cycle_array" bl_label = "Context Array Cycle" - bl_options = {'UNDO'} + bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop reverse = rna_reverse_prop @@ -406,7 +408,7 @@ class WM_MT_context_menu_enum(bpy.types.Menu): class WM_OT_context_menu_enum(bpy.types.Operator): bl_idname = "wm.context_menu_enum" bl_label = "Context Enum Menu" - bl_options = {'UNDO'} + bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop def execute(self, context): @@ -420,7 +422,7 @@ class WM_OT_context_set_id(bpy.types.Operator): '''Toggle a context value.''' bl_idname = "wm.context_set_id" bl_label = "Set Library ID" - bl_options = {'UNDO'} + bl_options = {'UNDO', 'INTERNAL'} data_path = rna_path_prop value = StringProperty(name="Value", @@ -457,14 +459,76 @@ doc_id = StringProperty(name="Doc ID", doc_new = StringProperty(name="Edit Description", description="", maxlen=1024, default="") +data_path_iter = StringProperty( + description="The data path relative to the context, must point to an iterable.") + +data_path_item = StringProperty( + description="The data path from each iterable to the value (int or float)") + + +class WM_OT_context_collection_boolean_set(bpy.types.Operator): + '''Set boolean values for a collection of items''' + bl_idname = "wm.context_collection_boolean_set" + bl_label = "Context Collection Boolean Set" + bl_options = {'UNDO', 'REGISTER', 'INTERNAL'} + + data_path_iter = data_path_iter + data_path_item = data_path_item + + type = EnumProperty(items=( + ('TOGGLE', "Toggle", ""), + ('ENABLE', "Enable", ""), + ('DISABLE', "Disable", ""), + ), + name="Type") + + def execute(self, context): + data_path_iter = self.data_path_iter + data_path_item = self.data_path_item + + items = list(getattr(context, data_path_iter)) + items_ok = [] + is_set = False + for item in items: + try: + value_orig = eval("item." + data_path_item) + except: + continue + + if value_orig == True: + is_set = True + elif value_orig == False: + pass + else: + self.report({'WARNING'}, "Non boolean value found: %s[ ].%s" % + (data_path_iter, data_path_item)) + return {'CANCELLED'} + + items_ok.append(item) + + if self.type == 'ENABLE': + is_set = True + elif self.type == 'DISABLE': + is_set = False + else: + is_set = not is_set + + exec_str = "item.%s = %s" % (data_path_item, is_set) + for item in items_ok: + exec(exec_str) + + return {'FINISHED'} + class WM_OT_context_modal_mouse(bpy.types.Operator): '''Adjust arbitrary values with mouse input''' bl_idname = "wm.context_modal_mouse" bl_label = "Context Modal Mouse" + bl_options = {'GRAB_POINTER', 'BLOCKING', 'INTERNAL'} + + data_path_iter = data_path_iter + data_path_item = data_path_item - data_path_iter = StringProperty(description="The data path relative to the context, must point to an iterable.") - data_path_item = StringProperty(description="The data path from each iterable to the value (int or float)") input_scale = FloatProperty(default=0.01, description="Scale the mouse movement by this value before applying the delta") invert = BoolProperty(default=False, description="Invert the mouse input") initial_x = IntProperty(options={'HIDDEN'}) @@ -940,6 +1004,14 @@ class WM_OT_copy_prev_settings(bpy.types.Operator): self.report({'ERROR'}, "Source path %r exists" % path_src) else: shutil.copytree(path_src, path_dst) + + # in 2.57 and earlier windows installers, system scripts were copied + # into the configuration directory, don't want to copy those + system_script = os.path.join(path_dst, 'scripts/modules/bpy_types.py') + if os.path.isfile(system_script): + shutil.rmtree(os.path.join(path_dst, 'scripts')) + shutil.rmtree(os.path.join(path_dst, 'plugins')) + # dont loose users work if they open the splash later. if bpy.data.is_saved is bpy.data.is_dirty is False: bpy.ops.wm.read_homefile() |