diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 7 | ||||
-rw-r--r-- | source/blender/editors/render/render_internal.c | 20 | ||||
-rw-r--r-- | source/blender/editors/render/render_shading.c | 6 | ||||
-rw-r--r-- | source/blender/editors/scene/scene_edit.c | 13 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 4 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_context.c | 3 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 39 | ||||
-rw-r--r-- | source/blender/editors/screen/workspace_edit.c | 57 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/buttons_context.c | 22 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/buttons_texture.c | 9 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_select.c | 19 |
12 files changed, 88 insertions, 112 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index cc80108e20c..2b0729a8e13 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -204,9 +204,7 @@ void ED_screen_preview_render(const struct bScreen *screen, int size_x, int s /* workspaces */ struct WorkSpace *ED_workspace_add( struct Main *bmain, - const char *name, - Scene *scene, - ViewLayer *act_render_layer) ATTR_NONNULL(); + const char *name) ATTR_NONNULL(); bool ED_workspace_change( struct WorkSpace *workspace_new, struct bContext *C, @@ -220,9 +218,6 @@ bool ED_workspace_delete( struct wmWindowManager *wm) ATTR_NONNULL(); void ED_workspace_scene_data_sync( struct WorkSpaceInstanceHook *hook, Scene *scene) ATTR_NONNULL(); -void ED_workspace_view_layer_unset( - const struct Main *bmain, struct Scene *scene, - const ViewLayer *layer_unset, ViewLayer *layer_new) ATTR_NONNULL(1, 2); struct WorkSpaceLayout *ED_workspace_layout_add( struct Main *bmain, struct WorkSpace *workspace, diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 1385baa51ad..ae364828119 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -66,7 +66,6 @@ #include "BKE_screen.h" #include "BKE_scene.h" #include "BKE_undo_system.h" -#include "BKE_workspace.h" #include "DEG_depsgraph.h" @@ -263,7 +262,7 @@ static void image_buffer_rect_update(RenderJob *rj, RenderResult *rr, ImBuf *ibu /* set callbacks, exported to sequence render too. * Only call in foreground (UI) renders. */ -static void screen_render_single_layer_set(wmOperator *op, Main *mainp, WorkSpace *workspace, Scene **scene, ViewLayer **single_layer) +static void screen_render_single_layer_set(wmOperator *op, Main *mainp, ViewLayer *active_layer, Scene **scene, ViewLayer **single_layer) { /* single layer re-render */ if (RNA_struct_property_is_set(op->ptr, "scene")) { @@ -292,8 +291,8 @@ static void screen_render_single_layer_set(wmOperator *op, Main *mainp, WorkSpac if (rl) *single_layer = rl; } - else if (((*scene)->r.scemode & R_SINGLE_LAYER) && workspace) { - *single_layer = BKE_view_layer_from_workspace_get(*scene, workspace); + else if (((*scene)->r.scemode & R_SINGLE_LAYER) && active_layer) { + *single_layer = active_layer; } } @@ -302,12 +301,12 @@ static int screen_render_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); RenderEngineType *re_type = RE_engines_find(scene->r.engine); + ViewLayer *active_layer = CTX_data_view_layer(C); ViewLayer *single_layer = NULL; Render *re; Image *ima; View3D *v3d = CTX_wm_view3d(C); Main *mainp = CTX_data_main(C); - WorkSpace *workspace = CTX_wm_workspace(C); unsigned int lay_override; const bool is_animation = RNA_boolean_get(op->ptr, "animation"); const bool is_write_still = RNA_boolean_get(op->ptr, "write_still"); @@ -319,7 +318,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) } /* custom scene and single layer re-render */ - screen_render_single_layer_set(op, mainp, workspace, &scene, &single_layer); + screen_render_single_layer_set(op, mainp, active_layer, &scene, &single_layer); if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected"); @@ -846,8 +845,7 @@ static void clean_viewport_memory(Main *bmain, Scene *scene) /* Go over all the visible objects. */ for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { for (wmWindow *win = wm->windows.first; win; win = win->next) { - WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); - ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); for (base = view_layer->object_bases.first; base; base = base->next) { clean_viewport_memory_base(base); @@ -865,8 +863,9 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even { /* new render clears all callbacks */ Main *bmain = CTX_data_main(C); - ViewLayer *single_layer = NULL; Scene *scene = CTX_data_scene(C); + ViewLayer *active_layer = CTX_data_view_layer(C); + ViewLayer *single_layer = NULL; RenderEngineType *re_type = RE_engines_find(scene->r.engine); Render *re; wmJob *wm_job; @@ -877,7 +876,6 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even const bool is_write_still = RNA_boolean_get(op->ptr, "write_still"); const bool use_viewport = RNA_boolean_get(op->ptr, "use_viewport"); View3D *v3d = use_viewport ? CTX_wm_view3d(C) : NULL; - WorkSpace *workspace = CTX_wm_workspace(C); struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL; const char *name; ScrArea *sa; @@ -888,7 +886,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even } /* custom scene and single layer re-render */ - screen_render_single_layer_set(op, bmain, workspace, &scene, &single_layer); + screen_render_single_layer_set(op, bmain, active_layer, &scene, &single_layer); /* only one render job at a time */ if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER)) diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 31f25720f8d..07e0c124998 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -615,12 +615,12 @@ void WORLD_OT_new(wmOperatorType *ot) static int view_layer_add_exec(bContext *C, wmOperator *UNUSED(op)) { - WorkSpace *workspace = CTX_wm_workspace(C); + wmWindow *win = CTX_wm_window(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = BKE_view_layer_add(scene, NULL); - if (workspace) { - BKE_workspace_view_layer_set(workspace, view_layer, scene); + if (win) { + WM_window_set_active_view_layer(win, view_layer); } DEG_id_tag_update(&scene->id, 0); diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c index 0ebbd770c9f..62933178266 100644 --- a/source/blender/editors/scene/scene_edit.c +++ b/source/blender/editors/scene/scene_edit.c @@ -23,9 +23,11 @@ */ #include <stdio.h> +#include <string.h> #include "BLI_compiler_attrs.h" #include "BLI_listbase.h" +#include "BLI_string.h" #include "BKE_context.h" #include "BKE_global.h" @@ -175,12 +177,17 @@ bool ED_scene_view_layer_delete( BLI_remlink(&scene->view_layers, layer); BLI_assert(BLI_listbase_is_empty(&scene->view_layers) == false); - ED_workspace_view_layer_unset(bmain, scene, layer, scene->view_layers.first); + /* Remove from windows. */ + wmWindowManager *wm = bmain->wm.first; + for (wmWindow *win = wm->windows.first; win; win = win->next) { + if (win->scene == scene && STREQ(win->view_layer_name, layer->name)) { + ViewLayer *first_layer = BKE_view_layer_default_view(scene); + STRNCPY(win->view_layer_name, first_layer->name); + } + } BKE_view_layer_free(layer); - BKE_workspace_view_layer_remove(bmain, layer); - DEG_id_tag_update(&scene->id, 0); DEG_relations_tag_update(bmain); WM_main_add_notifier(NC_SCENE | ND_LAYER | NA_REMOVED, scene); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 5cb440d315b..77e178bf0b2 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1482,7 +1482,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) { WorkSpace *workspace = WM_window_get_active_workspace(win); const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); - Scene *scene = WM_window_get_active_scene(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); ARegion *ar; rcti rect, overlap_rect; rcti window_rect; @@ -1542,7 +1542,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) region_azones_add(screen, sa, ar, ar->alignment & ~RGN_SPLIT_PREV); } - WM_toolsystem_refresh_screen_area(workspace, scene, sa); + WM_toolsystem_refresh_screen_area(workspace, view_layer, sa); } static void region_update_rect(ARegion *ar) diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index fa18826005e..17b1af29010 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -91,8 +91,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult bScreen *sc = CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); Scene *scene = WM_window_get_active_scene(win); - WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); - ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); Object *obact = (view_layer && view_layer->basact) ? view_layer->basact->object : NULL; Object *obedit = view_layer ? OBEDIT_FROM_VIEW_LAYER(view_layer) : NULL; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 50609815168..8fbf74ed800 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -944,35 +944,36 @@ static void screen_set_3dview_camera(Scene *scene, ViewLayer *view_layer, ScrAre } } -static ViewLayer *scene_change_get_new_view_layer(const WorkSpace *workspace, const Scene *scene_new) -{ - ViewLayer *layer_new = BKE_workspace_view_layer_exists(workspace, scene_new); - return layer_new ? layer_new : BKE_view_layer_default_view(scene_new); -} - void ED_screen_scene_change(bContext *C, wmWindow *win, Scene *scene) { - const bScreen *screen = WM_window_get_active_screen(win); - WorkSpace *workspace = CTX_wm_workspace(C); - ViewLayer *view_layer = scene_change_get_new_view_layer(workspace, scene); - #if 0 - /* mode syncing */ - Object *obact_new = OBACT(view_layer); - UNUSED_VARS(obact_new); - eObjectMode object_mode_old = workspace->object_mode; - ViewLayer *layer_old = BKE_view_layer_from_workspace_get(scene_old, workspace); - Object *obact_old = OBACT(layer_old); - UNUSED_VARS(obact_old, object_mode_old); + ViewLayer *view_layer_old = WM_window_get_active_view_layer(win); #endif - BKE_workspace_view_layer_set(workspace, view_layer, scene); - + /* Switch scene. */ win->scene = scene; if (CTX_wm_window(C) == win) { CTX_data_scene_set(C, scene); } + /* Ensure the view layer name is updated. */ + WM_window_ensure_active_view_layer(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + +#if 0 + /* Mode Syncing. */ + if (view_layer_old) { + WorkSpace *workspace = CTX_wm_workspace(C); + Object *obact_new = OBACT(view_layer); + UNUSED_VARS(obact_new); + eObjectMode object_mode_old = workspace->object_mode; + Object *obact_old = OBACT(view_layer_old); + UNUSED_VARS(obact_old, object_mode_old); + } +#endif + + /* Update 3D view cameras. */ + const bScreen *screen = WM_window_get_active_screen(win); for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 9ba9b70a6e8..705d8992900 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -75,55 +75,33 @@ * \brief API for managing workspaces and their data. * \{ */ -WorkSpace *ED_workspace_add( - Main *bmain, const char *name, Scene *scene, - ViewLayer *act_view_layer) +WorkSpace *ED_workspace_add(Main *bmain, const char *name) { - WorkSpace *workspace = BKE_workspace_add(bmain, name); - - BKE_workspace_view_layer_set(workspace, act_view_layer, scene); - - return workspace; + return BKE_workspace_add(bmain, name); } /** * Changes the object mode (if needed) to the one set in \a workspace_new. * Object mode is still stored on object level. In future it should all be workspace level instead. */ -static void workspace_change_update_mode( - const WorkSpace *workspace_old, const WorkSpace *workspace_new, - bContext *C, Object *ob_act, ReportList *reports) +static void workspace_change_update( + WorkSpace *workspace_new, const WorkSpace *workspace_old, + bContext *C, wmWindowManager *wm) { - UNUSED_VARS(workspace_old, workspace_new, C, ob_act, reports); + /* needs to be done before changing mode! (to ensure right context) */ + UNUSED_VARS(workspace_old, workspace_new, C, wm); #if 0 + Object *ob_act = CTX_data_active_object(C) eObjectMode mode_old = workspace_old->object_mode; eObjectMode mode_new = workspace_new->object_mode; if (mode_old != mode_new) { - ED_object_mode_compat_set(C, ob_act, mode_new, reports); + ED_object_mode_compat_set(C, ob_act, mode_new, &wm->reports); ED_object_mode_toggle(C, mode_new); } #endif } -static void workspace_change_update_view_layer( - WorkSpace *workspace_new, const WorkSpace *workspace_old, - Scene *scene) -{ - if (!BKE_workspace_view_layer_exists(workspace_new, scene)) { - BKE_workspace_view_layer_set(workspace_new, BKE_workspace_view_layer_get(workspace_old, scene), scene); - } -} - -static void workspace_change_update( - WorkSpace *workspace_new, const WorkSpace *workspace_old, - bContext *C, wmWindowManager *wm) -{ - /* needs to be done before changing mode! (to ensure right context) */ - workspace_change_update_view_layer(workspace_new, workspace_old, CTX_data_scene(C)); - workspace_change_update_mode(workspace_old, workspace_new, C, CTX_data_active_object(C), &wm->reports); -} - static bool workspace_change_find_new_layout_cb(const WorkSpaceLayout *layout, void *UNUSED(arg)) { /* return false to stop the iterator if we've found a layout that can be activated */ @@ -199,7 +177,6 @@ bool ED_workspace_change( screen_change_update(C, win, screen_new); workspace_change_update(workspace_new, workspace_old, C, wm); - BLI_assert(BKE_workspace_view_layer_exists(workspace_new, CTX_data_scene(C)) != NULL); BLI_assert(CTX_wm_workspace(C) == workspace_new); WM_toolsystem_unlink_all(C, workspace_old); @@ -220,10 +197,7 @@ WorkSpace *ED_workspace_duplicate( { WorkSpaceLayout *layout_active_old = BKE_workspace_active_layout_get(win->workspace_hook); ListBase *layouts_old = BKE_workspace_layouts_get(workspace_old); - Scene *scene = WM_window_get_active_scene(win); - WorkSpace *workspace_new = ED_workspace_add( - bmain, workspace_old->id.name + 2, scene, - BKE_workspace_view_layer_get(workspace_old, scene)); + WorkSpace *workspace_new = ED_workspace_add(bmain, workspace_old->id.name + 2); /* TODO(campbell): tools */ @@ -271,17 +245,6 @@ void ED_workspace_scene_data_sync( BKE_screen_view3d_scene_sync(screen, scene); } -void ED_workspace_view_layer_unset( - const Main *bmain, Scene *scene, - const ViewLayer *layer_unset, ViewLayer *layer_new) -{ - for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) { - if (BKE_workspace_view_layer_get(workspace, scene) == layer_unset) { - BKE_workspace_view_layer_set(workspace, layer_new, scene); - } - } -} - /** \} Workspace API */ diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index dd943e7988d..4ad62ec705d 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -47,6 +47,7 @@ #include "DNA_world_types.h" #include "DNA_brush_types.h" #include "DNA_linestyle_types.h" +#include "DNA_windowmanager_types.h" #include "BKE_context.h" #include "BKE_action.h" @@ -70,6 +71,8 @@ #include "UI_interface.h" #include "UI_resources.h" +#include "WM_api.h" + #include "buttons_intern.h" // own include static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type) @@ -114,11 +117,13 @@ static int buttons_context_path_scene(ButsContextPath *path) return RNA_struct_is_a(ptr->type, &RNA_Scene); } -static int buttons_context_path_view_layer(ButsContextPath *path, WorkSpace *workspace) +static int buttons_context_path_view_layer(ButsContextPath *path, wmWindow *win) { if (buttons_context_path_scene(path)) { Scene *scene = path->ptr[path->len - 1].data; - ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace); + ViewLayer *view_layer = (win->scene == scene) ? + WM_window_get_active_view_layer(win) : + BKE_view_layer_default_view(scene); RNA_pointer_create(&scene->id, &RNA_ViewLayer, view_layer, &path->ptr[path->len]); path->len++; @@ -159,7 +164,7 @@ static int buttons_context_path_world(ButsContextPath *path) return 0; } -static int buttons_context_path_linestyle(ButsContextPath *path, WorkSpace *workspace) +static int buttons_context_path_linestyle(ButsContextPath *path, wmWindow *window) { FreestyleLineStyle *linestyle; PointerRNA *ptr = &path->ptr[path->len - 1]; @@ -169,7 +174,7 @@ static int buttons_context_path_linestyle(ButsContextPath *path, WorkSpace *work return 1; } /* if we have a view layer, use the lineset's linestyle */ - else if (buttons_context_path_view_layer(path, workspace)) { + else if (buttons_context_path_view_layer(path, window)) { ViewLayer *view_layer = path->ptr[path->len - 1].data; linestyle = BKE_linestyle_active_from_view_layer(view_layer); if (linestyle) { @@ -432,7 +437,7 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path else if (GS(id->name) == ID_OB) buttons_context_path_object(path); else if (GS(id->name) == ID_LS) - buttons_context_path_linestyle(path, CTX_wm_workspace(C)); + buttons_context_path_linestyle(path, CTX_wm_window(C)); } if (ct->texture) { @@ -472,8 +477,9 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma { SpaceButs *sbuts = CTX_wm_space_buts(C); Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + wmWindow *window = CTX_wm_window(C); WorkSpace *workspace = CTX_wm_workspace(C); - ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace); ID *id; int found; @@ -514,13 +520,13 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma case BCONTEXT_VIEW_LAYER: #ifdef WITH_FREESTYLE if (buttons_context_linestyle_pinnable(C, view_layer)) { - found = buttons_context_path_linestyle(path, workspace); + found = buttons_context_path_linestyle(path, window); if (found) { break; } } #endif - found = buttons_context_path_view_layer(path, workspace); + found = buttons_context_path_view_layer(path, window); break; case BCONTEXT_WORLD: found = buttons_context_path_world(path); diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index 5feb74edef7..66684de18ac 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -49,6 +49,7 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_linestyle_types.h" +#include "DNA_windowmanager_types.h" #include "BKE_context.h" #include "BKE_layer.h" @@ -72,6 +73,8 @@ #include "ED_node.h" #include "ED_screen.h" +#include "WM_api.h" + #include "../interface/interface_intern.h" #include "buttons_intern.h" // own include @@ -176,8 +179,10 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * const ID_Type id_type = pinid != NULL ? GS(pinid->name) : -1; if (!pinid || id_type == ID_SCE) { - WorkSpace *workspace = CTX_wm_workspace(C); - ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene); + wmWindow *win = CTX_wm_window(C); + ViewLayer *view_layer = (win->scene == scene) ? + WM_window_get_active_view_layer(win) : + BKE_view_layer_default_view(scene); brush = BKE_paint_brush(BKE_paint_get_active_from_context(C)); linestyle = BKE_linestyle_active_from_view_layer(view_layer); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 5c95d5944d1..9d89e21289d 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -51,6 +51,7 @@ #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_material.h" +#include "BKE_workspace.h" #include "DEG_depsgraph.h" diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 8a5df196c7b..bc514914b81 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -173,24 +173,25 @@ void outliner_object_mode_toggle( /* Outliner Element Selection/Activation on Click */ static eOLDrawState active_viewlayer( - bContext *C, Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) + bContext *C, Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *te, const eOLSetState set) { - Scene *sce; - /* paranoia check */ if (te->idcode != ID_SCE) return OL_DRAWSEL_NONE; - sce = (Scene *)tselem->id; - WorkSpace *workspace = CTX_wm_workspace(C); ViewLayer *view_layer = te->directdata; if (set != OL_SETSEL_NONE) { - BKE_workspace_view_layer_set(workspace, view_layer, sce); - WM_event_add_notifier(C, NC_SCREEN | ND_LAYER, NULL); + wmWindow *win = CTX_wm_window(C); + Scene *scene = WM_window_get_active_scene(win); + + if (BLI_findindex(&scene->view_layers, view_layer) != -1) { + WM_window_set_active_view_layer(win, view_layer); + WM_event_add_notifier(C, NC_SCREEN | ND_LAYER, NULL); + } } else { - return BKE_workspace_view_layer_get(workspace, sce) == view_layer; + return CTX_data_view_layer(C) == view_layer; } return OL_DRAWSEL_NONE; } @@ -895,7 +896,7 @@ eOLDrawState tree_element_type_active( case TSE_CONSTRAINT: return tree_element_active_constraint(C, scene, view_layer, te, tselem, set); case TSE_R_LAYER: - return active_viewlayer(C, scene, view_layer, te, tselem, set); + return active_viewlayer(C, scene, view_layer, te, set); case TSE_POSEGRP: return tree_element_active_posegroup(C, scene, view_layer, te, tselem, set); case TSE_SEQUENCE: |