Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-05-28 07:34:17 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-05-28 08:08:58 +0300
commit122cb1aea82362d1b2ff3dda4fc7d309933308be (patch)
tree516bffb58226cd128f2ed029e51739f9938ef94f /release/scripts/startup
parent16943c01464c7119480cae7cf5d089e1c597d8ab (diff)
Object: new add object tool, currently for primitive types
- Interactively adding primitives with two clicks. - Scene orientation used for new objects. - Depth [view-plane, axis-plane, surface] - Origin [base, center] - Primitive types [cube, cylinder, cone, uv-sphere, ico-sphere ] - Settings for object types in the top-bar. Shortcuts: - Snapping (Ctrl). - Constrain 1:1 aspect (Shift). - Toggle center (Alt). Part of T57210 design task.
Diffstat (limited to 'release/scripts/startup')
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_toolbar.py142
1 files changed, 128 insertions, 14 deletions
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index c1730f33798..1aa5dde168b 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -436,10 +436,124 @@ class _defs_view3d_select:
)
+class _defs_view3d_add:
+
+ # Layout tweaks here would be good to avoid,
+ # this shows limits in layout engine, as buttons are using a lot of space.
+ @staticmethod
+ def draw_settings_interactive_add(layout, tool):
+ props = tool.operator_properties("view3d.interactive_add")
+ row = layout.row()
+ row.scale_x = 0.8
+ row.label(text="Depth:")
+ row = layout.row()
+ row.scale_x = 0.9
+ row.prop(props, "plane_depth", text="")
+ row = layout.row()
+ row.prop(props, "plane_axis", text="")
+ row = layout.row()
+ row.scale_x = 0.7
+ row.prop(props, "plane_origin")
+
+ @ToolDef.from_fn
+ def cube_add():
+ def draw_settings(_context, layout, tool):
+ _defs_view3d_add.draw_settings_interactive_add(layout, tool)
+ return dict(
+ idname="builtin.primitive_cube_add",
+ label="Add Cube",
+ icon="ops.mesh.primitive_cube_add_gizmo",
+ description=(
+ "Add cube to mesh interactively"
+ ),
+ widget="VIEW3D_GGT_placement",
+ keymap="3D View Tool: Object, Add Primitive",
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
+ def cone_add():
+ def draw_settings(_context, layout, tool):
+ _defs_view3d_add.draw_settings_interactive_add(layout, tool)
+
+ props = tool.operator_properties("mesh.primitive_cone_add")
+ layout.prop(props, "vertices")
+ layout.prop(props, "end_fill_type")
+ return dict(
+ idname="builtin.primitive_cone_add",
+ label="Add Cone",
+ icon="ops.mesh.primitive_cube_add_gizmo",
+ description=(
+ "Add cone to mesh interactively"
+ ),
+ widget="VIEW3D_GGT_placement",
+ keymap="3D View Tool: Object, Add Primitive",
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
+ def cylinder_add():
+ def draw_settings(_context, layout, tool):
+ _defs_view3d_add.draw_settings_interactive_add(layout, tool)
+
+ props = tool.operator_properties("mesh.primitive_cylinder_add")
+ layout.prop(props, "vertices")
+ layout.prop(props, "end_fill_type")
+ return dict(
+ idname="builtin.primitive_cylinder_add",
+ label="Add Cylinder",
+ icon="ops.mesh.primitive_cylinder_add_gizmo",
+ description=(
+ "Add cylinder to mesh interactively"
+ ),
+ widget="VIEW3D_GGT_placement",
+ keymap="3D View Tool: Object, Add Primitive",
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
+ def uv_sphere_add():
+ def draw_settings(_context, layout, tool):
+ _defs_view3d_add.draw_settings_interactive_add(layout, tool)
+
+ props = tool.operator_properties("mesh.primitive_uv_sphere_add")
+ layout.prop(props, "segments")
+ layout.prop(props, "ring_count")
+ return dict(
+ idname="builtin.primitive_uv_sphere_add",
+ label="Add UV Sphere",
+ icon="ops.mesh.primitive_sphere_add_gizmo",
+ description=(
+ "Add cylinder to mesh interactively"
+ ),
+ widget="VIEW3D_GGT_placement",
+ keymap="3D View Tool: Object, Add Primitive",
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
+ def ico_sphere_add():
+ def draw_settings(_context, layout, tool):
+ _defs_view3d_add.draw_settings_interactive_add(layout, tool)
+
+ props = tool.operator_properties("mesh.primitive_ico_sphere_add")
+ layout.prop(props, "subdivisions")
+ return dict(
+ idname="builtin.primitive_ico_sphere_add",
+ label="Add Ico Sphere",
+ icon="ops.mesh.primitive_sphere_add_gizmo",
+ description=(
+ "Add cylinder to mesh interactively"
+ ),
+ widget="VIEW3D_GGT_placement",
+ keymap="3D View Tool: Object, Add Primitive",
+ draw_settings=draw_settings,
+ )
+
+
# -----------------------------------------------------------------------------
# Object Modes (named based on context.mode)
-
class _defs_edit_armature:
@ToolDef.from_fn
@@ -498,19 +612,6 @@ class _defs_edit_armature:
class _defs_edit_mesh:
@ToolDef.from_fn
- def cube_add():
- return dict(
- idname="builtin.add_cube",
- label="Add Cube",
- icon="ops.mesh.primitive_cube_add_gizmo",
- description=(
- "Add cube to mesh interactively"
- ),
- widget=None,
- keymap=(),
- )
-
- @ToolDef.from_fn
def rip_region():
def draw_settings(_context, layout, tool):
props = tool.operator_properties("mesh.rip_move")
@@ -2147,6 +2248,14 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
),
)
+ _tools_view3d_add = (
+ _defs_view3d_add.cube_add,
+ _defs_view3d_add.cone_add,
+ _defs_view3d_add.cylinder_add,
+ _defs_view3d_add.uv_sphere_add,
+ _defs_view3d_add.ico_sphere_add,
+ )
+
_tools_default = (
*_tools_select,
_defs_view3d_generic.cursor,
@@ -2165,6 +2274,9 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
],
'OBJECT': [
*_tools_default,
+
+ None,
+ _tools_view3d_add,
],
'POSE': [
*_tools_default,
@@ -2193,6 +2305,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
'EDIT_MESH': [
*_tools_default,
None,
+ _tools_view3d_add,
+ None,
(
_defs_edit_mesh.extrude,
_defs_edit_mesh.extrude_dissolve_and_intersect,