diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2017-06-01 21:41:18 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2017-06-01 21:46:18 +0300 |
commit | 46fc0bb87ebda166d08b23cbcca799acb2c54158 (patch) | |
tree | 1566d535d93c4fb81b962cdbc1346ca8242460f2 /source/blender/editors/transform/transform_ops.c | |
parent | 7f564d74f9edaaa41ce27c6e854869096f70b4da (diff) |
Move custom transform orientations to workspace
This commit moves the list of transform orientations from scenes to workspaces.
Main reasons for this are:
* Transform orientations are UI data and should not be stored in the scene.
* Introducion of workspaces caused some (expected) glitches with transform orientations. Mainly when removing one.
* Improves code.
More technically speaking, this commit does:
* Move list of custom transform orientations from Scene to WorkSpace struct.
* Store active transform orientation index separate from View3D.twmode (twmode can only be set to preprocessor defined values now).
* Display custom transform orientation name in header when transforming in it (used to show "global" which isn't really correct).
Diffstat (limited to 'source/blender/editors/transform/transform_ops.c')
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index a2a5307c707..dba442259d1 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -160,11 +160,12 @@ EnumPropertyItem rna_enum_transform_mode_types[] = static int select_orientation_exec(bContext *C, wmOperator *op) { + View3D *v3d = CTX_wm_view3d(C); int orientation = RNA_enum_get(op->ptr, "orientation"); - BIF_selectTransformOrientationValue(C, orientation); + BIF_selectTransformOrientationValue(v3d, orientation); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C)); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); return OPERATOR_FINISHED; } @@ -206,10 +207,9 @@ static void TRANSFORM_OT_select_orientation(struct wmOperatorType *ot) static int delete_orientation_exec(bContext *C, wmOperator *UNUSED(op)) { View3D *v3d = CTX_wm_view3d(C); - int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM); - BIF_removeTransformOrientationIndex(C, selected_index); - + BIF_removeTransformOrientationIndex(C, v3d->custom_orientation_index); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C)); @@ -223,18 +223,12 @@ static int delete_orientation_invoke(bContext *C, wmOperator *op, const wmEvent static int delete_orientation_poll(bContext *C) { - int selected_index = -1; View3D *v3d = CTX_wm_view3d(C); - + if (ED_operator_areaactive(C) == 0) return 0; - - - if (v3d) { - selected_index = (v3d->twmode - V3D_MANIP_CUSTOM); - } - return selected_index >= 0; + return (v3d->twmode >= V3D_MANIP_CUSTOM) && (v3d->custom_orientation_index != -1); } static void TRANSFORM_OT_delete_orientation(struct wmOperatorType *ot) |