From b95df9957d9217a7b850b6311ff6d569dbb9111b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 20 Apr 2018 15:59:42 +0200 Subject: UI: move manipulator to tool-system Current manipulator now follows active tool. --- source/blender/blenloader/intern/readfile.c | 2 - .../blender/blenloader/intern/versioning_legacy.c | 15 --- source/blender/editors/mesh/editmesh_bevel.c | 8 +- source/blender/editors/mesh/editmesh_bisect.c | 10 +- source/blender/editors/mesh/editmesh_extrude.c | 2 +- source/blender/editors/mesh/editmesh_inset.c | 8 +- source/blender/editors/space_view3d/space_view3d.c | 3 +- source/blender/editors/space_view3d/view3d_edit.c | 46 --------- .../blender/editors/space_view3d/view3d_header.c | 3 - .../blender/editors/space_view3d/view3d_intern.h | 1 - source/blender/editors/space_view3d/view3d_ops.c | 1 - source/blender/editors/transform/transform.h | 2 +- .../blender/editors/transform/transform_generics.c | 6 +- .../editors/transform/transform_manipulator.c | 111 ++++++++++++++------- source/blender/makesdna/DNA_view3d_types.h | 5 - source/blender/makesrna/intern/rna_space.c | 17 ---- 16 files changed, 93 insertions(+), 147 deletions(-) (limited to 'source') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 112b97b5901..5dc98964fbd 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7347,8 +7347,6 @@ void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions) } /* this was not initialized correct always */ - if (v3d->twtype == 0) - v3d->twtype = V3D_MANIP_TRANSLATE; if (v3d->gridsubdiv == 0) v3d->gridsubdiv = 10; } diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index b31aa7047b0..57530c6a004 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -1300,7 +1300,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile <= 236) { Object *ob; Camera *cam = main->camera.first; - bScreen *sc; while (cam) { if (cam->ortho_scale == 0.0f) { @@ -1310,22 +1309,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } cam = cam->id.next; } - /* set manipulator type */ /* force oops draw if depgraph was set*/ /* set time line var */ - for (sc = main->screen.first; sc; sc = sc->id.next) { - ScrArea *sa; - for (sa = sc->areabase.first; sa; sa = sa->next) { - SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_VIEW3D) { - View3D *v3d = (View3D *) sl; - if (v3d->twtype == 0) - v3d->twtype = V3D_MANIP_TRANSLATE; - } - } - } - } /* softbody init new vars */ for (ob = main->object.first; ob; ob = ob->id.next) { diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index c8d33a9cc60..ca5af7a535d 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -87,7 +87,7 @@ typedef struct { float mcenter[2]; BMBackup mesh_backup; void *draw_handle_pixel; - short twtype; + short twflag; short value_mode; /* Which value does mouse movement and numeric input affect? */ float segments; /* Segments as float so smooth mouse pan works in small increments */ } BevelData; @@ -180,8 +180,8 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) G.moving = G_TRANSFORM_EDIT; if (v3d) { - opdata->twtype = v3d->twtype; - v3d->twtype = 0; + opdata->twflag = v3d->twflag; + v3d->twflag = 0; } } @@ -254,7 +254,7 @@ static void edbm_bevel_exit(bContext *C, wmOperator *op) EDBM_redo_state_free(&opdata->mesh_backup, NULL, false); ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel); if (v3d) { - v3d->twtype = opdata->twtype; + v3d->twflag = opdata->twflag; } G.moving = 0; } diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index 741d16206cd..ac8c1f16477 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -70,7 +70,7 @@ typedef struct { /* modal only */ BMBackup mesh_backup; bool is_first; - short twtype; + short twflag; } BisectData; static bool mesh_bisect_interactive_calc( @@ -156,8 +156,8 @@ static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* misc other vars */ G.moving = G_TRANSFORM_EDIT; - opdata->twtype = v3d->twtype; - v3d->twtype = 0; + opdata->twflag = v3d->twflag; + v3d->twflag = 0; /* initialize modal callout */ ED_area_headerprint(CTX_wm_area(C), IFACE_("LMB: Click and drag to draw cut line")); @@ -169,7 +169,7 @@ static void edbm_bisect_exit(bContext *C, BisectData *opdata) { View3D *v3d = CTX_wm_view3d(C); EDBM_redo_state_free(&opdata->mesh_backup, NULL, false); - v3d->twtype = opdata->twtype; + v3d->twflag = opdata->twflag; G.moving = 0; } @@ -199,7 +199,7 @@ static int mesh_bisect_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Setup manipulators */ { View3D *v3d = CTX_wm_view3d(C); - if (v3d && (v3d->twtype & V3D_MANIPULATOR_DRAW)) { + if (v3d && (v3d->twflag & V3D_MANIPULATOR_DRAW)) { WM_manipulator_group_type_ensure("MESH_WGT_bisect"); } } diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 3031d2e09b3..2c60df9abe1 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -839,7 +839,7 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e #ifdef USE_MANIPULATOR if (ret & OPERATOR_FINISHED) { /* Setup manipulators */ - if (v3d && (v3d->twtype & V3D_MANIPULATOR_DRAW)) { + if (v3d && (v3d->twflag & V3D_MANIPULATOR_DRAW)) { WM_manipulator_group_type_ensure("MESH_WGT_spin"); } } diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index 3833b84b5d2..53ba5e4316f 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -72,7 +72,7 @@ typedef struct { float mcenter[2]; BMBackup mesh_backup; void *draw_handle_pixel; - short twtype; + short twflag; } InsetData; @@ -152,8 +152,8 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal) ar->type, ED_region_draw_mouse_line_cb, opdata->mcenter, REGION_DRAW_POST_PIXEL); G.moving = G_TRANSFORM_EDIT; if (v3d) { - opdata->twtype = v3d->twtype; - v3d->twtype = 0; + opdata->twflag = v3d->twflag; + v3d->twflag = 0; } } @@ -173,7 +173,7 @@ static void edbm_inset_exit(bContext *C, wmOperator *op) EDBM_redo_state_free(&opdata->mesh_backup, NULL, false); ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel); if (v3d) { - v3d->twtype = opdata->twtype; + v3d->twflag = opdata->twflag; } G.moving = 0; } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index bb521a1a3d9..a87154ea049 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -343,7 +343,6 @@ static SpaceLink *view3d_new(const bContext *C) v3d->far = 1000.0f; v3d->twflag |= U.manipulator_flag & V3D_MANIPULATOR_DRAW; - v3d->twtype = V3D_MANIP_TRANSLATE; v3d->around = V3D_AROUND_CENTER_MEAN; scene->orientation_index_custom = -1; @@ -707,7 +706,6 @@ static void view3d_widgets(void) wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure( &(const struct wmManipulatorMapType_Params){SPACE_VIEW3D, RGN_TYPE_WINDOW}); - WM_manipulatorgrouptype_append_and_link(mmap_type, TRANSFORM_WGT_manipulator); WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_spot); WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_area); WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp_target); @@ -717,6 +715,7 @@ static void view3d_widgets(void) WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_empty_image); WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_armature_spline); + WM_manipulatorgrouptype_append(TRANSFORM_WGT_manipulator); WM_manipulatorgrouptype_append(VIEW3D_WGT_xform_cage); WM_manipulatorgrouptype_append(VIEW3D_WGT_ruler); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 858a4a1dfb6..f80d4a3b4b4 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -4632,52 +4632,6 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot) /** \} */ -/* -------------------------------------------------------------------- */ -/** \name Enable Transform Manipulator Operator - * \{ */ - -static int enable_manipulator_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) -{ - View3D *v3d = CTX_wm_view3d(C); - - v3d->twtype = 0; - - if (RNA_boolean_get(op->ptr, "translate")) - v3d->twtype |= V3D_MANIP_TRANSLATE; - if (RNA_boolean_get(op->ptr, "rotate")) - v3d->twtype |= V3D_MANIP_ROTATE; - if (RNA_boolean_get(op->ptr, "scale")) - v3d->twtype |= V3D_MANIP_SCALE; - - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); - - return OPERATOR_FINISHED; -} - -void VIEW3D_OT_enable_manipulator(wmOperatorType *ot) -{ - PropertyRNA *prop; - - /* identifiers */ - ot->name = "Enable 3D Manipulator"; - ot->description = "Enable the transform manipulator for use"; - ot->idname = "VIEW3D_OT_enable_manipulator"; - - /* api callbacks */ - ot->invoke = enable_manipulator_invoke; - ot->poll = ED_operator_view3d_active; - - /* properties */ - prop = RNA_def_boolean(ot->srna, "translate", 0, "Translate", "Enable the translate manipulator"); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "rotate", 0, "Rotate", "Enable the rotate manipulator"); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "scale", 0, "Scale", "Enable the scale manipulator"); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); -} - -/** \} */ - /* -------------------------------------------------------------------- */ /** \name Toggle Render Shading Operator * \{ */ diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 0aa9a1700c3..6038a53f8a2 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -336,9 +336,6 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) /* Transform widget / manipulators */ row = uiLayoutRow(layout, true); uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); - if (v3d->twflag & V3D_MANIPULATOR_DRAW) { - uiItemR(row, &v3dptr, "transform_manipulators", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); - } uiItemR(row, &sceneptr, "transform_orientation", 0, "", ICON_NONE); } diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 58bf05299ea..7e0dc20203d 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -99,7 +99,6 @@ void VIEW3D_OT_view_orbit(struct wmOperatorType *ot); void VIEW3D_OT_view_roll(struct wmOperatorType *ot); void VIEW3D_OT_clip_border(struct wmOperatorType *ot); void VIEW3D_OT_cursor3d(struct wmOperatorType *ot); -void VIEW3D_OT_enable_manipulator(struct wmOperatorType *ot); void VIEW3D_OT_render_border(struct wmOperatorType *ot); void VIEW3D_OT_clear_render_border(struct wmOperatorType *ot); void VIEW3D_OT_zoom_border(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 0274ddd82fc..2e0ca07f601 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -196,7 +196,6 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_render_border); WM_operatortype_append(VIEW3D_OT_clear_render_border); WM_operatortype_append(VIEW3D_OT_zoom_border); - WM_operatortype_append(VIEW3D_OT_enable_manipulator); WM_operatortype_append(VIEW3D_OT_cursor3d); WM_operatortype_append(VIEW3D_OT_select_lasso); WM_operatortype_append(VIEW3D_OT_select_menu); diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 4a53bb2360d..1df6ee9c8c9 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -497,7 +497,7 @@ typedef struct TransInfo { short current_orientation; TransformOrientation *custom_orientation; /* this gets used when current_orientation is V3D_MANIP_CUSTOM */ - short twtype; /* backup from view3d, to restore on end */ + short twflag; /* backup from view3d, to restore on end */ short prop_mode; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 4bcc8fe9e71..68240da1ccb 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1315,8 +1315,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve /* turn manipulator off during transform */ if (t->flag & T_MODAL) { - t->twtype = v3d->twtype; - v3d->twtype = 0; + t->twflag = v3d->twflag; + v3d->twflag = 0; } if (v3d->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN; @@ -1627,7 +1627,7 @@ void postTrans(bContext *C, TransInfo *t) View3D *v3d = t->sa->spacedata.first; /* restore manipulator */ if (t->flag & T_MODAL) { - v3d->twtype = t->twtype; + v3d->twflag = t->twflag; } } diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 6fb9ed862ab..8221412b32a 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -155,8 +155,17 @@ 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; struct wmManipulator *manipulators[MAN_AXIS_LAST]; } ManipulatorGroup; @@ -249,7 +258,7 @@ static uint manipulator_orientation_axis(const int axis_idx, bool *r_is_plane) } static bool manipulator_is_axis_visible( - const View3D *v3d, const RegionView3D *rv3d, + const RegionView3D *rv3d, const int twtype, const float idot[3], const int axis_type, const int axis_idx) { bool is_plane = false; @@ -265,9 +274,9 @@ static bool manipulator_is_axis_visible( } } - if ((axis_type == MAN_AXES_TRANSLATE && !(v3d->twtype & V3D_MANIP_TRANSLATE)) || - (axis_type == MAN_AXES_ROTATE && !(v3d->twtype & V3D_MANIP_ROTATE)) || - (axis_type == MAN_AXES_SCALE && !(v3d->twtype & V3D_MANIP_SCALE))) + 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))) { return false; } @@ -297,34 +306,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 && (v3d->twtype & V3D_MANIP_TRANSLATE) == 0); + return (rv3d->twdrawflag & MAN_SCALE_C && (twtype & V3D_MANIP_TRANSLATE) == 0); case MAN_AXIS_TRANS_XY: return (rv3d->twdrawflag & MAN_TRANS_X && rv3d->twdrawflag & MAN_TRANS_Y && - (v3d->twtype & V3D_MANIP_ROTATE) == 0); + (twtype & V3D_MANIP_ROTATE) == 0); case MAN_AXIS_TRANS_YZ: return (rv3d->twdrawflag & MAN_TRANS_Y && rv3d->twdrawflag & MAN_TRANS_Z && - (v3d->twtype & V3D_MANIP_ROTATE) == 0); + (twtype & V3D_MANIP_ROTATE) == 0); case MAN_AXIS_TRANS_ZX: return (rv3d->twdrawflag & MAN_TRANS_Z && rv3d->twdrawflag & MAN_TRANS_X && - (v3d->twtype & V3D_MANIP_ROTATE) == 0); + (twtype & V3D_MANIP_ROTATE) == 0); case MAN_AXIS_SCALE_XY: return (rv3d->twdrawflag & MAN_SCALE_X && rv3d->twdrawflag & MAN_SCALE_Y && - (v3d->twtype & V3D_MANIP_TRANSLATE) == 0 && - (v3d->twtype & V3D_MANIP_ROTATE) == 0); + (twtype & V3D_MANIP_TRANSLATE) == 0 && + (twtype & V3D_MANIP_ROTATE) == 0); case MAN_AXIS_SCALE_YZ: return (rv3d->twdrawflag & MAN_SCALE_Y && rv3d->twdrawflag & MAN_SCALE_Z && - (v3d->twtype & V3D_MANIP_TRANSLATE) == 0 && - (v3d->twtype & V3D_MANIP_ROTATE) == 0); + (twtype & V3D_MANIP_TRANSLATE) == 0 && + (twtype & V3D_MANIP_ROTATE) == 0); case MAN_AXIS_SCALE_ZX: return (rv3d->twdrawflag & MAN_SCALE_Z && rv3d->twdrawflag & MAN_SCALE_X && - (v3d->twtype & V3D_MANIP_TRANSLATE) == 0 && - (v3d->twtype & V3D_MANIP_ROTATE) == 0); + (twtype & V3D_MANIP_TRANSLATE) == 0 && + (twtype & V3D_MANIP_ROTATE) == 0); } return false; } @@ -1093,7 +1102,7 @@ static void manipulator_prepare_mat( * Sets up \a r_start and \a r_len to define arrow line range. * Needed to adjust line drawing for combined manipulator axis types. */ -static void manipulator_line_range(const View3D *v3d, const short axis_type, float *r_start, float *r_len) +static void manipulator_line_range(const int twtype, const short axis_type, float *r_start, float *r_len) { const float ofs = 0.2f; @@ -1102,15 +1111,15 @@ static void manipulator_line_range(const View3D *v3d, const short axis_type, flo switch (axis_type) { case MAN_AXES_TRANSLATE: - if (v3d->twtype & V3D_MANIP_SCALE) { + if (twtype & V3D_MANIP_SCALE) { *r_start = *r_len - ofs + 0.075f; } - if (v3d->twtype & V3D_MANIP_ROTATE) { + if (twtype & V3D_MANIP_ROTATE) { *r_len += ofs; } break; case MAN_AXES_SCALE: - if (v3d->twtype & (V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE)) { + if (twtype & (V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE)) { *r_len -= ofs + 0.025f; } break; @@ -1252,7 +1261,7 @@ static int manipulator_modal( return OPERATOR_RUNNING_MODAL; } -static void WIDGETGROUP_manipulator_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup *mgroup) { ManipulatorGroup *man = manipulatorgroup_init(mgroup); struct { @@ -1261,6 +1270,27 @@ static void WIDGETGROUP_manipulator_setup(const bContext *UNUSED(C), wmManipulat mgroup->customdata = man; + { + /* TODO: support mixing modes again? - it's supported but tool system makes it unobvious. */ + man->twtype = 0; + WorkSpace *workspace = CTX_wm_workspace(C); + ScrArea *sa = CTX_wm_area(C); + wmKeyMap *km = WM_keymap_find_all(C, workspace->tool.keymap, sa->spacetype, RGN_TYPE_WINDOW); + /* Weak, check first event */ + wmKeyMapItem *kmi = km->items.first; + + if (STREQ(kmi->idname, "TRANSFORM_OT_translate")) { + man->twtype |= V3D_MANIP_TRANSLATE; + } + else if (STREQ(kmi->idname, "TRANSFORM_OT_rotate")) { + man->twtype |= V3D_MANIP_ROTATE; + } + else if (STREQ(kmi->idname, "TRANSFORM_OT_resize")) { + man->twtype |= V3D_MANIP_SCALE; + } + BLI_assert(man->twtype != 0); + } + /* *** set properties for axes *** */ MAN_ITER_AXES_BEGIN(axis, axis_idx) @@ -1403,7 +1433,7 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou float start_co[3] = {0.0f, 0.0f, 0.0f}; float len; - manipulator_line_range(v3d, axis_type, &start_co[2], &len); + manipulator_line_range(man->twtype, axis_type, &start_co[2], &len); WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); RNA_float_set(axis->ptr, "length", len); @@ -1445,9 +1475,9 @@ static void WIDGETGROUP_manipulator_message_subscribe( static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) { ManipulatorGroup *man = mgroup->customdata; - ScrArea *sa = CTX_wm_area(C); + // ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); - View3D *v3d = sa->spacedata.first; + // View3D *v3d = sa->spacedata.first; RegionView3D *rv3d = ar->regiondata; float idot[3]; @@ -1469,7 +1499,7 @@ static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulato { const short axis_type = manipulator_get_axis_type(axis_idx); /* XXX maybe unset _HIDDEN flag on redraw? */ - if (manipulator_is_axis_visible(v3d, rv3d, idot, axis_type, axis_idx)) { + if (manipulator_is_axis_visible(rv3d, man->twtype, idot, axis_type, axis_idx)) { WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, false); } else { @@ -1494,22 +1524,21 @@ static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulato MAN_ITER_AXES_END; } -static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmManipulatorGroupType *UNUSED(wgt)) +static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmManipulatorGroupType *wgt) { /* it's a given we only use this in 3D view */ - const ScrArea *sa = CTX_wm_area(C); - const View3D *v3d = sa->spacedata.first; + ScrArea *sa = CTX_wm_area(C); + View3D *v3d = sa->spacedata.first; + if (v3d && ((v3d->twflag & V3D_MANIPULATOR_DRAW)) == 0) { + return false; + } - if (((v3d->twflag & V3D_MANIPULATOR_DRAW) != 0) && - ((v3d->twtype & (V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE | V3D_MANIP_SCALE)) != 0)) - { - /* Don't show when tools have a manipulator. */ - WorkSpace *workspace = CTX_wm_workspace(C); - if (workspace->tool.manipulator_group[0] == '\0') { - return true; - } + WorkSpace *workspace = CTX_wm_workspace(C); + if (!STREQ(workspace->tool.manipulator_group, "TRANSFORM_WGT_manipulator")) { + WM_manipulator_group_type_unlink_delayed_ptr(wgt); + return false; } - return false; + return true; } void TRANSFORM_WGT_manipulator(wmManipulatorGroupType *wgt) @@ -1517,8 +1546,10 @@ void TRANSFORM_WGT_manipulator(wmManipulatorGroupType *wgt) wgt->name = "Transform Manipulator"; wgt->idname = "TRANSFORM_WGT_manipulator"; - wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | - WM_MANIPULATORGROUPTYPE_3D); + wgt->flag |= WM_MANIPULATORGROUPTYPE_3D; + + wgt->mmap_params.spaceid = SPACE_VIEW3D; + wgt->mmap_params.regionid = RGN_TYPE_WINDOW; wgt->poll = WIDGETGROUP_manipulator_poll; wgt->setup = WIDGETGROUP_manipulator_setup; @@ -1540,6 +1571,12 @@ struct XFormCageWidgetGroup { static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmManipulatorGroupType *wgt) { + ScrArea *sa = CTX_wm_area(C); + View3D *v3d = sa->spacedata.first; + if (v3d && ((v3d->twflag & V3D_MANIPULATOR_DRAW)) == 0) { + return false; + } + WorkSpace *workspace = CTX_wm_workspace(C); if (!STREQ(wgt->idname, workspace->tool.manipulator_group)) { WM_manipulator_group_type_unlink_delayed_ptr(wgt); diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 7c6ddb50f4b..f6bd0139fdb 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -371,11 +371,6 @@ enum { #define V3D_SHOW_Y 4 #define V3D_SHOW_Z 8 -/* View3d->twtype (bits, we can combine them) */ -#define V3D_MANIP_TRANSLATE 1 -#define V3D_MANIP_ROTATE 2 -#define V3D_MANIP_SCALE 4 - /* Scene.orientation_type */ #define V3D_MANIP_GLOBAL 0 #define V3D_MANIP_LOCAL 1 diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 7d5745c423e..e95bcfa9e63 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2148,16 +2148,6 @@ static void rna_def_space_view3d(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem manipulators_items[] = { - {V3D_MANIP_TRANSLATE, "TRANSLATE", ICON_MAN_TRANS, "Translate", - "Use the manipulator for movement transformations"}, - {V3D_MANIP_ROTATE, "ROTATE", ICON_MAN_ROT, "Rotate", - "Use the manipulator for rotation transformations"}, - {V3D_MANIP_SCALE, "SCALE", ICON_MAN_SCALE, "Scale", - "Use the manipulator for scale transformations"}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem rv3d_persp_items[] = { {RV3D_PERSP, "PERSP", 0, "Perspective", ""}, {RV3D_ORTHO, "ORTHO", 0, "Orthographic", ""}, @@ -2454,13 +2444,6 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_MANIPUL, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "transform_manipulators", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "twtype"); - RNA_def_property_enum_items(prop, manipulators_items); - RNA_def_property_flag(prop, PROP_ENUM_FLAG); - RNA_def_property_ui_text(prop, "Transform Manipulators", "Transformation manipulators"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "lock_camera_and_layers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scenelock", 1); RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceView3D_lock_camera_and_layers_set"); -- cgit v1.2.3