diff options
Diffstat (limited to 'source/blender/editors/transform/transform_ops.c')
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 109 |
1 files changed, 61 insertions, 48 deletions
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 81e065ee33a..c6d0d6cde2e 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -33,11 +33,12 @@ #include "BLI_math.h" #include "BLI_utildefines.h" -#include "BLF_translation.h" +#include "BLT_translation.h" #include "BKE_context.h" #include "BKE_global.h" #include "BKE_report.h" +#include "BKE_editmesh.h" #include "RNA_access.h" #include "RNA_define.h" @@ -63,23 +64,23 @@ typedef struct TransformModeItem { static const float VecOne[3] = {1, 1, 1}; -static char OP_TRANSLATION[] = "TRANSFORM_OT_translate"; -static char OP_ROTATION[] = "TRANSFORM_OT_rotate"; -static char OP_TOSPHERE[] = "TRANSFORM_OT_tosphere"; -static char OP_RESIZE[] = "TRANSFORM_OT_resize"; -static char OP_SKIN_RESIZE[] = "TRANSFORM_OT_skin_resize"; -static char OP_SHEAR[] = "TRANSFORM_OT_shear"; -static char OP_BEND[] = "TRANSFORM_OT_bend"; -static char OP_SHRINK_FATTEN[] = "TRANSFORM_OT_shrink_fatten"; -static char OP_PUSH_PULL[] = "TRANSFORM_OT_push_pull"; -static char OP_TILT[] = "TRANSFORM_OT_tilt"; -static char OP_TRACKBALL[] = "TRANSFORM_OT_trackball"; -static char OP_MIRROR[] = "TRANSFORM_OT_mirror"; -static char OP_EDGE_SLIDE[] = "TRANSFORM_OT_edge_slide"; -static char OP_VERT_SLIDE[] = "TRANSFORM_OT_vert_slide"; -static char OP_EDGE_CREASE[] = "TRANSFORM_OT_edge_crease"; -static char OP_EDGE_BWEIGHT[] = "TRANSFORM_OT_edge_bevelweight"; -static char OP_SEQ_SLIDE[] = "TRANSFORM_OT_seq_slide"; +static const char OP_TRANSLATION[] = "TRANSFORM_OT_translate"; +static const char OP_ROTATION[] = "TRANSFORM_OT_rotate"; +static const char OP_TOSPHERE[] = "TRANSFORM_OT_tosphere"; +static const char OP_RESIZE[] = "TRANSFORM_OT_resize"; +static const char OP_SKIN_RESIZE[] = "TRANSFORM_OT_skin_resize"; +static const char OP_SHEAR[] = "TRANSFORM_OT_shear"; +static const char OP_BEND[] = "TRANSFORM_OT_bend"; +static const char OP_SHRINK_FATTEN[] = "TRANSFORM_OT_shrink_fatten"; +static const char OP_PUSH_PULL[] = "TRANSFORM_OT_push_pull"; +static const char OP_TILT[] = "TRANSFORM_OT_tilt"; +static const char OP_TRACKBALL[] = "TRANSFORM_OT_trackball"; +static const char OP_MIRROR[] = "TRANSFORM_OT_mirror"; +static const char OP_EDGE_SLIDE[] = "TRANSFORM_OT_edge_slide"; +static const char OP_VERT_SLIDE[] = "TRANSFORM_OT_vert_slide"; +static const char OP_EDGE_CREASE[] = "TRANSFORM_OT_edge_crease"; +static const char OP_EDGE_BWEIGHT[] = "TRANSFORM_OT_edge_bevelweight"; +static const char OP_SEQ_SLIDE[] = "TRANSFORM_OT_seq_slide"; static void TRANSFORM_OT_translate(struct wmOperatorType *ot); static void TRANSFORM_OT_rotate(struct wmOperatorType *ot); @@ -140,8 +141,10 @@ EnumPropertyItem transform_mode_types[] = {TFM_MIRROR, "MIRROR", 0, "Mirror", ""}, {TFM_BONESIZE, "BONE_SIZE", 0, "Bonesize", ""}, {TFM_BONE_ENVELOPE, "BONE_ENVELOPE", 0, "Bone_Envelope", ""}, + {TFM_BONE_ENVELOPE_DIST, "BONE_ENVELOPE_DIST", 0, "Bone_Envelope_Distance", ""}, {TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", 0, "Curve_Shrinkfatten", ""}, {TFM_MASK_SHRINKFATTEN, "MASK_SHRINKFATTEN", 0, "Mask_Shrinkfatten", ""}, + {TFM_GPENCIL_SHRINKFATTEN, "GPENCIL_SHRINKFATTEN", 0, "GPencil_Shrinkfatten", ""}, {TFM_BONE_ROLL, "BONE_ROLL", 0, "Bone_Roll", ""}, {TFM_TIME_TRANSLATE, "TIME_TRANSLATE", 0, "Time_Translate", ""}, {TFM_TIME_SLIDE, "TIME_SLIDE", 0, "Time_Slide", ""}, @@ -171,12 +174,12 @@ static int select_orientation_invoke(bContext *C, wmOperator *UNUSED(op), const uiPopupMenu *pup; uiLayout *layout; - pup = uiPupMenuBegin(C, IFACE_("Orientation"), ICON_NONE); - layout = uiPupMenuLayout(pup); + pup = UI_popup_menu_begin(C, IFACE_("Orientation"), ICON_NONE); + layout = UI_popup_menu_layout(pup); uiItemsEnumO(layout, "TRANSFORM_OT_select_orientation", "orientation"); - uiPupMenuEnd(C, pup); + UI_popup_menu_end(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } static void TRANSFORM_OT_select_orientation(struct wmOperatorType *ot) @@ -324,6 +327,9 @@ static void transformops_loopsel_hack(bContext *C, wmOperator *op) } } } +#else +/* prevent removal by cleanup */ +# error "loopslide hack removed!" #endif /* USE_LOOPSLIDE_HACK */ @@ -484,7 +490,7 @@ static int transform_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* add temp handler */ WM_event_add_modal_handler(C, op); - op->flag |= OP_GRAB_POINTER; // XXX maybe we want this with the manipulator only? + op->flag |= OP_IS_MODAL_GRAB_CURSOR; // XXX maybe we want this with the manipulator only? return OPERATOR_RUNNING_MODAL; } } @@ -521,7 +527,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) RNA_def_enum(ot->srna, "proportional", proportional_editing_items, 0, "Proportional Editing", ""); prop = RNA_def_enum(ot->srna, "proportional_edit_falloff", proportional_falloff_items, 0, "Proportional Editing Falloff", "Falloff type for proportional editing mode"); - RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */ + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */ RNA_def_float(ot->srna, "proportional_size", 1, 0.00001f, FLT_MAX, "Proportional Size", "", 0.001, 100); } @@ -543,7 +549,11 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) } } } - + + if (flags & P_GPENCIL_EDIT) { + RNA_def_boolean(ot->srna, "gpencil_strokes", 0, "Edit Grease Pencil", "Edit selected Grease Pencil strokes"); + } + if ((flags & P_OPTIONS) && !(flags & P_NO_TEXSPACE)) { RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Texture Space", "Edit Object data texture space"); prop = RNA_def_boolean(ot->srna, "remove_on_cancel", 0, "Remove on Cancel", "Remove elements on cancel"); @@ -578,7 +588,7 @@ static void TRANSFORM_OT_translate(struct wmOperatorType *ot) RNA_def_float_vector_xyz(ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX); - Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_OPTIONS); + Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_OPTIONS | P_GPENCIL_EDIT); } static void TRANSFORM_OT_resize(struct wmOperatorType *ot) @@ -598,7 +608,7 @@ static void TRANSFORM_OT_resize(struct wmOperatorType *ot) RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX); - Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS); + Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS | P_GPENCIL_EDIT); } static int skin_resize_poll(bContext *C) @@ -633,8 +643,6 @@ static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot) static void TRANSFORM_OT_trackball(struct wmOperatorType *ot) { - PropertyRNA *prop; - /* identifiers */ ot->name = "Trackball"; ot->description = "Trackball style rotation of selected items"; @@ -649,16 +657,13 @@ static void TRANSFORM_OT_trackball(struct wmOperatorType *ot) ot->poll = ED_operator_screenactive; /* Maybe we could use float_vector_xyz here too? */ - prop = RNA_def_float_vector(ot->srna, "value", 2, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -FLT_MAX, FLT_MAX); - RNA_def_property_subtype(prop, PROP_ANGLE); + RNA_def_float_rotation(ot->srna, "value", 2, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -FLT_MAX, FLT_MAX); - Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP); + Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT); } static void TRANSFORM_OT_rotate(struct wmOperatorType *ot) { - PropertyRNA *prop; - /* identifiers */ ot->name = "Rotate"; ot->description = "Rotate selected items"; @@ -672,10 +677,9 @@ static void TRANSFORM_OT_rotate(struct wmOperatorType *ot) ot->cancel = transform_cancel; ot->poll = ED_operator_screenactive; - prop = RNA_def_float(ot->srna, "value", 0.0f, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2); - RNA_def_property_subtype(prop, PROP_ANGLE); + RNA_def_float_rotation(ot->srna, "value", 0, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2); - Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP); + Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_GPENCIL_EDIT); } static void TRANSFORM_OT_tilt(struct wmOperatorType *ot) @@ -721,7 +725,7 @@ static void TRANSFORM_OT_bend(struct wmOperatorType *ot) RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2); - Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP); + Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT); } static void TRANSFORM_OT_shear(struct wmOperatorType *ot) @@ -741,7 +745,7 @@ static void TRANSFORM_OT_shear(struct wmOperatorType *ot) RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX); - Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP); + Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT); // XXX Shear axis? } @@ -782,6 +786,8 @@ static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot) RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX); + RNA_def_boolean(ot->srna, "use_even_offset", true, "Offset Even", "Scale the offset to give more even thickness"); + Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP); } @@ -803,7 +809,7 @@ static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot) RNA_def_float_factor(ot->srna, "value", 0, 0, 1, "Factor", "", 0, 1); - Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP); + Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT); } static void TRANSFORM_OT_mirror(struct wmOperatorType *ot) @@ -821,11 +827,13 @@ static void TRANSFORM_OT_mirror(struct wmOperatorType *ot) ot->cancel = transform_cancel; ot->poll = ED_operator_screenactive; - Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL); + Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_GPENCIL_EDIT); } static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Edge Slide"; ot->description = "Slide an edge loop along a mesh"; @@ -837,9 +845,12 @@ static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_editmesh; + ot->poll = ED_operator_editmesh_region_view3d; - RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f); + RNA_def_float_factor(ot->srna, "value", 0, -10.0f, 10.0f, "Factor", "", -1.0f, 1.0f); + + prop = RNA_def_boolean(ot->srna, "single_side", false, "Single Side", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); Transform_Properties(ot, P_MIRROR | P_SNAP | P_CORRECT_UV); } @@ -857,11 +868,11 @@ static void TRANSFORM_OT_vert_slide(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_editmesh; + ot->poll = ED_operator_editmesh_region_view3d; RNA_def_float_factor(ot->srna, "value", 0, -10.0f, 10.0f, "Factor", "", -1.0f, 1.0f); - Transform_Properties(ot, P_MIRROR | P_SNAP); + Transform_Properties(ot, P_MIRROR | P_SNAP | P_CORRECT_UV); } static void TRANSFORM_OT_edge_crease(struct wmOperatorType *ot) @@ -967,7 +978,7 @@ static void TRANSFORM_OT_transform(struct wmOperatorType *ot) RNA_def_float_vector(ot->srna, "value", 4, NULL, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX); - Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP); + Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_GPENCIL_EDIT); } void transform_operatortypes(void) @@ -1107,8 +1118,10 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac WM_keymap_add_item(keymap, "NODE_OT_move_detach_links_release", EVT_TWEAK_A, KM_ANY, KM_ALT, 0); WM_keymap_add_item(keymap, "NODE_OT_move_detach_links", EVT_TWEAK_S, KM_ANY, KM_ALT, 0); - /* dettach and translate */ - WM_keymap_add_item(keymap, "NODE_OT_detach_translate_attach", FKEY, KM_PRESS, KM_ALT, 0); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.snap_node_element"); break; case SPACE_SEQ: WM_keymap_add_item(keymap, OP_SEQ_SLIDE, GKEY, KM_PRESS, 0, 0); |