2011-05-19 11:34:11 +00:00
|
|
|
/*
|
|
|
|
* 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) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup edrend
|
2011-05-19 11:34:11 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
|
|
#include "DNA_scene_types.h"
|
2012-12-14 15:09:59 +00:00
|
|
|
#include "DNA_userdef_types.h"
|
2011-05-19 11:34:11 +00:00
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_image.h"
|
|
|
|
#include "BKE_global.h"
|
2018-06-11 15:40:37 +02:00
|
|
|
#include "BKE_main.h"
|
2011-05-19 11:34:11 +00:00
|
|
|
#include "BKE_screen.h"
|
2015-10-07 00:27:27 +11:00
|
|
|
#include "BKE_report.h"
|
2011-05-19 11:34:11 +00:00
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "ED_screen.h"
|
2017-04-20 00:17:42 +02:00
|
|
|
#include "UI_interface.h"
|
2011-05-19 11:34:11 +00:00
|
|
|
|
|
|
|
#include "wm_window.h"
|
|
|
|
|
|
|
|
#include "render_intern.h"
|
|
|
|
|
|
|
|
/*********************** utilities for finding areas *************************/
|
|
|
|
|
|
|
|
/* returns biggest area that is not uv/image editor. Note that it uses buttons */
|
|
|
|
/* window as the last possible alternative. */
|
2011-11-04 01:15:04 +00:00
|
|
|
/* would use BKE_screen_find_big_area(...) but this is too specific */
|
2011-05-19 11:34:11 +00:00
|
|
|
static ScrArea *biggest_non_image_area(bContext *C)
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
bScreen *sc = CTX_wm_screen(C);
|
|
|
|
ScrArea *sa, *big = NULL;
|
|
|
|
int size, maxsize = 0, bwmaxsize = 0;
|
|
|
|
short foundwin = 0;
|
2011-05-19 11:34:11 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sa->winx > 30 && sa->winy > 30) {
|
2012-03-29 22:42:32 +00:00
|
|
|
size = sa->winx * sa->winy;
|
2019-02-16 10:44:15 +11:00
|
|
|
if (!sa->full && sa->spacetype == SPACE_PROPERTIES) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (foundwin == 0 && size > bwmaxsize) {
|
2012-03-29 22:42:32 +00:00
|
|
|
bwmaxsize = size;
|
|
|
|
big = sa;
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (sa->spacetype != SPACE_IMAGE && size > maxsize) {
|
2012-03-29 22:42:32 +00:00
|
|
|
maxsize = size;
|
|
|
|
big = sa;
|
|
|
|
foundwin = 1;
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return big;
|
|
|
|
}
|
|
|
|
|
2013-04-13 15:14:34 +00:00
|
|
|
static ScrArea *find_area_showing_r_result(bContext *C, Scene *scene, wmWindow **win)
|
2011-05-19 11:34:11 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
2011-05-19 11:34:11 +00:00
|
|
|
ScrArea *sa = NULL;
|
|
|
|
SpaceImage *sima;
|
|
|
|
|
|
|
|
/* find an imagewindow showing render result */
|
2012-03-29 22:42:32 +00:00
|
|
|
for (*win = wm->windows.first; *win; *win = (*win)->next) {
|
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 (WM_window_get_active_scene(*win) == scene) {
|
|
|
|
const bScreen *screen = WM_window_get_active_screen(*win);
|
|
|
|
|
|
|
|
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
2013-04-13 15:14:34 +00:00
|
|
|
if (sa->spacetype == SPACE_IMAGE) {
|
|
|
|
sima = sa->spacedata.first;
|
|
|
|
if (sima->image && sima->image->type == IMA_TYPE_R_RESULT)
|
|
|
|
break;
|
|
|
|
}
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
2013-04-13 15:14:34 +00:00
|
|
|
if (sa)
|
|
|
|
break;
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-05-19 11:34:11 +00:00
|
|
|
return sa;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ScrArea *find_area_image_empty(bContext *C)
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
bScreen *sc = CTX_wm_screen(C);
|
2011-05-19 11:34:11 +00:00
|
|
|
ScrArea *sa;
|
|
|
|
SpaceImage *sima;
|
|
|
|
|
|
|
|
/* find an imagewindow showing render result */
|
2012-03-29 22:42:32 +00:00
|
|
|
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
|
|
|
if (sa->spacetype == SPACE_IMAGE) {
|
|
|
|
sima = sa->spacedata.first;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!sima->image)
|
2011-05-19 11:34:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sa;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************** open image editor for render *************************/
|
|
|
|
|
|
|
|
/* new window uses x,y to set position */
|
2015-10-07 00:27:27 +11:00
|
|
|
ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
|
2011-05-19 11:34:11 +00:00
|
|
|
{
|
2018-06-11 15:40:37 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-03-29 22:42:32 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2017-04-20 00:17:42 +02:00
|
|
|
wmWindow *win = NULL;
|
2012-03-29 22:42:32 +00:00
|
|
|
ScrArea *sa = NULL;
|
2011-05-19 11:34:11 +00:00
|
|
|
SpaceImage *sima;
|
2014-01-28 03:52:21 +11:00
|
|
|
bool area_was_image = false;
|
2011-05-19 11:34:11 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (scene->r.displaymode == R_OUTPUT_NONE)
|
2013-12-17 23:42:38 +06:00
|
|
|
return NULL;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (scene->r.displaymode == R_OUTPUT_WINDOW) {
|
2017-04-20 00:17:42 +02:00
|
|
|
int sizex = 30 * UI_DPI_FAC + (scene->r.xsch * scene->r.size) / 100;
|
|
|
|
int sizey = 60 * UI_DPI_FAC + (scene->r.ysch * scene->r.size) / 100;
|
2011-05-19 11:34:11 +00:00
|
|
|
|
|
|
|
/* arbitrary... miniature image window views don't make much sense */
|
2012-03-29 22:42:32 +00:00
|
|
|
if (sizex < 320) sizex = 320;
|
|
|
|
if (sizey < 256) sizey = 256;
|
2011-05-19 11:34:11 +00:00
|
|
|
|
|
|
|
/* changes context! */
|
2017-04-20 00:17:42 +02:00
|
|
|
if (WM_window_open_temp(C, mx, my, sizex, sizey, WM_WINDOW_RENDER) == NULL) {
|
2015-10-07 00:27:27 +11:00
|
|
|
BKE_report(reports, RPT_ERROR, "Failed to open window!");
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-05-19 11:34:11 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
sa = CTX_wm_area(C);
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
2012-03-29 22:42:32 +00:00
|
|
|
else if (scene->r.displaymode == R_OUTPUT_SCREEN) {
|
2014-04-30 07:48:54 +10:00
|
|
|
sa = CTX_wm_area(C);
|
2011-05-19 11:34:11 +00:00
|
|
|
|
2015-01-24 22:53:22 +01:00
|
|
|
/* if the active screen is already in fullscreen mode, skip this and
|
|
|
|
* unset the area, so that the fullscreen area is just changed later */
|
2015-02-03 16:40:27 +11:00
|
|
|
if (sa && sa->full) {
|
2015-01-24 22:53:22 +01:00
|
|
|
sa = NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (sa && sa->spacetype == SPACE_IMAGE)
|
|
|
|
area_was_image = true;
|
|
|
|
|
|
|
|
/* this function returns with changed context */
|
|
|
|
sa = ED_screen_full_newspace(C, sa, SPACE_IMAGE);
|
|
|
|
}
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!sa) {
|
2013-04-13 15:14:34 +00:00
|
|
|
sa = find_area_showing_r_result(C, scene, &win);
|
2012-03-29 22:42:32 +00:00
|
|
|
if (sa == NULL)
|
|
|
|
sa = find_area_image_empty(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-05-19 11:34:11 +00:00
|
|
|
/* if area found in other window, we make that one show in front */
|
2012-03-29 22:42:32 +00:00
|
|
|
if (win && win != CTX_wm_window(C))
|
2011-05-19 11:34:11 +00:00
|
|
|
wm_window_raise(win);
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (sa == NULL) {
|
2011-05-19 11:34:11 +00:00
|
|
|
/* find largest open non-image area */
|
2012-03-29 22:42:32 +00:00
|
|
|
sa = biggest_non_image_area(C);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sa) {
|
Fix a bunch of temp full-screen glitches
Steps to reproduce fixed glitches were:
* Change any editor to be file browser from menu, Ctrl+O *from the file browser area*, Esc -> area reset to what it was before changing to file browser initially
* Ctrl+O from any area, F12, Esc -> returns to initial editor in full-screen (expected is file browser in full-screen)
Fixes T46229
Core of the fix is removing old area from spacedata list when going back to previous area (see ED_area_prevspace -> BKE_spacedata_remove). Also, when creating a new temp area we now don't exit old area anymore (needed so SpaceFile->op is kept, but it also makes sense in general)
Aaand finally removes some ugly hacks.
Tested quite a bit, so I think it's safe to apply (besides of remark below), just would like to get things double checked and confirmed. After all, this full-screen stuff finally starts to feel like it's working :P
Note, there's still a memory leak when quitting Blender with temp area open. Haven't found out how to solve yet, but it's not that important for review anyway.
Reviewers: campbellbarton, brecht
Reviewed By: brecht
Subscribers: plyczkowski, Blendify
Maniphest Tasks: T46229
Differential Revision: https://developer.blender.org/D1531
2016-02-29 16:18:42 +01:00
|
|
|
ED_area_newspace(C, sa, SPACE_IMAGE, true);
|
2012-03-29 22:42:32 +00:00
|
|
|
sima = sa->spacedata.first;
|
2011-05-19 11:34:11 +00:00
|
|
|
|
|
|
|
/* makes ESC go back to prev space */
|
|
|
|
sima->flag |= SI_PREVSPACE;
|
2015-01-28 02:32:52 +01:00
|
|
|
|
|
|
|
/* we already had a fullscreen here -> mark new space as a stacked fullscreen */
|
|
|
|
if (sa->full) {
|
2015-06-08 17:20:21 +02:00
|
|
|
sa->flag |= (AREA_FLAG_STACKED_FULLSCREEN | AREA_FLAG_TEMP_TYPE);
|
2015-01-28 02:32:52 +01:00
|
|
|
}
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* use any area of decent size */
|
2015-01-21 13:43:46 +11:00
|
|
|
sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TYPE_ANY, 0);
|
2012-03-29 22:42:32 +00:00
|
|
|
if (sa->spacetype != SPACE_IMAGE) {
|
2011-05-19 11:34:11 +00:00
|
|
|
// XXX newspace(sa, SPACE_IMAGE);
|
2012-03-29 22:42:32 +00:00
|
|
|
sima = sa->spacedata.first;
|
2011-05-19 11:34:11 +00:00
|
|
|
|
|
|
|
/* makes ESC go back to prev space */
|
|
|
|
sima->flag |= SI_PREVSPACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-29 22:42:32 +00:00
|
|
|
sima = sa->spacedata.first;
|
2011-05-19 11:34:11 +00:00
|
|
|
|
|
|
|
/* get the correct image, and scale it */
|
2018-06-11 15:40:37 +02:00
|
|
|
sima->image = BKE_image_verify_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result");
|
2011-05-19 11:34:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* if we're rendering to full screen, set appropriate hints on image editor
|
|
|
|
* so it can restore properly on pressing esc */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sa->full) {
|
2011-05-19 11:34:11 +00:00
|
|
|
sima->flag |= SI_FULLWINDOW;
|
|
|
|
|
|
|
|
/* Tell the image editor to revert to previous space in space list on close
|
|
|
|
* _only_ if it wasn't already an image editor when the render was invoked */
|
|
|
|
if (area_was_image == 0)
|
|
|
|
sima->flag |= SI_PREVSPACE;
|
|
|
|
else {
|
|
|
|
/* Leave it alone so the image editor will just go back from
|
|
|
|
* full screen to the original tiled setup */
|
|
|
|
}
|
|
|
|
}
|
2013-12-17 23:42:38 +06:00
|
|
|
|
|
|
|
return sa;
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************** cancel render viewer **********************/
|
|
|
|
|
|
|
|
static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
SpaceImage *sima = sa->spacedata.first;
|
2011-05-19 11:34:11 +00:00
|
|
|
|
2015-05-28 19:48:28 +02:00
|
|
|
/* ensure image editor fullscreen and area fullscreen states are in sync */
|
|
|
|
if ((sima->flag & SI_FULLWINDOW) && !sa->full) {
|
|
|
|
sima->flag &= ~SI_FULLWINDOW;
|
|
|
|
}
|
|
|
|
|
2011-05-19 11:34:11 +00:00
|
|
|
/* test if we have a temp screen in front */
|
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 (WM_window_is_temp_screen(win)) {
|
2014-04-30 07:48:54 +10:00
|
|
|
wm_window_lower(win);
|
2011-05-19 11:34:11 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
/* determine if render already shows */
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (sima->flag & SI_PREVSPACE) {
|
2011-05-19 11:34:11 +00:00
|
|
|
sima->flag &= ~SI_PREVSPACE;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sima->flag & SI_FULLWINDOW) {
|
2011-05-19 11:34:11 +00:00
|
|
|
sima->flag &= ~SI_FULLWINDOW;
|
Fix a bunch of temp full-screen glitches
Steps to reproduce fixed glitches were:
* Change any editor to be file browser from menu, Ctrl+O *from the file browser area*, Esc -> area reset to what it was before changing to file browser initially
* Ctrl+O from any area, F12, Esc -> returns to initial editor in full-screen (expected is file browser in full-screen)
Fixes T46229
Core of the fix is removing old area from spacedata list when going back to previous area (see ED_area_prevspace -> BKE_spacedata_remove). Also, when creating a new temp area we now don't exit old area anymore (needed so SpaceFile->op is kept, but it also makes sense in general)
Aaand finally removes some ugly hacks.
Tested quite a bit, so I think it's safe to apply (besides of remark below), just would like to get things double checked and confirmed. After all, this full-screen stuff finally starts to feel like it's working :P
Note, there's still a memory leak when quitting Blender with temp area open. Haven't found out how to solve yet, but it's not that important for review anyway.
Reviewers: campbellbarton, brecht
Reviewed By: brecht
Subscribers: plyczkowski, Blendify
Maniphest Tasks: T46229
Differential Revision: https://developer.blender.org/D1531
2016-02-29 16:18:42 +01:00
|
|
|
ED_screen_full_prevspace(C, sa);
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
2015-05-28 19:48:28 +02:00
|
|
|
else {
|
2011-05-19 11:34:11 +00:00
|
|
|
ED_area_prevspace(C, sa);
|
2015-05-28 19:48:28 +02:00
|
|
|
}
|
2011-05-19 11:34:11 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (sima->flag & SI_FULLWINDOW) {
|
2011-05-19 11:34:11 +00:00
|
|
|
sima->flag &= ~SI_FULLWINDOW;
|
2014-10-14 15:05:44 -03:00
|
|
|
ED_screen_state_toggle(C, win, sa, SCREENMAXIMIZED);
|
2011-05-19 11:34:11 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RENDER_OT_view_cancel(struct wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Cancel Render View";
|
|
|
|
ot->description = "Cancel show render view";
|
|
|
|
ot->idname = "RENDER_OT_view_cancel";
|
2011-05-19 11:34:11 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = render_view_cancel_exec;
|
|
|
|
ot->poll = ED_operator_image_active;
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************* show render viewer *****************/
|
|
|
|
|
2015-10-07 00:27:27 +11:00
|
|
|
static int render_view_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2011-05-19 11:34:11 +00:00
|
|
|
{
|
|
|
|
wmWindow *wincur = CTX_wm_window(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-05-19 11:34:11 +00:00
|
|
|
/* test if we have currently a temp screen active */
|
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 (WM_window_is_temp_screen(wincur)) {
|
2011-05-19 11:34:11 +00:00
|
|
|
wm_window_lower(wincur);
|
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
else {
|
2011-05-19 11:34:11 +00:00
|
|
|
wmWindow *win, *winshow;
|
2013-04-13 15:14:34 +00:00
|
|
|
ScrArea *sa = find_area_showing_r_result(C, CTX_data_scene(C), &winshow);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-04-13 15:14:34 +00:00
|
|
|
/* is there another window on current scene showing result? */
|
2012-03-29 22:42:32 +00:00
|
|
|
for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) {
|
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 *sc = WM_window_get_active_screen(win);
|
|
|
|
|
|
|
|
if ((WM_window_is_temp_screen(win) && ((ScrArea *)sc->areabase.first)->spacetype == SPACE_IMAGE) ||
|
2013-02-11 00:49:00 +00:00
|
|
|
(win == winshow && winshow != wincur))
|
|
|
|
{
|
2011-05-19 11:34:11 +00:00
|
|
|
wm_window_raise(win);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-05-19 11:34:11 +00:00
|
|
|
/* determine if render already shows */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sa) {
|
2011-05-19 11:34:11 +00:00
|
|
|
/* but don't close it when rendering */
|
2014-04-01 11:34:00 +11:00
|
|
|
if (G.is_rendering == false) {
|
2012-03-29 22:42:32 +00:00
|
|
|
SpaceImage *sima = sa->spacedata.first;
|
2011-05-19 11:34:11 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sima->flag & SI_PREVSPACE) {
|
2011-05-19 11:34:11 +00:00
|
|
|
sima->flag &= ~SI_PREVSPACE;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sima->flag & SI_FULLWINDOW) {
|
2011-05-19 11:34:11 +00:00
|
|
|
sima->flag &= ~SI_FULLWINDOW;
|
Fix a bunch of temp full-screen glitches
Steps to reproduce fixed glitches were:
* Change any editor to be file browser from menu, Ctrl+O *from the file browser area*, Esc -> area reset to what it was before changing to file browser initially
* Ctrl+O from any area, F12, Esc -> returns to initial editor in full-screen (expected is file browser in full-screen)
Fixes T46229
Core of the fix is removing old area from spacedata list when going back to previous area (see ED_area_prevspace -> BKE_spacedata_remove). Also, when creating a new temp area we now don't exit old area anymore (needed so SpaceFile->op is kept, but it also makes sense in general)
Aaand finally removes some ugly hacks.
Tested quite a bit, so I think it's safe to apply (besides of remark below), just would like to get things double checked and confirmed. After all, this full-screen stuff finally starts to feel like it's working :P
Note, there's still a memory leak when quitting Blender with temp area open. Haven't found out how to solve yet, but it's not that important for review anyway.
Reviewers: campbellbarton, brecht
Reviewed By: brecht
Subscribers: plyczkowski, Blendify
Maniphest Tasks: T46229
Differential Revision: https://developer.blender.org/D1531
2016-02-29 16:18:42 +01:00
|
|
|
ED_screen_full_prevspace(C, sa);
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
Fix a bunch of temp full-screen glitches
Steps to reproduce fixed glitches were:
* Change any editor to be file browser from menu, Ctrl+O *from the file browser area*, Esc -> area reset to what it was before changing to file browser initially
* Ctrl+O from any area, F12, Esc -> returns to initial editor in full-screen (expected is file browser in full-screen)
Fixes T46229
Core of the fix is removing old area from spacedata list when going back to previous area (see ED_area_prevspace -> BKE_spacedata_remove). Also, when creating a new temp area we now don't exit old area anymore (needed so SpaceFile->op is kept, but it also makes sense in general)
Aaand finally removes some ugly hacks.
Tested quite a bit, so I think it's safe to apply (besides of remark below), just would like to get things double checked and confirmed. After all, this full-screen stuff finally starts to feel like it's working :P
Note, there's still a memory leak when quitting Blender with temp area open. Haven't found out how to solve yet, but it's not that important for review anyway.
Reviewers: campbellbarton, brecht
Reviewed By: brecht
Subscribers: plyczkowski, Blendify
Maniphest Tasks: T46229
Differential Revision: https://developer.blender.org/D1531
2016-02-29 16:18:42 +01:00
|
|
|
else {
|
|
|
|
ED_area_prevspace(C, sa);
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2015-10-07 00:27:27 +11:00
|
|
|
render_view_open(C, event->x, event->y, op->reports);
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RENDER_OT_view_show(struct wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Show/Hide Render View";
|
|
|
|
ot->description = "Toggle show render view";
|
|
|
|
ot->idname = "RENDER_OT_view_show";
|
2011-05-19 11:34:11 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = render_view_show_invoke;
|
|
|
|
ot->poll = ED_operator_screenactive;
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|