Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-07-04 14:00:46 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-07-04 19:40:33 +0300
commitc43443d530bff67693dc2db4efdca6307703ce61 (patch)
tree40305a5fe154a25387c3fd3afcbfc560346bf383 /source/blender/editors/space_buttons
parent4e2228525fc9bbcff58e315c5e3bbc193cd63a0b (diff)
Workspaces: store view layer per main window, instead of per workspace.
It was a bit odd that the scene was stored per window but not the view layer. The reasoning was that you would use different view layers for different tasks. This is still possible, but it's more predictable to switch them both explicitly, and with child window support manually syncing the view layers between multiple windows is no longer needed as often.
Diffstat (limited to 'source/blender/editors/space_buttons')
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c22
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c9
2 files changed, 21 insertions, 10 deletions
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);