diff options
author | Monique Dewanchand <mdewanchand> | 2022-09-14 22:30:20 +0300 |
---|---|---|
committer | Monique <mdewanchand@atmind.nl> | 2022-09-14 22:30:56 +0300 |
commit | 23276bcc37acc54f1e1814abdf482a432523c3a6 (patch) | |
tree | 8677bacc96fb953fb27625a6ae563aa1ae5e1769 /source/blender/windowmanager/intern | |
parent | 1a4854898000661dd7cf57492a7a75cb60ea63ef (diff) |
Adding `const Scene*` parameter in many areas.
Related to {D15885} that requires scene parameter
to be added in many places. To speed up the review process
the adding of the scene parameter was added in a separate
patch.
Reviewed By: mont29
Maniphest Tasks: T73411
Differential Revision: https://developer.blender.org/D15930
Diffstat (limited to 'source/blender/windowmanager/intern')
5 files changed, 41 insertions, 23 deletions
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index a3334c79ba0..663a41212ba 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -894,7 +894,8 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) if (area->flag & AREA_FLAG_ACTIVE_TOOL_UPDATE) { if ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) { - WM_toolsystem_update_from_context(C, CTX_wm_workspace(C), CTX_data_view_layer(C), area); + WM_toolsystem_update_from_context( + C, CTX_wm_workspace(C), CTX_data_scene(C), CTX_data_view_layer(C), area); } area->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE; } diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index bc19e2c09c3..5f7a6078328 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -5929,11 +5929,12 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) bToolRef *tref = nullptr; if ((region->regiontype == RGN_TYPE_WINDOW) && ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK)) { + const Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); WorkSpace *workspace = WM_window_get_active_workspace(win); bToolKey tkey{}; tkey.space_type = area->spacetype; - tkey.mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype); + tkey.mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype); tref = WM_toolsystem_ref_find(workspace, &tkey); } wm_event_cursor_store(&cd->state, win->eventstate, area->spacetype, region->regiontype, tref); diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index f2c41dada48..0ea783af1af 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -258,7 +258,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) /* from here down, no error returns */ if (view_layer && RNA_boolean_get(op->ptr, "autoselect")) { - BKE_view_layer_base_deselect_all(view_layer); + BKE_view_layer_base_deselect_all(scene, view_layer); } /* tag everything, all untagged data can be made local diff --git a/source/blender/windowmanager/intern/wm_operator_utils.c b/source/blender/windowmanager/intern/wm_operator_utils.c index bde072bf000..6fc9300926c 100644 --- a/source/blender/windowmanager/intern/wm_operator_utils.c +++ b/source/blender/windowmanager/intern/wm_operator_utils.c @@ -209,10 +209,11 @@ static int op_generic_value_invoke(bContext *C, wmOperator *op, const wmEvent *e return WM_operator_call_notest(C, op); } + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); uint objects_len; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( - view_layer, CTX_wm_view3d(C), &objects_len); + scene, view_layer, CTX_wm_view3d(C), &objects_len); if (objects_len == 0) { MEM_freeN(objects); return OPERATOR_CANCELLED; diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index a3aaef6af31..4b229e48e12 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -58,6 +58,7 @@ static void toolsystem_refresh_screen_from_active_tool(Main *bmain, struct bToolRef *WM_toolsystem_ref_from_context(struct bContext *C) { WorkSpace *workspace = CTX_wm_workspace(C); + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); ScrArea *area = CTX_wm_area(C); if ((area == NULL) || ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) { @@ -65,7 +66,7 @@ struct bToolRef *WM_toolsystem_ref_from_context(struct bContext *C) } const bToolKey tkey = { .space_type = area->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), + .mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype), }; bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); /* We could return 'area->runtime.tool' in this case. */ @@ -269,6 +270,7 @@ void WM_toolsystem_refresh_all(struct bContext *C, struct WorkSpace *workspace) void WM_toolsystem_reinit_all(struct bContext *C, wmWindow *win) { bScreen *screen = WM_window_get_active_screen(win); + const Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) { @@ -278,7 +280,7 @@ void WM_toolsystem_reinit_all(struct bContext *C, wmWindow *win) WorkSpace *workspace = WM_window_get_active_workspace(win); const bToolKey tkey = { .space_type = area->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), + .mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype), }; bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); if (tref) { @@ -438,7 +440,10 @@ static bool toolsystem_key_ensure_check(const bToolKey *tkey) return false; } -int WM_toolsystem_mode_from_spacetype(ViewLayer *view_layer, ScrArea *area, int space_type) +int WM_toolsystem_mode_from_spacetype(const Scene *UNUSED(scene), + ViewLayer *view_layer, + ScrArea *area, + int space_type) { int mode = -1; switch (space_type) { @@ -472,14 +477,17 @@ int WM_toolsystem_mode_from_spacetype(ViewLayer *view_layer, ScrArea *area, int return mode; } -bool WM_toolsystem_key_from_context(ViewLayer *view_layer, ScrArea *area, bToolKey *tkey) +bool WM_toolsystem_key_from_context(const Scene *scene, + ViewLayer *view_layer, + ScrArea *area, + bToolKey *tkey) { int space_type = SPACE_EMPTY; int mode = -1; if (area != NULL) { space_type = area->spacetype; - mode = WM_toolsystem_mode_from_spacetype(view_layer, area, space_type); + mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, space_type); } if (mode != -1) { @@ -505,6 +513,7 @@ void WM_toolsystem_refresh_active(bContext *C) LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { WorkSpace *workspace = WM_window_get_active_workspace(win); bScreen *screen = WM_window_get_active_screen(win); + const Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); /* Could skip loop for modes that don't depend on space type. */ int space_type_mask_handled = 0; @@ -516,7 +525,7 @@ void WM_toolsystem_refresh_active(bContext *C) space_type_mask_handled |= space_type_mask; const bToolKey tkey = { .space_type = area->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), + .mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype), }; bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); if (tref != area->runtime.tool) { @@ -558,11 +567,14 @@ void WM_toolsystem_refresh_active(bContext *C) } } -void WM_toolsystem_refresh_screen_area(WorkSpace *workspace, ViewLayer *view_layer, ScrArea *area) +void WM_toolsystem_refresh_screen_area(WorkSpace *workspace, + const Scene *scene, + ViewLayer *view_layer, + ScrArea *area) { area->runtime.tool = NULL; area->runtime.is_tool_set = true; - const int mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype); + const int mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype); LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { if (tref->space_type == area->spacetype) { if (tref->mode == mode) { @@ -581,12 +593,13 @@ void WM_toolsystem_refresh_screen_window(wmWindow *win) space_type_has_tools[tref->space_type] = true; } bScreen *screen = WM_window_get_active_screen(win); + const Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { area->runtime.tool = NULL; area->runtime.is_tool_set = true; if (space_type_has_tools[area->spacetype]) { - WM_toolsystem_refresh_screen_area(workspace, view_layer, area); + WM_toolsystem_refresh_screen_area(workspace, scene, view_layer, area); } } } @@ -610,10 +623,11 @@ static void toolsystem_refresh_screen_from_active_tool(Main *bmain, LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (workspace == WM_window_get_active_workspace(win)) { bScreen *screen = WM_window_get_active_screen(win); + const Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area->spacetype == tref->space_type) { - int mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype); + int mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype); if (mode == tref->mode) { area->runtime.tool = tref; area->runtime.is_tool_set = true; @@ -668,10 +682,11 @@ bToolRef *WM_toolsystem_ref_set_by_id_ex( bToolRef *WM_toolsystem_ref_set_by_id(bContext *C, const char *name) { + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); ScrArea *area = CTX_wm_area(C); bToolKey tkey; - if (WM_toolsystem_key_from_context(view_layer, area, &tkey)) { + if (WM_toolsystem_key_from_context(scene, view_layer, area, &tkey)) { WorkSpace *workspace = CTX_wm_workspace(C); return WM_toolsystem_ref_set_by_id_ex(C, workspace, &tkey, name, false); } @@ -761,11 +776,12 @@ static bToolRef *toolsystem_reinit_ensure_toolref(bContext *C, static void wm_toolsystem_update_from_context_view3d_impl(bContext *C, WorkSpace *workspace) { + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); int space_type = SPACE_VIEW3D; const bToolKey tkey = { .space_type = space_type, - .mode = WM_toolsystem_mode_from_spacetype(view_layer, NULL, space_type), + .mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, NULL, space_type), }; toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL); } @@ -801,14 +817,12 @@ void WM_toolsystem_update_from_context_view3d(bContext *C) } } -void WM_toolsystem_update_from_context(bContext *C, - WorkSpace *workspace, - ViewLayer *view_layer, - ScrArea *area) +void WM_toolsystem_update_from_context( + bContext *C, WorkSpace *workspace, const Scene *scene, ViewLayer *view_layer, ScrArea *area) { const bToolKey tkey = { .space_type = area->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), + .mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype), }; if (toolsystem_key_ensure_check(&tkey)) { toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL); @@ -838,14 +852,15 @@ void WM_toolsystem_do_msg_notify_tag_refresh(bContext *C, } WorkSpace *workspace = WM_window_get_active_workspace(win); + const Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); const bToolKey tkey = { .space_type = area->spacetype, - .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), + .mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype), }; WM_toolsystem_refresh(C, workspace, &tkey); - WM_toolsystem_refresh_screen_area(workspace, view_layer, area); + WM_toolsystem_refresh_screen_area(workspace, scene, view_layer, area); } static IDProperty *idprops_ensure_named_group(IDProperty *group, const char *idname) |