2012-04-30 14:24:11 +00:00
|
|
|
/*
|
2008-01-07 18:03:41 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
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.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2007-12-24 18:38:03 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-27 20:40:57 +00:00
|
|
|
/** \file blender/blenkernel/intern/screen.c
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
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 <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2008-12-08 15:02:57 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2015-02-12 18:54:41 +01:00
|
|
|
#include "GPU_compositing.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"
|
2009-09-14 12:26:34 +00:00
|
|
|
#include "DNA_view3d_types.h"
|
2008-12-08 15:02:57 +00:00
|
|
|
|
2012-05-19 13:28:19 +00:00
|
|
|
#include "BLI_listbase.h"
|
|
|
|
#include "BLI_utildefines.h"
|
2015-01-21 13:43:46 +11:00
|
|
|
#include "BLI_rect.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2016-12-01 16:43:57 +01:00
|
|
|
#include "BKE_icons.h"
|
2013-08-29 12:55:31 +00:00
|
|
|
#include "BKE_idprop.h"
|
2005-03-09 19:45:59 +00:00
|
|
|
#include "BKE_screen.h"
|
|
|
|
|
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)
|
|
|
|
{
|
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
|
|
|
ARegionType *art;
|
2009-04-19 13:37:59 +00:00
|
|
|
PanelType *pt;
|
2009-04-22 18:39:44 +00:00
|
|
|
HeaderType *ht;
|
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
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (art = st->regiontypes.first; art; art = art->next) {
|
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
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (pt = art->paneltypes.first; pt; pt = pt->next)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pt->ext.free)
|
2009-07-21 20:05:16 +00:00
|
|
|
pt->ext.free(pt->ext.data);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (ht = art->headertypes.first; ht; ht = ht->next)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ht->ext.free)
|
2009-07-21 20:05:16 +00:00
|
|
|
ht->ext.free(ht->ext.data);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-03-29 19:44:39 +00:00
|
|
|
BLI_freelistN(&art->paneltypes);
|
|
|
|
BLI_freelistN(&art->headertypes);
|
|
|
|
}
|
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
|
|
|
|
2008-12-08 15:02:57 +00:00
|
|
|
BLI_freelistN(&st->regiontypes);
|
2009-07-02 11:23:19 +00:00
|
|
|
BLI_freelistN(&st->toolshelf);
|
|
|
|
|
2008-12-08 15:02:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_spacetypes_free(void)
|
|
|
|
{
|
2008-12-14 17:25:46 +00:00
|
|
|
SpaceType *st;
|
2008-12-08 15:02:57 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (st = spacetypes.first; st; st = st->next) {
|
2008-12-08 15:02:57 +00:00
|
|
|
spacetype_free(st);
|
2008-12-14 11:39:00 +00: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)
|
|
|
|
{
|
|
|
|
SpaceType *st;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (st = spacetypes.first; st; st = st->next) {
|
|
|
|
if (st->spaceid == spaceid)
|
2008-01-07 18:03:41 +00:00
|
|
|
return st;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid)
|
|
|
|
{
|
|
|
|
ARegionType *art;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (art = st->regiontypes.first; art; art = art->next)
|
|
|
|
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;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
SpaceType *stype;
|
|
|
|
|
|
|
|
/* sanity check */
|
2012-05-06 15:15:33 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2008-12-14 17:25:46 +00:00
|
|
|
SpaceLink *sl;
|
|
|
|
ARegion *ar;
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (sl = lb->first; sl; sl = sl->next) {
|
|
|
|
SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2008-12-14 17:25:46 +00:00
|
|
|
/* free regions for pushed spaces */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (ar = sl->regionbase.first; ar; ar = ar->next)
|
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
|
|
|
BKE_area_region_free(st, ar);
|
|
|
|
|
2008-12-11 19:35:27 +00:00
|
|
|
BLI_freelistN(&sl->regionbase);
|
2008-12-14 11:55:49 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (st && st->free)
|
2008-12-14 11:55:49 +00:00
|
|
|
st->free(sl);
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BLI_freelistN(lb);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
|
2008-12-14 17:25:46 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
ARegion *newar = MEM_dupallocN(ar);
|
2008-12-26 13:11:04 +00:00
|
|
|
Panel *pa, *newpa, *patab;
|
2008-12-14 17:25:46 +00: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);
|
2012-05-06 15:15:33 +00:00
|
|
|
newar->swinid = 0;
|
2016-10-07 16:34:55 +02:00
|
|
|
newar->manipulator_map = NULL;
|
2015-11-17 11:22:30 +11:00
|
|
|
newar->regiontimer = NULL;
|
2008-12-14 17:25:46 +00: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 */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ar->regiondata) {
|
2012-05-06 15:15:33 +00:00
|
|
|
ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
|
2008-12-26 13:11:04 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (art && art->duplicate)
|
2012-05-06 15:15:33 +00:00
|
|
|
newar->regiondata = art->duplicate(ar->regiondata);
|
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
|
|
|
else
|
2012-05-06 15:15:33 +00:00
|
|
|
newar->regiondata = MEM_dupallocN(ar->regiondata);
|
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
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ar->v2d.tab_offset)
|
2012-05-06 15:15:33 +00:00
|
|
|
newar->v2d.tab_offset = MEM_dupallocN(ar->v2d.tab_offset);
|
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
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(&newar->panels);
|
2008-12-26 13:11:04 +00:00
|
|
|
BLI_duplicatelist(&newar->panels, &ar->panels);
|
2014-04-23 17:13:28 +10:00
|
|
|
|
|
|
|
BLI_listbase_clear(&newar->ui_previews);
|
|
|
|
BLI_duplicatelist(&newar->ui_previews, &ar->ui_previews);
|
|
|
|
|
2008-12-26 13:11:04 +00:00
|
|
|
/* copy panel pointers */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (newpa = newar->panels.first; newpa; newpa = newpa->next) {
|
|
|
|
patab = newar->panels.first;
|
|
|
|
pa = ar->panels.first;
|
2012-03-24 06:18:31 +00:00
|
|
|
while (patab) {
|
|
|
|
if (newpa->paneltab == pa) {
|
2008-12-26 13:11:04 +00:00
|
|
|
newpa->paneltab = patab;
|
|
|
|
break;
|
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
patab = patab->next;
|
|
|
|
pa = pa->next;
|
2008-12-26 13:11:04 +00: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
|
|
|
{
|
|
|
|
ARegion *ar;
|
|
|
|
|
|
|
|
/* to be sure */
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(lb1);
|
2008-12-14 17:25:46 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (ar = lb2->first; ar; ar = ar->next) {
|
|
|
|
ARegion *arnew = BKE_area_region_copy(st, ar);
|
2008-12-14 17:25:46 +00:00
|
|
|
BLI_addtail(lb1, arnew);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
/* lb1 should be empty */
|
|
|
|
void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2)
|
|
|
|
{
|
|
|
|
SpaceLink *sl;
|
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(lb1); /* to be sure */
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (sl = lb2->first; sl; sl = sl->next) {
|
|
|
|
SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
|
2008-01-07 18:03:41 +00: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);
|
2008-12-14 17:25:46 +00:00
|
|
|
|
|
|
|
BLI_addtail(lb1, slnew);
|
|
|
|
|
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 */
|
|
|
|
void BKE_spacedata_draw_locks(int set)
|
|
|
|
{
|
|
|
|
SpaceType *st;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (st = spacetypes.first; st; st = st->next) {
|
2011-03-25 17:11:32 +00:00
|
|
|
ARegionType *art;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (art = st->regiontypes.first; art; art = art->next) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (set)
|
2012-05-06 15:15:33 +00:00
|
|
|
art->do_lock = art->lock;
|
2011-03-25 17:11:32 +00:00
|
|
|
else
|
2014-04-01 11:34:00 +11:00
|
|
|
art->do_lock = false;
|
2011-03-25 17:11:32 +00: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
|
|
|
static void (*spacedata_id_remap_cb)(struct ScrArea *sa, struct SpaceLink *sl, ID *old_id, ID *new_id) = NULL;
|
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
|
|
|
void BKE_spacedata_callback_id_remap_set(void (*func)(ScrArea *sa, 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!!! */
|
|
|
|
void BKE_spacedata_id_unref(struct ScrArea *sa, 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) {
|
|
|
|
spacedata_id_remap_cb(sa, sl, id, NULL);
|
2015-05-04 15:07:24 +10:00
|
|
|
}
|
|
|
|
}
|
2011-03-25 17:11:32 +00:00
|
|
|
|
2016-10-07 16:34:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Avoid bad-level calls to #WM_manipulatormap_delete.
|
|
|
|
*/
|
|
|
|
static void (*region_free_manipulatormap_callback)(struct wmManipulatorMap *) = NULL;
|
|
|
|
|
|
|
|
void BKE_region_callback_free_manipulatormap_set(void (*callback)(struct wmManipulatorMap *))
|
|
|
|
{
|
|
|
|
region_free_manipulatormap_callback = callback;
|
|
|
|
}
|
|
|
|
|
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 */
|
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
|
|
|
void BKE_area_region_free(SpaceType *st, ARegion *ar)
|
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
|
|
|
{
|
2013-08-27 15:27:41 +00:00
|
|
|
uiList *uilst;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (st) {
|
2012-05-06 15:15:33 +00:00
|
|
|
ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
|
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
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (art && art->free)
|
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
|
|
|
art->free(ar);
|
2009-01-25 20:22:05 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ar->regiondata)
|
2009-01-25 20:22:05 +00:00
|
|
|
printf("regiondata free error\n");
|
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
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (ar->type && ar->type->free)
|
2009-01-23 20:36:47 +00:00
|
|
|
ar->type->free(ar);
|
2009-07-29 22:57:53 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ar->v2d.tab_offset) {
|
2009-07-29 22:57:53 +00:00
|
|
|
MEM_freeN(ar->v2d.tab_offset);
|
2012-05-06 15:15:33 +00:00
|
|
|
ar->v2d.tab_offset = NULL;
|
2009-07-29 22:57:53 +00:00
|
|
|
}
|
2009-01-23 20:36:47 +00:00
|
|
|
|
2015-09-19 17:38:36 +10:00
|
|
|
if (!BLI_listbase_is_empty(&ar->panels)) {
|
|
|
|
Panel *pa, *pa_next;
|
|
|
|
for (pa = ar->panels.first; pa; pa = pa_next) {
|
|
|
|
pa_next = pa->next;
|
|
|
|
if (pa->activedata) {
|
|
|
|
MEM_freeN(pa->activedata);
|
|
|
|
}
|
|
|
|
MEM_freeN(pa);
|
|
|
|
}
|
|
|
|
}
|
2013-08-27 15:27:41 +00:00
|
|
|
|
|
|
|
for (uilst = ar->ui_lists.first; uilst; uilst = uilst->next) {
|
|
|
|
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);
|
|
|
|
MEM_freeN(uilst->properties);
|
2013-08-27 15:27:41 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-07 16:34:55 +02:00
|
|
|
|
|
|
|
region_free_manipulatormap_callback(ar->manipulator_map);
|
2012-12-28 10:36:25 +00:00
|
|
|
BLI_freelistN(&ar->ui_lists);
|
Add drag-resize to uiTemplatePreview (mat/tex/etc. preview widget).
This is done by adding a new button type, GRIP, similar to other numbuttons
(scroll, slider, ...), which here controls the preview height.
Then, we add a new DNA struct to be able to save that height in Blend files
(note I choose not to use Panel struct for this, because we would then have the
same limitation we used to have with uiLists, only one preview per panel
and no preview outside panel).
This implies a change to template_preview UI RNA/py API (each preview needs an ID),
but this is backward compatible, as by default datablock type will be used if no ID is
given (which means e.g. all material previews with no ID will have same height).
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D342
2014-04-02 12:59:48 +02:00
|
|
|
BLI_freelistN(&ar->ui_previews);
|
2013-12-17 03:21:55 +11:00
|
|
|
BLI_freelistN(&ar->panels_category);
|
|
|
|
BLI_freelistN(&ar->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 */
|
|
|
|
void BKE_screen_area_free(ScrArea *sa)
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
SpaceType *st = BKE_spacetype_from_id(sa->spacetype);
|
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
|
|
|
ARegion *ar;
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next)
|
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
|
|
|
BKE_area_region_free(st, ar);
|
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
|
|
|
|
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
|
|
|
BLI_freelistN(&sa->regionbase);
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
BKE_spacedata_freelist(&sa->spacedata);
|
|
|
|
|
2008-01-17 05:33:54 +00:00
|
|
|
BLI_freelistN(&sa->actionzones);
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
2002-11-25 12:02:15 +00: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
|
|
|
/** Free (or release) any data used by this screen (does not free the screen itself). */
|
2012-05-05 14:03:12 +00:00
|
|
|
void BKE_screen_free(bScreen *sc)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2008-12-11 23:05:18 +00:00
|
|
|
ScrArea *sa, *san;
|
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
|
|
|
ARegion *ar;
|
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
|
|
|
|
|
|
|
/* No animdata here. */
|
Lots of stuff; couldn't commit in parts because of refactor work.
* Changes in interface/ module
This commit brings back the way how buttons/menus work under control
of WM event system. The previous implementation extended usage of
handlers and operators in an interesting but confusing way. Better to
try it first according the design specs. :)
Most obviously:
- modal-handler operators are not stored anymore in regions/areas/windows.
such modal handlers own their operator, and should remove it themselves.
- removed code to move handlers from one queue to another.
(needs review with brecht!)
- WM fix: the API call to remove a modal handler got removed. This was a
dangerous thing anyway, and you should leave that to the event system.
Now, if a handler modal() call gets a cancel/finish return, it frees
itself in event system. WM_event_remove_modal_handler was a confusing
call anyway!
Todo:
- allow button-activate to refresh after using button
- re-enable arrow keys for menus
(do both after commit)
- review return values of operator callbacks in interface_ops.c
* Fixes in WM system
- Freeing areas/regions/windows, also on quit, now correctly closes
running modal handlers
- On starting a modal handler, the handler now stores previous area
and region context, so they send proper notifiers etc.
* Other fixes
- Area-split operator had bug, wrong minimal size checking. This
solves error when trying to split a very narrow area.
- removed DNA_USHORT_FIX from screen_types.h, gave warning
- operators didn't get ID name copied when activated, needed for
later re-use or saving.
2008-12-02 14:22:52 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (ar = sc->regionbase.first; ar; ar = ar->next)
|
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
|
|
|
BKE_area_region_free(NULL, ar);
|
|
|
|
|
Lots of stuff; couldn't commit in parts because of refactor work.
* Changes in interface/ module
This commit brings back the way how buttons/menus work under control
of WM event system. The previous implementation extended usage of
handlers and operators in an interesting but confusing way. Better to
try it first according the design specs. :)
Most obviously:
- modal-handler operators are not stored anymore in regions/areas/windows.
such modal handlers own their operator, and should remove it themselves.
- removed code to move handlers from one queue to another.
(needs review with brecht!)
- WM fix: the API call to remove a modal handler got removed. This was a
dangerous thing anyway, and you should leave that to the event system.
Now, if a handler modal() call gets a cancel/finish return, it frees
itself in event system. WM_event_remove_modal_handler was a confusing
call anyway!
Todo:
- allow button-activate to refresh after using button
- re-enable arrow keys for menus
(do both after commit)
- review return values of operator callbacks in interface_ops.c
* Fixes in WM system
- Freeing areas/regions/windows, also on quit, now correctly closes
running modal handlers
- On starting a modal handler, the handler now stores previous area
and region context, so they send proper notifiers etc.
* Other fixes
- Area-split operator had bug, wrong minimal size checking. This
solves error when trying to split a very narrow area.
- removed DNA_USHORT_FIX from screen_types.h, gave warning
- operators didn't get ID name copied when activated, needed for
later re-use or saving.
2008-12-02 14:22:52 +00:00
|
|
|
BLI_freelistN(&sc->regionbase);
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (sa = sc->areabase.first; sa; sa = san) {
|
|
|
|
san = sa->next;
|
2008-01-07 18:03:41 +00:00
|
|
|
BKE_screen_area_free(sa);
|
2008-12-11 23:05:18 +00:00
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_freelistN(&sc->vertbase);
|
|
|
|
BLI_freelistN(&sc->edgebase);
|
|
|
|
BLI_freelistN(&sc->areabase);
|
2016-12-01 16:43:57 +01:00
|
|
|
|
|
|
|
BKE_previewimg_free(&sc->preview);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2009-09-14 12:26:34 +00:00
|
|
|
/* for depsgraph */
|
2009-12-04 01:25:43 +00:00
|
|
|
unsigned int BKE_screen_visible_layers(bScreen *screen, Scene *scene)
|
2009-09-14 12:26:34 +00:00
|
|
|
{
|
|
|
|
ScrArea *sa;
|
2012-05-06 15:15:33 +00:00
|
|
|
unsigned int layer = 0;
|
2009-09-14 12:26:34 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (screen) {
|
2009-12-04 01:25:43 +00:00
|
|
|
/* get all used view3d layers */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (sa = screen->areabase.first; sa; sa = sa->next)
|
|
|
|
if (sa->spacetype == SPACE_VIEW3D)
|
2009-12-04 01:25:43 +00:00
|
|
|
layer |= ((View3D *)sa->spacedata.first)->lay;
|
|
|
|
}
|
2009-09-14 12:26:34 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!layer)
|
2009-12-04 01:25:43 +00:00
|
|
|
return scene->lay;
|
2009-09-14 12:26:34 +00:00
|
|
|
|
|
|
|
return layer;
|
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2010-02-07 23:39:44 +00:00
|
|
|
/* ***************** Utilities ********************** */
|
|
|
|
|
|
|
|
/* Find a region of the specified type from the given area */
|
|
|
|
ARegion *BKE_area_find_region_type(ScrArea *sa, int type)
|
|
|
|
{
|
|
|
|
if (sa) {
|
|
|
|
ARegion *ar;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
2010-02-07 23:39:44 +00:00
|
|
|
if (ar->regiontype == type)
|
|
|
|
return ar;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-04-22 19:57:18 +00:00
|
|
|
|
2013-01-30 12:22:02 +00:00
|
|
|
ARegion *BKE_area_find_region_active_win(ScrArea *sa)
|
|
|
|
{
|
|
|
|
if (sa) {
|
|
|
|
ARegion *ar = BLI_findlink(&sa->regionbase, sa->region_active_win);
|
|
|
|
if (ar && (ar->regiontype == RGN_TYPE_WINDOW)) {
|
|
|
|
return ar;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fallback to any */
|
|
|
|
return BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-04-27 18:53:45 +10:00
|
|
|
ARegion *BKE_area_find_region_xy(ScrArea *sa, const int regiontype, int x, int y)
|
|
|
|
{
|
|
|
|
ARegion *ar_found = NULL;
|
|
|
|
if (sa) {
|
|
|
|
ARegion *ar;
|
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
|
|
|
if ((regiontype == RGN_TYPE_ANY) || (ar->regiontype == regiontype)) {
|
|
|
|
if (BLI_rcti_isect_pt(&ar->winrct, x, y)) {
|
|
|
|
ar_found = ar;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ar_found;
|
|
|
|
}
|
|
|
|
|
2015-01-08 01:14:07 +11:00
|
|
|
/**
|
|
|
|
* \note, ideally we can get the area from the context,
|
|
|
|
* there are a few places however where this isn't practical.
|
|
|
|
*/
|
|
|
|
ScrArea *BKE_screen_find_area_from_space(struct bScreen *sc, SpaceLink *sl)
|
|
|
|
{
|
|
|
|
ScrArea *sa;
|
|
|
|
|
|
|
|
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
|
|
|
if (BLI_findindex(&sa->spacedata, sl) != -1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sa;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
*/
|
2012-07-26 22:47:05 +00:00
|
|
|
ScrArea *BKE_screen_find_big_area(bScreen *sc, const int spacetype, const short min)
|
2011-11-04 01:15:04 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
ScrArea *sa, *big = NULL;
|
|
|
|
int size, maxsize = 0;
|
2011-11-04 01:15:04 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
2015-01-21 13:43:46 +11:00
|
|
|
if ((spacetype == SPACE_TYPE_ANY) || (sa->spacetype == spacetype)) {
|
2011-11-04 04:27:46 +00:00
|
|
|
if (min <= sa->winx && min <= sa->winy) {
|
2012-05-06 15:15:33 +00:00
|
|
|
size = sa->winx * sa->winy;
|
2011-11-04 01:15:04 +00:00
|
|
|
if (size > maxsize) {
|
2012-05-06 15:15:33 +00:00
|
|
|
maxsize = size;
|
|
|
|
big = sa;
|
2011-11-04 01:15:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return big;
|
|
|
|
}
|
|
|
|
|
2015-01-21 13:43:46 +11:00
|
|
|
ScrArea *BKE_screen_find_area_xy(bScreen *sc, const int spacetype, int x, int y)
|
|
|
|
{
|
|
|
|
ScrArea *sa, *sa_found = NULL;
|
|
|
|
|
|
|
|
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
|
|
|
if (BLI_rcti_isect_pt(&sa->totrct, x, y)) {
|
|
|
|
if ((spacetype == SPACE_TYPE_ANY) || (sa->spacetype == spacetype)) {
|
|
|
|
sa_found = sa;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sa_found;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-02 20:45:28 +10:00
|
|
|
/**
|
|
|
|
* Utility function to get the active layer to use when adding new objects.
|
|
|
|
*/
|
|
|
|
unsigned int BKE_screen_view3d_layer_active_ex(const View3D *v3d, const Scene *scene, bool use_localvd)
|
|
|
|
{
|
|
|
|
unsigned int lay;
|
|
|
|
if ((v3d == NULL) || (v3d->scenelock && !v3d->localvd)) {
|
|
|
|
lay = scene->layact;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lay = v3d->layact;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_localvd) {
|
|
|
|
if (v3d && v3d->localvd) {
|
|
|
|
lay |= v3d->lay;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return lay;
|
|
|
|
}
|
|
|
|
unsigned int BKE_screen_view3d_layer_active(const struct View3D *v3d, const struct Scene *scene)
|
|
|
|
{
|
|
|
|
return BKE_screen_view3d_layer_active_ex(v3d, scene, true);
|
|
|
|
}
|
|
|
|
|
2015-05-13 10:56:40 +10:00
|
|
|
/**
|
|
|
|
* Accumulate all visible layers on this screen.
|
|
|
|
*/
|
|
|
|
unsigned int BKE_screen_view3d_layer_all(const bScreen *sc)
|
|
|
|
{
|
|
|
|
const ScrArea *sa;
|
|
|
|
unsigned int lay = 0;
|
|
|
|
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
|
|
|
if (sa->spacetype == SPACE_VIEW3D) {
|
|
|
|
View3D *v3d = sa->spacedata.first;
|
|
|
|
lay |= v3d->lay;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return lay;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
int bit;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (v3d->scenelock && v3d->localvd == NULL) {
|
|
|
|
v3d->lay = scene->lay;
|
|
|
|
v3d->camera = scene->camera;
|
2010-04-22 19:57:18 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (v3d->camera == NULL) {
|
2010-04-22 19:57:18 +00:00
|
|
|
ARegion *ar;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (ar = v3d->regionbase.first; ar; ar = ar->next) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ar->regiontype == RGN_TYPE_WINDOW) {
|
2012-05-06 15:15:33 +00:00
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
|
|
|
if (rv3d->persp == RV3D_CAMOB)
|
|
|
|
rv3d->persp = RV3D_PERSP;
|
2010-04-22 19:57:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((v3d->lay & v3d->layact) == 0) {
|
2012-05-06 15:15:33 +00:00
|
|
|
for (bit = 0; bit < 32; bit++) {
|
2015-03-20 15:26:47 +11:00
|
|
|
if (v3d->lay & (1u << bit)) {
|
|
|
|
v3d->layact = (1u << bit);
|
2010-04-22 19:57:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_screen_view3d_scene_sync(bScreen *sc)
|
|
|
|
{
|
|
|
|
/* are there cameras in the views that are not in the scene? */
|
|
|
|
ScrArea *sa;
|
2012-05-06 15:15:33 +00:00
|
|
|
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
2010-04-22 19:57:18 +00:00
|
|
|
SpaceLink *sl;
|
2012-05-06 15:15:33 +00:00
|
|
|
for (sl = sa->spacedata.first; sl; sl = sl->next) {
|
|
|
|
if (sl->spacetype == SPACE_VIEW3D) {
|
|
|
|
View3D *v3d = (View3D *) sl;
|
2010-04-22 19:57:18 +00:00
|
|
|
BKE_screen_view3d_sync(v3d, sc->scene);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_screen_view3d_main_sync(ListBase *screen_lb, Scene *scene)
|
|
|
|
{
|
|
|
|
bScreen *sc;
|
|
|
|
ScrArea *sa;
|
|
|
|
SpaceLink *sl;
|
|
|
|
|
|
|
|
/* from scene copy to the other views */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (sc = screen_lb->first; sc; sc = sc->id.next) {
|
|
|
|
if (sc->scene != scene)
|
2010-04-22 19:57:18 +00:00
|
|
|
continue;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (sa = sc->areabase.first; sa; sa = sa->next)
|
|
|
|
for (sl = sa->spacedata.first; sl; sl = sl->next)
|
|
|
|
if (sl->spacetype == SPACE_VIEW3D)
|
|
|
|
BKE_screen_view3d_sync((View3D *)sl, scene);
|
2010-04-22 19:57:18 +00:00
|
|
|
}
|
|
|
|
}
|
2011-03-25 17:11:32 +00:00
|
|
|
|
2013-11-25 08:37:57 +11:00
|
|
|
void BKE_screen_view3d_twmode_remove(View3D *v3d, const int i)
|
|
|
|
{
|
|
|
|
const int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
|
|
|
|
if (selected_index == i) {
|
|
|
|
v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
|
|
|
|
}
|
|
|
|
else if (selected_index > i) {
|
|
|
|
v3d->twmode--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_screen_view3d_main_twmode_remove(ListBase *screen_lb, Scene *scene, const int i)
|
|
|
|
{
|
|
|
|
bScreen *sc;
|
|
|
|
|
|
|
|
for (sc = screen_lb->first; sc; sc = sc->id.next) {
|
|
|
|
if (sc->scene == scene) {
|
|
|
|
ScrArea *sa;
|
|
|
|
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
|
|
|
SpaceLink *sl;
|
|
|
|
for (sl = sa->spacedata.first; sl; sl = sl->next) {
|
|
|
|
if (sl->spacetype == SPACE_VIEW3D) {
|
|
|
|
View3D *v3d = (View3D *)sl;
|
|
|
|
BKE_screen_view3d_twmode_remove(v3d, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
void BKE_screen_gpu_fx_validate(GPUFXSettings *fx_settings)
|
|
|
|
{
|
|
|
|
/* currently we use DOF from the camera _only_,
|
|
|
|
* so we never allocate this, only copy from the Camera */
|
|
|
|
#if 0
|
|
|
|
if ((fx_settings->dof == NULL) &&
|
|
|
|
(fx_settings->fx_flag & GPU_FX_FLAG_DOF))
|
|
|
|
{
|
|
|
|
GPUDOFSettings *fx_dof;
|
|
|
|
fx_dof = fx_settings->dof = MEM_callocN(sizeof(GPUDOFSettings), __func__);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ((fx_settings->ssao == NULL) &&
|
|
|
|
(fx_settings->fx_flag & GPU_FX_FLAG_SSAO))
|
|
|
|
{
|
|
|
|
GPUSSAOSettings *fx_ssao;
|
|
|
|
fx_ssao = fx_settings->ssao = MEM_callocN(sizeof(GPUSSAOSettings), __func__);
|
|
|
|
|
|
|
|
GPU_fx_compositor_init_ssao_settings(fx_ssao);
|
|
|
|
}
|
|
|
|
}
|