2015-04-06 10:40:12 -03:00
|
|
|
/*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2015 by Blender Foundation
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): Dalai Felinto
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file blender/windowmanager/intern/wm_stereo.c
|
|
|
|
* \ingroup wm
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "DNA_listBase.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BLI_listbase.h"
|
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_report.h"
|
|
|
|
|
|
|
|
#include "GHOST_C-api.h"
|
|
|
|
|
|
|
|
#include "ED_screen.h"
|
|
|
|
|
2016-09-26 14:31:41 +00:00
|
|
|
#include "GPU_immediate.h"
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
#include "wm.h"
|
|
|
|
#include "wm_draw.h" /* wmDrawTriple */
|
|
|
|
#include "wm_window.h"
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
|
|
|
static void wm_method_draw_stereo3d_pageflip(wmWindow *win)
|
|
|
|
{
|
|
|
|
wmDrawData *drawdata;
|
|
|
|
int view;
|
|
|
|
|
|
|
|
for (view = 0; view < 2; view ++) {
|
|
|
|
drawdata = BLI_findlink(&win->drawdata, (view * 2) + 1);
|
|
|
|
|
|
|
|
if (view == STEREO_LEFT_ID)
|
|
|
|
glDrawBuffer(GL_BACK_LEFT);
|
|
|
|
else //STEREO_RIGHT_ID
|
|
|
|
glDrawBuffer(GL_BACK_RIGHT);
|
|
|
|
|
2017-01-09 17:58:13 +01:00
|
|
|
wm_triple_draw_textures(win, drawdata->triple, 1.0f);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
2015-04-09 15:20:45 -03:00
|
|
|
|
|
|
|
glDrawBuffer(GL_BACK);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2017-01-09 17:58:13 +01:00
|
|
|
static GPUInterlaceShader interlace_gpu_id_from_type(eStereo3dInterlaceType interlace_type)
|
|
|
|
{
|
|
|
|
switch (interlace_type) {
|
2017-10-07 15:57:14 +11:00
|
|
|
case S3D_INTERLACE_ROW:
|
|
|
|
return GPU_SHADER_INTERLACE_ROW;
|
|
|
|
case S3D_INTERLACE_COLUMN:
|
|
|
|
return GPU_SHADER_INTERLACE_COLUMN;
|
|
|
|
case S3D_INTERLACE_CHECKERBOARD:
|
|
|
|
default:
|
|
|
|
return GPU_SHADER_INTERLACE_CHECKER;
|
2017-01-09 17:58:13 +01:00
|
|
|
}
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
static void wm_method_draw_stereo3d_interlace(wmWindow *win)
|
|
|
|
{
|
2015-12-25 22:57:50 +01:00
|
|
|
bool swap = (win->stereo3d_format->flag & S3D_INTERLACE_SWAP) != 0;
|
|
|
|
enum eStereo3dInterlaceType interlace_type = win->stereo3d_format->interlace_type;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2017-01-09 17:58:13 +01:00
|
|
|
wmDrawData *drawdata[2];
|
|
|
|
for (int eye = 0; eye < 2; eye++) {
|
|
|
|
int view = swap ? !eye : eye;
|
|
|
|
drawdata[eye] = BLI_findlink(&win->drawdata, (view * 2) + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
const int sizex = WM_window_pixels_x(win);
|
|
|
|
const int sizey = WM_window_pixels_y(win);
|
|
|
|
|
|
|
|
/* wmOrtho for the screen has this same offset */
|
|
|
|
float ratiox = sizex;
|
|
|
|
float ratioy = sizey;
|
|
|
|
float halfx = GLA_PIXEL_OFS;
|
|
|
|
float halfy = GLA_PIXEL_OFS;
|
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertFormat *format = immVertexFormat();
|
|
|
|
unsigned int texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
|
|
|
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
2017-01-09 17:58:13 +01:00
|
|
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_INTERLACE);
|
|
|
|
|
|
|
|
/* leave GL_TEXTURE0 as the latest bind texture */
|
|
|
|
for (int eye = 1; eye >= 0; eye--) {
|
|
|
|
glActiveTexture(GL_TEXTURE0 + eye);
|
|
|
|
glBindTexture(drawdata[eye]->triple->target, drawdata[eye]->triple->bind);
|
|
|
|
}
|
|
|
|
|
|
|
|
immUniform1i("image_a", 0);
|
|
|
|
immUniform1i("image_b", 1);
|
|
|
|
|
|
|
|
immUniform1i("interlace_id", interlace_gpu_id_from_type(interlace_type));
|
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
immBegin(GWN_PRIM_TRI_FAN, 4);
|
2017-01-09 17:58:13 +01:00
|
|
|
|
|
|
|
immAttrib2f(texcoord, halfx, halfy);
|
|
|
|
immVertex2f(pos, 0.0f, 0.0f);
|
|
|
|
|
|
|
|
immAttrib2f(texcoord, ratiox + halfx, halfy);
|
|
|
|
immVertex2f(pos, sizex, 0.0f);
|
|
|
|
|
|
|
|
immAttrib2f(texcoord, ratiox + halfx, ratioy + halfy);
|
|
|
|
immVertex2f(pos, sizex, sizey);
|
|
|
|
|
|
|
|
immAttrib2f(texcoord, halfx, ratioy + halfy);
|
|
|
|
immVertex2f(pos, 0.0f, sizey);
|
|
|
|
|
|
|
|
immEnd();
|
|
|
|
immUnbindProgram();
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2017-01-09 17:58:13 +01:00
|
|
|
for (int eye = 0; eye < 2; eye++) {
|
|
|
|
glBindTexture(drawdata[eye]->triple->target, 0);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wm_method_draw_stereo3d_anaglyph(wmWindow *win)
|
|
|
|
{
|
|
|
|
wmDrawData *drawdata;
|
|
|
|
int view, bit;
|
|
|
|
|
|
|
|
for (view = 0; view < 2; view ++) {
|
|
|
|
drawdata = BLI_findlink(&win->drawdata, (view * 2) + 1);
|
|
|
|
|
|
|
|
bit = view + 1;
|
|
|
|
switch (win->stereo3d_format->anaglyph_type) {
|
|
|
|
case S3D_ANAGLYPH_REDCYAN:
|
|
|
|
glColorMask((1&bit) ? GL_TRUE : GL_FALSE,
|
|
|
|
(2&bit) ? GL_TRUE : GL_FALSE,
|
|
|
|
(2&bit) ? GL_TRUE : GL_FALSE,
|
|
|
|
GL_FALSE);
|
|
|
|
break;
|
|
|
|
case S3D_ANAGLYPH_GREENMAGENTA:
|
|
|
|
glColorMask((2&bit) ? GL_TRUE : GL_FALSE,
|
|
|
|
(1&bit) ? GL_TRUE : GL_FALSE,
|
|
|
|
(2&bit) ? GL_TRUE : GL_FALSE,
|
|
|
|
GL_FALSE);
|
|
|
|
break;
|
|
|
|
case S3D_ANAGLYPH_YELLOWBLUE:
|
|
|
|
glColorMask((1&bit) ? GL_TRUE : GL_FALSE,
|
|
|
|
(1&bit) ? GL_TRUE : GL_FALSE,
|
|
|
|
(2&bit) ? GL_TRUE : GL_FALSE,
|
|
|
|
GL_FALSE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-09 17:58:13 +01:00
|
|
|
wm_triple_draw_textures(win, drawdata->triple, 1.0f);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wm_method_draw_stereo3d_sidebyside(wmWindow *win)
|
|
|
|
{
|
|
|
|
wmDrawData *drawdata;
|
|
|
|
wmDrawTriple *triple;
|
|
|
|
float halfx, halfy, ratiox, ratioy;
|
|
|
|
int view;
|
|
|
|
int soffx;
|
|
|
|
bool cross_eyed = (win->stereo3d_format->flag & S3D_SIDEBYSIDE_CROSSEYED) != 0;
|
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertFormat *format = immVertexFormat();
|
|
|
|
unsigned int texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
|
|
|
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
2016-10-18 00:08:34 -04:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
for (view = 0; view < 2; view ++) {
|
|
|
|
drawdata = BLI_findlink(&win->drawdata, (view * 2) + 1);
|
|
|
|
triple = drawdata->triple;
|
|
|
|
|
|
|
|
soffx = WM_window_pixels_x(win) * 0.5f;
|
|
|
|
if (view == STEREO_LEFT_ID) {
|
|
|
|
if (!cross_eyed)
|
|
|
|
soffx = 0;
|
|
|
|
}
|
|
|
|
else { //RIGHT_LEFT_ID
|
|
|
|
if (cross_eyed)
|
|
|
|
soffx = 0;
|
|
|
|
}
|
|
|
|
|
2015-12-06 21:41:21 +01:00
|
|
|
const int sizex = triple->x;
|
|
|
|
const int sizey = triple->y;
|
|
|
|
|
|
|
|
/* wmOrtho for the screen has this same offset */
|
|
|
|
ratiox = sizex;
|
|
|
|
ratioy = sizey;
|
|
|
|
halfx = GLA_PIXEL_OFS;
|
|
|
|
halfy = GLA_PIXEL_OFS;
|
|
|
|
|
|
|
|
/* texture rectangle has unnormalized coordinates */
|
|
|
|
if (triple->target == GL_TEXTURE_2D) {
|
|
|
|
ratiox /= triple->x;
|
|
|
|
ratioy /= triple->y;
|
|
|
|
halfx /= triple->x;
|
|
|
|
halfy /= triple->y;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2016-10-18 00:08:34 -04:00
|
|
|
/* TODO: if target is always same for both eyes, bind program & set uniform before loop */
|
|
|
|
immBindBuiltinProgram((triple->target == GL_TEXTURE_2D) ? GPU_SHADER_3D_IMAGE_MODULATE_ALPHA : GPU_SHADER_3D_IMAGE_RECT_MODULATE_ALPHA);
|
2016-09-26 14:31:41 +00:00
|
|
|
|
2015-12-06 21:41:21 +01:00
|
|
|
glBindTexture(triple->target, triple->bind);
|
|
|
|
|
2016-10-21 20:42:33 +00:00
|
|
|
immUniform1f("alpha", 1.0f);
|
2016-10-25 01:02:41 -04:00
|
|
|
immUniform1i("image", 0); /* default GL_TEXTURE0 unit */
|
2016-09-26 14:31:41 +00:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
immBegin(GWN_PRIM_TRI_FAN, 4);
|
2016-09-26 14:31:41 +00:00
|
|
|
|
|
|
|
immAttrib2f(texcoord, halfx, halfy);
|
|
|
|
immVertex2f(pos, soffx, 0.0f);
|
|
|
|
|
|
|
|
immAttrib2f(texcoord, ratiox + halfx, halfy);
|
|
|
|
immVertex2f(pos, soffx + (sizex * 0.5f), 0.0f);
|
2015-12-06 21:41:21 +01:00
|
|
|
|
2016-09-26 14:31:41 +00:00
|
|
|
immAttrib2f(texcoord, ratiox + halfx, ratioy + halfy);
|
|
|
|
immVertex2f(pos, soffx + (sizex * 0.5f), sizey);
|
2015-12-06 21:41:21 +01:00
|
|
|
|
2016-09-26 14:31:41 +00:00
|
|
|
immAttrib2f(texcoord, halfx, ratioy + halfy);
|
|
|
|
immVertex2f(pos, soffx, sizey);
|
2015-12-06 21:41:21 +01:00
|
|
|
|
2016-09-26 14:31:41 +00:00
|
|
|
immEnd();
|
2015-12-06 21:41:21 +01:00
|
|
|
|
2016-10-18 00:08:34 -04:00
|
|
|
/* TODO: if target is always same for both eyes, unbind program & texture target after loop */
|
2015-04-06 10:40:12 -03:00
|
|
|
glBindTexture(triple->target, 0);
|
2016-10-18 00:08:34 -04:00
|
|
|
immUnbindProgram();
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wm_method_draw_stereo3d_topbottom(wmWindow *win)
|
|
|
|
{
|
|
|
|
wmDrawData *drawdata;
|
|
|
|
wmDrawTriple *triple;
|
|
|
|
float halfx, halfy, ratiox, ratioy;
|
|
|
|
int view;
|
|
|
|
int soffy;
|
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertFormat *format = immVertexFormat();
|
|
|
|
unsigned int texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
|
|
|
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
2016-10-18 00:08:34 -04:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
for (view = 0; view < 2; view ++) {
|
|
|
|
drawdata = BLI_findlink(&win->drawdata, (view * 2) + 1);
|
|
|
|
triple = drawdata->triple;
|
|
|
|
|
|
|
|
if (view == STEREO_LEFT_ID) {
|
|
|
|
soffy = WM_window_pixels_y(win) * 0.5f;
|
|
|
|
}
|
|
|
|
else { /* STEREO_RIGHT_ID */
|
|
|
|
soffy = 0;
|
|
|
|
}
|
|
|
|
|
2015-12-06 21:41:21 +01:00
|
|
|
const int sizex = triple->x;
|
|
|
|
const int sizey = triple->y;
|
|
|
|
|
|
|
|
/* wmOrtho for the screen has this same offset */
|
|
|
|
ratiox = sizex;
|
|
|
|
ratioy = sizey;
|
|
|
|
halfx = GLA_PIXEL_OFS;
|
|
|
|
halfy = GLA_PIXEL_OFS;
|
|
|
|
|
|
|
|
/* texture rectangle has unnormalized coordinates */
|
|
|
|
if (triple->target == GL_TEXTURE_2D) {
|
|
|
|
ratiox /= triple->x;
|
|
|
|
ratioy /= triple->y;
|
|
|
|
halfx /= triple->x;
|
|
|
|
halfy /= triple->y;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2016-10-18 00:08:34 -04:00
|
|
|
/* TODO: if target is always same for both eyes, bind program & set uniforms before loop */
|
|
|
|
immBindBuiltinProgram((triple->target == GL_TEXTURE_2D) ? GPU_SHADER_3D_IMAGE_MODULATE_ALPHA : GPU_SHADER_3D_IMAGE_RECT_MODULATE_ALPHA);
|
2016-09-26 14:31:41 +00:00
|
|
|
|
2015-12-06 21:41:21 +01:00
|
|
|
glBindTexture(triple->target, triple->bind);
|
|
|
|
|
2016-09-28 18:48:51 +00:00
|
|
|
immUniform1f("alpha", 1.0f);
|
2016-10-25 01:02:41 -04:00
|
|
|
immUniform1i("image", 0); /* default GL_TEXTURE0 unit */
|
2016-09-26 14:31:41 +00:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
immBegin(GWN_PRIM_TRI_FAN, 4);
|
2016-09-26 14:31:41 +00:00
|
|
|
|
|
|
|
immAttrib2f(texcoord, halfx, halfy);
|
|
|
|
immVertex2f(pos, 0.0f, soffy);
|
|
|
|
|
|
|
|
immAttrib2f(texcoord, ratiox + halfx, halfy);
|
|
|
|
immVertex2f(pos, sizex, soffy);
|
2015-12-06 21:41:21 +01:00
|
|
|
|
2016-09-26 14:31:41 +00:00
|
|
|
immAttrib2f(texcoord, ratiox + halfx, ratioy + halfy);
|
|
|
|
immVertex2f(pos, sizex, soffy + (sizey * 0.5f));
|
2015-12-06 21:41:21 +01:00
|
|
|
|
2016-09-26 14:31:41 +00:00
|
|
|
immAttrib2f(texcoord, halfx, ratioy + halfy);
|
|
|
|
immVertex2f(pos, 0.0f, soffy + (sizey * 0.5f));
|
2015-12-06 21:41:21 +01:00
|
|
|
|
2016-09-26 14:31:41 +00:00
|
|
|
immEnd();
|
2015-12-06 21:41:21 +01:00
|
|
|
|
2016-10-18 00:08:34 -04:00
|
|
|
/* TODO: if target is always same for both eyes, unbind program & texture target after loop */
|
|
|
|
immUnbindProgram();
|
2015-04-06 10:40:12 -03:00
|
|
|
glBindTexture(triple->target, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void wm_method_draw_stereo3d(const bContext *UNUSED(C), wmWindow *win)
|
|
|
|
{
|
|
|
|
switch (win->stereo3d_format->display_mode) {
|
|
|
|
case S3D_DISPLAY_ANAGLYPH:
|
|
|
|
wm_method_draw_stereo3d_anaglyph(win);
|
|
|
|
break;
|
|
|
|
case S3D_DISPLAY_INTERLACE:
|
|
|
|
wm_method_draw_stereo3d_interlace(win);
|
|
|
|
break;
|
|
|
|
case S3D_DISPLAY_PAGEFLIP:
|
|
|
|
wm_method_draw_stereo3d_pageflip(win);
|
|
|
|
break;
|
|
|
|
case S3D_DISPLAY_SIDEBYSIDE:
|
|
|
|
wm_method_draw_stereo3d_sidebyside(win);
|
|
|
|
break;
|
|
|
|
case S3D_DISPLAY_TOPBOTTOM:
|
|
|
|
wm_method_draw_stereo3d_topbottom(win);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-10 13:41:57 +10:00
|
|
|
static bool wm_stereo3d_quadbuffer_supported(void)
|
2015-04-09 20:43:59 -03:00
|
|
|
{
|
2016-10-25 01:02:41 -04:00
|
|
|
GLboolean stereo = GL_FALSE;
|
|
|
|
glGetBooleanv(GL_STEREO, &stereo);
|
|
|
|
return stereo == GL_TRUE;
|
2015-04-09 20:43:59 -03:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static bool wm_stereo3d_is_fullscreen_required(eStereoDisplayMode stereo_display)
|
|
|
|
{
|
|
|
|
return ELEM(stereo_display,
|
|
|
|
S3D_DISPLAY_SIDEBYSIDE,
|
2015-04-23 19:01:49 -03:00
|
|
|
S3D_DISPLAY_TOPBOTTOM);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool WM_stereo3d_enabled(wmWindow *win, bool skip_stereo3d_check)
|
|
|
|
{
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
const bScreen *screen = WM_window_get_active_screen(win);
|
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-08-23 21:12:48 +10:00
|
|
|
/* some 3d methods change the window arrangement, thus they shouldn't
|
2015-06-13 11:23:01 -03:00
|
|
|
* toggle on/off just because there is no 3d elements being drawn */
|
|
|
|
if (wm_stereo3d_is_fullscreen_required(win->stereo3d_format->display_mode)) {
|
|
|
|
return GHOST_GetWindowState(win->ghostwin) == GHOST_kWindowStateFullScreen;
|
|
|
|
}
|
|
|
|
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
if ((skip_stereo3d_check == false) && (ED_screen_stereo3d_required(screen, scene) == false)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return false;
|
2015-04-09 20:43:59 -03:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-08-23 21:12:48 +10:00
|
|
|
/* some 3d methods change the window arrangement, thus they shouldn't
|
2015-06-13 11:23:01 -03:00
|
|
|
* toggle on/off just because there is no 3d elements being drawn */
|
2015-04-08 01:59:24 -03:00
|
|
|
if (wm_stereo3d_is_fullscreen_required(win->stereo3d_format->display_mode)) {
|
2015-06-13 11:23:01 -03:00
|
|
|
return GHOST_GetWindowState(win->ghostwin) == GHOST_kWindowStateFullScreen;
|
2015-04-08 01:59:24 -03:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-06 00:40:48 +01:00
|
|
|
/**
|
|
|
|
* If needed, this adjusts \a r_mouse_xy so that drawn cursor and handled mouse position are matching visually.
|
|
|
|
*/
|
|
|
|
void wm_stereo3d_mouse_offset_apply(wmWindow *win, int *r_mouse_xy)
|
|
|
|
{
|
|
|
|
if (!WM_stereo3d_enabled(win, false))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (win->stereo3d_format->display_mode == S3D_DISPLAY_SIDEBYSIDE) {
|
|
|
|
const int half_x = win->sizex / 2;
|
|
|
|
/* right half of the screen */
|
|
|
|
if (r_mouse_xy[0] > half_x) {
|
|
|
|
r_mouse_xy[0] -= half_x;
|
|
|
|
}
|
|
|
|
r_mouse_xy[0] *= 2;
|
|
|
|
}
|
|
|
|
else if (win->stereo3d_format->display_mode == S3D_DISPLAY_TOPBOTTOM) {
|
|
|
|
const int half_y = win->sizey / 2;
|
|
|
|
/* upper half of the screen */
|
|
|
|
if (r_mouse_xy[1] > half_y) {
|
|
|
|
r_mouse_xy[1] -= half_y;
|
|
|
|
}
|
|
|
|
r_mouse_xy[1] *= 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/************************** Stereo 3D operator **********************************/
|
|
|
|
typedef struct Stereo3dData {
|
|
|
|
Stereo3dFormat stereo3d_format;
|
|
|
|
} Stereo3dData;
|
|
|
|
|
2015-04-09 20:43:59 -03:00
|
|
|
static bool wm_stereo3d_set_properties(bContext *UNUSED(C), wmOperator *op)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2015-04-09 20:43:59 -03:00
|
|
|
Stereo3dData *s3dd = op->customdata;
|
|
|
|
Stereo3dFormat *s3d = &s3dd->stereo3d_format;
|
2015-04-06 10:40:12 -03:00
|
|
|
PropertyRNA *prop;
|
|
|
|
bool is_set = false;
|
|
|
|
|
|
|
|
prop = RNA_struct_find_property(op->ptr, "display_mode");
|
|
|
|
if (RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
s3d->display_mode = RNA_property_enum_get(op->ptr, prop);
|
|
|
|
is_set = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop = RNA_struct_find_property(op->ptr, "anaglyph_type");
|
|
|
|
if (RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
s3d->anaglyph_type = RNA_property_enum_get(op->ptr, prop);
|
|
|
|
is_set = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop = RNA_struct_find_property(op->ptr, "interlace_type");
|
|
|
|
if (RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
s3d->interlace_type = RNA_property_enum_get(op->ptr, prop);
|
|
|
|
is_set = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop = RNA_struct_find_property(op->ptr, "use_interlace_swap");
|
|
|
|
if (RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
if (RNA_property_boolean_get(op->ptr, prop))
|
|
|
|
s3d->flag |= S3D_INTERLACE_SWAP;
|
|
|
|
else
|
|
|
|
s3d->flag &= ~S3D_INTERLACE_SWAP;
|
|
|
|
is_set = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop = RNA_struct_find_property(op->ptr, "use_sidebyside_crosseyed");
|
|
|
|
if (RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
if (RNA_property_boolean_get(op->ptr, prop))
|
|
|
|
s3d->flag |= S3D_SIDEBYSIDE_CROSSEYED;
|
|
|
|
else
|
|
|
|
s3d->flag &= ~S3D_SIDEBYSIDE_CROSSEYED;
|
|
|
|
is_set = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return is_set;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wm_stereo3d_set_init(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Stereo3dData *s3dd;
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
|
|
|
op->customdata = s3dd = MEM_callocN(sizeof(Stereo3dData), __func__);
|
|
|
|
|
|
|
|
/* store the original win stereo 3d settings in case of cancel */
|
|
|
|
s3dd->stereo3d_format = *win->stereo3d_format;
|
|
|
|
}
|
|
|
|
|
|
|
|
int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
2015-06-09 01:25:34 +10:00
|
|
|
wmWindow *win_src = CTX_wm_window(C);
|
|
|
|
wmWindow *win_dst = NULL;
|
|
|
|
const bool is_fullscreen = WM_window_is_fullscreen(win_src);
|
|
|
|
char prev_display_mode = win_src->stereo3d_format->display_mode;
|
2015-04-24 13:06:04 -03:00
|
|
|
Stereo3dData *s3dd;
|
2015-05-28 18:43:49 +10:00
|
|
|
bool ok = true;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-04-24 13:06:04 -03:00
|
|
|
if (G.background)
|
2015-04-06 10:40:12 -03:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2015-04-24 13:06:04 -03:00
|
|
|
if (op->customdata == NULL) {
|
|
|
|
/* no invoke means we need to set the operator properties here */
|
|
|
|
wm_stereo3d_set_init(C, op);
|
|
|
|
wm_stereo3d_set_properties(C, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
s3dd = op->customdata;
|
2015-06-09 01:25:34 +10:00
|
|
|
*win_src->stereo3d_format = s3dd->stereo3d_format;
|
2015-04-09 20:43:59 -03:00
|
|
|
|
2015-04-24 12:51:20 -03:00
|
|
|
if (prev_display_mode == S3D_DISPLAY_PAGEFLIP &&
|
2015-06-09 01:25:34 +10:00
|
|
|
prev_display_mode != win_src->stereo3d_format->display_mode)
|
2015-04-24 12:51:20 -03:00
|
|
|
{
|
|
|
|
/* in case the hardward supports pageflip but not the display */
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
if ((win_dst = wm_window_copy_test(C, win_src, false))) {
|
2015-06-09 01:25:34 +10:00
|
|
|
/* pass */
|
2015-04-24 12:51:20 -03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
BKE_report(op->reports, RPT_ERROR,
|
2015-04-27 20:10:32 +02:00
|
|
|
"Failed to create a window without quad-buffer support, you may experience flickering");
|
2015-05-28 18:43:49 +10:00
|
|
|
ok = false;
|
2015-04-24 12:51:20 -03:00
|
|
|
}
|
|
|
|
}
|
2015-06-09 01:25:34 +10:00
|
|
|
else if (win_src->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP) {
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
const bScreen *screen = WM_window_get_active_screen(win_src);
|
|
|
|
|
|
|
|
/* ED_workspace_layout_duplicate() can't handle other cases yet T44688 */
|
|
|
|
if (screen->state != SCREENNORMAL) {
|
2015-06-08 18:40:48 -03:00
|
|
|
BKE_report(op->reports, RPT_ERROR,
|
|
|
|
"Failed to switch to Time Sequential mode when in fullscreen");
|
|
|
|
ok = false;
|
|
|
|
}
|
2015-04-24 12:51:20 -03:00
|
|
|
/* pageflip requires a new window to be created with the proper OS flags */
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
else if ((win_dst = wm_window_copy_test(C, win_src, false))) {
|
2015-04-23 19:01:49 -03:00
|
|
|
if (wm_stereo3d_quadbuffer_supported()) {
|
|
|
|
BKE_report(op->reports, RPT_INFO, "Quad-buffer window successfully created");
|
|
|
|
}
|
|
|
|
else {
|
2015-06-09 01:25:34 +10:00
|
|
|
wm_window_close(C, wm, win_dst);
|
|
|
|
win_dst = NULL;
|
2015-04-23 19:01:49 -03:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Quad-buffer not supported by the system");
|
2015-05-28 18:43:49 +10:00
|
|
|
ok = false;
|
2015-04-23 19:01:49 -03:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
else {
|
2015-04-13 21:00:06 +02:00
|
|
|
BKE_report(op->reports, RPT_ERROR,
|
2015-04-27 20:10:32 +02:00
|
|
|
"Failed to create a window compatible with the time sequential display method");
|
2015-05-28 18:43:49 +10:00
|
|
|
ok = false;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
}
|
2015-04-24 12:51:20 -03:00
|
|
|
|
|
|
|
if (wm_stereo3d_is_fullscreen_required(s3dd->stereo3d_format.display_mode)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
if (!is_fullscreen) {
|
2015-04-13 21:00:06 +02:00
|
|
|
BKE_report(op->reports, RPT_INFO, "Stereo 3D Mode requires the window to be fullscreen");
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-24 13:06:04 -03:00
|
|
|
MEM_freeN(op->customdata);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-05-28 18:43:49 +10:00
|
|
|
if (ok) {
|
2015-06-09 01:25:34 +10:00
|
|
|
if (win_dst) {
|
|
|
|
wm_window_close(C, wm, win_src);
|
|
|
|
}
|
|
|
|
|
2015-05-28 18:43:49 +10:00
|
|
|
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* without this, the popup won't be freed freed properly T44688 */
|
2015-06-09 01:25:34 +10:00
|
|
|
CTX_wm_window_set(C, win_src);
|
2015-06-08 18:40:48 -03:00
|
|
|
win_src->stereo3d_format->display_mode = prev_display_mode;
|
2015-05-28 18:43:49 +10:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
int wm_stereo3d_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
|
|
|
{
|
|
|
|
wm_stereo3d_set_init(C, op);
|
|
|
|
|
|
|
|
if (wm_stereo3d_set_properties(C, op))
|
|
|
|
return wm_stereo3d_set_exec(C, op);
|
|
|
|
else
|
|
|
|
return WM_operator_props_dialog_popup(C, op, 250, 100);
|
|
|
|
}
|
|
|
|
|
2015-04-09 20:43:59 -03:00
|
|
|
void wm_stereo3d_set_draw(bContext *UNUSED(C), wmOperator *op)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2015-04-09 20:43:59 -03:00
|
|
|
Stereo3dData *s3dd = op->customdata;
|
2015-04-06 10:40:12 -03:00
|
|
|
PointerRNA stereo3d_format_ptr;
|
|
|
|
uiLayout *layout = op->layout;
|
|
|
|
uiLayout *col;
|
|
|
|
|
2015-04-09 20:43:59 -03:00
|
|
|
RNA_pointer_create(NULL, &RNA_Stereo3dDisplay, &s3dd->stereo3d_format, &stereo3d_format_ptr);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, false);
|
|
|
|
uiItemR(col, &stereo3d_format_ptr, "display_mode", 0, NULL, ICON_NONE);
|
|
|
|
|
2015-04-09 20:43:59 -03:00
|
|
|
switch (s3dd->stereo3d_format.display_mode) {
|
2015-04-06 10:40:12 -03:00
|
|
|
case S3D_DISPLAY_ANAGLYPH:
|
|
|
|
{
|
|
|
|
uiItemR(col, &stereo3d_format_ptr, "anaglyph_type", 0, NULL, ICON_NONE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case S3D_DISPLAY_INTERLACE:
|
|
|
|
{
|
|
|
|
uiItemR(col, &stereo3d_format_ptr, "interlace_type", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, &stereo3d_format_ptr, "use_interlace_swap", 0, NULL, ICON_NONE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case S3D_DISPLAY_SIDEBYSIDE:
|
|
|
|
{
|
|
|
|
uiItemR(col, &stereo3d_format_ptr, "use_sidebyside_crosseyed", 0, NULL, ICON_NONE);
|
|
|
|
/* fall-through */
|
|
|
|
}
|
|
|
|
case S3D_DISPLAY_PAGEFLIP:
|
|
|
|
case S3D_DISPLAY_TOPBOTTOM:
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-07 15:42:44 -03:00
|
|
|
bool wm_stereo3d_set_check(bContext *UNUSED(C), wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
/* the check function guarantees that the menu is updated to show the
|
|
|
|
* sub-options when an enum change (e.g., it shows the anaglyph options
|
|
|
|
* when anaglyph is on, and the interlace options when this is on */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-09 20:43:59 -03:00
|
|
|
void wm_stereo3d_set_cancel(bContext *UNUSED(C), wmOperator *op)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
|
|
|
MEM_freeN(op->customdata);
|
|
|
|
op->customdata = NULL;
|
|
|
|
}
|