diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-16 19:41:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-17 16:57:33 +0300 |
commit | edf6676a77b30290918e60547544bc1a6f7a8838 (patch) | |
tree | 26012f315c75686553e6be87b73ad270b98eb01a /source/blender/editors | |
parent | 20cc14e2b7551bb043472174b8be79d8aaa4df3d (diff) |
Tool System: per space/mode tool support
This patch adds support for:
- Per space-type tools (3D view and edit).
- Per mode tools (object, edit, weight-paint .. etc).
The top-bar shows the last activated tools options, this is a design
issue with using a global topbar to show per-space settings.
See D3395
Diffstat (limited to 'source/blender/editors')
11 files changed, 47 insertions, 18 deletions
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 2e3d0a9c675..67596ef5c8a 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -420,7 +420,10 @@ static void manipulator_mesh_extrude_orientation_matrix_set( static bool manipulator_mesh_extrude_poll(const bContext *C, wmManipulatorGroupType *wgt) { WorkSpace *workspace = CTX_wm_workspace(C); - if (!STREQ(workspace->tool.manipulator_group, "MESH_WGT_extrude") || + const bToolKey tkey = { .space_type = SPACE_VIEW3D, .mode = OB_MODE_EDIT}; + bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_find(workspace, &tkey); + if ((tref_rt == NULL) || + !STREQ(wgt->idname, tref_rt->manipulator_group) || !ED_operator_editmesh_view3d((bContext *)C)) { WM_manipulator_group_type_unlink_delayed_ptr(wgt); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index e87a24b3af0..b9a7da02611 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -481,6 +481,8 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op) WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode); + WM_toolsystem_update_from_context_view3d(C); + return OPERATOR_FINISHED; } @@ -579,6 +581,8 @@ static int posemode_exec(bContext *C, wmOperator *op) WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode); + WM_toolsystem_update_from_context_view3d(C); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index e0427b4797c..6197457293f 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -4527,6 +4527,8 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); + WM_toolsystem_update_from_context_view3d(C); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index bd4381f4099..fe52e945399 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -201,8 +201,8 @@ bool ED_workspace_change( BLI_assert(BKE_workspace_view_layer_get(workspace_new, CTX_data_scene(C)) != NULL); BLI_assert(CTX_wm_workspace(C) == workspace_new); - WM_toolsystem_unlink(C, workspace_old); - WM_toolsystem_link(C, workspace_new); + WM_toolsystem_unlink_all(C, workspace_old); + WM_toolsystem_link_all(C, workspace_new); return true; } @@ -224,7 +224,7 @@ WorkSpace *ED_workspace_duplicate( bmain, workspace_old->id.name + 2, scene, BKE_workspace_view_layer_get(workspace_old, scene)); - workspace_new->tool = workspace_old->tool; + /* TODO(campbell): tools */ for (WorkSpaceLayout *layout_old = layouts_old->first; layout_old; layout_old = layout_old->next) { WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(workspace_new, layout_old, win); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index cbf755d26b5..6a32fdecfad 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1136,6 +1136,8 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); + WM_toolsystem_update_from_context_view3d(C); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 196505c9542..3c3df2067ab 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1252,6 +1252,8 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); + WM_toolsystem_update_from_context_view3d(C); + return OPERATOR_FINISHED; } @@ -2386,6 +2388,8 @@ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op) WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); + WM_toolsystem_update_from_context_view3d(C); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 048555d3fcc..709d6d4c690 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -5820,6 +5820,8 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op) WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); + WM_toolsystem_update_from_context_view3d(C); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c index 8cf27d86cfe..4342fa87f89 100644 --- a/source/blender/editors/space_topbar/space_topbar.c +++ b/source/blender/editors/space_topbar/space_topbar.c @@ -201,9 +201,10 @@ static void topbar_header_region_message_subscribe( .user_data = ar, .notify = ED_region_do_msg_notify_tag_redraw, }; + WM_msg_subscribe_rna_prop( mbus, &workspace->id, workspace, - WorkSpace, tool_keymap, &msg_sub_value_region_tag_redraw); + WorkSpace, tools, &msg_sub_value_region_tag_redraw); } static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu) diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index fa147ff1226..de2ef45247b 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1017,8 +1017,8 @@ static void view3d_main_region_listener( static void view3d_main_region_message_subscribe( const struct bContext *C, - struct WorkSpace *workspace, struct Scene *UNUSED(scene), - struct bScreen *UNUSED(screen), struct ScrArea *UNUSED(sa), struct ARegion *ar, + struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene), + struct bScreen *UNUSED(screen), struct ScrArea *sa, struct ARegion *ar, struct wmMsgBus *mbus) { /* Developer note: there are many properties that impact 3D view drawing, @@ -1091,10 +1091,10 @@ static void view3d_main_region_message_subscribe( } } - if (workspace->tool.spacetype == SPACE_VIEW3D) { + { wmMsgSubscribeValue msg_sub_value_region_tag_refresh = { .owner = ar, - .user_data = ar, + .user_data = sa, .notify = WM_toolsystem_do_msg_notify_tag_refresh, }; WM_msg_subscribe_rna_anon_prop( diff --git a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c index 9f69a33861d..d46673b4817 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c @@ -982,8 +982,10 @@ void VIEW3D_WT_ruler_item(wmManipulatorType *wt) static bool WIDGETGROUP_ruler_poll(const bContext *C, wmManipulatorGroupType *wgt) { - WorkSpace *workspace = CTX_wm_workspace(C); - if (!STREQ(wgt->idname, workspace->tool.manipulator_group)) { + bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); + if ((tref_rt == NULL) || + !STREQ(wgt->idname, tref_rt->manipulator_group)) + { WM_manipulator_group_type_unlink_delayed_ptr(wgt); return false; } @@ -1030,8 +1032,9 @@ void VIEW3D_WGT_ruler(wmManipulatorGroupType *wgt) static int view3d_ruler_poll(bContext *C) { - WorkSpace *workspace = CTX_wm_workspace(C); - if (!STREQ(view3d_wgt_ruler_id, workspace->tool.manipulator_group) || + bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); + if ((tref_rt == NULL) || + !STREQ(view3d_wgt_ruler_id, tref_rt->manipulator_group) || CTX_wm_region_view3d(C) == NULL) { return false; diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c index 8257ad595d7..c24291953c8 100644 --- a/source/blender/editors/transform/transform_manipulator_3d.c +++ b/source/blender/editors/transform/transform_manipulator_3d.c @@ -1283,8 +1283,14 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup /* TODO: support mixing modes again? - it's supported but tool system makes it unobvious. */ man->twtype = 0; WorkSpace *workspace = CTX_wm_workspace(C); + Scene *scene = CTX_data_scene(C); ScrArea *sa = CTX_wm_area(C); - wmKeyMap *km = WM_keymap_find_all(C, workspace->tool.keymap, sa->spacetype, RGN_TYPE_WINDOW); + const bToolKey tkey = { + .space_type = sa->spacetype, + .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, NULL, sa->spacetype), + }; + bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_find(workspace, &tkey); + wmKeyMap *km = WM_keymap_find_all(C, tref_rt->keymap, sa->spacetype, RGN_TYPE_WINDOW); /* Weak, check first event */ wmKeyMapItem *kmi = km ? km->items.first : NULL; @@ -1552,8 +1558,10 @@ static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmMani return false; } - WorkSpace *workspace = CTX_wm_workspace(C); - if (!STREQ(workspace->tool.manipulator_group, "TRANSFORM_WGT_manipulator")) { + bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); + if ((tref_rt == NULL) || + !STREQ(wgt->idname, tref_rt->manipulator_group)) + { WM_manipulator_group_type_unlink_delayed_ptr(wgt); return false; } @@ -1596,8 +1604,8 @@ static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmManipulatorGroupTyp return false; } - WorkSpace *workspace = CTX_wm_workspace(C); - if (!STREQ(wgt->idname, workspace->tool.manipulator_group)) { + bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); + if (!STREQ(wgt->idname, tref_rt->manipulator_group)) { WM_manipulator_group_type_unlink_delayed_ptr(wgt); return false; } |