diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-22 20:22:49 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-22 20:23:27 +0300 |
commit | a997b5d17bafa1b00df84da8d21e19131d1ef608 (patch) | |
tree | ebc723378d233ec91000b35a5ae08f6ce990f8e1 | |
parent | cc4dc2dce26c724e27598e4a1878e00fdf30dcf2 (diff) |
Tool System: transform can now toggle loc/rot/scale
-rw-r--r-- | release/scripts/startup/bl_ui/space_toolsystem_toolbar.py | 5 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 5 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_manipulator_3d.c | 62 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 10 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 22 |
5 files changed, 72 insertions, 32 deletions
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 933519eff4a..c5c17d2c3cb 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -173,11 +173,16 @@ class _defs_transform: @ToolDef.from_fn def transform(): + def draw_settings(context, layout, tool): + tool_settings = context.tool_settings + layout.prop(tool_settings, "use_manipulator_mode") + return dict( text="Transform", icon="ops.transform.transform", widget="TRANSFORM_WGT_manipulator", # No keymap default action, only for manipulators! + draw_settings=draw_settings, ) diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 53e9ada214b..08b1e47cbaa 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1526,5 +1526,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { + if (scene->toolsettings->manipulator_flag == 0) { + scene->toolsettings->manipulator_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; + } + } } } diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c index 75da0fc2d23..b04fd1909d4 100644 --- a/source/blender/editors/transform/transform_manipulator_3d.c +++ b/source/blender/editors/transform/transform_manipulator_3d.c @@ -159,14 +159,6 @@ enum { MAN_AXES_SCALE, }; -/* naming from old blender we may combine. */ -enum { - V3D_MANIP_TRANSLATE = 1, - V3D_MANIP_ROTATE = 2, - V3D_MANIP_SCALE = 4, -}; - - typedef struct ManipulatorGroup { bool all_hidden; int twtype; @@ -269,9 +261,9 @@ static bool manipulator_is_axis_visible( } } - if ((axis_type == MAN_AXES_TRANSLATE && !(twtype & V3D_MANIP_TRANSLATE)) || - (axis_type == MAN_AXES_ROTATE && !(twtype & V3D_MANIP_ROTATE)) || - (axis_type == MAN_AXES_SCALE && !(twtype & V3D_MANIP_SCALE))) + if ((axis_type == MAN_AXES_TRANSLATE && !(twtype & SCE_MANIP_TRANSLATE)) || + (axis_type == MAN_AXES_ROTATE && !(twtype & SCE_MANIP_ROTATE)) || + (axis_type == MAN_AXES_SCALE && !(twtype & SCE_MANIP_SCALE))) { return false; } @@ -301,34 +293,34 @@ static bool manipulator_is_axis_visible( case MAN_AXIS_SCALE_Z: return (rv3d->twdrawflag & MAN_SCALE_Z); case MAN_AXIS_SCALE_C: - return (rv3d->twdrawflag & MAN_SCALE_C && (twtype & V3D_MANIP_TRANSLATE) == 0); + return (rv3d->twdrawflag & MAN_SCALE_C && (twtype & SCE_MANIP_TRANSLATE) == 0); case MAN_AXIS_TRANS_XY: return (rv3d->twdrawflag & MAN_TRANS_X && rv3d->twdrawflag & MAN_TRANS_Y && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_TRANS_YZ: return (rv3d->twdrawflag & MAN_TRANS_Y && rv3d->twdrawflag & MAN_TRANS_Z && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_TRANS_ZX: return (rv3d->twdrawflag & MAN_TRANS_Z && rv3d->twdrawflag & MAN_TRANS_X && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_SCALE_XY: return (rv3d->twdrawflag & MAN_SCALE_X && rv3d->twdrawflag & MAN_SCALE_Y && - (twtype & V3D_MANIP_TRANSLATE) == 0 && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_TRANSLATE) == 0 && + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_SCALE_YZ: return (rv3d->twdrawflag & MAN_SCALE_Y && rv3d->twdrawflag & MAN_SCALE_Z && - (twtype & V3D_MANIP_TRANSLATE) == 0 && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_TRANSLATE) == 0 && + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_SCALE_ZX: return (rv3d->twdrawflag & MAN_SCALE_Z && rv3d->twdrawflag & MAN_SCALE_X && - (twtype & V3D_MANIP_TRANSLATE) == 0 && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_TRANSLATE) == 0 && + (twtype & SCE_MANIP_ROTATE) == 0); } return false; } @@ -1122,15 +1114,15 @@ static void manipulator_line_range(const int twtype, const short axis_type, floa switch (axis_type) { case MAN_AXES_TRANSLATE: - if (twtype & V3D_MANIP_SCALE) { + if (twtype & SCE_MANIP_SCALE) { *r_start = *r_len - ofs + 0.075f; } - if (twtype & V3D_MANIP_ROTATE) { + if (twtype & SCE_MANIP_ROTATE) { *r_len += ofs; } break; case MAN_AXES_SCALE: - if (twtype & (V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE)) { + if (twtype & (SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE)) { *r_len -= ofs + 0.025f; } break; @@ -1172,8 +1164,10 @@ static void manipulator_xform_message_subscribe( if (type_fn == TRANSFORM_WGT_manipulator) { extern PropertyRNA rna_ToolSettings_transform_pivot_point; + extern PropertyRNA rna_ToolSettings_use_manipulator_mode; const PropertyRNA *props[] = { - &rna_ToolSettings_transform_pivot_point + &rna_ToolSettings_transform_pivot_point, + &rna_ToolSettings_use_manipulator_mode, }; for (int i = 0; i < ARRAY_SIZE(props); i++) { WM_msg_subscribe_rna(mbus, &toolsettings_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); @@ -1304,16 +1298,16 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup wmKeyMapItem *kmi = km ? km->items.first : NULL; if (kmi == NULL) { - man->twtype |= V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE | V3D_MANIP_SCALE; + man->twtype = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; } else if (STREQ(kmi->idname, "TRANSFORM_OT_translate")) { - man->twtype |= V3D_MANIP_TRANSLATE; + man->twtype |= SCE_MANIP_TRANSLATE; } else if (STREQ(kmi->idname, "TRANSFORM_OT_rotate")) { - man->twtype |= V3D_MANIP_ROTATE; + man->twtype |= SCE_MANIP_ROTATE; } else if (STREQ(kmi->idname, "TRANSFORM_OT_resize")) { - man->twtype |= V3D_MANIP_SCALE; + man->twtype |= SCE_MANIP_SCALE; } BLI_assert(man->twtype != 0); } @@ -1340,7 +1334,7 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup case MAN_AXIS_SCALE_Z: if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { int draw_options = 0; - if ((man->twtype & (V3D_MANIP_ROTATE | V3D_MANIP_SCALE)) == 0) { + if ((man->twtype & (SCE_MANIP_ROTATE | SCE_MANIP_SCALE)) == 0) { draw_options |= ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM; } RNA_enum_set(axis->ptr, "draw_options", draw_options); @@ -1443,6 +1437,12 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou RegionView3D *rv3d = ar->regiondata; struct TransformBounds tbounds; + { + Scene *scene = CTX_data_scene(C); + int manipulator_flag_all = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; + man->twtype = scene->toolsettings->manipulator_flag & manipulator_flag_all; + } + /* skip, we don't draw anything anyway */ if ((man->all_hidden = (ED_transform_calc_manipulator_stats( @@ -1481,7 +1481,7 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou RNA_float_set(axis->ptr, "length", len); if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { - if (man->twtype & V3D_MANIP_ROTATE) { + if (man->twtype & SCE_MANIP_ROTATE) { /* Avoid rotate and translate arrows overlap. */ start_co[2] += 0.215f; } diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 3a0568112a0..c83b2510ed8 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1236,6 +1236,9 @@ typedef struct ToolSettings { /* Auto-IK */ short autoik_chainlen; /* runtime only */ + /* SCE_MPR_LOC/SCAL */ + char manipulator_flag; + /* Grease Pencil */ char gpencil_flags; /* flags/options for how the tool works */ char gpencil_src; /* for main 3D view Grease Pencil, where data comes from */ @@ -1245,7 +1248,7 @@ typedef struct ToolSettings { char gpencil_seq_align; /* : Sequencer Preview */ char gpencil_ima_align; /* : Image Editor */ - char _pad3[4]; + char _pad3[3]; /* Grease Pencil Sculpt */ struct GP_BrushEdit_Settings gp_sculpt; @@ -2000,6 +2003,11 @@ typedef enum eImagePaintMode { #define EDGE_MODE_TAG_BEVEL 4 #define EDGE_MODE_TAG_FREESTYLE 5 +/* ToolSettings.manipulator_flag */ +#define SCE_MANIP_TRANSLATE 1 +#define SCE_MANIP_ROTATE 2 +#define SCE_MANIP_SCALE 4 + /* ToolSettings.gpencil_flags */ typedef enum eGPencil_Flags { /* "Continuous Drawing" - The drawing operator enters a mode where multiple strokes can be drawn */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 4b0c955d51a..1fbb416f3d8 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -413,6 +413,13 @@ const EnumPropertyItem rna_enum_bake_pass_filter_type_items[] = { {0, NULL, 0, NULL, NULL} }; +static const EnumPropertyItem rna_enum_manipulator_items[] = { + {SCE_MANIP_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, + {SCE_MANIP_ROTATE, "ROTATE", 0, "Rotate", ""}, + {SCE_MANIP_SCALE, "SCALE", 0, "Scale", ""}, + {0, NULL, 0, NULL, NULL} +}; + #ifndef RNA_RUNTIME static const EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = { /* interpolation */ @@ -640,6 +647,14 @@ static void rna_GPencilBrush_name_set(PointerRNA *ptr, const char *value) /* ----------------- end of Grease pencil drawing brushes ------------*/ +static void rna_ToolSettings_manipulator_flag_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +{ + ToolSettings *ts = scene->toolsettings; + if ((ts->manipulator_flag & (SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE)) == 0) { + ts->manipulator_flag |= SCE_MANIP_TRANSLATE; + } +} + static void rna_SpaceImageEditor_uv_sculpt_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr)) { ED_space_image_uv_sculpt_update(bmain, bmain->wm.first, scene); @@ -2671,6 +2686,13 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_ORTHO, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ + prop = RNA_def_property(srna, "use_manipulator_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "manipulator_flag"); + RNA_def_property_enum_items(prop, rna_enum_manipulator_items); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_ui_text(prop, "Manipulator", ""); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ToolSettings_manipulator_flag_update"); + /* Grease Pencil */ prop = RNA_def_property(srna, "use_gpencil_continuous_drawing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_PAINTSESSIONS_ON); |