From 7f3da8f5c91e5dbf030b938a5d852ebc9ce6b361 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2016 05:01:15 +1100 Subject: UI: Presets for scene units This adds simple preset menu for unit scale scene property. D1799 by @alm --- release/scripts/startup/bl_operators/presets.py | 18 ++++++++++ release/scripts/startup/bl_ui/properties_scene.py | 43 ++++++++++++++++++----- 2 files changed, 53 insertions(+), 8 deletions(-) (limited to 'release/scripts/startup') diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index daa8ab52766..e01e509b292 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -662,3 +662,21 @@ class WM_MT_operator_presets(Menu): return AddPresetOperator.operator_path(self.operator) preset_operator = "script.execute_preset" + + +class AddPresetUnitsLength(AddPresetBase, Operator): + """Add or remove length units preset""" + bl_idname = "scene.units_length_preset_add" + bl_label = "Add Length Units Preset" + preset_menu = "SCENE_MT_units_length_presets" + + preset_defines = [ + "scene = bpy.context.scene" + ] + + preset_values = [ + "scene.unit_settings.system", + "scene.unit_settings.scale_length", + ] + + preset_subdir = "units_length" diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index bbf11abe6d9..a05f0ac9618 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -18,7 +18,12 @@ # import bpy -from bpy.types import Panel, UIList +from bpy.types import ( + Menu, + Panel, + UIList, + ) + from rna_prop_ui import PropertyPanel from bl_ui.properties_physics_common import ( @@ -27,6 +32,14 @@ from bl_ui.properties_physics_common import ( ) +class SCENE_MT_units_length_presets(Menu): + """Sets the unit of measure for properties that use length values""" + bl_label = "Unit Presets" + preset_subdir = "units_length" + preset_operator = "script.execute_preset" + draw = Menu.draw_preset + + class SCENE_UL_keying_set_paths(UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): # assert(isinstance(item, bpy.types.KeyingSetPath) @@ -75,14 +88,28 @@ class SCENE_PT_unit(SceneButtonsPanel, Panel): unit = context.scene.unit_settings - col = layout.column() - col.row().prop(unit, "system", expand=True) - col.row().prop(unit, "system_rotation", expand=True) + row = layout.row(align=True) + row.menu("SCENE_MT_units_length_presets", text=SCENE_MT_units_length_presets.bl_label) + row.operator("scene.units_length_preset_add", text="", icon='ZOOMIN') + row.operator("scene.units_length_preset_add", text="", icon='ZOOMOUT').remove_active = True - if unit.system != 'NONE': - row = layout.row() - row.prop(unit, "scale_length", text="Scale") - row.prop(unit, "use_separate") + layout.separator() + + split = layout.split(percentage=0.35) + split.label("Length:") + split.prop(unit, "system", text="") + split = layout.split(percentage=0.35) + split.label("Angle:") + split.prop(unit, "system_rotation", text="") + + col = layout.column() + col.enabled = unit.system != 'NONE' + split = col.split(percentage=0.35) + split.label("Unit Scale:") + split.prop(unit, "scale_length", text="") + split = col.split(percentage=0.35) + split.row() + split.prop(unit, "use_separate") class SceneKeyingSetsPanel: -- cgit v1.2.3