2012-04-30 14:24:11 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +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
|
2007-12-24 18:38:03 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup bke
|
2011-02-27 20:40:57 +00:00
|
|
|
*/
|
|
|
|
|
|
2020-10-30 15:27:57 +01:00
|
|
|
/* Allow using deprecated functionality for .blend file I/O. */
|
|
|
|
|
#define DNA_DEPRECATED_ALLOW
|
|
|
|
|
|
2012-04-15 07:54:07 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
|
# include "BLI_winstuff.h"
|
|
|
|
|
#endif
|
2011-02-27 20:40:57 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <math.h>
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-12-08 15:02:57 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2020-12-15 10:47:58 +11:00
|
|
|
#include "DNA_collection_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_defaults.h"
|
2020-05-18 18:51:06 +02:00
|
|
|
#include "DNA_gpencil_types.h"
|
|
|
|
|
#include "DNA_mask_types.h"
|
2009-09-14 12:26:34 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_screen_types.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "DNA_space_types.h"
|
2020-05-18 18:51:06 +02:00
|
|
|
#include "DNA_text_types.h"
|
2009-09-14 12:26:34 +00:00
|
|
|
#include "DNA_view3d_types.h"
|
2017-06-13 12:02:08 +02:00
|
|
|
#include "DNA_workspace_types.h"
|
2008-12-08 15:02:57 +00:00
|
|
|
|
2012-05-19 13:28:19 +00:00
|
|
|
#include "BLI_listbase.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_math_vector.h"
|
2020-05-18 18:51:06 +02:00
|
|
|
#include "BLI_mempool.h"
|
2015-01-21 13:43:46 +11:00
|
|
|
#include "BLI_rect.h"
|
2018-07-11 11:43:56 +02:00
|
|
|
#include "BLI_utildefines.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2020-03-06 15:19:32 +01:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
|
2020-10-30 15:27:57 +01:00
|
|
|
#include "BKE_gpencil.h"
|
2016-12-01 16:43:57 +01:00
|
|
|
#include "BKE_icons.h"
|
2013-08-29 12:55:31 +00:00
|
|
|
#include "BKE_idprop.h"
|
2020-03-06 15:19:32 +01:00
|
|
|
#include "BKE_idtype.h"
|
2020-10-30 15:59:34 +01:00
|
|
|
#include "BKE_lib_id.h"
|
2020-05-18 18:51:06 +02:00
|
|
|
#include "BKE_lib_query.h"
|
|
|
|
|
#include "BKE_node.h"
|
2005-03-09 19:45:59 +00:00
|
|
|
#include "BKE_screen.h"
|
2017-06-01 20:41:18 +02:00
|
|
|
#include "BKE_workspace.h"
|
2005-03-09 19:45:59 +00:00
|
|
|
|
2020-10-30 14:44:03 +01:00
|
|
|
#include "BLO_read_write.h"
|
|
|
|
|
|
2021-02-24 11:57:29 -03:00
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
|
# include "BPY_extern.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-03-06 15:19:32 +01:00
|
|
|
static void screen_free_data(ID *id)
|
|
|
|
|
{
|
|
|
|
|
bScreen *screen = (bScreen *)id;
|
|
|
|
|
|
|
|
|
|
/* No animdata here. */
|
|
|
|
|
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
|
2020-03-06 16:56:42 +01:00
|
|
|
BKE_area_region_free(NULL, region);
|
2020-03-06 15:19:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_freelistN(&screen->regionbase);
|
|
|
|
|
|
|
|
|
|
BKE_screen_area_map_free(AREAMAP_FROM_SCREEN(screen));
|
|
|
|
|
|
|
|
|
|
BKE_previewimg_free(&screen->preview);
|
|
|
|
|
|
|
|
|
|
/* Region and timer are freed by the window manager. */
|
|
|
|
|
MEM_SAFE_FREE(screen->tool_tip);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-18 18:51:06 +02:00
|
|
|
static void screen_foreach_id_dopesheet(LibraryForeachIDData *data, bDopeSheet *ads)
|
|
|
|
|
{
|
|
|
|
|
if (ads != NULL) {
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS_ID(data, ads->source, IDWALK_CB_NOP);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, ads->filter_grp, IDWALK_CB_NOP);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_screen_foreach_id_screen_area(LibraryForeachIDData *data, ScrArea *area)
|
|
|
|
|
{
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, area->full, IDWALK_CB_NOP);
|
|
|
|
|
|
|
|
|
|
/* TODO this should be moved to a callback in `SpaceType`, defined in each editor's own code.
|
|
|
|
|
* Will be for a later round of cleanup though... */
|
|
|
|
|
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
|
|
|
|
switch (sl->spacetype) {
|
|
|
|
|
case SPACE_VIEW3D: {
|
|
|
|
|
View3D *v3d = (View3D *)sl;
|
|
|
|
|
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, v3d->camera, IDWALK_CB_NOP);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, v3d->ob_center, IDWALK_CB_NOP);
|
|
|
|
|
|
|
|
|
|
if (v3d->localvd) {
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, v3d->localvd->camera, IDWALK_CB_NOP);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_GRAPH: {
|
|
|
|
|
SpaceGraph *sipo = (SpaceGraph *)sl;
|
|
|
|
|
|
|
|
|
|
screen_foreach_id_dopesheet(data, sipo->ads);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_PROPERTIES: {
|
|
|
|
|
SpaceProperties *sbuts = (SpaceProperties *)sl;
|
|
|
|
|
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS_ID(data, sbuts->pinid, IDWALK_CB_NOP);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_FILE:
|
|
|
|
|
break;
|
|
|
|
|
case SPACE_ACTION: {
|
|
|
|
|
SpaceAction *saction = (SpaceAction *)sl;
|
|
|
|
|
|
|
|
|
|
screen_foreach_id_dopesheet(data, &saction->ads);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, saction->action, IDWALK_CB_NOP);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_IMAGE: {
|
|
|
|
|
SpaceImage *sima = (SpaceImage *)sl;
|
|
|
|
|
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, sima->image, IDWALK_CB_USER_ONE);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, sima->mask_info.mask, IDWALK_CB_USER_ONE);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, sima->gpd, IDWALK_CB_USER);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_SEQ: {
|
|
|
|
|
SpaceSeq *sseq = (SpaceSeq *)sl;
|
|
|
|
|
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, sseq->gpd, IDWALK_CB_USER);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_NLA: {
|
|
|
|
|
SpaceNla *snla = (SpaceNla *)sl;
|
|
|
|
|
|
|
|
|
|
screen_foreach_id_dopesheet(data, snla->ads);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_TEXT: {
|
|
|
|
|
SpaceText *st = (SpaceText *)sl;
|
|
|
|
|
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, st->text, IDWALK_CB_NOP);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_SCRIPT: {
|
|
|
|
|
SpaceScript *scpt = (SpaceScript *)sl;
|
|
|
|
|
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, scpt->script, IDWALK_CB_NOP);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_OUTLINER: {
|
2020-08-07 11:47:23 -06:00
|
|
|
SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
|
2020-05-18 18:51:06 +02:00
|
|
|
|
2020-08-07 11:47:23 -06:00
|
|
|
BKE_LIB_FOREACHID_PROCESS_ID(data, space_outliner->search_tse.id, IDWALK_CB_NOP);
|
2020-05-18 18:51:06 +02:00
|
|
|
|
2020-08-07 11:47:23 -06:00
|
|
|
if (space_outliner->treestore != NULL) {
|
2020-05-18 18:51:06 +02:00
|
|
|
TreeStoreElem *tselem;
|
|
|
|
|
BLI_mempool_iter iter;
|
|
|
|
|
|
2020-08-07 11:47:23 -06:00
|
|
|
BLI_mempool_iternew(space_outliner->treestore, &iter);
|
2020-05-18 18:51:06 +02:00
|
|
|
while ((tselem = BLI_mempool_iterstep(&iter))) {
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS_ID(data, tselem->id, IDWALK_CB_NOP);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_NODE: {
|
|
|
|
|
SpaceNode *snode = (SpaceNode *)sl;
|
|
|
|
|
|
|
|
|
|
const bool is_private_nodetree = snode->id != NULL &&
|
|
|
|
|
ntreeFromID(snode->id) == snode->nodetree;
|
|
|
|
|
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS_ID(data, snode->id, IDWALK_CB_NOP);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS_ID(data, snode->from, IDWALK_CB_NOP);
|
|
|
|
|
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(
|
|
|
|
|
data, snode->nodetree, is_private_nodetree ? IDWALK_CB_EMBEDDED : IDWALK_CB_USER_ONE);
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (bNodeTreePath *, path, &snode->treepath) {
|
|
|
|
|
if (path == snode->treepath.first) {
|
|
|
|
|
/* first nodetree in path is same as snode->nodetree */
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data,
|
|
|
|
|
path->nodetree,
|
|
|
|
|
is_private_nodetree ? IDWALK_CB_EMBEDDED :
|
|
|
|
|
IDWALK_CB_USER_ONE);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, path->nodetree, IDWALK_CB_USER_ONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (path->nodetree == NULL) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, snode->edittree, IDWALK_CB_NOP);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_CLIP: {
|
|
|
|
|
SpaceClip *sclip = (SpaceClip *)sl;
|
|
|
|
|
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, sclip->clip, IDWALK_CB_USER_ONE);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, sclip->mask_info.mask, IDWALK_CB_USER_ONE);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void screen_foreach_id(ID *id, LibraryForeachIDData *data)
|
|
|
|
|
{
|
|
|
|
|
if (BKE_lib_query_foreachid_process_flags_get(data) & IDWALK_INCLUDE_UI) {
|
|
|
|
|
bScreen *screen = (bScreen *)id;
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
|
|
|
|
BKE_screen_foreach_id_screen_area(data, area);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-30 15:59:34 +01:00
|
|
|
static void screen_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
|
|
|
|
{
|
|
|
|
|
bScreen *screen = (bScreen *)id;
|
|
|
|
|
/* Screens are reference counted, only saved if used by a workspace. */
|
|
|
|
|
if (screen->id.us > 0 || BLO_write_is_undo(writer)) {
|
|
|
|
|
/* write LibData */
|
|
|
|
|
/* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
|
|
|
|
|
BLO_write_struct_at_address_with_filecode(writer, ID_SCRN, bScreen, id_address, screen);
|
|
|
|
|
BKE_id_blend_write(writer, &screen->id);
|
|
|
|
|
|
|
|
|
|
BKE_previewimg_blend_write(writer, screen->preview);
|
|
|
|
|
|
|
|
|
|
/* direct data */
|
|
|
|
|
BKE_screen_area_map_blend_write(writer, AREAMAP_FROM_SCREEN(screen));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-06 18:37:52 +01:00
|
|
|
/* Cannot use IDTypeInfo callback yet, because of the return value. */
|
2020-11-06 18:41:03 +01:00
|
|
|
bool BKE_screen_blend_read_data(BlendDataReader *reader, bScreen *screen)
|
2020-11-06 18:37:52 +01:00
|
|
|
{
|
|
|
|
|
bool success = true;
|
|
|
|
|
|
|
|
|
|
screen->regionbase.first = screen->regionbase.last = NULL;
|
|
|
|
|
screen->context = NULL;
|
|
|
|
|
screen->active_region = NULL;
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &screen->preview);
|
|
|
|
|
BKE_previewimg_blend_read(reader, screen->preview);
|
|
|
|
|
|
|
|
|
|
if (!BKE_screen_area_map_blend_read_data(reader, AREAMAP_FROM_SCREEN(screen))) {
|
|
|
|
|
printf("Error reading Screen %s... removing it.\n", screen->id.name + 2);
|
|
|
|
|
success = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-30 15:59:34 +01:00
|
|
|
/* note: file read without screens option G_FILE_NO_UI;
|
|
|
|
|
* check lib pointers in call below */
|
|
|
|
|
static void screen_blend_read_lib(BlendLibReader *reader, ID *id)
|
|
|
|
|
{
|
|
|
|
|
bScreen *screen = (bScreen *)id;
|
|
|
|
|
/* deprecated, but needed for versioning (will be NULL'ed then) */
|
|
|
|
|
BLO_read_id_address(reader, screen->id.lib, &screen->scene);
|
|
|
|
|
|
|
|
|
|
screen->animtimer = NULL; /* saved in rare cases */
|
|
|
|
|
screen->tool_tip = NULL;
|
|
|
|
|
screen->scrubbing = false;
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
|
|
|
|
BKE_screen_area_blend_read_lib(reader, &screen->id, area);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-06 15:19:32 +01:00
|
|
|
IDTypeInfo IDType_ID_SCR = {
|
|
|
|
|
.id_code = ID_SCR,
|
|
|
|
|
.id_filter = 0,
|
|
|
|
|
.main_listbase_index = INDEX_ID_SCR,
|
|
|
|
|
.struct_size = sizeof(bScreen),
|
|
|
|
|
.name = "Screen",
|
|
|
|
|
.name_plural = "screens",
|
|
|
|
|
.translation_context = BLT_I18NCONTEXT_ID_SCREEN,
|
2020-10-07 12:35:58 +02:00
|
|
|
.flags = IDTYPE_FLAGS_NO_COPY | IDTYPE_FLAGS_NO_MAKELOCAL | IDTYPE_FLAGS_NO_ANIMDATA,
|
2020-03-06 15:19:32 +01:00
|
|
|
|
|
|
|
|
.init_data = NULL,
|
|
|
|
|
.copy_data = NULL,
|
|
|
|
|
.free_data = screen_free_data,
|
|
|
|
|
.make_local = NULL,
|
2020-05-18 18:51:06 +02:00
|
|
|
.foreach_id = screen_foreach_id,
|
2020-08-28 13:05:48 +02:00
|
|
|
.foreach_cache = NULL,
|
2021-02-25 10:17:31 +01:00
|
|
|
.owner_get = NULL,
|
2020-08-28 13:05:48 +02:00
|
|
|
|
2020-10-30 15:59:34 +01:00
|
|
|
.blend_write = screen_blend_write,
|
|
|
|
|
/* Cannot be used yet, because #direct_link_screen has a return value. */
|
2020-08-28 13:05:48 +02:00
|
|
|
.blend_read_data = NULL,
|
2020-10-30 15:59:34 +01:00
|
|
|
.blend_read_lib = screen_blend_read_lib,
|
2020-08-28 13:05:48 +02:00
|
|
|
.blend_read_expand = NULL,
|
2020-11-03 11:39:36 +01:00
|
|
|
|
|
|
|
|
.blend_read_undo_preserve = NULL,
|
2021-01-22 14:52:50 +01:00
|
|
|
|
|
|
|
|
.lib_override_apply_post = NULL,
|
2020-03-06 15:19:32 +01:00
|
|
|
};
|
|
|
|
|
|
2008-12-08 15:02:57 +00:00
|
|
|
/* ************ Spacetype/regiontype handling ************** */
|
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
/* keep global; this has to be accessible outside of windowmanager */
|
2012-05-06 15:15:33 +00:00
|
|
|
static ListBase spacetypes = {NULL, NULL};
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2008-12-08 15:02:57 +00:00
|
|
|
/* not SpaceType itself */
|
|
|
|
|
static void spacetype_free(SpaceType *st)
|
|
|
|
|
{
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ARegionType *, art, &st->regiontypes) {
|
2021-02-24 11:57:29 -03:00
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
|
BPY_callback_screen_free(art);
|
|
|
|
|
#endif
|
2.5
New: Custom region draw callbacks.
For Martin: an example is now in space_view3d/view3d_edit.c
On middlemouse rotate view, it draws a small square in center.
It works likes this:
#include "ED_space_api.h"
handle= ED_region_draw_cb_activate(region->type, drawfunc, type)
and to stop it:
ED_region_draw_cb_exit(region->type, handle)
drawfunc is of type (const bContext *C, ARegion *ar)
currently it gets called only as type REGION_DRAW_POST, later we
can add more (PRE, POST_XRAY, POST_2D, etc).
For correct usage, these calls should return leaving view transform
unaltered.
2009-01-09 15:04:52 +00:00
|
|
|
BLI_freelistN(&art->drawcalls);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (PanelType *, pt, &art->paneltypes) {
|
2020-04-03 18:24:08 +02:00
|
|
|
if (pt->rna_ext.free) {
|
|
|
|
|
pt->rna_ext.free(pt->rna_ext.data);
|
2018-06-03 13:32:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_freelistN(&pt->children);
|
|
|
|
|
}
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (HeaderType *, ht, &art->headertypes) {
|
2020-04-03 18:24:08 +02:00
|
|
|
if (ht->rna_ext.free) {
|
|
|
|
|
ht->rna_ext.free(ht->rna_ext.data);
|
2018-06-03 13:32:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-03-29 19:44:39 +00:00
|
|
|
BLI_freelistN(&art->paneltypes);
|
|
|
|
|
BLI_freelistN(&art->headertypes);
|
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-12-08 15:02:57 +00:00
|
|
|
BLI_freelistN(&st->regiontypes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_spacetypes_free(void)
|
|
|
|
|
{
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (SpaceType *, st, &spacetypes) {
|
2008-12-08 15:02:57 +00:00
|
|
|
spacetype_free(st);
|
2008-12-14 11:39:00 +00:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-12-08 15:02:57 +00:00
|
|
|
BLI_freelistN(&spacetypes);
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
SpaceType *BKE_spacetype_from_id(int spaceid)
|
|
|
|
|
{
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (SpaceType *, st, &spacetypes) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (st->spaceid == spaceid) {
|
2008-01-07 18:03:41 +00:00
|
|
|
return st;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-02 16:25:59 -06:00
|
|
|
ARegionType *BKE_regiontype_from_id_or_first(const SpaceType *st, int regionid)
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
{
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ARegionType *, art, &st->regiontypes) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (art->regionid == regionid) {
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
return art;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2013-09-29 13:25:42 +00:00
|
|
|
printf(
|
|
|
|
|
"Error, region type %d missing in - name:\"%s\", id:%d\n", regionid, st->name, st->spaceid);
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
return st->regiontypes.first;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-02 16:25:59 -06:00
|
|
|
ARegionType *BKE_regiontype_from_id(const SpaceType *st, int regionid)
|
2018-06-12 17:26:38 +02:00
|
|
|
{
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ARegionType *, art, &st->regiontypes) {
|
2018-06-12 17:26:38 +02:00
|
|
|
if (art->regionid == regionid) {
|
|
|
|
|
return art;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
const ListBase *BKE_spacetypes_list(void)
|
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
|
|
|
{
|
|
|
|
|
return &spacetypes;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
void BKE_spacetype_register(SpaceType *st)
|
|
|
|
|
{
|
2008-12-08 15:02:57 +00:00
|
|
|
/* sanity check */
|
2020-11-29 20:30:11 -05:00
|
|
|
SpaceType *stype = BKE_spacetype_from_id(st->spaceid);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (stype) {
|
2008-12-08 15:02:57 +00:00
|
|
|
printf("error: redefinition of spacetype %s\n", stype->name);
|
|
|
|
|
spacetype_free(stype);
|
|
|
|
|
MEM_freeN(stype);
|
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
BLI_addtail(&spacetypes, st);
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-21 13:43:46 +11:00
|
|
|
bool BKE_spacetype_exists(int spaceid)
|
2013-08-10 21:17:46 +00:00
|
|
|
{
|
|
|
|
|
return BKE_spacetype_from_id(spaceid) != NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-08 15:02:57 +00:00
|
|
|
/* ***************** Space handling ********************** */
|
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
void BKE_spacedata_freelist(ListBase *lb)
|
|
|
|
|
{
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (SpaceLink *, sl, lb) {
|
2012-05-06 15:15:33 +00:00
|
|
|
SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-12-14 17:25:46 +00:00
|
|
|
/* free regions for pushed spaces */
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
|
2020-03-06 16:56:42 +01:00
|
|
|
BKE_area_region_free(st, region);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
|
2008-12-11 19:35:27 +00:00
|
|
|
BLI_freelistN(&sl->regionbase);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (st && st->free) {
|
2008-12-14 11:55:49 +00:00
|
|
|
st->free(sl);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
BLI_freelistN(lb);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-03 13:32:36 +02:00
|
|
|
static void panel_list_copy(ListBase *newlb, const ListBase *lb)
|
|
|
|
|
{
|
|
|
|
|
BLI_listbase_clear(newlb);
|
|
|
|
|
BLI_duplicatelist(newlb, lb);
|
|
|
|
|
|
|
|
|
|
/* copy panel pointers */
|
2020-04-03 22:20:25 -05:00
|
|
|
Panel *new_panel = newlb->first;
|
|
|
|
|
Panel *panel = lb->first;
|
|
|
|
|
for (; new_panel; new_panel = new_panel->next, panel = panel->next) {
|
|
|
|
|
new_panel->activedata = NULL;
|
2020-06-29 15:00:25 -04:00
|
|
|
new_panel->runtime.custom_data_ptr = NULL;
|
2020-04-03 22:20:25 -05:00
|
|
|
panel_list_copy(&new_panel->children, &panel->children);
|
2018-06-03 13:32:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-02 16:25:59 -06:00
|
|
|
ARegion *BKE_area_region_copy(const SpaceType *st, const ARegion *region)
|
2008-12-14 17:25:46 +00:00
|
|
|
{
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *newar = MEM_dupallocN(region);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
newar->prev = newar->next = NULL;
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(&newar->handlers);
|
|
|
|
|
BLI_listbase_clear(&newar->uiblocks);
|
|
|
|
|
BLI_listbase_clear(&newar->panels_category);
|
|
|
|
|
BLI_listbase_clear(&newar->panels_category_active);
|
|
|
|
|
BLI_listbase_clear(&newar->ui_lists);
|
2018-02-16 22:41:46 +01:00
|
|
|
newar->visible = 0;
|
2018-07-14 23:49:00 +02:00
|
|
|
newar->gizmo_map = NULL;
|
2015-11-17 11:22:30 +11:00
|
|
|
newar->regiontimer = NULL;
|
2018-06-28 12:06:00 +02:00
|
|
|
newar->headerstr = NULL;
|
2018-04-27 10:22:37 +02:00
|
|
|
newar->draw_buffer = NULL;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
/* use optional regiondata callback */
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region->regiondata) {
|
|
|
|
|
ARegionType *art = BKE_regiontype_from_id(st, region->regiontype);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2018-06-14 22:27:58 +02:00
|
|
|
if (art && art->duplicate) {
|
2020-03-06 16:56:42 +01:00
|
|
|
newar->regiondata = art->duplicate(region->regiondata);
|
2018-06-14 22:27:58 +02:00
|
|
|
}
|
2020-03-06 16:56:42 +01:00
|
|
|
else if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
|
2018-06-14 22:27:58 +02:00
|
|
|
newar->regiondata = NULL;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2020-03-06 16:56:42 +01:00
|
|
|
newar->regiondata = MEM_dupallocN(region->regiondata);
|
2018-06-14 22:27:58 +02:00
|
|
|
}
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
}
|
2009-07-29 22:57:53 +00:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
panel_list_copy(&newar->panels, ®ion->panels);
|
2014-04-23 17:13:28 +10:00
|
|
|
|
|
|
|
|
BLI_listbase_clear(&newar->ui_previews);
|
2020-03-06 16:56:42 +01:00
|
|
|
BLI_duplicatelist(&newar->ui_previews, ®ion->ui_previews);
|
2014-04-23 17:13:28 +10:00
|
|
|
|
2008-12-14 17:25:46 +00:00
|
|
|
return newar;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-09 00:41:09 +00:00
|
|
|
/* from lb2 to lb1, lb1 is supposed to be freed */
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
static void region_copylist(SpaceType *st, ListBase *lb1, ListBase *lb2)
|
2008-12-14 17:25:46 +00:00
|
|
|
{
|
|
|
|
|
/* to be sure */
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(lb1);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ARegion *, region, lb2) {
|
2020-11-29 18:10:47 -05:00
|
|
|
ARegion *region_new = BKE_area_region_copy(st, region);
|
|
|
|
|
BLI_addtail(lb1, region_new);
|
2008-12-14 17:25:46 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
/* lb1 should be empty */
|
|
|
|
|
void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2)
|
|
|
|
|
{
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(lb1); /* to be sure */
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (SpaceLink *, sl, lb2) {
|
2012-05-06 15:15:33 +00:00
|
|
|
SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (st && st->duplicate) {
|
2012-05-06 15:15:33 +00:00
|
|
|
SpaceLink *slnew = st->duplicate(sl);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-12-14 17:25:46 +00:00
|
|
|
BLI_addtail(lb1, slnew);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
region_copylist(st, &slnew->regionbase, &sl->regionbase);
|
2008-12-14 17:25:46 +00:00
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-25 17:11:32 +00:00
|
|
|
/* facility to set locks for drawing to survive (render) threads accessing drawing data */
|
|
|
|
|
/* lock can become bitflag too */
|
|
|
|
|
/* should be replaced in future by better local data handling for threads */
|
2021-02-26 16:50:36 +11:00
|
|
|
void BKE_spacedata_draw_locks(bool set)
|
2011-03-25 17:11:32 +00:00
|
|
|
{
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (SpaceType *, st, &spacetypes) {
|
|
|
|
|
LISTBASE_FOREACH (ARegionType *, art, &st->regiontypes) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (set) {
|
2012-05-06 15:15:33 +00:00
|
|
|
art->do_lock = art->lock;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2014-04-01 11:34:00 +11:00
|
|
|
art->do_lock = false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-03-25 17:11:32 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-25 16:21:35 +01:00
|
|
|
/**
|
2019-04-27 12:07:07 +10:00
|
|
|
* Version of #BKE_area_find_region_type that also works if \a slink
|
2020-04-03 13:25:03 +02:00
|
|
|
* is not the active space of \a area.
|
2018-11-25 16:21:35 +01:00
|
|
|
*/
|
2020-04-03 13:25:03 +02:00
|
|
|
ARegion *BKE_spacedata_find_region_type(const SpaceLink *slink,
|
|
|
|
|
const ScrArea *area,
|
|
|
|
|
int region_type)
|
2018-11-25 16:21:35 +01:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
const bool is_slink_active = slink == area->spacedata.first;
|
|
|
|
|
const ListBase *regionbase = (is_slink_active) ? &area->regionbase : &slink->regionbase;
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = NULL;
|
2018-11-25 16:21:35 +01:00
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
BLI_assert(BLI_findindex(&area->spacedata, slink) != -1);
|
2020-11-29 20:30:11 -05:00
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (ARegion *, region_iter, regionbase) {
|
|
|
|
|
if (region_iter->regiontype == region_type) {
|
|
|
|
|
region = region_iter;
|
2018-11-25 16:21:35 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Should really unit test this instead. */
|
2020-04-03 13:25:03 +02:00
|
|
|
BLI_assert(!is_slink_active || region == BKE_area_find_region_type(area, region_type));
|
2018-11-25 16:21:35 +01:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
return region;
|
2018-11-25 16:21:35 +01:00
|
|
|
}
|
|
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
static void (*spacedata_id_remap_cb)(struct ScrArea *area,
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
struct SpaceLink *sl,
|
|
|
|
|
ID *old_id,
|
|
|
|
|
ID *new_id) = NULL;
|
2015-05-04 15:07:24 +10:00
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
void BKE_spacedata_callback_id_remap_set(void (*func)(ScrArea *area, SpaceLink *sl, ID *, ID *))
|
2015-05-04 15:07:24 +10:00
|
|
|
{
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
spacedata_id_remap_cb = func;
|
2015-05-04 15:07:24 +10:00
|
|
|
}
|
|
|
|
|
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
/* UNUSED!!! */
|
2020-04-03 13:25:03 +02:00
|
|
|
void BKE_spacedata_id_unref(struct ScrArea *area, struct SpaceLink *sl, struct ID *id)
|
2015-05-04 15:07:24 +10:00
|
|
|
{
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
if (spacedata_id_remap_cb) {
|
2020-04-03 13:25:03 +02:00
|
|
|
spacedata_id_remap_cb(area, sl, id, NULL);
|
2015-05-04 15:07:24 +10:00
|
|
|
}
|
|
|
|
|
}
|
2011-03-25 17:11:32 +00:00
|
|
|
|
2017-07-31 14:35:10 +10:00
|
|
|
/**
|
2018-07-14 23:49:00 +02:00
|
|
|
* Avoid bad-level calls to #WM_gizmomap_tag_refresh.
|
2017-07-31 14:35:10 +10:00
|
|
|
*/
|
2018-07-14 23:49:00 +02:00
|
|
|
static void (*region_refresh_tag_gizmomap_callback)(struct wmGizmoMap *) = NULL;
|
2017-07-31 14:35:10 +10:00
|
|
|
|
2018-07-14 23:49:00 +02:00
|
|
|
void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizmoMap *))
|
2017-07-31 14:35:10 +10:00
|
|
|
{
|
2018-07-14 23:49:00 +02:00
|
|
|
region_refresh_tag_gizmomap_callback = callback;
|
2017-07-31 14:35:10 +10:00
|
|
|
}
|
|
|
|
|
|
2020-04-03 14:23:21 +02:00
|
|
|
void BKE_screen_gizmo_tag_refresh(struct bScreen *screen)
|
2017-07-31 14:35:10 +10:00
|
|
|
{
|
2018-07-14 23:49:00 +02:00
|
|
|
if (region_refresh_tag_gizmomap_callback == NULL) {
|
2017-07-31 14:35:10 +10:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
|
|
|
|
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region->gizmo_map != NULL) {
|
|
|
|
|
region_refresh_tag_gizmomap_callback(region->gizmo_map);
|
2017-07-31 14:35:10 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-07 16:34:55 +02:00
|
|
|
|
|
|
|
|
/**
|
2018-07-14 23:49:00 +02:00
|
|
|
* Avoid bad-level calls to #WM_gizmomap_delete.
|
2016-10-07 16:34:55 +02:00
|
|
|
*/
|
2018-07-14 23:49:00 +02:00
|
|
|
static void (*region_free_gizmomap_callback)(struct wmGizmoMap *) = NULL;
|
2016-10-07 16:34:55 +02:00
|
|
|
|
2018-07-14 23:49:00 +02:00
|
|
|
void BKE_region_callback_free_gizmomap_set(void (*callback)(struct wmGizmoMap *))
|
2016-10-07 16:34:55 +02:00
|
|
|
{
|
2018-07-14 23:49:00 +02:00
|
|
|
region_free_gizmomap_callback = callback;
|
2016-10-07 16:34:55 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-29 15:00:25 -04:00
|
|
|
static void area_region_panels_free_recursive(Panel *panel)
|
2018-06-03 13:32:36 +02:00
|
|
|
{
|
2020-06-29 15:00:25 -04:00
|
|
|
MEM_SAFE_FREE(panel->activedata);
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH_MUTABLE (Panel *, child_panel, &panel->children) {
|
|
|
|
|
area_region_panels_free_recursive(child_panel);
|
2018-06-03 13:32:36 +02:00
|
|
|
}
|
2018-08-21 15:21:53 +02:00
|
|
|
|
2020-06-29 15:00:25 -04:00
|
|
|
MEM_freeN(panel);
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
void BKE_area_region_panels_free(ListBase *panels)
|
2020-06-29 15:00:25 -04:00
|
|
|
{
|
2020-09-04 20:59:13 +02:00
|
|
|
LISTBASE_FOREACH_MUTABLE (Panel *, panel, panels) {
|
2020-06-29 15:00:25 -04:00
|
|
|
/* Free custom data just for parent panels to avoid a double free. */
|
|
|
|
|
MEM_SAFE_FREE(panel->runtime.custom_data_ptr);
|
|
|
|
|
area_region_panels_free_recursive(panel);
|
|
|
|
|
}
|
2020-09-04 20:59:13 +02:00
|
|
|
BLI_listbase_clear(panels);
|
2018-06-03 13:32:36 +02:00
|
|
|
}
|
|
|
|
|
|
Various changes made in the process of working on the UI code:
* Added functions to generate Timer events. There was some unfinished code to
create one timer per window, this replaces that with a way to let operators
or other handlers add/remove their own timers as needed. This is currently
delivered as an event with the timer handle, perhaps this should be a notifier
instead? Also includes some fixes in ghost for timer events that were not
delivered in time, due to passing negative timeout.
* Added a Message event, which is a generic event that can be added by any
operator. This is used in the UI code to communicate the results of opened
blocks. Again, this may be better as a notifier.
* These two events should not be blocked as they are intended for a specific
operator or handler, so there were exceptions added for this, which is one
of the reasons they might work better as notifiers, but currently these
things can't listen to notifier yet.
* Added an option to events to indicate if the customdata should be freed or
not.
* Added a free() callback for area regions, and added a free function for
area regions in blenkernel since it was already there for screens and areas.
* Added ED_screen/area/region_exit functions to clean up things like operators
and handlers when they are closed.
* Added screen level regions, these will draw over areas boundaries, with the
last created region on top. These are useful for tooltips, menus, etc, and
are not saved to file. It's using the same ARegion struct as areas to avoid
code duplication, but perhaps that should be renamed then. Note that redraws
currently go correct, because only full window redraws are used, for partial
redraws without any frontbuffer drawing, the window manager needs to get
support for compositing subwindows.
* Minor changes in the subwindow code to retrieve the matrix, and moved
setlinestyle to glutil.c.
* Reversed argument order in WM_event_add/remove_keymap_handler to be consistent
with modal_handler.
* Operators can now block events but not necessarily cancel/finish.
* Modal operators are now stored in a list in the window/area/region they were
created in. This means for example that when a transform operator is invoked
from a region but registers a handler at the window level (since mouse motion
across areas should work), it will still get removed when the region is closed
while the operator is running.
2008-11-11 15:18:21 +00:00
|
|
|
/* not region itself */
|
2020-03-06 16:56:42 +01:00
|
|
|
void BKE_area_region_free(SpaceType *st, ARegion *region)
|
Various changes made in the process of working on the UI code:
* Added functions to generate Timer events. There was some unfinished code to
create one timer per window, this replaces that with a way to let operators
or other handlers add/remove their own timers as needed. This is currently
delivered as an event with the timer handle, perhaps this should be a notifier
instead? Also includes some fixes in ghost for timer events that were not
delivered in time, due to passing negative timeout.
* Added a Message event, which is a generic event that can be added by any
operator. This is used in the UI code to communicate the results of opened
blocks. Again, this may be better as a notifier.
* These two events should not be blocked as they are intended for a specific
operator or handler, so there were exceptions added for this, which is one
of the reasons they might work better as notifiers, but currently these
things can't listen to notifier yet.
* Added an option to events to indicate if the customdata should be freed or
not.
* Added a free() callback for area regions, and added a free function for
area regions in blenkernel since it was already there for screens and areas.
* Added ED_screen/area/region_exit functions to clean up things like operators
and handlers when they are closed.
* Added screen level regions, these will draw over areas boundaries, with the
last created region on top. These are useful for tooltips, menus, etc, and
are not saved to file. It's using the same ARegion struct as areas to avoid
code duplication, but perhaps that should be renamed then. Note that redraws
currently go correct, because only full window redraws are used, for partial
redraws without any frontbuffer drawing, the window manager needs to get
support for compositing subwindows.
* Minor changes in the subwindow code to retrieve the matrix, and moved
setlinestyle to glutil.c.
* Reversed argument order in WM_event_add/remove_keymap_handler to be consistent
with modal_handler.
* Operators can now block events but not necessarily cancel/finish.
* Modal operators are now stored in a list in the window/area/region they were
created in. This means for example that when a transform operator is invoked
from a region but registers a handler at the window level (since mouse motion
across areas should work), it will still get removed when the region is closed
while the operator is running.
2008-11-11 15:18:21 +00:00
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (st) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegionType *art = BKE_regiontype_from_id(st, region->regiontype);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (art && art->free) {
|
2020-03-06 16:56:42 +01:00
|
|
|
art->free(region);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region->regiondata) {
|
2009-01-25 20:22:05 +00:00
|
|
|
printf("regiondata free error\n");
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
}
|
2020-03-06 16:56:42 +01:00
|
|
|
else if (region->type && region->type->free) {
|
|
|
|
|
region->type->free(region);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
BKE_area_region_panels_free(®ion->panels);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (uiList *, uilst, ®ion->ui_lists) {
|
2013-08-27 15:27:41 +00:00
|
|
|
if (uilst->dyn_data) {
|
2013-08-29 12:55:31 +00:00
|
|
|
uiListDyn *dyn_data = uilst->dyn_data;
|
|
|
|
|
if (dyn_data->items_filter_flags) {
|
|
|
|
|
MEM_freeN(dyn_data->items_filter_flags);
|
|
|
|
|
}
|
|
|
|
|
if (dyn_data->items_filter_neworder) {
|
|
|
|
|
MEM_freeN(dyn_data->items_filter_neworder);
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(dyn_data);
|
|
|
|
|
}
|
|
|
|
|
if (uilst->properties) {
|
|
|
|
|
IDP_FreeProperty(uilst->properties);
|
2013-08-27 15:27:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region->gizmo_map != NULL) {
|
|
|
|
|
region_free_gizmomap_callback(region->gizmo_map);
|
2017-07-31 11:26:03 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
BLI_freelistN(®ion->ui_lists);
|
|
|
|
|
BLI_freelistN(®ion->ui_previews);
|
|
|
|
|
BLI_freelistN(®ion->panels_category);
|
|
|
|
|
BLI_freelistN(®ion->panels_category_active);
|
Various changes made in the process of working on the UI code:
* Added functions to generate Timer events. There was some unfinished code to
create one timer per window, this replaces that with a way to let operators
or other handlers add/remove their own timers as needed. This is currently
delivered as an event with the timer handle, perhaps this should be a notifier
instead? Also includes some fixes in ghost for timer events that were not
delivered in time, due to passing negative timeout.
* Added a Message event, which is a generic event that can be added by any
operator. This is used in the UI code to communicate the results of opened
blocks. Again, this may be better as a notifier.
* These two events should not be blocked as they are intended for a specific
operator or handler, so there were exceptions added for this, which is one
of the reasons they might work better as notifiers, but currently these
things can't listen to notifier yet.
* Added an option to events to indicate if the customdata should be freed or
not.
* Added a free() callback for area regions, and added a free function for
area regions in blenkernel since it was already there for screens and areas.
* Added ED_screen/area/region_exit functions to clean up things like operators
and handlers when they are closed.
* Added screen level regions, these will draw over areas boundaries, with the
last created region on top. These are useful for tooltips, menus, etc, and
are not saved to file. It's using the same ARegion struct as areas to avoid
code duplication, but perhaps that should be renamed then. Note that redraws
currently go correct, because only full window redraws are used, for partial
redraws without any frontbuffer drawing, the window manager needs to get
support for compositing subwindows.
* Minor changes in the subwindow code to retrieve the matrix, and moved
setlinestyle to glutil.c.
* Reversed argument order in WM_event_add/remove_keymap_handler to be consistent
with modal_handler.
* Operators can now block events but not necessarily cancel/finish.
* Modal operators are now stored in a list in the window/area/region they were
created in. This means for example that when a transform operator is invoked
from a region but registers a handler at the window level (since mouse motion
across areas should work), it will still get removed when the region is closed
while the operator is running.
2008-11-11 15:18:21 +00:00
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
|
/* not area itself */
|
2020-04-03 13:25:03 +02:00
|
|
|
void BKE_screen_area_free(ScrArea *area)
|
2008-01-07 18:03:41 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceType *st = BKE_spacetype_from_id(area->spacetype);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
2020-03-06 16:56:42 +01:00
|
|
|
BKE_area_region_free(st, region);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
Various changes made in the process of working on the UI code:
* Added functions to generate Timer events. There was some unfinished code to
create one timer per window, this replaces that with a way to let operators
or other handlers add/remove their own timers as needed. This is currently
delivered as an event with the timer handle, perhaps this should be a notifier
instead? Also includes some fixes in ghost for timer events that were not
delivered in time, due to passing negative timeout.
* Added a Message event, which is a generic event that can be added by any
operator. This is used in the UI code to communicate the results of opened
blocks. Again, this may be better as a notifier.
* These two events should not be blocked as they are intended for a specific
operator or handler, so there were exceptions added for this, which is one
of the reasons they might work better as notifiers, but currently these
things can't listen to notifier yet.
* Added an option to events to indicate if the customdata should be freed or
not.
* Added a free() callback for area regions, and added a free function for
area regions in blenkernel since it was already there for screens and areas.
* Added ED_screen/area/region_exit functions to clean up things like operators
and handlers when they are closed.
* Added screen level regions, these will draw over areas boundaries, with the
last created region on top. These are useful for tooltips, menus, etc, and
are not saved to file. It's using the same ARegion struct as areas to avoid
code duplication, but perhaps that should be renamed then. Note that redraws
currently go correct, because only full window redraws are used, for partial
redraws without any frontbuffer drawing, the window manager needs to get
support for compositing subwindows.
* Minor changes in the subwindow code to retrieve the matrix, and moved
setlinestyle to glutil.c.
* Reversed argument order in WM_event_add/remove_keymap_handler to be consistent
with modal_handler.
* Operators can now block events but not necessarily cancel/finish.
* Modal operators are now stored in a list in the window/area/region they were
created in. This means for example that when a transform operator is invoked
from a region but registers a handler at the window level (since mouse motion
across areas should work), it will still get removed when the region is closed
while the operator is running.
2008-11-11 15:18:21 +00:00
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
MEM_SAFE_FREE(area->global);
|
|
|
|
|
BLI_freelistN(&area->regionbase);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
BKE_spacedata_freelist(&area->spacedata);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
BLI_freelistN(&area->actionzones);
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
2002-11-25 12:02:15 +00:00
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
void BKE_screen_area_map_free(ScrAreaMap *area_map)
|
|
|
|
|
{
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH_MUTABLE (ScrArea *, area, &area_map->areabase) {
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
BKE_screen_area_free(area);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_freelistN(&area_map->vertbase);
|
|
|
|
|
BLI_freelistN(&area_map->edgebase);
|
|
|
|
|
BLI_freelistN(&area_map->areabase);
|
|
|
|
|
}
|
|
|
|
|
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
/** Free (or release) any data used by this screen (does not free the screen itself). */
|
2020-04-03 14:23:21 +02:00
|
|
|
void BKE_screen_free(bScreen *screen)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2020-04-03 14:23:21 +02:00
|
|
|
screen_free_data(&screen->id);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2018-04-13 21:43:57 +02:00
|
|
|
/* ***************** Screen edges & verts ***************** */
|
|
|
|
|
|
2020-09-05 17:56:05 +02:00
|
|
|
ScrEdge *BKE_screen_find_edge(const bScreen *screen, ScrVert *v1, ScrVert *v2)
|
2018-04-13 21:43:57 +02:00
|
|
|
{
|
|
|
|
|
BKE_screen_sort_scrvert(&v1, &v2);
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) {
|
2018-04-13 21:43:57 +02:00
|
|
|
if (se->v1 == v1 && se->v2 == v2) {
|
|
|
|
|
return se;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_screen_sort_scrvert(ScrVert **v1, ScrVert **v2)
|
|
|
|
|
{
|
|
|
|
|
if (*v1 > *v2) {
|
2020-11-29 20:30:11 -05:00
|
|
|
ScrVert *tmp = *v1;
|
2018-04-13 21:43:57 +02:00
|
|
|
*v1 = *v2;
|
|
|
|
|
*v2 = tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-03 14:23:21 +02:00
|
|
|
void BKE_screen_remove_double_scrverts(bScreen *screen)
|
2018-04-13 21:43:57 +02:00
|
|
|
{
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ScrVert *, verg, &screen->vertbase) {
|
2018-04-13 21:43:57 +02:00
|
|
|
if (verg->newv == NULL) { /* !!! */
|
2020-11-29 20:30:11 -05:00
|
|
|
ScrVert *v1 = verg->next;
|
2018-04-13 21:43:57 +02:00
|
|
|
while (v1) {
|
|
|
|
|
if (v1->newv == NULL) { /* !?! */
|
|
|
|
|
if (v1->vec.x == verg->vec.x && v1->vec.y == verg->vec.y) {
|
|
|
|
|
/* printf("doublevert\n"); */
|
|
|
|
|
v1->newv = verg;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-04-13 21:43:57 +02:00
|
|
|
}
|
|
|
|
|
v1 = v1->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-13 21:43:57 +02:00
|
|
|
/* replace pointers in edges and faces */
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (se->v1->newv) {
|
2018-04-13 21:43:57 +02:00
|
|
|
se->v1 = se->v1->newv;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (se->v2->newv) {
|
2018-04-13 21:43:57 +02:00
|
|
|
se->v2 = se->v2->newv;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-04-13 21:43:57 +02:00
|
|
|
/* edges changed: so.... */
|
|
|
|
|
BKE_screen_sort_scrvert(&(se->v1), &(se->v2));
|
|
|
|
|
}
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
2020-04-03 13:25:03 +02:00
|
|
|
if (area->v1->newv) {
|
|
|
|
|
area->v1 = area->v1->newv;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-04-03 13:25:03 +02:00
|
|
|
if (area->v2->newv) {
|
|
|
|
|
area->v2 = area->v2->newv;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-04-03 13:25:03 +02:00
|
|
|
if (area->v3->newv) {
|
|
|
|
|
area->v3 = area->v3->newv;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-04-03 13:25:03 +02:00
|
|
|
if (area->v4->newv) {
|
|
|
|
|
area->v4 = area->v4->newv;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-04-13 21:43:57 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-13 21:43:57 +02:00
|
|
|
/* remove */
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH_MUTABLE (ScrVert *, verg, &screen->vertbase) {
|
2018-04-13 21:43:57 +02:00
|
|
|
if (verg->newv) {
|
2020-04-03 14:23:21 +02:00
|
|
|
BLI_remlink(&screen->vertbase, verg);
|
2018-04-13 21:43:57 +02:00
|
|
|
MEM_freeN(verg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-03 14:23:21 +02:00
|
|
|
void BKE_screen_remove_double_scredges(bScreen *screen)
|
2018-04-13 21:43:57 +02:00
|
|
|
{
|
|
|
|
|
/* compare */
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ScrEdge *, verg, &screen->edgebase) {
|
|
|
|
|
ScrEdge *se = verg->next;
|
2018-04-13 21:43:57 +02:00
|
|
|
while (se) {
|
2020-11-29 20:30:11 -05:00
|
|
|
ScrEdge *sn = se->next;
|
2018-04-13 21:43:57 +02:00
|
|
|
if (verg->v1 == se->v1 && verg->v2 == se->v2) {
|
2020-04-03 14:23:21 +02:00
|
|
|
BLI_remlink(&screen->edgebase, se);
|
2018-04-13 21:43:57 +02:00
|
|
|
MEM_freeN(se);
|
|
|
|
|
}
|
|
|
|
|
se = sn;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-03 14:23:21 +02:00
|
|
|
void BKE_screen_remove_unused_scredges(bScreen *screen)
|
2018-04-13 21:43:57 +02:00
|
|
|
{
|
|
|
|
|
/* sets flags when edge is used in area */
|
2020-11-29 20:30:11 -05:00
|
|
|
int a = 0;
|
|
|
|
|
LISTBASE_FOREACH_INDEX (ScrArea *, area, &screen->areabase, a) {
|
|
|
|
|
ScrEdge *se = BKE_screen_find_edge(screen, area->v1, area->v2);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (se == NULL) {
|
2018-04-13 21:43:57 +02:00
|
|
|
printf("error: area %d edge 1 doesn't exist\n", a);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2018-04-13 21:43:57 +02:00
|
|
|
se->flag = 1;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-04-03 14:23:21 +02:00
|
|
|
se = BKE_screen_find_edge(screen, area->v2, area->v3);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (se == NULL) {
|
2018-04-13 21:43:57 +02:00
|
|
|
printf("error: area %d edge 2 doesn't exist\n", a);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2018-04-13 21:43:57 +02:00
|
|
|
se->flag = 1;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-04-03 14:23:21 +02:00
|
|
|
se = BKE_screen_find_edge(screen, area->v3, area->v4);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (se == NULL) {
|
2018-04-13 21:43:57 +02:00
|
|
|
printf("error: area %d edge 3 doesn't exist\n", a);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2018-04-13 21:43:57 +02:00
|
|
|
se->flag = 1;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-04-03 14:23:21 +02:00
|
|
|
se = BKE_screen_find_edge(screen, area->v4, area->v1);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (se == NULL) {
|
2018-04-13 21:43:57 +02:00
|
|
|
printf("error: area %d edge 4 doesn't exist\n", a);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2018-04-13 21:43:57 +02:00
|
|
|
se->flag = 1;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-04-13 21:43:57 +02:00
|
|
|
}
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH_MUTABLE (ScrEdge *, se, &screen->edgebase) {
|
2018-04-13 21:43:57 +02:00
|
|
|
if (se->flag == 0) {
|
2020-04-03 14:23:21 +02:00
|
|
|
BLI_remlink(&screen->edgebase, se);
|
2018-04-13 21:43:57 +02:00
|
|
|
MEM_freeN(se);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
se->flag = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-03 14:23:21 +02:00
|
|
|
void BKE_screen_remove_unused_scrverts(bScreen *screen)
|
2018-04-13 21:43:57 +02:00
|
|
|
{
|
|
|
|
|
/* we assume edges are ok */
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) {
|
2018-04-13 21:43:57 +02:00
|
|
|
se->v1->flag = 1;
|
|
|
|
|
se->v2->flag = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH_MUTABLE (ScrVert *, sv, &screen->vertbase) {
|
2018-04-13 21:43:57 +02:00
|
|
|
if (sv->flag == 0) {
|
2020-04-03 14:23:21 +02:00
|
|
|
BLI_remlink(&screen->vertbase, sv);
|
2018-04-13 21:43:57 +02:00
|
|
|
MEM_freeN(sv);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
sv->flag = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-07 23:39:44 +00:00
|
|
|
/* ***************** Utilities ********************** */
|
|
|
|
|
|
2018-11-25 16:21:35 +01:00
|
|
|
/**
|
2020-04-03 13:25:03 +02:00
|
|
|
* Find a region of type \a region_type in the currently active space of \a area.
|
2018-11-25 16:21:35 +01:00
|
|
|
*
|
|
|
|
|
* \note This does _not_ work if the region to look up is not in the active
|
|
|
|
|
* space. Use #BKE_spacedata_find_region_type if that may be the case.
|
|
|
|
|
*/
|
2020-04-03 13:25:03 +02:00
|
|
|
ARegion *BKE_area_find_region_type(const ScrArea *area, int region_type)
|
2010-02-07 23:39:44 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
if (area) {
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region->regiontype == region_type) {
|
|
|
|
|
return region;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2010-02-07 23:39:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
2018-11-25 16:21:35 +01:00
|
|
|
|
2010-02-07 23:39:44 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2010-04-22 19:57:18 +00:00
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
ARegion *BKE_area_find_region_active_win(ScrArea *area)
|
2013-01-30 12:22:02 +00:00
|
|
|
{
|
2020-11-29 20:30:11 -05:00
|
|
|
if (area == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2013-01-30 12:22:02 +00:00
|
|
|
|
2020-11-29 20:30:11 -05:00
|
|
|
ARegion *region = BLI_findlink(&area->regionbase, area->region_active_win);
|
|
|
|
|
if (region && (region->regiontype == RGN_TYPE_WINDOW)) {
|
|
|
|
|
return region;
|
2013-01-30 12:22:02 +00:00
|
|
|
}
|
2020-11-29 20:30:11 -05:00
|
|
|
|
|
|
|
|
/* fallback to any */
|
|
|
|
|
return BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
|
2013-01-30 12:22:02 +00:00
|
|
|
}
|
|
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
ARegion *BKE_area_find_region_xy(ScrArea *area, const int regiontype, int x, int y)
|
2015-04-27 18:53:45 +10:00
|
|
|
{
|
2020-11-29 20:30:11 -05:00
|
|
|
if (area == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
|
|
|
|
if (ELEM(regiontype, RGN_TYPE_ANY, region->regiontype)) {
|
|
|
|
|
if (BLI_rcti_isect_pt(®ion->winrct, x, y)) {
|
|
|
|
|
return region;
|
2015-04-27 18:53:45 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-29 20:30:11 -05:00
|
|
|
return NULL;
|
2015-04-27 18:53:45 +10:00
|
|
|
}
|
|
|
|
|
|
2019-07-01 12:10:49 +10:00
|
|
|
/**
|
|
|
|
|
* \note This is only for screen level regions (typically menus/popups).
|
|
|
|
|
*/
|
2020-04-03 14:23:21 +02:00
|
|
|
ARegion *BKE_screen_find_region_xy(bScreen *screen, const int regiontype, int x, int y)
|
2019-07-01 12:10:49 +10:00
|
|
|
{
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
|
2020-11-06 12:30:59 +11:00
|
|
|
if (ELEM(regiontype, RGN_TYPE_ANY, region->regiontype)) {
|
2020-03-06 16:56:42 +01:00
|
|
|
if (BLI_rcti_isect_pt(®ion->winrct, x, y)) {
|
2020-11-29 20:30:11 -05:00
|
|
|
return region;
|
2019-07-01 12:10:49 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-29 20:30:11 -05:00
|
|
|
return NULL;
|
2019-07-01 12:10:49 +10:00
|
|
|
}
|
|
|
|
|
|
2015-01-08 01:14:07 +11:00
|
|
|
/**
|
2019-11-25 01:14:39 +11:00
|
|
|
* \note Ideally we can get the area from the context,
|
2015-01-08 01:14:07 +11:00
|
|
|
* there are a few places however where this isn't practical.
|
|
|
|
|
*/
|
2020-04-03 14:23:21 +02:00
|
|
|
ScrArea *BKE_screen_find_area_from_space(struct bScreen *screen, SpaceLink *sl)
|
2015-01-08 01:14:07 +11:00
|
|
|
{
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
2020-04-03 13:25:03 +02:00
|
|
|
if (BLI_findindex(&area->spacedata, sl) != -1) {
|
2020-11-29 20:30:11 -05:00
|
|
|
return area;
|
2015-01-08 01:14:07 +11:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-29 20:30:11 -05:00
|
|
|
return NULL;
|
2015-01-08 01:14:07 +11:00
|
|
|
}
|
|
|
|
|
|
2015-01-21 13:43:46 +11:00
|
|
|
/**
|
|
|
|
|
* \note Using this function is generally a last resort, you really want to be
|
2011-11-04 01:15:04 +00:00
|
|
|
* using the context when you can - campbell
|
2015-01-21 13:43:46 +11:00
|
|
|
*/
|
2020-04-03 14:23:21 +02:00
|
|
|
ScrArea *BKE_screen_find_big_area(bScreen *screen, const int spacetype, const short min)
|
2011-11-04 01:15:04 +00:00
|
|
|
{
|
2020-11-29 20:30:11 -05:00
|
|
|
ScrArea *big = NULL;
|
|
|
|
|
int maxsize = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
2020-11-06 12:30:59 +11:00
|
|
|
if (ELEM(spacetype, SPACE_TYPE_ANY, area->spacetype)) {
|
2020-04-03 13:25:03 +02:00
|
|
|
if (min <= area->winx && min <= area->winy) {
|
2020-11-29 20:30:11 -05:00
|
|
|
int size = area->winx * area->winy;
|
2011-11-04 01:15:04 +00:00
|
|
|
if (size > maxsize) {
|
2012-05-06 15:15:33 +00:00
|
|
|
maxsize = size;
|
2020-04-03 13:25:03 +02:00
|
|
|
big = area;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-11-04 01:15:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-04 01:15:04 +00:00
|
|
|
return big;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-02 16:48:18 +02:00
|
|
|
ScrArea *BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap,
|
|
|
|
|
const int spacetype,
|
|
|
|
|
int x,
|
|
|
|
|
int y)
|
2015-01-21 13:43:46 +11:00
|
|
|
{
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &areamap->areabase) {
|
2020-04-03 13:25:03 +02:00
|
|
|
if (BLI_rcti_isect_pt(&area->totrct, x, y)) {
|
2020-11-06 12:30:59 +11:00
|
|
|
if (ELEM(spacetype, SPACE_TYPE_ANY, area->spacetype)) {
|
2020-04-03 13:25:03 +02:00
|
|
|
return area;
|
2015-01-21 13:43:46 +11:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-02 16:48:18 +02:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2020-04-03 14:23:21 +02:00
|
|
|
ScrArea *BKE_screen_find_area_xy(bScreen *screen, const int spacetype, int x, int y)
|
2018-07-02 16:48:18 +02:00
|
|
|
{
|
2020-04-03 14:23:21 +02:00
|
|
|
return BKE_screen_area_map_find_area_xy(AREAMAP_FROM_SCREEN(screen), spacetype, x, y);
|
2015-01-21 13:43:46 +11:00
|
|
|
}
|
|
|
|
|
|
2013-11-25 08:37:57 +11:00
|
|
|
void BKE_screen_view3d_sync(View3D *v3d, struct Scene *scene)
|
2010-04-22 19:57:18 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
if (v3d->scenelock && v3d->localvd == NULL) {
|
|
|
|
|
v3d->camera = scene->camera;
|
2010-04-22 19:57:18 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (v3d->camera == NULL) {
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ARegion *, region, &v3d->regionbase) {
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region->regiontype == RGN_TYPE_WINDOW) {
|
|
|
|
|
RegionView3D *rv3d = region->regiondata;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (rv3d->persp == RV3D_CAMOB) {
|
2012-05-06 15:15:33 +00:00
|
|
|
rv3d->persp = RV3D_PERSP;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2010-04-22 19:57:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-03 14:23:21 +02:00
|
|
|
void BKE_screen_view3d_scene_sync(bScreen *screen, Scene *scene)
|
2010-04-22 19:57:18 +00:00
|
|
|
{
|
|
|
|
|
/* are there cameras in the views that are not in the scene? */
|
2020-11-29 20:30:11 -05:00
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
|
|
|
|
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
2012-05-06 15:15:33 +00:00
|
|
|
if (sl->spacetype == SPACE_VIEW3D) {
|
|
|
|
|
View3D *v3d = (View3D *)sl;
|
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
|
|
|
BKE_screen_view3d_sync(v3d, scene);
|
2010-04-22 19:57:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-11 11:43:56 +02:00
|
|
|
void BKE_screen_view3d_shading_init(View3DShading *shading)
|
|
|
|
|
{
|
2019-09-09 22:32:34 +10:00
|
|
|
const View3DShading *shading_default = DNA_struct_default_get(View3DShading);
|
|
|
|
|
memcpy(shading, shading_default, sizeof(*shading));
|
2018-07-11 11:43:56 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-03 17:25:30 +02:00
|
|
|
ARegion *BKE_screen_find_main_region_at_xy(bScreen *screen,
|
|
|
|
|
const int space_type,
|
|
|
|
|
const int x,
|
|
|
|
|
const int y)
|
|
|
|
|
{
|
|
|
|
|
ScrArea *area = BKE_screen_find_area_xy(screen, space_type, x, y);
|
|
|
|
|
if (!area) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
return BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-20 04:14:29 +00:00
|
|
|
/* magic zoom calculation, no idea what
|
|
|
|
|
* it signifies, if you find out, tell me! -zr
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* simple, its magic dude!
|
|
|
|
|
* well, to be honest, this gives a natural feeling zooming
|
|
|
|
|
* with multiple keypad presses (ton)
|
|
|
|
|
*/
|
|
|
|
|
float BKE_screen_view3d_zoom_to_fac(float camzoom)
|
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
return powf(((float)M_SQRT2 + camzoom / 50.0f), 2.0f) / 4.0f;
|
2011-05-20 04:14:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float BKE_screen_view3d_zoom_from_fac(float zoomfac)
|
|
|
|
|
{
|
|
|
|
|
return ((sqrtf(4.0f * zoomfac) - (float)M_SQRT2) * 50.0f);
|
|
|
|
|
}
|
2015-02-12 18:54:41 +01:00
|
|
|
|
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
|
|
|
bool BKE_screen_is_fullscreen_area(const bScreen *screen)
|
|
|
|
|
{
|
|
|
|
|
return ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BKE_screen_is_used(const bScreen *screen)
|
|
|
|
|
{
|
|
|
|
|
return (screen->winid != 0);
|
|
|
|
|
}
|
2019-02-06 21:15:39 +11:00
|
|
|
|
|
|
|
|
void BKE_screen_header_alignment_reset(bScreen *screen)
|
|
|
|
|
{
|
|
|
|
|
int alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
|
|
|
|
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
2020-03-06 16:56:42 +01:00
|
|
|
if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
|
2020-04-03 13:25:03 +02:00
|
|
|
if (ELEM(area->spacetype, SPACE_FILE, SPACE_USERPREF, SPACE_OUTLINER, SPACE_PROPERTIES)) {
|
2020-03-06 16:56:42 +01:00
|
|
|
region->alignment = RGN_ALIGN_TOP;
|
2019-02-06 21:15:39 +11:00
|
|
|
continue;
|
|
|
|
|
}
|
2020-03-06 16:56:42 +01:00
|
|
|
region->alignment = alignment;
|
2019-02-06 21:15:39 +11:00
|
|
|
}
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region->regiontype == RGN_TYPE_FOOTER) {
|
2020-04-03 13:25:03 +02:00
|
|
|
if (ELEM(area->spacetype, SPACE_FILE, SPACE_USERPREF, SPACE_OUTLINER, SPACE_PROPERTIES)) {
|
2020-03-06 16:56:42 +01:00
|
|
|
region->alignment = RGN_ALIGN_BOTTOM;
|
2019-04-05 13:48:26 +02:00
|
|
|
continue;
|
|
|
|
|
}
|
2020-03-06 16:56:42 +01:00
|
|
|
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
|
2019-04-05 13:48:26 +02:00
|
|
|
}
|
2019-02-06 21:15:39 +11:00
|
|
|
}
|
|
|
|
|
}
|
2019-02-07 07:42:07 +11:00
|
|
|
screen->do_refresh = true;
|
2019-02-06 21:15:39 +11:00
|
|
|
}
|
2020-10-30 14:44:03 +01:00
|
|
|
|
|
|
|
|
void BKE_screen_view3d_shading_blend_write(BlendWriter *writer, View3DShading *shading)
|
|
|
|
|
{
|
|
|
|
|
if (shading->prop) {
|
|
|
|
|
IDP_BlendWrite(writer, shading->prop);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_screen_view3d_shading_blend_read_data(BlendDataReader *reader, View3DShading *shading)
|
|
|
|
|
{
|
|
|
|
|
if (shading->prop) {
|
|
|
|
|
BLO_read_data_address(reader, &shading->prop);
|
|
|
|
|
IDP_BlendDataRead(reader, &shading->prop);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-30 15:27:57 +01:00
|
|
|
|
|
|
|
|
static void write_region(BlendWriter *writer, ARegion *region, int spacetype)
|
|
|
|
|
{
|
|
|
|
|
BLO_write_struct(writer, ARegion, region);
|
|
|
|
|
|
|
|
|
|
if (region->regiondata) {
|
|
|
|
|
if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (spacetype) {
|
|
|
|
|
case SPACE_VIEW3D:
|
|
|
|
|
if (region->regiontype == RGN_TYPE_WINDOW) {
|
|
|
|
|
RegionView3D *rv3d = region->regiondata;
|
|
|
|
|
BLO_write_struct(writer, RegionView3D, rv3d);
|
|
|
|
|
|
|
|
|
|
if (rv3d->localvd) {
|
|
|
|
|
BLO_write_struct(writer, RegionView3D, rv3d->localvd);
|
|
|
|
|
}
|
|
|
|
|
if (rv3d->clipbb) {
|
|
|
|
|
BLO_write_struct(writer, BoundBox, rv3d->clipbb);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
printf("regiondata write missing!\n");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf("regiondata write missing!\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void write_uilist(BlendWriter *writer, uiList *ui_list)
|
|
|
|
|
{
|
|
|
|
|
BLO_write_struct(writer, uiList, ui_list);
|
|
|
|
|
|
|
|
|
|
if (ui_list->properties) {
|
|
|
|
|
IDP_BlendWrite(writer, ui_list->properties);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void write_space_outliner(BlendWriter *writer, SpaceOutliner *space_outliner)
|
|
|
|
|
{
|
|
|
|
|
BLI_mempool *ts = space_outliner->treestore;
|
|
|
|
|
|
|
|
|
|
if (ts) {
|
|
|
|
|
SpaceOutliner space_outliner_flat = *space_outliner;
|
|
|
|
|
|
|
|
|
|
int elems = BLI_mempool_len(ts);
|
|
|
|
|
/* linearize mempool to array */
|
|
|
|
|
TreeStoreElem *data = elems ? BLI_mempool_as_arrayN(ts, "TreeStoreElem") : NULL;
|
|
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
|
/* In this block we use the memory location of the treestore
|
|
|
|
|
* but _not_ its data, the addresses in this case are UUID's,
|
|
|
|
|
* since we can't rely on malloc giving us different values each time.
|
|
|
|
|
*/
|
|
|
|
|
TreeStore ts_flat = {0};
|
|
|
|
|
|
|
|
|
|
/* we know the treestore is at least as big as a pointer,
|
|
|
|
|
* so offsetting works to give us a UUID. */
|
|
|
|
|
void *data_addr = (void *)POINTER_OFFSET(ts, sizeof(void *));
|
|
|
|
|
|
|
|
|
|
ts_flat.usedelem = elems;
|
|
|
|
|
ts_flat.totelem = elems;
|
|
|
|
|
ts_flat.data = data_addr;
|
|
|
|
|
|
|
|
|
|
BLO_write_struct(writer, SpaceOutliner, space_outliner);
|
|
|
|
|
|
|
|
|
|
BLO_write_struct_at_address(writer, TreeStore, ts, &ts_flat);
|
|
|
|
|
BLO_write_struct_array_at_address(writer, TreeStoreElem, elems, data_addr, data);
|
|
|
|
|
|
|
|
|
|
MEM_freeN(data);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
space_outliner_flat.treestore = NULL;
|
|
|
|
|
BLO_write_struct_at_address(writer, SpaceOutliner, space_outliner, &space_outliner_flat);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLO_write_struct(writer, SpaceOutliner, space_outliner);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void write_panel_list(BlendWriter *writer, ListBase *lb)
|
|
|
|
|
{
|
|
|
|
|
LISTBASE_FOREACH (Panel *, panel, lb) {
|
|
|
|
|
BLO_write_struct(writer, Panel, panel);
|
|
|
|
|
write_panel_list(writer, &panel->children);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-09 14:17:06 +01:00
|
|
|
static void write_area(BlendWriter *writer, ScrArea *area)
|
2020-10-30 15:27:57 +01:00
|
|
|
{
|
|
|
|
|
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
|
|
|
|
write_region(writer, region, area->spacetype);
|
|
|
|
|
write_panel_list(writer, ®ion->panels);
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (PanelCategoryStack *, pc_act, ®ion->panels_category_active) {
|
|
|
|
|
BLO_write_struct(writer, PanelCategoryStack, pc_act);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (uiList *, ui_list, ®ion->ui_lists) {
|
|
|
|
|
write_uilist(writer, ui_list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (uiPreview *, ui_preview, ®ion->ui_previews) {
|
|
|
|
|
BLO_write_struct(writer, uiPreview, ui_preview);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
|
|
|
|
LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
|
|
|
|
|
write_region(writer, region, sl->spacetype);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sl->spacetype == SPACE_VIEW3D) {
|
|
|
|
|
View3D *v3d = (View3D *)sl;
|
|
|
|
|
BLO_write_struct(writer, View3D, v3d);
|
|
|
|
|
|
|
|
|
|
if (v3d->localvd) {
|
|
|
|
|
BLO_write_struct(writer, View3D, v3d->localvd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_screen_view3d_shading_blend_write(writer, &v3d->shading);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_GRAPH) {
|
|
|
|
|
SpaceGraph *sipo = (SpaceGraph *)sl;
|
|
|
|
|
ListBase tmpGhosts = sipo->runtime.ghost_curves;
|
|
|
|
|
|
|
|
|
|
/* temporarily disable ghost curves when saving */
|
|
|
|
|
BLI_listbase_clear(&sipo->runtime.ghost_curves);
|
|
|
|
|
|
|
|
|
|
BLO_write_struct(writer, SpaceGraph, sl);
|
|
|
|
|
if (sipo->ads) {
|
|
|
|
|
BLO_write_struct(writer, bDopeSheet, sipo->ads);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* reenable ghost curves */
|
|
|
|
|
sipo->runtime.ghost_curves = tmpGhosts;
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_PROPERTIES) {
|
|
|
|
|
BLO_write_struct(writer, SpaceProperties, sl);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_FILE) {
|
|
|
|
|
SpaceFile *sfile = (SpaceFile *)sl;
|
|
|
|
|
|
|
|
|
|
BLO_write_struct(writer, SpaceFile, sl);
|
|
|
|
|
if (sfile->params) {
|
|
|
|
|
BLO_write_struct(writer, FileSelectParams, sfile->params);
|
|
|
|
|
}
|
2020-12-14 13:50:36 +01:00
|
|
|
if (sfile->asset_params) {
|
|
|
|
|
BLO_write_struct(writer, FileAssetSelectParams, sfile->asset_params);
|
|
|
|
|
}
|
2020-10-30 15:27:57 +01:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_SEQ) {
|
|
|
|
|
BLO_write_struct(writer, SpaceSeq, sl);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_OUTLINER) {
|
|
|
|
|
SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
|
|
|
|
|
write_space_outliner(writer, space_outliner);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_IMAGE) {
|
|
|
|
|
BLO_write_struct(writer, SpaceImage, sl);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_TEXT) {
|
|
|
|
|
BLO_write_struct(writer, SpaceText, sl);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_SCRIPT) {
|
|
|
|
|
SpaceScript *scr = (SpaceScript *)sl;
|
|
|
|
|
scr->but_refs = NULL;
|
|
|
|
|
BLO_write_struct(writer, SpaceScript, sl);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_ACTION) {
|
|
|
|
|
BLO_write_struct(writer, SpaceAction, sl);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_NLA) {
|
|
|
|
|
SpaceNla *snla = (SpaceNla *)sl;
|
|
|
|
|
|
|
|
|
|
BLO_write_struct(writer, SpaceNla, snla);
|
|
|
|
|
if (snla->ads) {
|
|
|
|
|
BLO_write_struct(writer, bDopeSheet, snla->ads);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_NODE) {
|
|
|
|
|
SpaceNode *snode = (SpaceNode *)sl;
|
|
|
|
|
BLO_write_struct(writer, SpaceNode, snode);
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (bNodeTreePath *, path, &snode->treepath) {
|
|
|
|
|
BLO_write_struct(writer, bNodeTreePath, path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_CONSOLE) {
|
|
|
|
|
SpaceConsole *con = (SpaceConsole *)sl;
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (ConsoleLine *, cl, &con->history) {
|
|
|
|
|
/* 'len_alloc' is invalid on write, set from 'len' on read */
|
|
|
|
|
BLO_write_struct(writer, ConsoleLine, cl);
|
|
|
|
|
BLO_write_raw(writer, (size_t)cl->len + 1, cl->line);
|
|
|
|
|
}
|
|
|
|
|
BLO_write_struct(writer, SpaceConsole, sl);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_TOPBAR) {
|
|
|
|
|
BLO_write_struct(writer, SpaceTopBar, sl);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_STATUSBAR) {
|
|
|
|
|
BLO_write_struct(writer, SpaceStatusBar, sl);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_USERPREF) {
|
|
|
|
|
BLO_write_struct(writer, SpaceUserPref, sl);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_CLIP) {
|
|
|
|
|
BLO_write_struct(writer, SpaceClip, sl);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_INFO) {
|
|
|
|
|
BLO_write_struct(writer, SpaceInfo, sl);
|
|
|
|
|
}
|
2021-03-08 16:23:21 +01:00
|
|
|
else if (sl->spacetype == SPACE_SPREADSHEET) {
|
|
|
|
|
BLO_write_struct(writer, SpaceSpreadsheet, sl);
|
|
|
|
|
}
|
2020-10-30 15:27:57 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_screen_area_map_blend_write(BlendWriter *writer, ScrAreaMap *area_map)
|
|
|
|
|
{
|
|
|
|
|
BLO_write_struct_list(writer, ScrVert, &area_map->vertbase);
|
|
|
|
|
BLO_write_struct_list(writer, ScrEdge, &area_map->edgebase);
|
|
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) {
|
|
|
|
|
area->butspacetype = area->spacetype; /* Just for compatibility, will be reset below. */
|
|
|
|
|
|
|
|
|
|
BLO_write_struct(writer, ScrArea, area);
|
|
|
|
|
|
|
|
|
|
BLO_write_struct(writer, ScrGlobalAreaData, area->global);
|
|
|
|
|
|
2021-03-09 14:17:06 +01:00
|
|
|
write_area(writer, area);
|
2020-10-30 15:27:57 +01:00
|
|
|
|
|
|
|
|
area->butspacetype = SPACE_EMPTY; /* Unset again, was changed above. */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void direct_link_panel_list(BlendDataReader *reader, ListBase *lb)
|
|
|
|
|
{
|
|
|
|
|
BLO_read_list(reader, lb);
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (Panel *, panel, lb) {
|
|
|
|
|
panel->runtime_flag = 0;
|
|
|
|
|
panel->activedata = NULL;
|
|
|
|
|
panel->type = NULL;
|
|
|
|
|
panel->runtime.custom_data_ptr = NULL;
|
|
|
|
|
direct_link_panel_list(reader, &panel->children);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void direct_link_region(BlendDataReader *reader, ARegion *region, int spacetype)
|
|
|
|
|
{
|
|
|
|
|
direct_link_panel_list(reader, ®ion->panels);
|
|
|
|
|
|
|
|
|
|
BLO_read_list(reader, ®ion->panels_category_active);
|
|
|
|
|
|
|
|
|
|
BLO_read_list(reader, ®ion->ui_lists);
|
|
|
|
|
|
|
|
|
|
/* The area's search filter is runtime only, so we need to clear the active flag on read. */
|
|
|
|
|
region->flag &= ~RGN_FLAG_SEARCH_FILTER_ACTIVE;
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (uiList *, ui_list, ®ion->ui_lists) {
|
|
|
|
|
ui_list->type = NULL;
|
|
|
|
|
ui_list->dyn_data = NULL;
|
|
|
|
|
BLO_read_data_address(reader, &ui_list->properties);
|
|
|
|
|
IDP_BlendDataRead(reader, &ui_list->properties);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLO_read_list(reader, ®ion->ui_previews);
|
|
|
|
|
|
|
|
|
|
if (spacetype == SPACE_EMPTY) {
|
|
|
|
|
/* unknown space type, don't leak regiondata */
|
|
|
|
|
region->regiondata = NULL;
|
|
|
|
|
}
|
|
|
|
|
else if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
|
|
|
|
|
/* Runtime data, don't use. */
|
|
|
|
|
region->regiondata = NULL;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLO_read_data_address(reader, ®ion->regiondata);
|
|
|
|
|
if (region->regiondata) {
|
|
|
|
|
if (spacetype == SPACE_VIEW3D) {
|
|
|
|
|
RegionView3D *rv3d = region->regiondata;
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &rv3d->localvd);
|
|
|
|
|
BLO_read_data_address(reader, &rv3d->clipbb);
|
|
|
|
|
|
|
|
|
|
rv3d->depths = NULL;
|
|
|
|
|
rv3d->render_engine = NULL;
|
|
|
|
|
rv3d->sms = NULL;
|
|
|
|
|
rv3d->smooth_timer = NULL;
|
|
|
|
|
|
|
|
|
|
rv3d->rflag &= ~(RV3D_NAVIGATING | RV3D_PAINTING);
|
|
|
|
|
rv3d->runtime_viewlock = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
region->v2d.sms = NULL;
|
|
|
|
|
region->v2d.alpha_hor = region->v2d.alpha_vert = 255; /* visible by default */
|
|
|
|
|
BLI_listbase_clear(®ion->panels_category);
|
|
|
|
|
BLI_listbase_clear(®ion->handlers);
|
|
|
|
|
BLI_listbase_clear(®ion->uiblocks);
|
|
|
|
|
region->headerstr = NULL;
|
|
|
|
|
region->visible = 0;
|
|
|
|
|
region->type = NULL;
|
|
|
|
|
region->do_draw = 0;
|
|
|
|
|
region->gizmo_map = NULL;
|
|
|
|
|
region->regiontimer = NULL;
|
|
|
|
|
region->draw_buffer = NULL;
|
|
|
|
|
memset(®ion->drawrct, 0, sizeof(region->drawrct));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* for the saved 2.50 files without regiondata */
|
|
|
|
|
/* and as patch for 2.48 and older */
|
|
|
|
|
void BKE_screen_view3d_do_versions_250(View3D *v3d, ListBase *regions)
|
|
|
|
|
{
|
|
|
|
|
LISTBASE_FOREACH (ARegion *, region, regions) {
|
|
|
|
|
if (region->regiontype == RGN_TYPE_WINDOW && region->regiondata == NULL) {
|
|
|
|
|
RegionView3D *rv3d;
|
|
|
|
|
|
|
|
|
|
rv3d = region->regiondata = MEM_callocN(sizeof(RegionView3D), "region v3d patch");
|
|
|
|
|
rv3d->persp = (char)v3d->persp;
|
|
|
|
|
rv3d->view = (char)v3d->view;
|
|
|
|
|
rv3d->dist = v3d->dist;
|
|
|
|
|
copy_v3_v3(rv3d->ofs, v3d->ofs);
|
|
|
|
|
copy_qt_qt(rv3d->viewquat, v3d->viewquat);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* this was not initialized correct always */
|
|
|
|
|
if (v3d->gridsubdiv == 0) {
|
|
|
|
|
v3d->gridsubdiv = 10;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void direct_link_area(BlendDataReader *reader, ScrArea *area)
|
|
|
|
|
{
|
|
|
|
|
BLO_read_list(reader, &(area->spacedata));
|
|
|
|
|
BLO_read_list(reader, &(area->regionbase));
|
|
|
|
|
|
|
|
|
|
BLI_listbase_clear(&area->handlers);
|
|
|
|
|
area->type = NULL; /* spacetype callbacks */
|
|
|
|
|
|
|
|
|
|
/* Should always be unset so that rna_Area_type_get works correctly. */
|
|
|
|
|
area->butspacetype = SPACE_EMPTY;
|
|
|
|
|
|
|
|
|
|
area->region_active_win = -1;
|
|
|
|
|
|
|
|
|
|
area->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE;
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &area->global);
|
|
|
|
|
|
|
|
|
|
/* if we do not have the spacetype registered we cannot
|
|
|
|
|
* free it, so don't allocate any new memory for such spacetypes. */
|
|
|
|
|
if (!BKE_spacetype_exists(area->spacetype)) {
|
|
|
|
|
/* Hint for versioning code to replace deprecated space types. */
|
|
|
|
|
area->butspacetype = area->spacetype;
|
|
|
|
|
|
|
|
|
|
area->spacetype = SPACE_EMPTY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
|
|
|
|
direct_link_region(reader, region, area->spacetype);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* accident can happen when read/save new file with older version */
|
|
|
|
|
/* 2.50: we now always add spacedata for info */
|
|
|
|
|
if (area->spacedata.first == NULL) {
|
|
|
|
|
SpaceInfo *sinfo = MEM_callocN(sizeof(SpaceInfo), "spaceinfo");
|
|
|
|
|
area->spacetype = sinfo->spacetype = SPACE_INFO;
|
|
|
|
|
BLI_addtail(&area->spacedata, sinfo);
|
|
|
|
|
}
|
|
|
|
|
/* add local view3d too */
|
|
|
|
|
else if (area->spacetype == SPACE_VIEW3D) {
|
|
|
|
|
BKE_screen_view3d_do_versions_250(area->spacedata.first, &area->regionbase);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
|
|
|
|
BLO_read_list(reader, &(sl->regionbase));
|
|
|
|
|
|
|
|
|
|
/* if we do not have the spacetype registered we cannot
|
|
|
|
|
* free it, so don't allocate any new memory for such spacetypes. */
|
|
|
|
|
if (!BKE_spacetype_exists(sl->spacetype)) {
|
|
|
|
|
sl->spacetype = SPACE_EMPTY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
|
|
|
|
|
direct_link_region(reader, region, sl->spacetype);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sl->spacetype == SPACE_VIEW3D) {
|
|
|
|
|
View3D *v3d = (View3D *)sl;
|
|
|
|
|
|
|
|
|
|
v3d->flag |= V3D_INVALID_BACKBUF;
|
|
|
|
|
|
|
|
|
|
if (v3d->gpd) {
|
|
|
|
|
BLO_read_data_address(reader, &v3d->gpd);
|
|
|
|
|
BKE_gpencil_blend_read_data(reader, v3d->gpd);
|
|
|
|
|
}
|
|
|
|
|
BLO_read_data_address(reader, &v3d->localvd);
|
|
|
|
|
|
|
|
|
|
/* Runtime data */
|
|
|
|
|
v3d->runtime.properties_storage = NULL;
|
|
|
|
|
v3d->runtime.flag = 0;
|
|
|
|
|
|
|
|
|
|
/* render can be quite heavy, set to solid on load */
|
|
|
|
|
if (v3d->shading.type == OB_RENDER) {
|
|
|
|
|
v3d->shading.type = OB_SOLID;
|
|
|
|
|
}
|
|
|
|
|
v3d->shading.prev_type = OB_SOLID;
|
|
|
|
|
|
|
|
|
|
BKE_screen_view3d_shading_blend_read_data(reader, &v3d->shading);
|
|
|
|
|
|
|
|
|
|
BKE_screen_view3d_do_versions_250(v3d, &sl->regionbase);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_GRAPH) {
|
|
|
|
|
SpaceGraph *sipo = (SpaceGraph *)sl;
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &sipo->ads);
|
|
|
|
|
BLI_listbase_clear(&sipo->runtime.ghost_curves);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_NLA) {
|
|
|
|
|
SpaceNla *snla = (SpaceNla *)sl;
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &snla->ads);
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_OUTLINER) {
|
|
|
|
|
SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
|
|
|
|
|
|
|
|
|
|
/* use #BLO_read_get_new_data_address_no_us and do not free old memory avoiding double
|
|
|
|
|
* frees and use of freed memory. this could happen because of a
|
|
|
|
|
* bug fixed in revision 58959 where the treestore memory address
|
|
|
|
|
* was not unique */
|
|
|
|
|
TreeStore *ts = BLO_read_get_new_data_address_no_us(reader, space_outliner->treestore);
|
|
|
|
|
space_outliner->treestore = NULL;
|
|
|
|
|
if (ts) {
|
|
|
|
|
TreeStoreElem *elems = BLO_read_get_new_data_address_no_us(reader, ts->data);
|
|
|
|
|
|
|
|
|
|
space_outliner->treestore = BLI_mempool_create(
|
|
|
|
|
sizeof(TreeStoreElem), ts->usedelem, 512, BLI_MEMPOOL_ALLOW_ITER);
|
|
|
|
|
if (ts->usedelem && elems) {
|
|
|
|
|
for (int i = 0; i < ts->usedelem; i++) {
|
|
|
|
|
TreeStoreElem *new_elem = BLI_mempool_alloc(space_outliner->treestore);
|
|
|
|
|
*new_elem = elems[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* we only saved what was used */
|
|
|
|
|
space_outliner->storeflag |= SO_TREESTORE_CLEANUP; /* at first draw */
|
|
|
|
|
}
|
|
|
|
|
space_outliner->tree.first = space_outliner->tree.last = NULL;
|
UI Code Quality: Start refactoring Outliner tree building (using C++)
This introduces a new C++ abstraction "tree-display" (in this commit named
tree-view, renamed in a followup) to help constructing and managing the tree
for the different display types (View Layer, Scene, Blender file, etc.).
See https://developer.blender.org/D9499 for more context. Other developers
approved this rather significantly different design approach there.
----
Motivation
General problems with current design:
* The Outliner tree building code is messy and hard to follow.
* Hard-coded display mode checks are scattered over many places.
* Data is passed around in rather unsafe ways (e.g. lots of `void *`).
* There are no individually testable units.
* Data-structure use is inefficient.
The current Outliner code needs quite some untangling, the tree building seems
like a good place to start. This and the followup commits tackle that.
----
Design Idea
Idea is to have an abstract base class (`AbstractTreeDisplay`), and then
sub-classes with the implementation for each display type (e.g.
`TreeDisplayViewLayer`, `TreeDisplayDataAPI`, etc). The tree-display is kept
alive until tree-rebuild as runtime data of the space, so that further queries
based on the display type can be executed (e.g. "does the display support
selection syncing?", "does it support restriction toggle columns?", etc.).
New files are in a new `space_outliner/tree` sub-directory.
With the new design, display modes become proper units, making them more
maintainable, safer and testable. It should also be easier now to add new
display modes.
2020-11-06 20:54:20 +01:00
|
|
|
space_outliner->runtime = NULL;
|
2020-10-30 15:27:57 +01:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_IMAGE) {
|
|
|
|
|
SpaceImage *sima = (SpaceImage *)sl;
|
|
|
|
|
|
|
|
|
|
sima->iuser.scene = NULL;
|
|
|
|
|
sima->iuser.ok = 1;
|
|
|
|
|
sima->scopes.waveform_1 = NULL;
|
|
|
|
|
sima->scopes.waveform_2 = NULL;
|
|
|
|
|
sima->scopes.waveform_3 = NULL;
|
|
|
|
|
sima->scopes.vecscope = NULL;
|
|
|
|
|
sima->scopes.ok = 0;
|
|
|
|
|
|
|
|
|
|
/* WARNING: gpencil data is no longer stored directly in sima after 2.5
|
|
|
|
|
* so sacrifice a few old files for now to avoid crashes with new files!
|
|
|
|
|
* committed: r28002 */
|
|
|
|
|
#if 0
|
|
|
|
|
sima->gpd = newdataadr(fd, sima->gpd);
|
|
|
|
|
if (sima->gpd) {
|
|
|
|
|
BKE_gpencil_blend_read_data(fd, sima->gpd);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_NODE) {
|
|
|
|
|
SpaceNode *snode = (SpaceNode *)sl;
|
|
|
|
|
|
|
|
|
|
if (snode->gpd) {
|
|
|
|
|
BLO_read_data_address(reader, &snode->gpd);
|
|
|
|
|
BKE_gpencil_blend_read_data(reader, snode->gpd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLO_read_list(reader, &snode->treepath);
|
|
|
|
|
snode->edittree = NULL;
|
2021-01-19 16:43:08 -06:00
|
|
|
snode->runtime = NULL;
|
2020-10-30 15:27:57 +01:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_TEXT) {
|
|
|
|
|
SpaceText *st = (SpaceText *)sl;
|
|
|
|
|
memset(&st->runtime, 0, sizeof(st->runtime));
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_SEQ) {
|
|
|
|
|
SpaceSeq *sseq = (SpaceSeq *)sl;
|
|
|
|
|
|
|
|
|
|
/* grease pencil data is not a direct data and can't be linked from direct_link*
|
|
|
|
|
* functions, it should be linked from lib_link* functions instead
|
|
|
|
|
*
|
|
|
|
|
* otherwise it'll lead to lost grease data on open because it'll likely be
|
|
|
|
|
* read from file after all other users of grease pencil and newdataadr would
|
|
|
|
|
* simple return NULL here (sergey)
|
|
|
|
|
*/
|
|
|
|
|
#if 0
|
|
|
|
|
if (sseq->gpd) {
|
|
|
|
|
sseq->gpd = newdataadr(fd, sseq->gpd);
|
|
|
|
|
BKE_gpencil_blend_read_data(fd, sseq->gpd);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
sseq->scopes.reference_ibuf = NULL;
|
|
|
|
|
sseq->scopes.zebra_ibuf = NULL;
|
|
|
|
|
sseq->scopes.waveform_ibuf = NULL;
|
|
|
|
|
sseq->scopes.sep_waveform_ibuf = NULL;
|
|
|
|
|
sseq->scopes.vector_ibuf = NULL;
|
|
|
|
|
sseq->scopes.histogram_ibuf = NULL;
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_PROPERTIES) {
|
|
|
|
|
SpaceProperties *sbuts = (SpaceProperties *)sl;
|
|
|
|
|
|
|
|
|
|
sbuts->path = NULL;
|
|
|
|
|
sbuts->texuser = NULL;
|
|
|
|
|
sbuts->mainbo = sbuts->mainb;
|
|
|
|
|
sbuts->mainbuser = sbuts->mainb;
|
|
|
|
|
sbuts->runtime = NULL;
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_CONSOLE) {
|
|
|
|
|
SpaceConsole *sconsole = (SpaceConsole *)sl;
|
|
|
|
|
|
|
|
|
|
BLO_read_list(reader, &sconsole->scrollback);
|
|
|
|
|
BLO_read_list(reader, &sconsole->history);
|
|
|
|
|
|
|
|
|
|
/* comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
|
|
|
|
|
* from left to right. the right-most expression sets the result of the comma
|
|
|
|
|
* expression as a whole*/
|
|
|
|
|
LISTBASE_FOREACH_MUTABLE (ConsoleLine *, cl, &sconsole->history) {
|
|
|
|
|
BLO_read_data_address(reader, &cl->line);
|
|
|
|
|
if (cl->line) {
|
|
|
|
|
/* the allocted length is not written, so reset here */
|
|
|
|
|
cl->len_alloc = cl->len + 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_remlink(&sconsole->history, cl);
|
|
|
|
|
MEM_freeN(cl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_FILE) {
|
|
|
|
|
SpaceFile *sfile = (SpaceFile *)sl;
|
|
|
|
|
|
|
|
|
|
/* this sort of info is probably irrelevant for reloading...
|
|
|
|
|
* plus, it isn't saved to files yet!
|
|
|
|
|
*/
|
|
|
|
|
sfile->folders_prev = sfile->folders_next = NULL;
|
2020-12-14 13:50:36 +01:00
|
|
|
BLI_listbase_clear(&sfile->folder_histories);
|
2020-10-30 15:27:57 +01:00
|
|
|
sfile->files = NULL;
|
|
|
|
|
sfile->layout = NULL;
|
|
|
|
|
sfile->op = NULL;
|
|
|
|
|
sfile->previews_timer = NULL;
|
2020-12-14 13:50:36 +01:00
|
|
|
sfile->tags = 0;
|
2021-03-05 15:00:56 +01:00
|
|
|
sfile->runtime = NULL;
|
2020-10-30 15:27:57 +01:00
|
|
|
BLO_read_data_address(reader, &sfile->params);
|
2020-12-14 13:50:36 +01:00
|
|
|
BLO_read_data_address(reader, &sfile->asset_params);
|
2020-10-30 15:27:57 +01:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_CLIP) {
|
|
|
|
|
SpaceClip *sclip = (SpaceClip *)sl;
|
|
|
|
|
|
|
|
|
|
sclip->scopes.track_search = NULL;
|
|
|
|
|
sclip->scopes.track_preview = NULL;
|
|
|
|
|
sclip->scopes.ok = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_listbase_clear(&area->actionzones);
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &area->v1);
|
|
|
|
|
BLO_read_data_address(reader, &area->v2);
|
|
|
|
|
BLO_read_data_address(reader, &area->v3);
|
|
|
|
|
BLO_read_data_address(reader, &area->v4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \return false on error.
|
|
|
|
|
*/
|
|
|
|
|
bool BKE_screen_area_map_blend_read_data(BlendDataReader *reader, ScrAreaMap *area_map)
|
|
|
|
|
{
|
|
|
|
|
BLO_read_list(reader, &area_map->vertbase);
|
|
|
|
|
BLO_read_list(reader, &area_map->edgebase);
|
|
|
|
|
BLO_read_list(reader, &area_map->areabase);
|
|
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) {
|
|
|
|
|
direct_link_area(reader, area);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* edges */
|
|
|
|
|
LISTBASE_FOREACH (ScrEdge *, se, &area_map->edgebase) {
|
|
|
|
|
BLO_read_data_address(reader, &se->v1);
|
|
|
|
|
BLO_read_data_address(reader, &se->v2);
|
|
|
|
|
BKE_screen_sort_scrvert(&se->v1, &se->v2);
|
|
|
|
|
|
|
|
|
|
if (se->v1 == NULL) {
|
|
|
|
|
BLI_remlink(&area_map->edgebase, se);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_screen_area_blend_read_lib(BlendLibReader *reader, ID *parent_id, ScrArea *area)
|
|
|
|
|
{
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &area->full);
|
|
|
|
|
|
|
|
|
|
memset(&area->runtime, 0x0, sizeof(area->runtime));
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
|
|
|
|
switch (sl->spacetype) {
|
|
|
|
|
case SPACE_VIEW3D: {
|
|
|
|
|
View3D *v3d = (View3D *)sl;
|
|
|
|
|
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &v3d->camera);
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &v3d->ob_center);
|
|
|
|
|
|
|
|
|
|
if (v3d->localvd) {
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &v3d->localvd->camera);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_GRAPH: {
|
|
|
|
|
SpaceGraph *sipo = (SpaceGraph *)sl;
|
|
|
|
|
bDopeSheet *ads = sipo->ads;
|
|
|
|
|
|
|
|
|
|
if (ads) {
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &ads->source);
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_PROPERTIES: {
|
|
|
|
|
SpaceProperties *sbuts = (SpaceProperties *)sl;
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &sbuts->pinid);
|
|
|
|
|
if (sbuts->pinid == NULL) {
|
|
|
|
|
sbuts->flag &= ~SB_PIN_CONTEXT;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2020-12-14 13:50:36 +01:00
|
|
|
case SPACE_FILE: {
|
|
|
|
|
SpaceFile *sfile = (SpaceFile *)sl;
|
|
|
|
|
sfile->tags |= FILE_TAG_REBUILD_MAIN_FILES;
|
2020-10-30 15:27:57 +01:00
|
|
|
break;
|
2020-12-14 13:50:36 +01:00
|
|
|
}
|
2020-10-30 15:27:57 +01:00
|
|
|
case SPACE_ACTION: {
|
|
|
|
|
SpaceAction *saction = (SpaceAction *)sl;
|
|
|
|
|
bDopeSheet *ads = &saction->ads;
|
|
|
|
|
|
|
|
|
|
if (ads) {
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &ads->source);
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &saction->action);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_IMAGE: {
|
|
|
|
|
SpaceImage *sima = (SpaceImage *)sl;
|
|
|
|
|
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &sima->image);
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &sima->mask_info.mask);
|
|
|
|
|
|
|
|
|
|
/* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
|
|
|
|
|
* so fingers crossed this works fine!
|
|
|
|
|
*/
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &sima->gpd);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_SEQ: {
|
|
|
|
|
SpaceSeq *sseq = (SpaceSeq *)sl;
|
|
|
|
|
|
|
|
|
|
/* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
|
|
|
|
|
* so fingers crossed this works fine!
|
|
|
|
|
*/
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &sseq->gpd);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_NLA: {
|
|
|
|
|
SpaceNla *snla = (SpaceNla *)sl;
|
|
|
|
|
bDopeSheet *ads = snla->ads;
|
|
|
|
|
|
|
|
|
|
if (ads) {
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &ads->source);
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_TEXT: {
|
|
|
|
|
SpaceText *st = (SpaceText *)sl;
|
|
|
|
|
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &st->text);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_SCRIPT: {
|
|
|
|
|
SpaceScript *scpt = (SpaceScript *)sl;
|
|
|
|
|
/*scpt->script = NULL; - 2.45 set to null, better re-run the script */
|
|
|
|
|
if (scpt->script) {
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &scpt->script);
|
|
|
|
|
if (scpt->script) {
|
|
|
|
|
SCRIPT_SET_NULL(scpt->script);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_OUTLINER: {
|
|
|
|
|
SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
|
|
|
|
|
BLO_read_id_address(reader, NULL, &space_outliner->search_tse.id);
|
|
|
|
|
|
|
|
|
|
if (space_outliner->treestore) {
|
|
|
|
|
TreeStoreElem *tselem;
|
|
|
|
|
BLI_mempool_iter iter;
|
|
|
|
|
|
|
|
|
|
BLI_mempool_iternew(space_outliner->treestore, &iter);
|
|
|
|
|
while ((tselem = BLI_mempool_iterstep(&iter))) {
|
|
|
|
|
BLO_read_id_address(reader, NULL, &tselem->id);
|
|
|
|
|
}
|
2020-12-04 19:43:33 +01:00
|
|
|
/* rebuild hash table, because it depends on ids too */
|
|
|
|
|
space_outliner->storeflag |= SO_TREESTORE_REBUILD;
|
2020-10-30 15:27:57 +01:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_NODE: {
|
|
|
|
|
SpaceNode *snode = (SpaceNode *)sl;
|
|
|
|
|
|
|
|
|
|
/* node tree can be stored locally in id too, link this first */
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &snode->id);
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &snode->from);
|
|
|
|
|
|
|
|
|
|
bNodeTree *ntree = snode->id ? ntreeFromID(snode->id) : NULL;
|
|
|
|
|
if (ntree) {
|
|
|
|
|
snode->nodetree = ntree;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &snode->nodetree);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bNodeTreePath *path;
|
|
|
|
|
for (path = snode->treepath.first; path; path = path->next) {
|
|
|
|
|
if (path == snode->treepath.first) {
|
|
|
|
|
/* first nodetree in path is same as snode->nodetree */
|
|
|
|
|
path->nodetree = snode->nodetree;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &path->nodetree);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!path->nodetree) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* remaining path entries are invalid, remove */
|
|
|
|
|
bNodeTreePath *path_next;
|
|
|
|
|
for (; path; path = path_next) {
|
|
|
|
|
path_next = path->next;
|
|
|
|
|
|
|
|
|
|
BLI_remlink(&snode->treepath, path);
|
|
|
|
|
MEM_freeN(path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* edittree is just the last in the path,
|
|
|
|
|
* set this directly since the path may have been shortened above */
|
|
|
|
|
if (snode->treepath.last) {
|
|
|
|
|
path = snode->treepath.last;
|
|
|
|
|
snode->edittree = path->nodetree;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
snode->edittree = NULL;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_CLIP: {
|
|
|
|
|
SpaceClip *sclip = (SpaceClip *)sl;
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &sclip->clip);
|
|
|
|
|
BLO_read_id_address(reader, parent_id->lib, &sclip->mask_info.mask);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|