Gizmo: initial extrude support for non mesh types

This commit is contained in:
Campbell Barton
2018-11-21 09:09:34 +11:00
parent c17cc4c0d8
commit 34b9bd3a9b
2 changed files with 30 additions and 8 deletions

View File

@@ -63,6 +63,15 @@ def generate_from_enum_ex(
return tuple(tool_defs)
# Use for shared widget data.
class _template_widget:
class MESH_GGT_extrude:
@staticmethod
def draw_settings(context, layout, tool):
props = tool.gizmo_group_properties("MESH_GGT_extrude")
layout.prop(props, "axis_type", expand=True)
class _defs_view3d_generic:
@ToolDef.from_fn
def cursor():
@@ -355,8 +364,9 @@ class _defs_edit_armature:
return dict(
text="Extrude",
icon="ops.armature.extrude_move",
widget=None,
widget="MESH_GGT_extrude",
keymap=(),
draw_settings=_template_widget.MESH_GGT_extrude.draw_settings,
)
@ToolDef.from_fn
@@ -509,9 +519,6 @@ class _defs_edit_mesh:
@ToolDef.from_fn
def extrude():
def draw_settings(context, layout, tool):
props = tool.gizmo_group_properties("MESH_GGT_extrude")
layout.prop(props, "axis_type", expand=True)
return dict(
text="Extrude Region",
# The operator description isn't useful in this case, give our own.
@@ -523,7 +530,7 @@ class _defs_edit_mesh:
# Important to use same operator as 'E' key.
operator="view3d.edit_mesh_extrude_move_normal",
keymap=(),
draw_settings=draw_settings,
draw_settings=_template_widget.MESH_GGT_extrude.draw_settings,
)
@ToolDef.from_fn
@@ -733,8 +740,9 @@ class _defs_edit_curve:
return dict(
text="Extrude",
icon="ops.curve.extrude_move",
widget=None,
widget="MESH_GGT_extrude",
keymap=(),
draw_settings=_template_widget.MESH_GGT_extrude.draw_settings,
)
@ToolDef.from_fn

View File

@@ -117,7 +117,7 @@ static void gizmo_mesh_extrude_orientation_matrix_set_for_adjust(
swap_v3_v3(ggd->adjust->matrix_basis[ggd->adjust_axis], ggd->adjust->matrix_basis[2]);
}
static void gizmo_mesh_extrude_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
static void gizmo_mesh_extrude_setup(const bContext *C, wmGizmoGroup *gzgroup)
{
struct GizmoExtrudeGroup *ggd = MEM_callocN(sizeof(GizmoExtrudeGroup), __func__);
gzgroup->customdata = ggd;
@@ -141,7 +141,21 @@ static void gizmo_mesh_extrude_setup(const bContext *UNUSED(C), wmGizmoGroup *gz
}
{
ggd->ot_extrude = WM_operatortype_find("MESH_OT_extrude_context_move", true);
const Object *obedit = CTX_data_edit_object(C);
const char *op_idname = NULL;
if (obedit->type == OB_MESH) {
op_idname = "MESH_OT_extrude_context_move";
}
else if (obedit->type == OB_ARMATURE) {
op_idname = "ARMATURE_OT_extrude_move";
}
else if (obedit->type == OB_CURVE) {
op_idname = "CURVE_OT_extrude_move";
}
else {
BLI_assert(0);
}
ggd->ot_extrude = WM_operatortype_find(op_idname, true);
ggd->gzgt_axis_type_prop = RNA_struct_type_find_property(gzgroup->type->srna, "axis_type");
}