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:
authorRohan Rathi <rohanrathi08@gmail.com>2018-07-21 16:59:15 +0300
committerRohan Rathi <rohanrathi08@gmail.com>2018-07-21 16:59:15 +0300
commit4e6bcd10e559ab541df53a3d7b645faac1a7fe27 (patch)
treeba214c23868fe76ec5d2199b83846814bf79be25 /source/blender/editors/screen
parentb6b185691f018f6b175ffb58c65418991cda75f2 (diff)
parente361e9e99c5b6140b6284e81fa315bdcc48cee58 (diff)
Merge branch 'blender2.8' into soc-2018-bevel
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r--source/blender/editors/screen/area.c82
-rw-r--r--source/blender/editors/screen/glutil.c20
-rw-r--r--source/blender/editors/screen/screen_context.c3
-rw-r--r--source/blender/editors/screen/screen_draw.c38
-rw-r--r--source/blender/editors/screen/screen_edit.c54
-rw-r--r--source/blender/editors/screen/screen_ops.c118
-rw-r--r--source/blender/editors/screen/workspace_edit.c66
7 files changed, 207 insertions, 174 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 46bbc0fdf4f..1a63bc1cd53 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -105,12 +105,12 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct, int sides)
float color[4] = {0.0f, 0.0f, 0.0f, 0.25f};
UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(color);
- immBeginAtMost(GWN_PRIM_LINES, 8);
+ immBeginAtMost(GPU_PRIM_LINES, 8);
/* right */
if (sides & REGION_EMBOSS_RIGHT) {
@@ -146,11 +146,11 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct, int sides)
void ED_region_pixelspace(ARegion *ar)
{
wmOrtho2_region_pixelspace(ar);
- gpuLoadIdentity();
+ GPU_matrix_identity_set();
}
/* only exported for WM */
-void ED_region_do_listen(bScreen *sc, ScrArea *sa, ARegion *ar, wmNotifier *note, const Scene *scene)
+void ED_region_do_listen(wmWindow *win, ScrArea *sa, ARegion *ar, wmNotifier *note, const Scene *scene)
{
/* generic notes first */
switch (note->category) {
@@ -164,15 +164,15 @@ void ED_region_do_listen(bScreen *sc, ScrArea *sa, ARegion *ar, wmNotifier *note
}
if (ar->type && ar->type->listener)
- ar->type->listener(sc, sa, ar, note, scene);
+ ar->type->listener(win, sa, ar, note, scene);
}
/* only exported for WM */
-void ED_area_do_listen(bScreen *sc, ScrArea *sa, wmNotifier *note, Scene *scene, WorkSpace *workspace)
+void ED_area_do_listen(wmWindow *win, ScrArea *sa, wmNotifier *note, Scene *scene)
{
/* no generic notes? */
if (sa->type && sa->type->listener) {
- sa->type->listener(sc, sa, note, scene, workspace);
+ sa->type->listener(win, sa, note, scene);
}
}
@@ -262,8 +262,8 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f
BLI_rcti_init(&click_rect, x, x + icon_size, y, y + icon_size);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -271,7 +271,7 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f
imm_draw_box_wire_2d(pos, click_rect.xmin, click_rect.ymin, click_rect.xmax, click_rect.ymax);
immUniformColor4f(0.0f, 1.0f, 1.0f, alpha);
- immBegin(GWN_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, click_rect.xmin, click_rect.ymin);
immVertex2f(pos, click_rect.xmax, click_rect.ymax);
immVertex2f(pos, click_rect.xmin, click_rect.ymax);
@@ -295,8 +295,8 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2)
float width = 0.1f * U.widget_unit;
float pad = 0.2f * U.widget_unit;
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
GPU_blend(true);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -352,8 +352,8 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
GPU_blend(true);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- gpuPushMatrix();
- gpuTranslate2f(-ar->winrct.xmin, -ar->winrct.ymin);
+ GPU_matrix_push();
+ GPU_matrix_translate_2f(-ar->winrct.xmin, -ar->winrct.ymin);
for (az = sa->actionzones.first; az; az = az->next) {
/* test if action zone is over this region */
@@ -388,7 +388,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
}
}
- gpuPopMatrix();
+ GPU_matrix_pop();
GPU_blend(false);
}
@@ -500,8 +500,8 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
/* for debugging unneeded area redraws and partial redraw */
#if 0
GPU_blend(true);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(drand48(), drand48(), drand48(), 0.1f);
immRectf(pos, ar->drawrct.xmin - ar->winrct.xmin, ar->drawrct.ymin - ar->winrct.ymin,
@@ -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)
@@ -2472,8 +2472,8 @@ void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float
GPU_blend(true);
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(fill_color);
immRecti(pos, rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1);
@@ -2674,11 +2674,11 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
return;
/* find window pixel coordinates of origin */
- gpuPushMatrix();
+ GPU_matrix_push();
/* offset and zoom using ogl */
- gpuTranslate2f(x, y);
- gpuScale2f(zoomx, zoomy);
+ GPU_matrix_translate_2f(x, y);
+ GPU_matrix_scale_2f(zoomx, zoomy);
BLF_size(blf_mono_font, style->widgetlabel.points * 1.5f * U.pixelsize, U.dpi);
@@ -2691,8 +2691,8 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
/* set up rect */
BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymax, frame->ymax + box_y);
/* draw top box */
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_METADATA_BG);
immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
@@ -2716,8 +2716,8 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
/* set up box rect */
BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymin - box_y, frame->ymin);
/* draw top box */
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_METADATA_BG);
immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
@@ -2732,7 +2732,7 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
BLF_disable(blf_mono_font, BLF_CLIPPING);
}
- gpuPopMatrix();
+ GPU_matrix_pop();
}
void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
@@ -2745,8 +2745,8 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x1, &y1);
UI_view2d_view_to_region(&ar->v2d, 1.0f, 1.0f, &x2, &y2);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShade(TH_BACK, 20);
@@ -2778,12 +2778,12 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
int count_large = 1.0f / (4.0f * gridstep);
if (count_fine > 0) {
- GWN_vertformat_clear(format);
- pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ GPU_vertformat_clear(format);
+ pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ unsigned color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBegin(GWN_PRIM_LINES, 4 * count_fine + 4 * count_large);
+ immBegin(GPU_PRIM_LINES, 4 * count_fine + 4 * count_large);
float theme_color[3];
UI_GetThemeColorShade3fv(TH_BACK, (int)(20.0f * (1.0f - blendfac)), theme_color);
@@ -2877,7 +2877,7 @@ void ED_region_visible_rect(ARegion *ar, rcti *rect)
void ED_region_cache_draw_background(const ARegion *ar)
{
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ub(128, 128, 255, 64);
immRecti(pos, 0, 0, ar->winx, 8 * UI_DPI_FAC);
@@ -2897,7 +2897,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f
BLF_width_and_height(fontid, numstr, sizeof(numstr), &font_dims[0], &font_dims[1]);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_CFRAME);
immRecti(pos, x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f);
@@ -2911,7 +2911,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f
void ED_region_cache_draw_cached_segments(const ARegion *ar, const int num_segments, const int *points, const int sfra, const int efra)
{
if (num_segments) {
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ub(128, 128, 255, 128);
@@ -2936,8 +2936,8 @@ void ED_region_message_subscribe(
struct bScreen *screen, struct ScrArea *sa, struct ARegion *ar,
struct wmMsgBus *mbus)
{
- if (ar->manipulator_map != NULL) {
- WM_manipulatormap_message_subscribe(C, ar->manipulator_map, ar, mbus);
+ if (ar->gizmo_map != NULL) {
+ WM_gizmomap_message_subscribe(C, ar->gizmo_map, ar, mbus);
}
if (BLI_listbase_is_empty(&ar->uiblocks)) {
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 6cff82295f0..7fa093106df 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -140,9 +140,9 @@ static int get_cached_work_texture(int *r_w, int *r_h)
static void immDrawPixelsTexSetupAttributes(IMMDrawPixelsTexState *state)
{
- Gwn_VertFormat *vert_format = immVertexFormat();
- state->pos = GWN_vertformat_attr_add(vert_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- state->texco = GWN_vertformat_attr_add(vert_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ GPUVertFormat *vert_format = immVertexFormat();
+ state->pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ state->texco = GPU_vertformat_attr_add(vert_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
/* To be used before calling immDrawPixelsTex
@@ -297,7 +297,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, format, GL_UNSIGNED_BYTE, &uc_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components + (subpart_x * offset_x + subpart_w - 1) * components]);
}
- immBegin(GWN_PRIM_TRI_FAN, 4);
+ immBegin(GPU_PRIM_TRI_FAN, 4);
immAttrib2f(texco, (float)(0 + offset_left) / tex_w, (float)(0 + offset_bot) / tex_h);
immVertex2f(pos, rast_x + (float)offset_left * xzoom, rast_y + (float)offset_bot * yzoom);
@@ -364,7 +364,7 @@ void bglPolygonOffset(float viewdist, float dist)
// glPolygonOffset(-1.0, -1.0);
/* hack below is to mimic polygon offset */
- gpuGetProjectionMatrix(winmat);
+ GPU_matrix_projection_get(winmat);
/* dist is from camera to center point */
@@ -401,7 +401,7 @@ void bglPolygonOffset(float viewdist, float dist)
offset = 0.0;
}
- gpuLoadProjectionMatrix(winmat);
+ GPU_matrix_projection_set(winmat);
}
/* **** Color management helper functions for GLSL display/transform ***** */
@@ -551,28 +551,28 @@ void immDrawBorderCorners(unsigned int pos, const rcti *border, float zoomx, flo
delta_y = min_ff(delta_y, border->ymax - border->ymin);
/* left bottom corner */
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2f(pos, border->xmin, border->ymin + delta_y);
immVertex2f(pos, border->xmin, border->ymin);
immVertex2f(pos, border->xmin + delta_x, border->ymin);
immEnd();
/* left top corner */
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2f(pos, border->xmin, border->ymax - delta_y);
immVertex2f(pos, border->xmin, border->ymax);
immVertex2f(pos, border->xmin + delta_x, border->ymax);
immEnd();
/* right bottom corner */
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2f(pos, border->xmax - delta_x, border->ymin);
immVertex2f(pos, border->xmax, border->ymin);
immVertex2f(pos, border->xmax, border->ymin + delta_y);
immEnd();
/* right top corner */
- immBegin(GWN_PRIM_LINE_STRIP, 3);
+ immBegin(GPU_PRIM_LINE_STRIP, 3);
immVertex2f(pos, border->xmax - delta_x, border->ymax);
immVertex2f(pos, border->xmax, border->ymax);
immVertex2f(pos, border->xmax, border->ymax - delta_y);
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_draw.c b/source/blender/editors/screen/screen_draw.c
index b5b0d16f6a7..10d72d74b22 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -99,7 +99,7 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos)
}
}
- immBegin(GWN_PRIM_TRI_FAN, 5);
+ immBegin(GPU_PRIM_TRI_FAN, 5);
for (i = 0; i < 5; i++) {
immVertex2f(pos, points[i].x, points[i].y);
@@ -107,7 +107,7 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos)
immEnd();
- immBegin(GWN_PRIM_TRI_FAN, 5);
+ immBegin(GPU_PRIM_TRI_FAN, 5);
for (i = 4; i < 8; i++) {
immVertex2f(pos, points[i].x, points[i].y);
@@ -180,7 +180,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos)
}
}
- immBegin(GWN_PRIM_TRI_FAN, 5);
+ immBegin(GPU_PRIM_TRI_FAN, 5);
for (i = 0; i < 5; i++) {
immVertex2f(pos, points[i].x, points[i].y);
@@ -188,7 +188,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos)
immEnd();
- immBegin(GWN_PRIM_TRI_FAN, 5);
+ immBegin(GPU_PRIM_TRI_FAN, 5);
for (i = 4; i < 8; i++) {
immVertex2f(pos, points[i].x, points[i].y);
@@ -323,11 +323,11 @@ static void drawscredge_corner(ScrArea *sa, int sizex, int sizey)
/* Wrap up the corners with a nice embossing. */
rcti rect = sa->totrct;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(color);
- immBeginAtMost(GWN_PRIM_LINES, 8);
+ immBeginAtMost(GPU_PRIM_LINES, 8);
/* Right. */
immVertex2f(pos, rect.xmax, rect.ymax);
@@ -386,7 +386,7 @@ static void drawscredge_area_draw(int sizex, int sizey, short x1, short y1, shor
return;
}
- immBegin(GWN_PRIM_LINES, count);
+ immBegin(GPU_PRIM_LINES, count);
/* right border area */
if (x2 < sizex - 1) {
@@ -439,7 +439,7 @@ void ED_screen_draw_edges(wmWindow *win)
ScrArea *sa;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* Note: first loop only draws if U.pixelsize > 1, skip otherwise */
@@ -477,7 +477,7 @@ void ED_screen_draw_edges(wmWindow *win)
*/
void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2)
{
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
GPU_line_width(1);
@@ -518,14 +518,14 @@ void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2)
void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
{
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* splitpoint */
GPU_blend(true);
immUniformColor4ub(255, 255, 255, 100);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
if (dir == 'h') {
const float y = (1 - fac) * sa->totrct.ymin + fac * sa->totrct.ymax;
@@ -537,7 +537,7 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
immUniformColor4ub(0, 0, 0, 100);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, sa->totrct.xmin, y + 1);
immVertex2f(pos, sa->totrct.xmax, y + 1);
@@ -555,7 +555,7 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
immUniformColor4ub(0, 0, 0, 100);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, x + 1, sa->totrct.ymin);
immVertex2f(pos, x + 1, sa->totrct.ymax);
@@ -594,7 +594,7 @@ static void screen_preview_draw_areas(const bScreen *screen, const float scale[2
const float ofs_between_areas)
{
const float ofs_h = ofs_between_areas * 0.5f;
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(col);
@@ -607,7 +607,7 @@ static void screen_preview_draw_areas(const bScreen *screen, const float scale[2
.ymax = sa->totrct.ymax * scale[1] - ofs_h
};
- immBegin(GWN_PRIM_TRI_FAN, 4);
+ immBegin(GPU_PRIM_TRI_FAN, 4);
immVertex2f(pos, rect.xmin, rect.ymin);
immVertex2f(pos, rect.xmax, rect.ymin);
immVertex2f(pos, rect.xmax, rect.ymax);
@@ -627,14 +627,14 @@ static void screen_preview_draw(const bScreen *screen, int size_x, int size_y)
wmOrtho2(0.0f, size_x, 0.0f, size_y);
/* center */
- gpuPushMatrix();
- gpuLoadIdentity();
- gpuTranslate2f(size_x * (1.0f - asp[0]) * 0.5f, size_y * (1.0f - asp[1]) * 0.5f);
+ GPU_matrix_push();
+ GPU_matrix_identity_set();
+ GPU_matrix_translate_2f(size_x * (1.0f - asp[0]) * 0.5f, size_y * (1.0f - asp[1]) * 0.5f);
screen_preview_scale_get(screen, size_x, size_y, asp, scale);
screen_preview_draw_areas(screen, scale, col, 1.5f);
- gpuPopMatrix();
+ GPU_matrix_pop();
}
/**
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 6bc8a6c10cf..1d14940085b 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -381,8 +381,8 @@ static void region_cursor_set(wmWindow *win, bool swin_changed)
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar == screen->active_region) {
if (swin_changed || (ar->type && ar->type->event_cursor)) {
- if (ar->manipulator_map != NULL) {
- if (WM_manipulatormap_cursor_set(ar->manipulator_map, win)) {
+ if (ar->gizmo_map != NULL) {
+ if (WM_gizmomap_cursor_set(ar->gizmo_map, win)) {
return;
}
}
@@ -477,8 +477,8 @@ void ED_screens_initialize(Main *bmain, wmWindowManager *wm)
wmWindow *win;
for (win = wm->windows.first; win; win = win->next) {
- if (WM_window_get_active_workspace(win) == NULL) {
- WM_window_set_active_workspace(win, bmain->workspaces.first);
+ if (BKE_workspace_active_get(win->workspace_hook) == NULL) {
+ BKE_workspace_active_set(win->workspace_hook, bmain->workspaces.first);
}
if (BLI_listbase_is_empty(&win->global_areas.areabase)) {
@@ -792,11 +792,19 @@ static void screen_global_statusbar_area_create(wmWindow *win)
void ED_screen_global_areas_create(wmWindow *win)
{
+ /* Don't create global areas for child windows. */
+ if (win->parent) {
+ return;
+ }
+
+ /* Don't create global area for temporary windows. */
bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
- if (screen->temp == 0) {
- screen_global_topbar_area_create(win);
- screen_global_statusbar_area_create(win);
+ if (screen->temp) {
+ return;
}
+
+ screen_global_topbar_area_create(win);
+ screen_global_statusbar_area_create(win);
}
@@ -936,13 +944,41 @@ static void screen_set_3dview_camera(Scene *scene, ViewLayer *view_layer, ScrAre
}
}
-void ED_screen_update_after_scene_change(const bScreen *screen, Scene *scene_new, ViewLayer *view_layer)
+void ED_screen_scene_change(bContext *C, wmWindow *win, Scene *scene)
{
+#if 0
+ ViewLayer *view_layer_old = WM_window_get_active_view_layer(win);
+#endif
+
+ /* 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) {
View3D *v3d = (View3D *)sl;
- screen_set_3dview_camera(scene_new, view_layer, sa, v3d);
+ screen_set_3dview_camera(scene, view_layer, sa, v3d);
}
}
}
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index fb269740109..e2d6a9aa6ca 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -753,7 +753,6 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo
if (az->direction == AZ_SCROLL_HOR) {
az->alpha = 1.0f;
v2d->alpha_hor = 255;
- v2d->size_hor = V2D_SCROLL_HEIGHT;
redraw = true;
}
}
@@ -761,7 +760,6 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo
if (az->direction == AZ_SCROLL_VERT) {
az->alpha = 1.0f;
v2d->alpha_vert = 255;
- v2d->size_vert = V2D_SCROLL_WIDTH;
redraw = true;
}
}
@@ -775,9 +773,6 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo
alpha = 1.0f - dist_fac;
v2d->alpha_hor = alpha * 255;
- v2d->size_hor = round_fl_to_int(
- V2D_SCROLL_HEIGHT -
- ((V2D_SCROLL_HEIGHT - V2D_SCROLL_HEIGHT_MIN) * dist_fac));
}
else if (az->direction == AZ_SCROLL_VERT) {
dist_fac = BLI_rcti_length_x(&v2d->vert, local_xy[0]) / AZONEFADEIN;
@@ -785,9 +780,6 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo
alpha = 1.0f - dist_fac;
v2d->alpha_vert = alpha * 255;
- v2d->size_vert = round_fl_to_int(
- V2D_SCROLL_WIDTH -
- ((V2D_SCROLL_WIDTH - V2D_SCROLL_WIDTH_MIN) * dist_fac));
}
az->alpha = alpha;
redraw = true;
@@ -1140,7 +1132,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
newwin->scene = scene;
- WM_window_set_active_workspace(newwin, workspace);
+ BKE_workspace_active_set(newwin->workspace_hook, workspace);
/* allocs new screen and adds to newly created window, using window size */
layout_new = ED_workspace_layout_add(bmain, workspace, newwin, BKE_workspace_layout_name_get(layout_old));
newsc = BKE_workspace_layout_screen_get(layout_new);
@@ -1219,11 +1211,11 @@ typedef struct sAreaMoveData {
SNAP_NONE = 0,
/* Snap to an invisible grid with a unit defined in AREAGRID */
SNAP_AREAGRID,
- /* Snap to mid-point and adjacent edges. */
- SNAP_MIDPOINT_AND_ADJACENT,
+ /* Snap to fraction (half, third.. etc) and adjacent edges. */
+ SNAP_FRACTION_AND_ADJACENT,
/* Snap to either bigger or smaller, nothing in-between (used for
* global areas). This has priority over other snap types, if it is
- * used, toggling SNAP_MIDPOINT_AND_ADJACENT doesn't work. */
+ * used, toggling SNAP_FRACTION_AND_ADJACENT doesn't work. */
SNAP_BIGGER_SMALLER_ONLY,
} snap_type;
} sAreaMoveData;
@@ -1368,32 +1360,50 @@ static int area_snap_calc_location(
const int bigger, const int smaller)
{
BLI_assert(snap_type != SNAP_NONE);
- int final_loc = -1;
- const int m_loc = origval + delta;
+ int m_cursor_final = -1;
+ const int m_cursor = origval + delta;
+ const int m_span = (float)(bigger + smaller);
+ const int m_min = origval - smaller;
+ // const int axis_max = axis_min + m_span;
switch (snap_type) {
case SNAP_AREAGRID:
- final_loc = m_loc;
+ m_cursor_final = m_cursor;
if (delta != bigger && delta != -smaller) {
- final_loc -= (m_loc % AREAGRID);
- CLAMP(final_loc, origval - smaller, origval + bigger);
+ m_cursor_final -= (m_cursor % AREAGRID);
+ CLAMP(m_cursor_final, origval - smaller, origval + bigger);
}
break;
case SNAP_BIGGER_SMALLER_ONLY:
- final_loc = (m_loc >= bigger) ? bigger : smaller;
+ m_cursor_final = (m_cursor >= bigger) ? bigger : smaller;
break;
- case SNAP_MIDPOINT_AND_ADJACENT:
+ case SNAP_FRACTION_AND_ADJACENT:
{
const int axis = (dir == 'v') ? 0 : 1;
- int snap_dist;
- int dist;
+ int snap_dist_best = INT_MAX;
{
- /* Test the snap to middle. */
- int middle = origval + (bigger - smaller) / 2;
- snap_dist = abs(m_loc - middle);
- final_loc = middle;
+ const float div_array[] = {
+ /* Middle. */
+ 1.0f / 2.0f,
+ /* Thirds. */
+ 1.0f / 3.0f, 2.0f / 3.0f,
+ /* Quaters. */
+ 1.0f / 4.0f, 3.0f / 4.0f,
+ /* Eighth. */
+ 1.0f / 8.0f, 3.0f / 8.0f,
+ 5.0f / 8.0f, 7.0f / 8.0f,
+ };
+ /* Test the snap to the best division. */
+ for (int i = 0; i < ARRAY_SIZE(div_array); i++) {
+ const int m_cursor_test = m_min + round_fl_to_int(m_span * div_array[i]);
+ const int snap_dist_test = abs(m_cursor - m_cursor_test);
+ if (snap_dist_best >= snap_dist_test) {
+ snap_dist_best = snap_dist_test;
+ m_cursor_final = m_cursor_test;
+ }
+ }
}
for (const ScrVert *v1 = sc->vertbase.first; v1; v1 = v1->next) {
@@ -1410,10 +1420,10 @@ static int area_snap_calc_location(
const int v_loc2 = (&v2->vec.x)[axis];
/* Do not snap to the vertices at the ends. */
if ((origval - smaller) < v_loc2 && v_loc2 < (origval + bigger)) {
- dist = abs(m_loc - v_loc2);
- if (dist <= snap_dist) {
- snap_dist = dist;
- final_loc = v_loc2;
+ const int snap_dist_test = abs(m_cursor - v_loc2);
+ if (snap_dist_best >= snap_dist_test) {
+ snap_dist_best = snap_dist_test;
+ m_cursor_final = v_loc2;
}
}
}
@@ -1426,9 +1436,9 @@ static int area_snap_calc_location(
}
BLI_assert(ELEM(snap_type, SNAP_BIGGER_SMALLER_ONLY) ||
- IN_RANGE_INCL(final_loc, origval - smaller, origval + bigger));
+ IN_RANGE_INCL(m_cursor_final, origval - smaller, origval + bigger));
- return final_loc;
+ return m_cursor_final;
}
/* moves selected screen edge amount of delta, used by split & move */
@@ -1580,7 +1590,7 @@ static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event)
case KM_MODAL_SNAP_ON:
if (md->snap_type != SNAP_BIGGER_SMALLER_ONLY) {
- md->snap_type = SNAP_MIDPOINT_AND_ADJACENT;
+ md->snap_type = SNAP_FRACTION_AND_ADJACENT;
}
break;
@@ -2062,7 +2072,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (sd->previewmode == 0) {
if (sd->do_snap) {
const int snap_loc = area_snap_calc_location(
- CTX_wm_screen(C), SNAP_MIDPOINT_AND_ADJACENT, sd->delta, sd->origval, dir,
+ CTX_wm_screen(C), SNAP_FRACTION_AND_ADJACENT, sd->delta, sd->origval, dir,
sd->bigger, sd->smaller);
sd->delta = snap_loc - sd->origval;
}
@@ -2090,7 +2100,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 1;
const int snap_loc = area_snap_calc_location(
- CTX_wm_screen(C), SNAP_MIDPOINT_AND_ADJACENT, sd->delta, sd->origval, dir,
+ CTX_wm_screen(C), SNAP_FRACTION_AND_ADJACENT, sd->delta, sd->origval, dir,
sd->origmin + sd->origsize, -sd->origmin);
sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 0;
@@ -3669,27 +3679,38 @@ static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot)
/** \name Header Tools Operator
* \{ */
+static bool header_context_menu_poll(bContext *C)
+{
+ ScrArea *sa = CTX_wm_area(C);
+ return (sa && sa->spacetype != SPACE_STATUSBAR);
+}
+
void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
const char *but_flip_str = (ar->alignment == RGN_ALIGN_TOP) ? IFACE_("Flip to Bottom") : IFACE_("Flip to Top");
- uiItemO(layout, IFACE_("Toggle Header"), ICON_NONE, "SCREEN_OT_header");
+ if (!ELEM(sa->spacetype, SPACE_TOPBAR)) {
+ uiItemO(layout, IFACE_("Toggle Header"), ICON_NONE, "SCREEN_OT_header");
+ }
/* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
- uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip");
+ if (!ELEM(sa->spacetype, SPACE_TOPBAR)) {
+ uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip");
+ }
+
uiItemO(layout, IFACE_("Collapse Menus"),
(sa->flag & HEADER_NO_PULLDOWN) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT,
"SCREEN_OT_header_toggle_menus");
- uiItemS(layout);
-
/* file browser should be fullscreen all the time, topbar should
* never be. But other regions can be maximized/restored... */
if (!ELEM(sa->spacetype, SPACE_FILE, SPACE_TOPBAR)) {
+ uiItemS(layout);
+
const char *but_str = sa->full ? IFACE_("Tile Area") : IFACE_("Maximize Area");
uiItemO(layout, but_str, ICON_NONE, "SCREEN_OT_screen_full_area");
}
@@ -3718,6 +3739,7 @@ static void SCREEN_OT_header_context_menu(wmOperatorType *ot)
ot->idname = "SCREEN_OT_header_context_menu";
/* api callbacks */
+ ot->poll = header_context_menu_poll;
ot->invoke = header_context_menu_invoke;
}
@@ -4866,8 +4888,8 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
#endif
- WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_SHIFT, 0);
- kmi = WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_CTRL, 0);
+ kmi = WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "use_hide_panels", true);
#ifdef USE_WM_KEYMAP_27X
@@ -4886,9 +4908,11 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
/* tests */
WM_keymap_add_item(keymap, "SCREEN_OT_region_quadview", QKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
+
+ WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_SHIFT, 0);
+
#ifdef USE_WM_KEYMAP_27X
WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", RKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
- WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_verify_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "SCRIPT_OT_reload", F8KEY, KM_PRESS, 0, 0);
@@ -4966,9 +4990,19 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "next", false);
+#ifdef USE_WM_KEYMAP_27X
/* play (forward and backwards) */
WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0);
- RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0)->ptr, "reverse", true);
+ RNA_boolean_set(
+ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0)->ptr,
+ "reverse", true);
+#else
+ /* play (forward and backwards) */
+ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", SPACEKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_boolean_set(
+ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", SPACEKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr,
+ "reverse", true);
+#endif
WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", ESCKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", MEDIAPLAY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 9d329355500..e54a764faa7 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 */
@@ -134,6 +112,7 @@ static WorkSpaceLayout *workspace_change_get_new_layout(
Main *bmain, WorkSpace *workspace_new, wmWindow *win)
{
/* ED_workspace_duplicate may have stored a layout to activate once the workspace gets activated. */
+ WorkSpaceLayout *layout_old = WM_window_get_active_layout(win);
WorkSpaceLayout *layout_new;
bScreen *screen_new;
@@ -154,8 +133,8 @@ static WorkSpaceLayout *workspace_change_get_new_layout(
workspace_new, layout_new, workspace_change_find_new_layout_cb,
NULL, false);
if (!layout_temp) {
- /* fallback solution: duplicate layout */
- layout_temp = ED_workspace_layout_duplicate(bmain, workspace_new, layout_new, win);
+ /* fallback solution: duplicate layout from old workspace */
+ layout_temp = ED_workspace_layout_duplicate(bmain, workspace_new, layout_old, win);
}
layout_new = layout_temp;
}
@@ -191,15 +170,14 @@ bool ED_workspace_change(
BLI_assert(BKE_workspace_layout_screen_get(layout_new) == screen_new);
if (screen_new) {
- WM_window_set_active_layout(win, workspace_new, layout_new);
- WM_window_set_active_workspace(win, workspace_new);
+ BKE_workspace_hook_layout_for_workspace_set(win->workspace_hook, workspace_new, layout_new);
+ BKE_workspace_active_set(win->workspace_hook, workspace_new);
/* update screen *after* changing workspace - which also causes the
* actual screen change and updates context (including CTX_wm_workspace) */
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 +198,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 +246,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 */