| 
									
										
										
										
											2011-02-23 10:52:22 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							| 
									
										
										
										
											2018-06-01 18:19:39 +02:00
										 |  |  |  * of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +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. | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2008 Blender Foundation. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-27 20:29:51 +00:00
										 |  |  | /** \file blender/editors/screen/screen_edit.c
 | 
					
						
							|  |  |  |  *  \ingroup edscr | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												2.5 getting-back-into-coding commit :)
- cleaned up join and split operations. Most noticable is operator callback
  design, which should make a design based on user-less exec() first, then
  wrap invoke() and modal() around it. The exec() should be callable with
  only Context and properties.
- split now works again; and inversed as previously, if you drag from a
  triangle (action zone) inside area it subdivides area as expected.
- dragging from triangle outside area, over an edge, joins areas
- split has been simplified, it had too many options... it could just work
  simpler (now)
- 'action zone' now is an operator itself, a widget sending an ACTIONZONE event,
  which can be handled by others (so other gestures can be added in action zone
  too)
Still evaluating:
- context gets set where?
- code structure confuses... what are proper functions for operators?
- what is WM... should low level screen stuff more there?
- when do you send event, notifier? 
- files grow to large, will clean
Oh yeah and docs, docs, docs. Coming! :)
											
										 
											2008-11-17 18:54:03 +00:00
										 |  |  | #include <string.h>
 | 
					
						
							| 
									
										
										
										
											2010-07-18 14:46:52 +00:00
										 |  |  | #include <math.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												2.5 getting-back-into-coding commit :)
- cleaned up join and split operations. Most noticable is operator callback
  design, which should make a design based on user-less exec() first, then
  wrap invoke() and modal() around it. The exec() should be callable with
  only Context and properties.
- split now works again; and inversed as previously, if you drag from a
  triangle (action zone) inside area it subdivides area as expected.
- dragging from triangle outside area, over an edge, joins areas
- split has been simplified, it had too many options... it could just work
  simpler (now)
- 'action zone' now is an operator itself, a widget sending an ACTIONZONE event,
  which can be handled by others (so other gestures can be added in action zone
  too)
Still evaluating:
- context gets set where?
- code structure confuses... what are proper functions for operators?
- what is WM... should low level screen stuff more there?
- when do you send event, notifier? 
- files grow to large, will clean
Oh yeah and docs, docs, docs. Coming! :)
											
										 
											2008-11-17 18:54:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | #include "MEM_guardedalloc.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-21 19:58:25 +00:00
										 |  |  | #include "DNA_scene_types.h"
 | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | #include "DNA_userdef_types.h"
 | 
					
						
							| 
									
										
											  
											
												2.5 getting-back-into-coding commit :)
- cleaned up join and split operations. Most noticable is operator callback
  design, which should make a design based on user-less exec() first, then
  wrap invoke() and modal() around it. The exec() should be callable with
  only Context and properties.
- split now works again; and inversed as previously, if you drag from a
  triangle (action zone) inside area it subdivides area as expected.
- dragging from triangle outside area, over an edge, joins areas
- split has been simplified, it had too many options... it could just work
  simpler (now)
- 'action zone' now is an operator itself, a widget sending an ACTIONZONE event,
  which can be handled by others (so other gestures can be added in action zone
  too)
Still evaluating:
- context gets set where?
- code structure confuses... what are proper functions for operators?
- what is WM... should low level screen stuff more there?
- when do you send event, notifier? 
- files grow to large, will clean
Oh yeah and docs, docs, docs. Coming! :)
											
										 
											2008-11-17 18:54:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-25 22:47:54 +00:00
										 |  |  | #include "BLI_math.h"
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | #include "BLI_blenlib.h"
 | 
					
						
							| 
									
										
										
										
											2011-01-07 18:36:47 +00:00
										 |  |  | #include "BLI_utildefines.h"
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-18 02:56:48 +00:00
										 |  |  | #include "BKE_context.h"
 | 
					
						
							| 
									
										
										
										
											2012-09-19 17:11:07 +00:00
										 |  |  | #include "BKE_depsgraph.h"
 | 
					
						
							| 
									
										
										
										
											2015-10-11 01:14:02 +02:00
										 |  |  | #include "BKE_image.h"
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | #include "BKE_global.h"
 | 
					
						
							|  |  |  | #include "BKE_library.h"
 | 
					
						
							| 
									
										
											  
											
												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
										 |  |  | #include "BKE_library_remap.h"
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | #include "BKE_main.h"
 | 
					
						
							| 
									
										
										
										
											2009-02-04 17:40:50 +00:00
										 |  |  | #include "BKE_node.h"
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | #include "BKE_screen.h"
 | 
					
						
							| 
									
										
										
										
											2009-02-04 17:40:50 +00:00
										 |  |  | #include "BKE_scene.h"
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "BIF_gl.h"
 | 
					
						
							|  |  |  | #include "BIF_glutil.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "WM_api.h"
 | 
					
						
							|  |  |  | #include "WM_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-28 13:15:29 +00:00
										 |  |  | #include "ED_object.h"
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | #include "ED_screen.h"
 | 
					
						
							| 
									
										
										
										
											2008-01-17 05:33:54 +00:00
										 |  |  | #include "ED_screen_types.h"
 | 
					
						
							| 
									
										
										
										
											2011-11-07 12:55:18 +00:00
										 |  |  | #include "ED_clip.h"
 | 
					
						
							| 
									
										
										
										
											2015-04-06 10:40:12 -03:00
										 |  |  | #include "ED_node.h"
 | 
					
						
							| 
									
										
										
										
											2011-11-11 11:42:29 +00:00
										 |  |  | #include "ED_render.h"
 | 
					
						
							| 
									
										
										
										
											2008-01-15 19:28:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-05 20:51:36 +00:00
										 |  |  | #include "UI_interface.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-24 12:43:59 +00:00
										 |  |  | /* XXX actually should be not here... solve later */ | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | #include "wm_subwindow.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | #include "screen_intern.h"  /* own module include */
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-19 17:54:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | /* ******************* screen vert, edge, area managing *********************** */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static ScrVert *screen_addvert(bScreen *sc, short x, short y) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	ScrVert *sv = MEM_callocN(sizeof(ScrVert), "addscrvert"); | 
					
						
							|  |  |  | 	sv->vec.x = x; | 
					
						
							|  |  |  | 	sv->vec.y = y; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	BLI_addtail(&sc->vertbase, sv); | 
					
						
							|  |  |  | 	return sv; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void sortscrvert(ScrVert **v1, ScrVert **v2) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	ScrVert *tmp; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	if (*v1 > *v2) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		tmp = *v1; | 
					
						
							|  |  |  | 		*v1 = *v2; | 
					
						
							|  |  |  | 		*v2 = tmp; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	ScrEdge *se = MEM_callocN(sizeof(ScrEdge), "addscredge"); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	sortscrvert(&v1, &v2); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	se->v1 = v1; | 
					
						
							|  |  |  | 	se->v2 = v2; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	BLI_addtail(&sc->edgebase, se); | 
					
						
							|  |  |  | 	return se; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2) | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	ScrEdge *se; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	sortscrvert(&v1, &v2); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (se = sc->edgebase.first; se; se = se->next) | 
					
						
							|  |  |  | 		if (se->v1 == v1 && se->v2 == v2) | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 			return se; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	return NULL; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | void removedouble_scrverts(bScreen *sc) | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	ScrVert *v1, *verg; | 
					
						
							|  |  |  | 	ScrEdge *se; | 
					
						
							|  |  |  | 	ScrArea *sa; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	verg = sc->vertbase.first; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	while (verg) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		if (verg->newv == NULL) { /* !!! */ | 
					
						
							|  |  |  | 			v1 = verg->next; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			while (v1) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 				if (v1->newv == NULL) {   /* !?! */ | 
					
						
							|  |  |  | 					if (v1->vec.x == verg->vec.x && v1->vec.y == verg->vec.y) { | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 						/* printf("doublevert\n"); */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 						v1->newv = verg; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 				v1 = v1->next; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		verg = verg->next; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* replace pointers in edges and faces */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	se = sc->edgebase.first; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	while (se) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		if (se->v1->newv) se->v1 = se->v1->newv; | 
					
						
							|  |  |  | 		if (se->v2->newv) se->v2 = se->v2->newv; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 		/* edges changed: so.... */ | 
					
						
							|  |  |  | 		sortscrvert(&(se->v1), &(se->v2)); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		se = se->next; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	sa = sc->areabase.first; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	while (sa) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		if (sa->v1->newv) sa->v1 = sa->v1->newv; | 
					
						
							|  |  |  | 		if (sa->v2->newv) sa->v2 = sa->v2->newv; | 
					
						
							|  |  |  | 		if (sa->v3->newv) sa->v3 = sa->v3->newv; | 
					
						
							|  |  |  | 		if (sa->v4->newv) sa->v4 = sa->v4->newv; | 
					
						
							|  |  |  | 		sa = sa->next; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* remove */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	verg = sc->vertbase.first; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	while (verg) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		v1 = verg->next; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (verg->newv) { | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 			BLI_remlink(&sc->vertbase, verg); | 
					
						
							|  |  |  | 			MEM_freeN(verg); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		verg = v1; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | void removenotused_scrverts(bScreen *sc) | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	ScrVert *sv, *svn; | 
					
						
							|  |  |  | 	ScrEdge *se; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	/* we assume edges are ok */ | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	se = sc->edgebase.first; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	while (se) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		se->v1->flag = 1; | 
					
						
							|  |  |  | 		se->v2->flag = 1; | 
					
						
							|  |  |  | 		se = se->next; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	sv = sc->vertbase.first; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	while (sv) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		svn = sv->next; | 
					
						
							|  |  |  | 		if (sv->flag == 0) { | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 			BLI_remlink(&sc->vertbase, sv); | 
					
						
							|  |  |  | 			MEM_freeN(sv); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-03-09 03:46:30 +00:00
										 |  |  | 		else { | 
					
						
							|  |  |  | 			sv->flag = 0; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sv = svn; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | void removedouble_scredges(bScreen *sc) | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	ScrEdge *verg, *se, *sn; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	/* compare */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	verg = sc->edgebase.first; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	while (verg) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		se = verg->next; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		while (se) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			sn = se->next; | 
					
						
							|  |  |  | 			if (verg->v1 == se->v1 && verg->v2 == se->v2) { | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 				BLI_remlink(&sc->edgebase, se); | 
					
						
							|  |  |  | 				MEM_freeN(se); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			se = sn; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		verg = verg->next; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | void removenotused_scredges(bScreen *sc) | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	ScrEdge *se, *sen; | 
					
						
							|  |  |  | 	ScrArea *sa; | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	int a = 0; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	/* sets flags when edge is used in area */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	sa = sc->areabase.first; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	while (sa) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		se = screen_findedge(sc, sa->v1, sa->v2); | 
					
						
							|  |  |  | 		if (se == NULL) printf("error: area %d edge 1 doesn't exist\n", a); | 
					
						
							|  |  |  | 		else se->flag = 1; | 
					
						
							|  |  |  | 		se = screen_findedge(sc, sa->v2, sa->v3); | 
					
						
							|  |  |  | 		if (se == NULL) printf("error: area %d edge 2 doesn't exist\n", a); | 
					
						
							|  |  |  | 		else se->flag = 1; | 
					
						
							|  |  |  | 		se = screen_findedge(sc, sa->v3, sa->v4); | 
					
						
							|  |  |  | 		if (se == NULL) printf("error: area %d edge 3 doesn't exist\n", a); | 
					
						
							|  |  |  | 		else se->flag = 1; | 
					
						
							|  |  |  | 		se = screen_findedge(sc, sa->v4, sa->v1); | 
					
						
							|  |  |  | 		if (se == NULL) printf("error: area %d edge 4 doesn't exist\n", a); | 
					
						
							|  |  |  | 		else se->flag = 1; | 
					
						
							|  |  |  | 		sa = sa->next; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 		a++; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	se = sc->edgebase.first; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	while (se) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sen = se->next; | 
					
						
							|  |  |  | 		if (se->flag == 0) { | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 			BLI_remlink(&sc->edgebase, se); | 
					
						
							|  |  |  | 			MEM_freeN(se); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-03-09 03:46:30 +00:00
										 |  |  | 		else { | 
					
						
							|  |  |  | 			se->flag = 0; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		se = sen; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-03 18:55:59 +11:00
										 |  |  | bool scredge_is_horizontal(ScrEdge *se) | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	return (se->v1->vec.y == se->v2->vec.y); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-25 13:40:58 +01:00
										 |  |  | /* need win size to make sure not to include edges along screen edge */ | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | ScrEdge *screen_find_active_scredge(bScreen *sc, | 
					
						
							|  |  |  |                                     const int winsize_x, const int winsize_y, | 
					
						
							|  |  |  |                                     const int mx, const int my) | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	ScrEdge *se; | 
					
						
							| 
									
										
										
										
											2012-12-13 01:00:21 +00:00
										 |  |  | 	int safety = U.widget_unit / 10; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
  Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
  This allows keeping UI and data without actual saves, until you actually save.
  When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). 
  Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. 
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
  Old option is called "Save Startup File" the new one "Save User Settings".
  To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
  This also fixes "Continuous Grab" for OSX. (error since 2009)
											
										 
											2012-12-12 18:58:11 +00:00
										 |  |  | 	if (safety < 2) safety = 2; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (se = sc->edgebase.first; se; se = se->next) { | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | 		if (scredge_is_horizontal(se)) { | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 			if (se->v1->vec.y > 0 && se->v1->vec.y < winsize_y - 1) { | 
					
						
							| 
									
										
										
										
											2013-11-25 13:40:58 +01:00
										 |  |  | 				short min, max; | 
					
						
							|  |  |  | 				min = MIN2(se->v1->vec.x, se->v2->vec.x); | 
					
						
							|  |  |  | 				max = MAX2(se->v1->vec.x, se->v2->vec.x); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-25 13:40:58 +01:00
										 |  |  | 				if (abs(my - se->v1->vec.y) <= safety && mx >= min && mx <= max) | 
					
						
							|  |  |  | 					return se; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2012-10-21 05:46:41 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 			if (se->v1->vec.x > 0 && se->v1->vec.x < winsize_x - 1) { | 
					
						
							| 
									
										
										
										
											2013-11-25 13:40:58 +01:00
										 |  |  | 				short min, max; | 
					
						
							|  |  |  | 				min = MIN2(se->v1->vec.y, se->v2->vec.y); | 
					
						
							|  |  |  | 				max = MAX2(se->v1->vec.y, se->v2->vec.y); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-25 13:40:58 +01:00
										 |  |  | 				if (abs(mx - se->v1->vec.x) <= safety && my >= min && my <= max) | 
					
						
							|  |  |  | 					return se; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | 	return NULL; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-18 13:51:02 +00:00
										 |  |  | /* adds no space data */ | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | static ScrArea *screen_addarea(bScreen *sc, ScrVert *v1, ScrVert *v2, ScrVert *v3, ScrVert *v4, short headertype, short spacetype) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	ScrArea *sa = MEM_callocN(sizeof(ScrArea), "addscrarea"); | 
					
						
							|  |  |  | 	sa->v1 = v1; | 
					
						
							|  |  |  | 	sa->v2 = v2; | 
					
						
							|  |  |  | 	sa->v3 = v3; | 
					
						
							|  |  |  | 	sa->v4 = v4; | 
					
						
							|  |  |  | 	sa->headertype = headertype; | 
					
						
							|  |  |  | 	sa->spacetype = sa->butspacetype = spacetype; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	BLI_addtail(&sc->areabase, sa); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	return sa; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-14 17:48:52 +00:00
										 |  |  | static void screen_delarea(bContext *C, bScreen *sc, ScrArea *sa) | 
					
						
							| 
									
										
											  
											
												
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
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-14 17:48:52 +00:00
										 |  |  | 	ED_area_exit(C, sa); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-14 20:46:42 +00:00
										 |  |  | 	BKE_screen_area_free(sa); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-14 20:46:42 +00:00
										 |  |  | 	BLI_remlink(&sc->areabase, sa); | 
					
						
							|  |  |  | 	MEM_freeN(sa); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | /* return 0: no split possible */ | 
					
						
							|  |  |  | /* else return (integer) screencoordinate split point */ | 
					
						
							| 
									
										
										
										
											2010-10-14 12:24:08 +00:00
										 |  |  | static short testsplitpoint(ScrArea *sa, char dir, float fac) | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	short x, y; | 
					
						
							| 
									
										
										
										
											2013-09-04 03:52:25 +00:00
										 |  |  | 	const short area_min_x = AREAMINX; | 
					
						
							|  |  |  | 	const short area_min_y = ED_area_headersize(); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 	// area big enough?
 | 
					
						
							| 
									
										
										
										
											2013-09-04 03:52:25 +00:00
										 |  |  | 	if (dir == 'v' && (sa->v4->vec.x - sa->v1->vec.x <= 2 * area_min_x)) return 0; | 
					
						
							|  |  |  | 	if (dir == 'h' && (sa->v2->vec.y - sa->v1->vec.y <= 2 * area_min_y)) return 0; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 	// to be sure
 | 
					
						
							| 
									
										
										
										
											2011-03-27 17:22:04 +00:00
										 |  |  | 	CLAMP(fac, 0.0f, 1.0f); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	if (dir == 'h') { | 
					
						
							|  |  |  | 		y = sa->v1->vec.y + fac * (sa->v2->vec.y - sa->v1->vec.y); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-04 03:52:25 +00:00
										 |  |  | 		if (y - sa->v1->vec.y < area_min_y) | 
					
						
							|  |  |  | 			y = sa->v1->vec.y + area_min_y; | 
					
						
							|  |  |  | 		else if (sa->v2->vec.y - y < area_min_y) | 
					
						
							|  |  |  | 			y = sa->v2->vec.y - area_min_y; | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		else y -= (y % AREAGRID); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 		return y; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		x = sa->v1->vec.x + fac * (sa->v4->vec.x - sa->v1->vec.x); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-04 03:52:25 +00:00
										 |  |  | 		if (x - sa->v1->vec.x < area_min_x) | 
					
						
							|  |  |  | 			x = sa->v1->vec.x + area_min_x; | 
					
						
							|  |  |  | 		else if (sa->v4->vec.x - x < area_min_x) | 
					
						
							|  |  |  | 			x = sa->v4->vec.x - area_min_x; | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		else x -= (x % AREAGRID); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 		return x; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-31 17:28:03 +00:00
										 |  |  | ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	ScrArea *newa = NULL; | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 	ScrVert *sv1, *sv2; | 
					
						
							|  |  |  | 	short split; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	if (sa == NULL) return NULL; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	split = testsplitpoint(sa, dir, fac); | 
					
						
							|  |  |  | 	if (split == 0) return NULL; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-04 21:23:32 +00:00
										 |  |  | 	/* note regarding (fac > 0.5f) checks below.
 | 
					
						
							| 
									
										
										
										
											2014-07-21 10:53:07 +10:00
										 |  |  | 	 * normally it shouldn't matter which is used since the copy should match the original | 
					
						
							| 
									
										
										
										
											2013-06-04 21:23:32 +00:00
										 |  |  | 	 * however with viewport rendering and python console this isn't the case. - campbell */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	if (dir == 'h') { | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 		/* new vertices */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sv1 = screen_addvert(sc, sa->v1->vec.x, split); | 
					
						
							|  |  |  | 		sv2 = screen_addvert(sc, sa->v4->vec.x, split); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 		/* new edges */ | 
					
						
							|  |  |  | 		screen_addedge(sc, sa->v1, sv1); | 
					
						
							|  |  |  | 		screen_addedge(sc, sv1, sa->v2); | 
					
						
							|  |  |  | 		screen_addedge(sc, sa->v3, sv2); | 
					
						
							|  |  |  | 		screen_addedge(sc, sv2, sa->v4); | 
					
						
							|  |  |  | 		screen_addedge(sc, sv1, sv2); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-04 21:23:32 +00:00
										 |  |  | 		if (fac > 0.5f) { | 
					
						
							|  |  |  | 			/* new areas: top */ | 
					
						
							|  |  |  | 			newa = screen_addarea(sc, sv1, sa->v2, sa->v3, sv2, sa->headertype, sa->spacetype); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* area below */ | 
					
						
							|  |  |  | 			sa->v2 = sv1; | 
					
						
							|  |  |  | 			sa->v3 = sv2; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			/* new areas: bottom */ | 
					
						
							|  |  |  | 			newa = screen_addarea(sc, sa->v1, sv1, sv2, sa->v4, sa->headertype, sa->spacetype); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* area above */ | 
					
						
							|  |  |  | 			sa->v1 = sv1; | 
					
						
							|  |  |  | 			sa->v4 = sv2; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-11 17:16:51 +10:00
										 |  |  | 		ED_area_data_copy(newa, sa, true); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		/* new vertices */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sv1 = screen_addvert(sc, split, sa->v1->vec.y); | 
					
						
							|  |  |  | 		sv2 = screen_addvert(sc, split, sa->v2->vec.y); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 		/* new edges */ | 
					
						
							|  |  |  | 		screen_addedge(sc, sa->v1, sv1); | 
					
						
							|  |  |  | 		screen_addedge(sc, sv1, sa->v4); | 
					
						
							|  |  |  | 		screen_addedge(sc, sa->v2, sv2); | 
					
						
							|  |  |  | 		screen_addedge(sc, sv2, sa->v3); | 
					
						
							|  |  |  | 		screen_addedge(sc, sv1, sv2); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-04 21:23:32 +00:00
										 |  |  | 		if (fac > 0.5f) { | 
					
						
							|  |  |  | 			/* new areas: right */ | 
					
						
							|  |  |  | 			newa = screen_addarea(sc, sv1, sv2, sa->v3, sa->v4, sa->headertype, sa->spacetype); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* area left */ | 
					
						
							|  |  |  | 			sa->v3 = sv2; | 
					
						
							|  |  |  | 			sa->v4 = sv1; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			/* new areas: left */ | 
					
						
							|  |  |  | 			newa = screen_addarea(sc, sa->v1, sa->v2, sv2, sv1, sa->headertype, sa->spacetype); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* area right */ | 
					
						
							|  |  |  | 			sa->v1 = sv1; | 
					
						
							|  |  |  | 			sa->v2 = sv2; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-11 17:16:51 +10:00
										 |  |  | 		ED_area_data_copy(newa, sa, true); | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 	/* remove double vertices en edges */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (merge) | 
					
						
							| 
									
										
										
										
											2011-01-31 17:28:03 +00:00
										 |  |  | 		removedouble_scrverts(sc); | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 	removedouble_scredges(sc); | 
					
						
							|  |  |  | 	removenotused_scredges(sc); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 	return newa; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2008-06-19 19:09:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-18 13:51:02 +00:00
										 |  |  | /* empty screen, with 1 dummy area without spacedata */ | 
					
						
							|  |  |  | /* uses window size */ | 
					
						
							| 
									
										
										
										
											2018-06-06 15:50:24 +02:00
										 |  |  | bScreen *ED_screen_add(Main *bmain, wmWindow *win, Scene *scene, const char *name) | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 	const int winsize_x = WM_window_pixels_x(win); | 
					
						
							|  |  |  | 	const int winsize_y = WM_window_pixels_y(win); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	bScreen *sc; | 
					
						
							|  |  |  | 	ScrVert *sv1, *sv2, *sv3, *sv4; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-06 15:50:24 +02:00
										 |  |  | 	sc = BKE_libblock_alloc(bmain, ID_SCR, name, 0); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	sc->scene = scene; | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 	sc->do_refresh = true; | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN; | 
					
						
							|  |  |  | 	sc->winid = win->winid; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	sv1 = screen_addvert(sc, 0, 0); | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 	sv2 = screen_addvert(sc, 0, winsize_y - 1); | 
					
						
							|  |  |  | 	sv3 = screen_addvert(sc, winsize_x - 1, winsize_y - 1); | 
					
						
							|  |  |  | 	sv4 = screen_addvert(sc, winsize_x - 1, 0); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	screen_addedge(sc, sv1, sv2); | 
					
						
							|  |  |  | 	screen_addedge(sc, sv2, sv3); | 
					
						
							|  |  |  | 	screen_addedge(sc, sv3, sv4); | 
					
						
							|  |  |  | 	screen_addedge(sc, sv4, sv1); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-18 13:51:02 +00:00
										 |  |  | 	/* dummy type, no spacedata */ | 
					
						
							| 
									
										
										
										
											2008-12-17 19:40:19 +00:00
										 |  |  | 	screen_addarea(sc, sv1, sv2, sv3, sv4, HEADERDOWN, SPACE_EMPTY); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	return sc; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void screen_copy(bScreen *to, bScreen *from) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	ScrVert *s1, *s2; | 
					
						
							|  |  |  | 	ScrEdge *se; | 
					
						
							|  |  |  | 	ScrArea *sa, *saf; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	/* free contents of 'to', is from blenkernel screen.c */ | 
					
						
							| 
									
										
										
										
											2012-05-05 14:03:12 +00:00
										 |  |  | 	BKE_screen_free(to); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	BLI_duplicatelist(&to->vertbase, &from->vertbase); | 
					
						
							|  |  |  | 	BLI_duplicatelist(&to->edgebase, &from->edgebase); | 
					
						
							|  |  |  | 	BLI_duplicatelist(&to->areabase, &from->areabase); | 
					
						
							| 
									
										
										
										
											2014-02-08 06:07:10 +11:00
										 |  |  | 	BLI_listbase_clear(&to->regionbase); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	s2 = to->vertbase.first; | 
					
						
							|  |  |  | 	for (s1 = from->vertbase.first; s1; s1 = s1->next, s2 = s2->next) { | 
					
						
							|  |  |  | 		s1->newv = s2; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (se = to->edgebase.first; se; se = se->next) { | 
					
						
							|  |  |  | 		se->v1 = se->v1->newv; | 
					
						
							|  |  |  | 		se->v2 = se->v2->newv; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 		sortscrvert(&(se->v1), &(se->v2)); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	saf = from->areabase.first; | 
					
						
							|  |  |  | 	for (sa = to->areabase.first; sa; sa = sa->next, saf = saf->next) { | 
					
						
							|  |  |  | 		sa->v1 = sa->v1->newv; | 
					
						
							|  |  |  | 		sa->v2 = sa->v2->newv; | 
					
						
							|  |  |  | 		sa->v3 = sa->v3->newv; | 
					
						
							|  |  |  | 		sa->v4 = sa->v4->newv; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-08 06:07:10 +11:00
										 |  |  | 		BLI_listbase_clear(&sa->spacedata); | 
					
						
							|  |  |  | 		BLI_listbase_clear(&sa->regionbase); | 
					
						
							|  |  |  | 		BLI_listbase_clear(&sa->actionzones); | 
					
						
							|  |  |  | 		BLI_listbase_clear(&sa->handlers); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-11 17:16:51 +10:00
										 |  |  | 		ED_area_data_copy(sa, saf, true); | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	/* put at zero (needed?) */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (s1 = from->vertbase.first; s1; s1 = s1->next) | 
					
						
							|  |  |  | 		s1->newv = NULL; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-14 20:46:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* with sa as center, sb is located at: 0=W, 1=N, 2=E, 3=S */ | 
					
						
							|  |  |  | /* -1 = not valid check */ | 
					
						
							| 
									
										
											  
											
												2.5 getting-back-into-coding commit :)
- cleaned up join and split operations. Most noticable is operator callback
  design, which should make a design based on user-less exec() first, then
  wrap invoke() and modal() around it. The exec() should be callable with
  only Context and properties.
- split now works again; and inversed as previously, if you drag from a
  triangle (action zone) inside area it subdivides area as expected.
- dragging from triangle outside area, over an edge, joins areas
- split has been simplified, it had too many options... it could just work
  simpler (now)
- 'action zone' now is an operator itself, a widget sending an ACTIONZONE event,
  which can be handled by others (so other gestures can be added in action zone
  too)
Still evaluating:
- context gets set where?
- code structure confuses... what are proper functions for operators?
- what is WM... should low level screen stuff more there?
- when do you send event, notifier? 
- files grow to large, will clean
Oh yeah and docs, docs, docs. Coming! :)
											
										 
											2008-11-17 18:54:03 +00:00
										 |  |  | /* used with join operator */ | 
					
						
							| 
									
										
										
										
											2010-10-14 12:24:08 +00:00
										 |  |  | int area_getorientation(ScrArea *sa, ScrArea *sb) | 
					
						
							| 
									
										
										
										
											2008-01-14 20:46:42 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2008-01-15 19:28:57 +00:00
										 |  |  | 	ScrVert *sav1, *sav2, *sav3, *sav4; | 
					
						
							|  |  |  | 	ScrVert *sbv1, *sbv2, *sbv3, *sbv4; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	if (sa == NULL || sb == NULL) return -1; | 
					
						
							| 
									
										
										
										
											2008-01-15 19:28:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	sav1 = sa->v1; | 
					
						
							|  |  |  | 	sav2 = sa->v2; | 
					
						
							|  |  |  | 	sav3 = sa->v3; | 
					
						
							|  |  |  | 	sav4 = sa->v4; | 
					
						
							|  |  |  | 	sbv1 = sb->v1; | 
					
						
							|  |  |  | 	sbv2 = sb->v2; | 
					
						
							|  |  |  | 	sbv3 = sb->v3; | 
					
						
							|  |  |  | 	sbv4 = sb->v4; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	if (sav1 == sbv4 && sav2 == sbv3) { /* sa to right of sb = W */ | 
					
						
							| 
									
										
										
										
											2008-01-14 20:46:42 +00:00
										 |  |  | 		return 0; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	else if (sav2 == sbv1 && sav3 == sbv4) { /* sa to bottom of sb = N */ | 
					
						
							| 
									
										
										
										
											2008-01-14 20:46:42 +00:00
										 |  |  | 		return 1; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	else if (sav3 == sbv2 && sav4 == sbv1) { /* sa to left of sb = E */ | 
					
						
							| 
									
										
										
										
											2008-01-14 20:46:42 +00:00
										 |  |  | 		return 2; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	else if (sav1 == sbv2 && sav4 == sbv3) { /* sa on top of sb = S*/ | 
					
						
							| 
									
										
										
										
											2008-01-14 20:46:42 +00:00
										 |  |  | 		return 3; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-14 20:46:42 +00:00
										 |  |  | 	return -1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | /* Helper function to join 2 areas, it has a return value, 0=failed 1=success
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  |  *  used by the split, join operators | 
					
						
							| 
									
										
										
										
											2012-03-03 16:31:46 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2) | 
					
						
							| 
									
										
										
										
											2008-01-14 20:46:42 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 	int dir; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-14 12:24:08 +00:00
										 |  |  | 	dir = area_getorientation(sa1, sa2); | 
					
						
							| 
									
										
										
										
											2012-03-31 00:59:17 +00:00
										 |  |  | 	/*printf("dir is : %i\n", dir);*/ | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-03 18:59:36 +11:00
										 |  |  | 	if (dir == -1) { | 
					
						
							| 
									
										
										
										
											2008-06-19 19:09:21 +00:00
										 |  |  | 		return 0; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (dir == 0) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sa1->v1 = sa2->v1; | 
					
						
							|  |  |  | 		sa1->v2 = sa2->v2; | 
					
						
							| 
									
										
										
										
											2008-06-19 19:09:21 +00:00
										 |  |  | 		screen_addedge(scr, sa1->v2, sa1->v3); | 
					
						
							|  |  |  | 		screen_addedge(scr, sa1->v1, sa1->v4); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	else if (dir == 1) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sa1->v2 = sa2->v2; | 
					
						
							|  |  |  | 		sa1->v3 = sa2->v3; | 
					
						
							| 
									
										
										
										
											2008-06-19 19:09:21 +00:00
										 |  |  | 		screen_addedge(scr, sa1->v1, sa1->v2); | 
					
						
							|  |  |  | 		screen_addedge(scr, sa1->v3, sa1->v4); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	else if (dir == 2) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sa1->v3 = sa2->v3; | 
					
						
							|  |  |  | 		sa1->v4 = sa2->v4; | 
					
						
							| 
									
										
										
										
											2008-06-19 19:09:21 +00:00
										 |  |  | 		screen_addedge(scr, sa1->v2, sa1->v3); | 
					
						
							|  |  |  | 		screen_addedge(scr, sa1->v1, sa1->v4); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	else if (dir == 3) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sa1->v1 = sa2->v1; | 
					
						
							|  |  |  | 		sa1->v4 = sa2->v4; | 
					
						
							| 
									
										
										
										
											2008-06-19 19:09:21 +00:00
										 |  |  | 		screen_addedge(scr, sa1->v1, sa1->v2); | 
					
						
							|  |  |  | 		screen_addedge(scr, sa1->v3, sa1->v4); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-14 17:48:52 +00:00
										 |  |  | 	screen_delarea(C, scr, sa2); | 
					
						
							| 
									
										
										
										
											2008-06-19 19:09:21 +00:00
										 |  |  | 	removedouble_scrverts(scr); | 
					
						
							| 
									
										
										
										
											2018-01-19 17:14:27 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-19 19:09:21 +00:00
										 |  |  | 	return 1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-14 10:52:48 +00:00
										 |  |  | void select_connected_scredge(bScreen *sc, ScrEdge *edge) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	ScrEdge *se; | 
					
						
							|  |  |  | 	ScrVert *sv; | 
					
						
							|  |  |  | 	int oneselected; | 
					
						
							|  |  |  | 	char dir; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-14 10:52:48 +00:00
										 |  |  | 	/* select connected, only in the right direction */ | 
					
						
							|  |  |  | 	/* 'dir' is the direction of EDGE */ | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	if (edge->v1->vec.x == edge->v2->vec.x) dir = 'v'; | 
					
						
							|  |  |  | 	else dir = 'h'; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	sv = sc->vertbase.first; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	while (sv) { | 
					
						
							| 
									
										
										
										
											2008-12-14 10:52:48 +00:00
										 |  |  | 		sv->flag = 0; | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sv = sv->next; | 
					
						
							| 
									
										
										
										
											2008-12-14 10:52:48 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	edge->v1->flag = 1; | 
					
						
							|  |  |  | 	edge->v2->flag = 1; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	oneselected = 1; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	while (oneselected) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		se = sc->edgebase.first; | 
					
						
							|  |  |  | 		oneselected = 0; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		while (se) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			if (se->v1->flag + se->v2->flag == 1) { | 
					
						
							|  |  |  | 				if (dir == 'h') { | 
					
						
							|  |  |  | 					if (se->v1->vec.y == se->v2->vec.y) { | 
					
						
							|  |  |  | 						se->v1->flag = se->v2->flag = 1; | 
					
						
							|  |  |  | 						oneselected = 1; | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2008-12-14 10:52:48 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 				if (dir == 'v') { | 
					
						
							|  |  |  | 					if (se->v1->vec.x == se->v2->vec.x) { | 
					
						
							|  |  |  | 						se->v1->flag = se->v2->flag = 1; | 
					
						
							|  |  |  | 						oneselected = 1; | 
					
						
							| 
									
										
										
										
											2008-12-14 10:52:48 +00:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2008-12-14 10:52:48 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			se = se->next; | 
					
						
							| 
									
										
										
										
											2008-12-14 10:52:48 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* test if screen vertices should be scaled */ | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y) | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-12-10 23:54:33 +11:00
										 |  |  | 	/* clamp Y size of header sized areas when expanding windows
 | 
					
						
							|  |  |  | 	 * avoids annoying empty space around file menu */ | 
					
						
							|  |  |  | #define USE_HEADER_SIZE_CLAMP
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-10 23:52:19 +11:00
										 |  |  | 	const int headery_init = ED_area_headersize(); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	ScrVert *sv = NULL; | 
					
						
							| 
									
										
										
										
											2008-12-14 17:48:52 +00:00
										 |  |  | 	ScrArea *sa; | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 	int winsize_x_prev, winsize_y_prev; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	float facx, facy, tempf, min[2], max[2]; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	/* calculate size */ | 
					
						
							| 
									
										
											  
											
												Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
  Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
  This allows keeping UI and data without actual saves, until you actually save.
  When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). 
  Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. 
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
  Old option is called "Save Startup File" the new one "Save User Settings".
  To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
  This also fixes "Continuous Grab" for OSX. (error since 2009)
											
										 
											2012-12-12 18:58:11 +00:00
										 |  |  | 	min[0] = min[1] = 20000.0f; | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	max[0] = max[1] = 0.0f; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (sv = sc->vertbase.first; sv; sv = sv->next) { | 
					
						
							| 
									
										
										
										
											2012-10-25 22:47:54 +00:00
										 |  |  | 		const float fv[2] = {(float)sv->vec.x, (float)sv->vec.y}; | 
					
						
							|  |  |  | 		minmax_v2v2_v2(min, max, fv); | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	/* always make 0.0 left under */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (sv = sc->vertbase.first; sv; sv = sv->next) { | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 		sv->vec.x -= min[0]; | 
					
						
							|  |  |  | 		sv->vec.y -= min[1]; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 	winsize_x_prev = (max[0] - min[0]) + 1; | 
					
						
							|  |  |  | 	winsize_y_prev = (max[1] - min[1]) + 1; | 
					
						
							| 
									
										
										
										
											2013-12-10 23:54:33 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef USE_HEADER_SIZE_CLAMP
 | 
					
						
							|  |  |  | #define TEMP_BOTTOM 1
 | 
					
						
							|  |  |  | #define TEMP_TOP 2
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* if the window's Y axis grows, clamp header sized areas */ | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 	if (winsize_y_prev < winsize_y) {  /* growing? */ | 
					
						
							|  |  |  | 		const int headery_margin_max = headery_init + 4; | 
					
						
							| 
									
										
										
										
											2013-12-10 23:54:33 +11:00
										 |  |  | 		for (sa = sc->areabase.first; sa; sa = sa->next) { | 
					
						
							|  |  |  | 			ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); | 
					
						
							|  |  |  | 			sa->temp = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (ar && !(ar->flag & RGN_FLAG_HIDDEN)) { | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 				if (sa->v2->vec.y == winsize_y_prev - 1) { | 
					
						
							|  |  |  | 					if ((sa->v2->vec.y - sa->v1->vec.y) < headery_margin_max) { | 
					
						
							| 
									
										
										
										
											2013-12-10 23:54:33 +11:00
										 |  |  | 						sa->temp = TEMP_TOP; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				else if (sa->v1->vec.y == 0) { | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 					if ((sa->v2->vec.y - sa->v1->vec.y) < headery_margin_max) { | 
					
						
							| 
									
										
										
										
											2013-12-10 23:54:33 +11:00
										 |  |  | 						sa->temp = TEMP_BOTTOM; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 	if (winsize_x_prev != winsize_x || winsize_y_prev != winsize_y) { | 
					
						
							| 
									
										
										
										
											2013-12-12 19:01:44 +11:00
										 |  |  | 		facx = ((float)winsize_x - 1) / ((float)winsize_x_prev - 1); | 
					
						
							|  |  |  | 		facy = ((float)winsize_y - 1) / ((float)winsize_y_prev - 1); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 		/* make sure it fits! */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		for (sv = sc->vertbase.first; sv; sv = sv->next) { | 
					
						
							| 
									
										
										
										
											2012-03-08 04:12:11 +00:00
										 |  |  | 			/* FIXME, this re-sizing logic is no good when re-sizing the window + redrawing [#24428]
 | 
					
						
							| 
									
										
										
										
											2010-11-03 22:11:17 +00:00
										 |  |  | 			 * need some way to store these as floats internally and re-apply from there. */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			tempf = ((float)sv->vec.x) * facx; | 
					
						
							|  |  |  | 			sv->vec.x = (short)(tempf + 0.5f); | 
					
						
							| 
									
										
										
										
											2013-05-25 14:08:56 +00:00
										 |  |  | 			//sv->vec.x += AREAGRID - 1;
 | 
					
						
							|  |  |  | 			//sv->vec.x -=  (sv->vec.x % AREAGRID);
 | 
					
						
							| 
									
										
										
										
											2010-11-03 22:11:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 			CLAMP(sv->vec.x, 0, winsize_x - 1); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			tempf = ((float)sv->vec.y) * facy; | 
					
						
							|  |  |  | 			sv->vec.y = (short)(tempf + 0.5f); | 
					
						
							| 
									
										
										
										
											2013-05-25 14:08:56 +00:00
										 |  |  | 			//sv->vec.y += AREAGRID - 1;
 | 
					
						
							|  |  |  | 			//sv->vec.y -=  (sv->vec.y % AREAGRID);
 | 
					
						
							| 
									
										
										
										
											2010-11-03 22:11:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 			CLAMP(sv->vec.y, 0, winsize_y - 1); | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-12-19 16:45:47 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-12-10 23:54:33 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef USE_HEADER_SIZE_CLAMP
 | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 	if (winsize_y_prev < winsize_y) {  /* growing? */ | 
					
						
							| 
									
										
										
										
											2013-12-10 23:54:33 +11:00
										 |  |  | 		for (sa = sc->areabase.first; sa; sa = sa->next) { | 
					
						
							|  |  |  | 			ScrEdge *se = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (sa->temp == 0) | 
					
						
							|  |  |  | 				continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (sa->v1 == sa->v2) | 
					
						
							|  |  |  | 				continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* adjust headery if verts are along the edge of window */ | 
					
						
							|  |  |  | 			if (sa->temp == TEMP_TOP) { | 
					
						
							|  |  |  | 				/* lower edge */ | 
					
						
							|  |  |  | 				const int yval = sa->v2->vec.y - headery_init; | 
					
						
							|  |  |  | 				se = screen_findedge(sc, sa->v4, sa->v1); | 
					
						
							| 
									
										
										
										
											2017-05-22 12:06:38 +02:00
										 |  |  | 				if (se != NULL) { | 
					
						
							|  |  |  | 					select_connected_scredge(sc, se); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2013-12-10 23:54:33 +11:00
										 |  |  | 				for (sv = sc->vertbase.first; sv; sv = sv->next) { | 
					
						
							|  |  |  | 					if (sv != sa->v2 && sv != sa->v3) { | 
					
						
							|  |  |  | 						if (sv->flag) { | 
					
						
							|  |  |  | 							sv->vec.y = yval; | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							|  |  |  | 				/* upper edge */ | 
					
						
							|  |  |  | 				const int yval = sa->v1->vec.y + headery_init; | 
					
						
							|  |  |  | 				se = screen_findedge(sc, sa->v2, sa->v3); | 
					
						
							| 
									
										
										
										
											2017-05-22 12:06:38 +02:00
										 |  |  | 				if (se != NULL) { | 
					
						
							|  |  |  | 					select_connected_scredge(sc, se); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2013-12-10 23:54:33 +11:00
										 |  |  | 				for (sv = sc->vertbase.first; sv; sv = sv->next) { | 
					
						
							|  |  |  | 					if (sv != sa->v1 && sv != sa->v4) { | 
					
						
							|  |  |  | 						if (sv->flag) { | 
					
						
							|  |  |  | 							sv->vec.y = yval; | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | #undef USE_HEADER_SIZE_CLAMP
 | 
					
						
							| 
									
										
										
										
											2013-12-10 23:54:33 +11:00
										 |  |  | #undef TEMP_BOTTOM
 | 
					
						
							|  |  |  | #undef TEMP_TOP
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	/* test for collapsed areas. This could happen in some blender version... */ | 
					
						
							| 
									
										
										
										
											2008-12-14 17:48:52 +00:00
										 |  |  | 	/* ton: removed option now, it needs Context... */ | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
  - name "Undo History"
  - hotkey alt+ctrl+z (alt+apple+z for mac)
  - works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
  - for small windows or screens, popup menus now allow to display
    all items, using internal scrolling
  - works with a timer, scrolling 10 items per second when mouse 
    is over the top or bottom arrow
  - if menu is too big to display, it now draws to top or bottom, 
    based on largest available space.
  - also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
  - widgets & headers now become bigger and smaller, to match 
    'dpi' font sizes. Works well to match UI to monitor size.
  - note that icons can get fuzzy, we need better mipmaps for it
											
										 
											2011-06-04 17:03:46 +00:00
										 |  |  | 	/* make each window at least ED_area_headersize() high */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (sa = sc->areabase.first; sa; sa = sa->next) { | 
					
						
							| 
									
										
										
										
											2013-12-10 23:52:19 +11:00
										 |  |  | 		int headery = headery_init; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-25 13:40:58 +01:00
										 |  |  | 		/* adjust headery if verts are along the edge of window */ | 
					
						
							|  |  |  | 		if (sa->v1->vec.y > 0) | 
					
						
							|  |  |  | 			headery += U.pixelsize; | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 		if (sa->v2->vec.y < winsize_y - 1) | 
					
						
							| 
									
										
										
										
											2013-11-25 13:40:58 +01:00
										 |  |  | 			headery += U.pixelsize; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-25 13:40:58 +01:00
										 |  |  | 		if (sa->v2->vec.y - sa->v1->vec.y + 1 < headery) { | 
					
						
							| 
									
										
										
										
											2008-12-14 10:52:48 +00:00
										 |  |  | 			/* lower edge */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			ScrEdge *se = screen_findedge(sc, sa->v4, sa->v1); | 
					
						
							|  |  |  | 			if (se && sa->v1 != sa->v2) { | 
					
						
							| 
									
										
										
										
											2008-12-14 10:52:48 +00:00
										 |  |  | 				int yval; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-14 10:52:48 +00:00
										 |  |  | 				select_connected_scredge(sc, se); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-14 10:52:48 +00:00
										 |  |  | 				/* all selected vertices get the right offset */ | 
					
						
							| 
									
										
										
										
											2013-11-25 13:40:58 +01:00
										 |  |  | 				yval = sa->v2->vec.y - headery + 1; | 
					
						
							| 
									
										
										
										
											2013-12-10 23:52:19 +11:00
										 |  |  | 				for (sv = sc->vertbase.first; sv; sv = sv->next) { | 
					
						
							| 
									
										
										
										
											2008-12-14 10:52:48 +00:00
										 |  |  | 					/* if is a collapsed area */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 					if (sv != sa->v2 && sv != sa->v3) { | 
					
						
							| 
									
										
										
										
											2013-12-10 23:52:19 +11:00
										 |  |  | 						if (sv->flag) { | 
					
						
							|  |  |  | 							sv->vec.y = yval; | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2008-12-14 10:52:48 +00:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | /* ****************** EXPORTED API TO OTHER MODULES *************************** */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-06 15:50:24 +02:00
										 |  |  | bScreen *ED_screen_duplicate(Main *bmain, wmWindow *win, bScreen *sc) | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	bScreen *newsc; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 	if (sc->state != SCREENNORMAL) return NULL;  /* XXX handle this case! */ | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 	/* make new empty screen: */ | 
					
						
							| 
									
										
										
										
											2018-06-06 15:50:24 +02:00
										 |  |  | 	newsc = ED_screen_add(bmain, win, sc->scene, sc->id.name + 2); | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 	/* copy all data */ | 
					
						
							|  |  |  | 	screen_copy(newsc, sc); | 
					
						
							| 
									
										
										
										
											2009-02-07 19:37:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 	return newsc; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-04 19:17:34 +00:00
										 |  |  | /* screen sets cursor based on swinid */ | 
					
						
							| 
									
										
										
										
											2012-05-22 14:13:33 +00:00
										 |  |  | static void region_cursor_set(wmWindow *win, int swinid, int swin_changed) | 
					
						
							| 
									
										
										
										
											2009-01-04 19:17:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-04-19 16:04:44 +02:00
										 |  |  | 	for (ScrArea *sa = win->screen->areabase.first; sa; sa = sa->next) { | 
					
						
							|  |  |  | 		for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (ar->swinid == swinid) { | 
					
						
							| 
									
										
										
										
											2012-05-22 14:13:33 +00:00
										 |  |  | 				if (swin_changed || (ar->type && ar->type->event_cursor)) { | 
					
						
							| 
									
										
										
										
											2016-04-19 16:04:44 +02:00
										 |  |  | 					ED_region_cursor_set(win, sa, ar); | 
					
						
							| 
									
										
										
										
											2012-05-22 14:13:33 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2009-01-04 19:17:34 +00:00
										 |  |  | 				return; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2008-11-19 16:28:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-09 18:42:35 +00:00
										 |  |  | void ED_screen_do_listen(bContext *C, wmNotifier *note) | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	wmWindow *win = CTX_wm_window(C); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 	/* generic notes */ | 
					
						
							| 
									
										
										
										
											2012-04-28 06:31:57 +00:00
										 |  |  | 	switch (note->category) { | 
					
						
							| 
									
										
										
										
											2009-02-07 10:00:46 +00:00
										 |  |  | 		case NC_WM: | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			if (note->data == ND_FILEREAD) | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 				win->screen->do_draw = true; | 
					
						
							| 
									
										
										
										
											2009-02-07 10:00:46 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2008-12-27 16:09:56 +00:00
										 |  |  | 		case NC_WINDOW: | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 			win->screen->do_draw = true; | 
					
						
							| 
									
										
										
										
											2008-01-10 17:38:17 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2008-12-27 16:09:56 +00:00
										 |  |  | 		case NC_SCREEN: | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			if (note->action == NA_EDITED) | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 				win->screen->do_draw = win->screen->do_refresh = true; | 
					
						
							| 
									
										
										
										
											2011-03-09 18:42:35 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2009-01-04 19:17:34 +00:00
										 |  |  | 		case NC_SCENE: | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			if (note->data == ND_MODE) | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 				region_cursor_set(win, note->swinid, true); | 
					
						
							| 
									
										
										
										
											2008-01-19 17:54:05 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2008-01-10 17:38:17 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
  - name "Undo History"
  - hotkey alt+ctrl+z (alt+apple+z for mac)
  - works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
  - for small windows or screens, popup menus now allow to display
    all items, using internal scrolling
  - works with a timer, scrolling 10 items per second when mouse 
    is over the top or bottom arrow
  - if menu is too big to display, it now draws to top or bottom, 
    based on largest available space.
  - also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
  - widgets & headers now become bigger and smaller, to match 
    'dpi' font sizes. Works well to match UI to monitor size.
  - note that icons can get fuzzy, we need better mipmaps for it
											
										 
											2011-06-04 17:03:46 +00:00
										 |  |  | /* helper call for below, dpi changes headers */ | 
					
						
							|  |  |  | static void screen_refresh_headersizes(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	const ListBase *lb = BKE_spacetypes_list(); | 
					
						
							| 
									
										
										
											
												Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
  - name "Undo History"
  - hotkey alt+ctrl+z (alt+apple+z for mac)
  - works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
  - for small windows or screens, popup menus now allow to display
    all items, using internal scrolling
  - works with a timer, scrolling 10 items per second when mouse 
    is over the top or bottom arrow
  - if menu is too big to display, it now draws to top or bottom, 
    based on largest available space.
  - also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
  - widgets & headers now become bigger and smaller, to match 
    'dpi' font sizes. Works well to match UI to monitor size.
  - note that icons can get fuzzy, we need better mipmaps for it
											
										 
											2011-06-04 17:03:46 +00:00
										 |  |  | 	SpaceType *st; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (st = lb->first; st; st = st->next) { | 
					
						
							| 
									
										
										
										
											2018-06-12 17:34:44 +02:00
										 |  |  | 		ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		if (art) art->prefsizey = ED_area_headersize(); | 
					
						
							| 
									
										
										
										
											2012-10-21 05:46:41 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
											
												Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
  - name "Undo History"
  - hotkey alt+ctrl+z (alt+apple+z for mac)
  - works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
  - for small windows or screens, popup menus now allow to display
    all items, using internal scrolling
  - works with a timer, scrolling 10 items per second when mouse 
    is over the top or bottom arrow
  - if menu is too big to display, it now draws to top or bottom, 
    based on largest available space.
  - also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
  - widgets & headers now become bigger and smaller, to match 
    'dpi' font sizes. Works well to match UI to monitor size.
  - note that icons can get fuzzy, we need better mipmaps for it
											
										 
											2011-06-04 17:03:46 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | /* make this screen usable */ | 
					
						
							| 
									
										
										
										
											2008-01-10 17:38:17 +00:00
										 |  |  | /* for file read and first use, for scaling window, area moves */ | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-10-27 16:05:31 +00:00
										 |  |  | 	/* exception for bg mode, we only need the screen context */ | 
					
						
							|  |  |  | 	if (!G.background) { | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 		const int winsize_x = WM_window_pixels_x(win); | 
					
						
							|  |  |  | 		const int winsize_y = WM_window_pixels_y(win); | 
					
						
							| 
									
										
										
										
											2010-10-30 17:16:37 +00:00
										 |  |  | 		ScrArea *sa; | 
					
						
							|  |  |  | 		rcti winrct; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 02:51:46 +00:00
										 |  |  | 		winrct.xmin = 0; | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 		winrct.xmax = winsize_x - 1; | 
					
						
							| 
									
										
										
										
											2012-03-24 02:51:46 +00:00
										 |  |  | 		winrct.ymin = 0; | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 		winrct.ymax = winsize_y - 1; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
  Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
  This allows keeping UI and data without actual saves, until you actually save.
  When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). 
  Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. 
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
  Old option is called "Save Startup File" the new one "Save User Settings".
  To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
  This also fixes "Continuous Grab" for OSX. (error since 2009)
											
										 
											2012-12-12 18:58:11 +00:00
										 |  |  | 		/* header size depends on DPI, let's verify */ | 
					
						
							| 
									
										
										
										
											2017-07-08 00:44:31 +02:00
										 |  |  | 		WM_window_set_dpi(win); | 
					
						
							| 
									
										
											  
											
												Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
  Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
  This allows keeping UI and data without actual saves, until you actually save.
  When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). 
  Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. 
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
  Old option is called "Save Startup File" the new one "Save User Settings".
  To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
  This also fixes "Continuous Grab" for OSX. (error since 2009)
											
										 
											2012-12-12 18:58:11 +00:00
										 |  |  | 		screen_refresh_headersizes(); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 		screen_test_scale(win->screen, winsize_x, winsize_y); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-02 14:13:57 +11:00
										 |  |  | 		if (win->screen->mainwin == 0) { | 
					
						
							|  |  |  | 			win->screen->mainwin = wm_subwindow_open(win, &winrct, false); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			wm_subwindow_position(win, win->screen->mainwin, &winrct, false); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		for (sa = win->screen->areabase.first; sa; sa = sa->next) { | 
					
						
							| 
									
										
										
										
											2010-10-27 16:05:31 +00:00
										 |  |  | 			/* set spacetype and region callbacks, calls init() */ | 
					
						
							|  |  |  | 			/* sets subwindows for regions, adds handlers */ | 
					
						
							|  |  |  | 			ED_area_initialize(wm, win, sa); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-27 16:05:31 +00:00
										 |  |  | 		/* wake up animtimer */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (win->screen->animtimer) | 
					
						
							| 
									
										
										
										
											2013-12-05 17:26:03 +11:00
										 |  |  | 			WM_event_timer_sleep(wm, win, win->screen->animtimer, false); | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00: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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-31 00:59:17 +00:00
										 |  |  | 	if (G.debug & G_DEBUG_EVENTS) { | 
					
						
							|  |  |  | 		printf("%s: set screen\n", __func__); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 	win->screen->do_refresh = false; | 
					
						
							| 
									
										
										
										
											2008-12-23 02:07:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	win->screen->context = ed_screen_context; | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* file read, set all screens, ... */ | 
					
						
							| 
									
										
										
										
											2018-06-06 15:50:24 +02:00
										 |  |  | void ED_screens_initialize(Main *bmain, wmWindowManager *wm) | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	wmWindow *win; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (win = wm->windows.first; win; win = win->next) { | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		if (win->screen == NULL) | 
					
						
							| 
									
										
										
										
											2018-06-06 15:50:24 +02:00
										 |  |  | 			win->screen = bmain->screen.first; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 		ED_screen_refresh(wm, win); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-16 12:28:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* *********** exit calls are for closing running stuff ******** */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												
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
										 |  |  | void ED_region_exit(bContext *C, ARegion *ar) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-03-15 19:56:29 +00:00
										 |  |  | 	wmWindowManager *wm = CTX_wm_manager(C); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	ARegion *prevar = CTX_wm_region(C); | 
					
						
							| 
									
										
											  
											
												
UI: don't use operators anymore for handling user interface events, but rather
a special UI handler which makes the code clearer. This UI handler is attached
to the region along with other handlers, and also gets a callback when all
handlers for the region are removed to ensure things are properly cleaned up.
This should fix XXX's in the UI code related to events and context switching.
Most of the changes are in interface_handlers.c, which was renamed from
interface_ops.c, to convert operators to the UI handler. UI code notes:
* uiBeginBlock/uiEndBlock/uiFreeBlocks now takes a context argument, this is
  required to properly cancel things like timers or tooltips when the region
  gets removed.
* UI_add_region_handlers will add the region level UI handlers, to be used
  when adding keymap handlers etc. This replaces the UI keymap.
* When the UI code starts a modal interaction (number sliding, text editing,
  opening a menu, ..), it will add an UI handler at the window level which
  will block events.
Windowmanager changes:
* Added an UI handler next to the existing keymap and operator modal handlers.
  It has an event handling and remove callback, and like operator modal handlers
  will remember the area and region if it is registered at the window level.
* Removed the MESSAGE event.
* Operator cancel and UI handler remove callbacks now get the
  window/area/region restored in the context, like the operator modal and UI
  handler event callbacks.
* Regions now receive MOUSEMOVE events for the mouse going outside of the
  region. This was already happening for areas, but UI buttons are at the region
  level so we need it there.
Issues:
* Tooltips and menus stay open when switching to another window, and button
  highlight doesn't work without moving the mouse first when Blender starts up.
  I tried using some events like Q_FIRSTTIME, WINTHAW, but those don't seem to
  arrive..
* Timeline header buttons seem to be moving one pixel or so sometimes when
  interacting with them.
* Seems not due to this commit, but UI and keymap handlers are leaking. It
  seems that handlers are being added to regions in all screens, also in regions
  of areas that are not visible, but these handlers are not removed. Probably
  there should only be handlers in visible regions?
											
										 
											2008-12-10 04:36:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-15 19:56:29 +00:00
										 |  |  | 	if (ar->type && ar->type->exit) | 
					
						
							|  |  |  | 		ar->type->exit(wm, ar); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-18 02:56:48 +00:00
										 |  |  | 	CTX_wm_region_set(C, 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
										 |  |  | 	WM_event_remove_handlers(C, &ar->handlers); | 
					
						
							| 
									
										
										
										
											2015-11-17 10:47:37 +11:00
										 |  |  | 	if (ar->swinid) { | 
					
						
							| 
									
										
										
										
											2008-12-18 14:53:39 +00:00
										 |  |  | 		wm_subwindow_close(CTX_wm_window(C), ar->swinid); | 
					
						
							| 
									
										
										
										
											2015-11-17 10:47:37 +11:00
										 |  |  | 		ar->swinid = 0; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-17 10:47:37 +11:00
										 |  |  | 	if (ar->headerstr) { | 
					
						
							| 
									
										
										
										
											2008-12-21 17:18:36 +00:00
										 |  |  | 		MEM_freeN(ar->headerstr); | 
					
						
							| 
									
										
										
										
											2015-11-17 10:47:37 +11:00
										 |  |  | 		ar->headerstr = NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-17 10:47:37 +11:00
										 |  |  | 	if (ar->regiontimer) { | 
					
						
							| 
									
										
											  
											
												Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
  Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
  This allows keeping UI and data without actual saves, until you actually save.
  When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). 
  Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. 
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
  Old option is called "Save Startup File" the new one "Save User Settings".
  To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
  This also fixes "Continuous Grab" for OSX. (error since 2009)
											
										 
											2012-12-12 18:58:11 +00:00
										 |  |  | 		WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), ar->regiontimer); | 
					
						
							| 
									
										
										
										
											2015-11-17 10:47:37 +11:00
										 |  |  | 		ar->regiontimer = NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
											  
											
												Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
  Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
  This allows keeping UI and data without actual saves, until you actually save.
  When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). 
  Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. 
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
  Old option is called "Save Startup File" the new one "Save User Settings".
  To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
  This also fixes "Continuous Grab" for OSX. (error since 2009)
											
										 
											2012-12-12 18:58:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-18 02:56:48 +00:00
										 |  |  | 	CTX_wm_region_set(C, prevar); | 
					
						
							| 
									
										
											  
											
												
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
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ED_area_exit(bContext *C, ScrArea *sa) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-03-15 19:56:29 +00:00
										 |  |  | 	wmWindowManager *wm = CTX_wm_manager(C); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	ScrArea *prevsa = CTX_wm_area(C); | 
					
						
							| 
									
										
											  
											
												
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
										 |  |  | 	ARegion *ar; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-15 19:56:29 +00:00
										 |  |  | 	if (sa->type && sa->type->exit) | 
					
						
							|  |  |  | 		sa->type->exit(wm, sa); | 
					
						
							| 
									
										
										
										
											2010-09-17 22:12:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-18 02:56:48 +00:00
										 |  |  | 	CTX_wm_area_set(C, sa); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (ar = sa->regionbase.first; ar; ar = ar->next) | 
					
						
							| 
									
										
											  
											
												
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
										 |  |  | 		ED_region_exit(C, 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
										 |  |  | 	WM_event_remove_handlers(C, &sa->handlers); | 
					
						
							| 
									
										
										
										
											2008-12-18 02:56:48 +00:00
										 |  |  | 	CTX_wm_area_set(C, prevsa); | 
					
						
							| 
									
										
											  
											
												
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
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	wmWindowManager *wm = CTX_wm_manager(C); | 
					
						
							|  |  |  | 	wmWindow *prevwin = CTX_wm_window(C); | 
					
						
							| 
									
										
											  
											
												
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
										 |  |  | 	ScrArea *sa; | 
					
						
							|  |  |  | 	ARegion *ar; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-18 02:56:48 +00:00
										 |  |  | 	CTX_wm_window_set(C, window); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (screen->animtimer) | 
					
						
							| 
									
										
										
										
											2009-10-20 13:58:53 +00:00
										 |  |  | 		WM_event_remove_timer(wm, window, screen->animtimer); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	screen->animtimer = NULL; | 
					
						
							| 
									
										
										
										
											2015-07-29 12:52:03 +02:00
										 |  |  | 	screen->scrubbing = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (screen->mainwin) | 
					
						
							| 
									
										
										
										
											2009-02-07 19:37:29 +00:00
										 |  |  | 		wm_subwindow_close(window, screen->mainwin); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	screen->mainwin = 0; | 
					
						
							|  |  |  | 	screen->subwinactive = 0; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (ar = screen->regionbase.first; ar; ar = ar->next) | 
					
						
							| 
									
										
											  
											
												
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
										 |  |  | 		ED_region_exit(C, ar); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (sa = screen->areabase.first; sa; sa = sa->next) | 
					
						
							| 
									
										
											  
											
												
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
										 |  |  | 		ED_area_exit(C, sa); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-07 19:37:29 +00:00
										 |  |  | 	/* mark it available for use for other windows */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	screen->winid = 0; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-09 14:54:59 +00:00
										 |  |  | 	if (prevwin->screen->temp == 0) { | 
					
						
							| 
									
										
										
										
											2010-01-13 21:37:13 +00:00
										 |  |  | 		/* use previous window if possible */ | 
					
						
							|  |  |  | 		CTX_wm_window_set(C, prevwin); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2010-01-13 21:37:13 +00:00
										 |  |  | 		/* none otherwise */ | 
					
						
							|  |  |  | 		CTX_wm_window_set(C, NULL); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +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
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-31 17:11:42 +00:00
										 |  |  | /* *********************************** */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-17 15:51:32 +00:00
										 |  |  | /* case when on area-edge or in azones, or outside window */ | 
					
						
							| 
									
										
										
										
											2017-10-14 17:29:54 +11:00
										 |  |  | static void screen_cursor_set(wmWindow *win, const wmEvent *event) | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 	const int winsize_x = WM_window_pixels_x(win); | 
					
						
							|  |  |  | 	const int winsize_y = WM_window_pixels_y(win); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	AZone *az = NULL; | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | 	ScrArea *sa; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (sa = win->screen->areabase.first; sa; sa = sa->next) | 
					
						
							| 
									
										
										
										
											2012-07-11 18:17:48 +00:00
										 |  |  | 		if ((az = is_in_area_actionzone(sa, &event->x))) | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (sa) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		if (az->type == AZONE_AREA) | 
					
						
							| 
									
										
											  
											
												2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
  (not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
  buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
  definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
  hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
  cursor change shape on every edge (and block input) is probably annoying
  too... but that can be tested.
Later more!
											
										 
											2009-05-24 13:29:29 +00:00
										 |  |  | 			WM_cursor_set(win, CURSOR_EDIT); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		else if (az->type == AZONE_REGION) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT) | 
					
						
							| 
									
										
											  
											
												2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
  (not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
  buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
  definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
  hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
  cursor change shape on every edge (and block input) is probably annoying
  too... but that can be tested.
Later more!
											
										 
											2009-05-24 13:29:29 +00:00
										 |  |  | 				WM_cursor_set(win, CURSOR_X_MOVE); | 
					
						
							|  |  |  | 			else | 
					
						
							|  |  |  | 				WM_cursor_set(win, CURSOR_Y_MOVE); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2013-12-11 12:42:04 +11:00
										 |  |  | 		ScrEdge *actedge = screen_find_active_scredge(win->screen, winsize_x, winsize_y, event->x, event->y); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-17 15:51:32 +00:00
										 |  |  | 		if (actedge) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (scredge_is_horizontal(actedge)) | 
					
						
							| 
									
										
										
										
											2008-12-17 15:51:32 +00:00
										 |  |  | 				WM_cursor_set(win, CURSOR_Y_MOVE); | 
					
						
							|  |  |  | 			else | 
					
						
							|  |  |  | 				WM_cursor_set(win, CURSOR_X_MOVE); | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-06-21 13:02:48 +00:00
										 |  |  | 		else | 
					
						
							|  |  |  | 			WM_cursor_set(win, CURSOR_STD); | 
					
						
							| 
									
										
										
										
											2012-05-22 14:13:33 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 18:03:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												2.5
Vertex Paint back!
Added WM level "paint cursor" system, which manages a custom painting
cursor for tools or modes. 
- Activate it with WM_paint_cursor_activate(). That function wants two
  callbacks, a poll(C) to check whether there's a cursor in given context
  and ARegion, and a draw(C, x, y) which gets called when appropriate.
- While paintcursor is active, the WM handles necessary redrawing events
  for all regions, also to nicely clear the cursor on region exit.
- WM_paint_cursor_activate returns a handle, which you have to use to
  end the paint cursor. This handle also means you can register as many
  custom cursors as you want.
At the moment, vertex paint mode registers only a mousemove handler,
all other events are still normally handled. This is stuff for the 
future todo.
											
										 
											2009-01-09 13:55:45 +00:00
										 |  |  | /* called in wm_event_system.c. sets state vars in screen, cursors */ | 
					
						
							|  |  |  | /* event type is mouse move */ | 
					
						
							| 
									
										
										
										
											2017-10-14 17:29:54 +11:00
										 |  |  | void ED_screen_set_subwinactive(bContext *C, const wmEvent *event) | 
					
						
							| 
									
										
										
										
											2008-01-10 17:38:17 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	wmWindow *win = CTX_wm_window(C); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (win->screen) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		bScreen *scr = win->screen; | 
					
						
							| 
									
										
										
										
											2008-01-10 17:38:17 +00:00
										 |  |  | 		ScrArea *sa; | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | 		ARegion *ar; | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		int oldswin = scr->subwinactive; | 
					
						
							| 
									
										
										
										
											2008-12-15 18:43:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		for (sa = scr->areabase.first; sa; sa = sa->next) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (event->x > sa->totrct.xmin && event->x < sa->totrct.xmax) | 
					
						
							|  |  |  | 				if (event->y > sa->totrct.ymin && event->y < sa->totrct.ymax) | 
					
						
							| 
									
										
										
										
											2012-07-11 18:17:48 +00:00
										 |  |  | 					if (NULL == is_in_area_actionzone(sa, &event->x)) | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | 						break; | 
					
						
							| 
									
										
										
										
											2008-01-10 17:38:17 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (sa) { | 
					
						
							| 
									
										
										
										
											2012-12-17 09:02:43 +00:00
										 |  |  | 			/* make overlap active when mouse over */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			for (ar = sa->regionbase.first; ar; ar = ar->next) { | 
					
						
							| 
									
										
										
										
											2012-12-17 09:02:43 +00:00
										 |  |  | 				if (BLI_rcti_isect_pt_v(&ar->winrct, &event->x)) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 					scr->subwinactive = ar->swinid; | 
					
						
							| 
									
										
										
										
											2012-12-17 09:02:43 +00:00
										 |  |  | 					break; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2008-01-10 17:38:17 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			scr->subwinactive = scr->mainwin; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 17:58:18 +00:00
										 |  |  | 		/* check for redraw headers */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		if (oldswin != scr->subwinactive) { | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			for (sa = scr->areabase.first; sa; sa = sa->next) { | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 				bool do_draw = false; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 				for (ar = sa->regionbase.first; ar; ar = ar->next) | 
					
						
							|  |  |  | 					if (ar->swinid == oldswin || ar->swinid == scr->subwinactive) | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 						do_draw = true; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (do_draw) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 					for (ar = sa->regionbase.first; ar; ar = ar->next) | 
					
						
							|  |  |  | 						if (ar->regiontype == RGN_TYPE_HEADER) | 
					
						
							| 
									
										
										
										
											2008-12-16 12:28:00 +00:00
										 |  |  | 							ED_region_tag_redraw(ar); | 
					
						
							| 
									
										
										
										
											2008-12-11 14:59:57 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2008-12-10 17:58:18 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | 		/* cursors, for time being set always on edges, otherwise aregion doesnt switch */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		if (scr->subwinactive == scr->mainwin) { | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | 			screen_cursor_set(win, event); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-05-22 14:13:33 +00:00
										 |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2012-12-22 11:52:53 +00:00
										 |  |  | 			/* notifier invokes freeing the buttons... causing a bit too much redraws */ | 
					
						
							| 
									
										
										
										
											2012-05-22 14:13:33 +00:00
										 |  |  | 			if (oldswin != scr->subwinactive) { | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 				region_cursor_set(win, scr->subwinactive, true); | 
					
						
							| 
									
										
										
										
											2013-09-23 23:31:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				/* this used to be a notifier, but needs to be done immediate
 | 
					
						
							|  |  |  | 				 * because it can undo setting the right button as active due | 
					
						
							|  |  |  | 				 * to delayed notifier handling */ | 
					
						
							| 
									
										
										
										
											2014-11-09 21:20:40 +01:00
										 |  |  | 				UI_screen_free_active_but(C, win->screen); | 
					
						
							| 
									
										
										
										
											2012-05-22 14:13:33 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			else | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 				region_cursor_set(win, scr->subwinactive, false); | 
					
						
							| 
									
										
										
										
											2008-12-15 16:54:47 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-01-10 17:38:17 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 17:58:18 +00:00
										 |  |  | int ED_screen_area_active(const bContext *C) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	wmWindow *win = CTX_wm_window(C); | 
					
						
							|  |  |  | 	bScreen *sc = CTX_wm_screen(C); | 
					
						
							|  |  |  | 	ScrArea *sa = CTX_wm_area(C); | 
					
						
							| 
									
										
											  
											
												2.5: gesture code in WM
- Simplified and cleaned previous border code
  It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines, 
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example. 
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
  work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
  gestures in Blender work. These will be configurable per area-region, and WM
  then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
  to which you then can assign operators. Such events will be generated with low 
  priority, so other handlers who swallowed mouse events have preference.
											
										 
											2008-11-19 13:16:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (win && sc && sa) { | 
					
						
							| 
									
										
										
										
											2012-07-11 18:17:48 +00:00
										 |  |  | 		AZone *az = is_in_area_actionzone(sa, &win->eventstate->x); | 
					
						
							| 
									
										
										
										
											2008-12-10 17:58:18 +00:00
										 |  |  | 		ARegion *ar; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-02 05:46:05 +00:00
										 |  |  | 		if (az && az->type == AZONE_REGION) | 
					
						
							|  |  |  | 			return 1; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		for (ar = sa->regionbase.first; ar; ar = ar->next) | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (ar->swinid == sc->subwinactive) | 
					
						
							| 
									
										
										
										
											2008-12-10 17:58:18 +00:00
										 |  |  | 				return 1; | 
					
						
							| 
									
										
										
										
											2012-10-21 05:46:41 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-10 17:58:18 +00:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2008-12-17 17:33:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-26 13:49:58 +10:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * operator call, WM + Window + screen already existed before | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \warning Do NOT call in area/region queues! | 
					
						
							|  |  |  |  * \returns success. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | bool ED_screen_set(bContext *C, bScreen *sc) | 
					
						
							| 
									
										
										
										
											2008-12-17 17:33:45 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-02-05 02:28:49 +00:00
										 |  |  | 	Main *bmain = CTX_data_main(C); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	wmWindowManager *wm = CTX_wm_manager(C); | 
					
						
							|  |  |  | 	wmWindow *win = CTX_wm_window(C); | 
					
						
							|  |  |  | 	bScreen *oldscreen = CTX_wm_screen(C); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-07 19:37:29 +00:00
										 |  |  | 	/* validate screen, it's called with notifier reference */ | 
					
						
							| 
									
										
										
										
											2015-08-26 13:49:58 +10:00
										 |  |  | 	if (BLI_findindex(&bmain->screen, sc) == -1) { | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-08-08 17:05:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-26 11:27:13 +10:00
										 |  |  | 	if (ELEM(sc->state, SCREENMAXIMIZED, SCREENFULL)) { | 
					
						
							|  |  |  | 		/* find associated full */ | 
					
						
							| 
									
										
										
										
											2008-12-17 17:33:45 +00:00
										 |  |  | 		bScreen *sc1; | 
					
						
							| 
									
										
										
										
											2013-02-05 02:28:49 +00:00
										 |  |  | 		for (sc1 = bmain->screen.first; sc1; sc1 = sc1->id.next) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			ScrArea *sa = sc1->areabase.first; | 
					
						
							|  |  |  | 			if (sa->full == sc) { | 
					
						
							|  |  |  | 				sc = sc1; | 
					
						
							| 
									
										
										
										
											2008-12-17 17:33:45 +00:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-08-08 17:05:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* check for valid winid */ | 
					
						
							| 
									
										
										
										
											2015-08-26 13:49:58 +10:00
										 |  |  | 	if (sc->winid != 0 && sc->winid != win->winid) { | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-22 12:57:53 +00:00
										 |  |  | 	if (oldscreen != sc) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		wmTimer *wt = oldscreen->animtimer; | 
					
						
							| 
									
										
										
										
											2010-01-12 23:30:19 +00:00
										 |  |  | 		ScrArea *sa; | 
					
						
							| 
									
										
										
										
											2013-12-26 17:24:42 +06:00
										 |  |  | 		Scene *oldscene = oldscreen->scene; | 
					
						
							| 
									
										
										
										
											2010-01-12 23:30:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* remove handlers referencing areas in old screen */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		for (sa = oldscreen->areabase.first; sa; sa = sa->next) { | 
					
						
							| 
									
										
										
										
											2010-01-12 23:30:19 +00:00
										 |  |  | 			WM_event_remove_area_handler(&win->modalhandlers, sa); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-22 12:57:53 +00:00
										 |  |  | 		/* we put timer to sleep, so screen_exit has to think there's no timer */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		oldscreen->animtimer = NULL; | 
					
						
							| 
									
										
										
										
											2014-03-21 15:15:24 +01:00
										 |  |  | 		if (wt) { | 
					
						
							| 
									
										
										
										
											2013-12-05 17:26:03 +11:00
										 |  |  | 			WM_event_timer_sleep(wm, win, wt, true); | 
					
						
							| 
									
										
										
										
											2014-03-21 15:15:24 +01:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-06 19:49:45 +00:00
										 |  |  | 		ED_screen_exit(C, win, oldscreen); | 
					
						
							| 
									
										
										
										
											2014-02-28 10:04:57 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* Same scene, "transfer" playback to new screen. */ | 
					
						
							| 
									
										
										
										
											2014-03-21 15:15:24 +01:00
										 |  |  | 		if (wt) { | 
					
						
							|  |  |  | 			if (oldscene == sc->scene) { | 
					
						
							|  |  |  | 				sc->animtimer = wt; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			/* Else, stop playback. */ | 
					
						
							|  |  |  | 			else { | 
					
						
							|  |  |  | 				oldscreen->animtimer = wt; | 
					
						
							|  |  |  | 				ED_screen_animation_play(C, 0, 0); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-02-28 10:04:57 +01:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		win->screen = sc; | 
					
						
							|  |  |  | 		CTX_wm_window_set(C, win);  // stores C->wm.screen... hrmf
 | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-07 19:37:29 +00:00
										 |  |  | 		/* prevent multiwin errors */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sc->winid = win->winid; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-18 02:56:48 +00:00
										 |  |  | 		ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C)); | 
					
						
							| 
									
										
										
										
											2008-12-27 16:09:56 +00:00
										 |  |  | 		WM_event_add_notifier(C, NC_WINDOW, NULL); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		WM_event_add_notifier(C, NC_SCREEN | ND_SCREENSET, sc); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-06 13:35:04 +00:00
										 |  |  | 		/* makes button hilites work */ | 
					
						
							|  |  |  | 		WM_event_add_mousemove(C); | 
					
						
							| 
									
										
										
										
											2013-12-26 17:24:42 +06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* Needed to make sure all the derivedMeshes are
 | 
					
						
							|  |  |  | 		 * up-to-date before viewport starts acquiring this. | 
					
						
							|  |  |  | 		 * | 
					
						
							|  |  |  | 		 * This is needed in cases when, for example, boolean | 
					
						
							|  |  |  | 		 * modifier uses operant from invisible layer. | 
					
						
							|  |  |  | 		 * Without this trick boolean wouldn't apply correct. | 
					
						
							|  |  |  | 		 * | 
					
						
							|  |  |  | 		 * Quite the same happens when setting screen's scene, | 
					
						
							|  |  |  | 		 * so perhaps this is in fact correct thing to do. | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 		if (oldscene != sc->scene) { | 
					
						
							|  |  |  | 			BKE_scene_set_background(bmain, sc->scene); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-01-21 15:01:32 +06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* Always do visible update since it's possible new screen will
 | 
					
						
							| 
									
										
										
										
											2015-09-21 06:59:50 +10:00
										 |  |  | 		 * have different layers visible in 3D view-ports. | 
					
						
							|  |  |  | 		 * This is possible because of view3d.lock_camera_and_layers option. | 
					
						
							| 
									
										
										
										
											2014-01-21 15:01:32 +06:00
										 |  |  | 		 */ | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 		DAG_on_visible_update(bmain, false); | 
					
						
							| 
									
										
										
										
											2008-12-17 17:33:45 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-26 13:49:58 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return true; | 
					
						
							| 
									
										
										
										
											2008-12-17 17:33:45 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-26 12:41:23 +10:00
										 |  |  | static bool ed_screen_used(wmWindowManager *wm, bScreen *sc) | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	wmWindow *win; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-26 12:41:23 +10:00
										 |  |  | 	for (win = wm->windows.first; win; win = win->next) { | 
					
						
							|  |  |  | 		if (win->screen == sc) { | 
					
						
							|  |  |  | 			return true; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (ELEM(win->screen->state, SCREENMAXIMIZED, SCREENFULL)) { | 
					
						
							|  |  |  | 			ScrArea *sa = win->screen->areabase.first; | 
					
						
							|  |  |  | 			if (sa->full == sc) { | 
					
						
							|  |  |  | 				return true; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return false; | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* only call outside of area/region loops */ | 
					
						
							| 
									
										
										
										
											2015-08-26 13:49:58 +10:00
										 |  |  | bool ED_screen_delete(bContext *C, bScreen *sc) | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	Main *bmain = CTX_data_main(C); | 
					
						
							|  |  |  | 	wmWindowManager *wm = CTX_wm_manager(C); | 
					
						
							|  |  |  | 	wmWindow *win = CTX_wm_window(C); | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | 	bScreen *newsc; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-08 07:12:06 +00:00
										 |  |  | 	/* don't allow deleting temp fullscreens for now */ | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 	if (ELEM(sc->state, SCREENMAXIMIZED, SCREENFULL)) { | 
					
						
							| 
									
										
										
										
											2015-08-26 13:49:58 +10:00
										 |  |  | 		return false; | 
					
						
							| 
									
										
										
										
											2009-12-08 07:12:06 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-26 13:49:58 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | 	/* screen can only be in use by one window at a time, so as
 | 
					
						
							| 
									
										
										
										
											2012-03-03 16:31:46 +00:00
										 |  |  | 	 * long as we are able to find a screen that is unused, we | 
					
						
							|  |  |  | 	 * can safely assume ours is not in use anywhere an delete it */ | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (newsc = sc->id.prev; newsc; newsc = newsc->id.prev) | 
					
						
							| 
									
										
										
										
											2015-08-26 14:14:50 +10:00
										 |  |  | 		if (!ed_screen_used(wm, newsc) && !newsc->temp) | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!newsc) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		for (newsc = sc->id.next; newsc; newsc = newsc->id.next) | 
					
						
							| 
									
										
										
										
											2015-08-26 14:14:50 +10:00
										 |  |  | 			if (!ed_screen_used(wm, newsc) && !newsc->temp) | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-26 13:49:58 +10:00
										 |  |  | 	if (!newsc) { | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	ED_screen_set(C, newsc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-26 13:49:58 +10:00
										 |  |  | 	if (win->screen != sc) { | 
					
						
							| 
									
										
										
										
											2014-01-15 16:37:03 +01:00
										 |  |  | 		BKE_libblock_free(bmain, sc); | 
					
						
							| 
									
										
										
										
											2015-08-26 13:49:58 +10:00
										 |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-24 23:09:22 +00:00
										 |  |  | static void ed_screen_set_3dview_camera(Scene *scene, bScreen *sc, ScrArea *sa, View3D *v3d) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* fix any cameras that are used in the 3d view but not in the scene */ | 
					
						
							|  |  |  | 	BKE_screen_view3d_sync(v3d, scene); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!v3d->camera || !BKE_scene_base_find(scene, v3d->camera)) { | 
					
						
							|  |  |  | 		v3d->camera = BKE_scene_camera_find(sc->scene); | 
					
						
							|  |  |  | 		// XXX if (sc == curscreen) handle_view3d_lock();
 | 
					
						
							|  |  |  | 		if (!v3d->camera) { | 
					
						
							|  |  |  | 			ARegion *ar; | 
					
						
							|  |  |  | 			ListBase *regionbase; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-24 23:09:22 +00:00
										 |  |  | 			/* regionbase is in different place depending if space is active */ | 
					
						
							|  |  |  | 			if (v3d == sa->spacedata.first) | 
					
						
							|  |  |  | 				regionbase = &sa->regionbase; | 
					
						
							|  |  |  | 			else | 
					
						
							|  |  |  | 				regionbase = &v3d->regionbase; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-24 23:09:22 +00:00
										 |  |  | 			for (ar = regionbase->first; ar; ar = ar->next) { | 
					
						
							|  |  |  | 				if (ar->regiontype == RGN_TYPE_WINDOW) { | 
					
						
							|  |  |  | 					RegionView3D *rv3d = ar->regiondata; | 
					
						
							|  |  |  | 					if (rv3d->persp == RV3D_CAMOB) { | 
					
						
							|  |  |  | 						rv3d->persp = RV3D_PERSP; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | /* only call outside of area/region loops */ | 
					
						
							| 
									
										
										
										
											2012-03-07 16:43:42 +00:00
										 |  |  | void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	Main *bmain = CTX_data_main(C); | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | 	bScreen *sc; | 
					
						
							| 
									
										
										
										
											2012-03-07 16:43:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (screen == NULL) | 
					
						
							| 
									
										
										
										
											2012-03-07 16:43:42 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2018-05-15 10:02:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (ed_screen_used(CTX_wm_manager(C), screen)) { | 
					
						
							|  |  |  | 		ED_object_editmode_exit(C, EM_FREEDATA); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-07-28 13:15:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-21 16:08:49 +00:00
										 |  |  | 	for (sc = bmain->screen.first; sc; sc = sc->id.next) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		if ((U.flag & USER_SCENEGLOBAL) || sc == screen) { | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (scene != sc->scene) { | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | 				/* all areas endlocalview */ | 
					
						
							| 
									
										
										
										
											2012-10-23 03:38:26 +00:00
										 |  |  | 				// XXX	ScrArea *sa = sc->areabase.first;
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 				//	while (sa) {
 | 
					
						
							|  |  |  | 				//		endlocalview(sa);
 | 
					
						
							| 
									
										
										
										
											2012-10-23 03:38:26 +00:00
										 |  |  | 				//		sa = sa->next;
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 				//	}
 | 
					
						
							|  |  |  | 				sc->scene = scene; | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | 	//  copy_view3d_lock(0);	/* space.c */
 | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | 	/* are there cameras in the views that are not in the scene? */ | 
					
						
							| 
									
										
										
										
											2013-04-21 16:08:49 +00:00
										 |  |  | 	for (sc = bmain->screen.first; sc; sc = sc->id.next) { | 
					
						
							| 
									
										
										
										
											2012-09-09 00:00:21 +00:00
										 |  |  | 		if ((U.flag & USER_SCENEGLOBAL) || sc == screen) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			ScrArea *sa = sc->areabase.first; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			while (sa) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 				SpaceLink *sl = sa->spacedata.first; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				while (sl) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 					if (sl->spacetype == SPACE_VIEW3D) { | 
					
						
							|  |  |  | 						View3D *v3d = (View3D *) sl; | 
					
						
							| 
									
										
										
										
											2013-04-24 23:09:22 +00:00
										 |  |  | 						ed_screen_set_3dview_camera(scene, sc, sa, v3d); | 
					
						
							| 
									
										
										
										
											2010-03-27 11:54:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 					sl = sl->next; | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 				sa = sa->next; | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | 	CTX_data_scene_set(C, scene); | 
					
						
							| 
									
										
										
										
											2012-05-05 14:33:36 +00:00
										 |  |  | 	BKE_scene_set_background(bmain, scene); | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 	DAG_on_visible_update(bmain, false); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-11 11:42:29 +00:00
										 |  |  | 	ED_render_engine_changed(bmain); | 
					
						
							| 
									
										
										
										
											2012-05-25 12:37:11 +00:00
										 |  |  | 	ED_update_for_newframe(bmain, scene, 1); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | 	/* complete redraw */ | 
					
						
							|  |  |  | 	WM_event_add_notifier(C, NC_WINDOW, NULL); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-08 12:16:35 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-14 15:49:14 +02:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * \note Only call outside of area/region loops | 
					
						
							|  |  |  |  * \return true if successful | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | bool ED_screen_delete_scene(bContext *C, Scene *scene) | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	Main *bmain = CTX_data_main(C); | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | 	Scene *newscene; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (scene->id.prev) | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		newscene = scene->id.prev; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	else if (scene->id.next) | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		newscene = scene->id.next; | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | 	else | 
					
						
							| 
									
										
										
										
											2015-08-14 15:49:14 +02:00
										 |  |  | 		return false; | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-07 16:43:42 +00:00
										 |  |  | 	ED_screen_set_scene(C, CTX_wm_screen(C), newscene); | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +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
										 |  |  | 	BKE_libblock_remap(bmain, scene, newscene, ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_NEVER_NULL_USAGE); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-12 15:54:43 +02:00
										 |  |  | 	id_us_clear_real(&scene->id); | 
					
						
							|  |  |  | 	if (scene->id.us == 0) { | 
					
						
							|  |  |  | 		BKE_libblock_free(bmain, scene); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-14 15:49:14 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return true; | 
					
						
							| 
									
										
										
										
											2009-08-15 16:43:03 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-06 00:42:36 +00:00
										 |  |  | ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	wmWindow *win = CTX_wm_window(C); | 
					
						
							|  |  |  | 	bScreen *screen = CTX_wm_screen(C); | 
					
						
							|  |  |  | 	ScrArea *newsa = NULL; | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	if (!sa || sa->full == NULL) { | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 		newsa = ED_screen_state_toggle(C, win, sa, SCREENMAXIMIZED); | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!newsa) { | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 		if (sa->full && (screen->state == SCREENMAXIMIZED)) { | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 			/* if this has been called from the temporary info header generated in
 | 
					
						
							|  |  |  | 			 * temp fullscreen layouts, find the correct fullscreen area to change | 
					
						
							|  |  |  | 			 * to create a new space inside */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			for (newsa = screen->areabase.first; newsa; newsa = newsa->next) { | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 				if (!(sa->flag & AREA_TEMP_INFO)) | 
					
						
							|  |  |  | 					break; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			newsa = sa; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-05-14 23:58:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	BLI_assert(newsa); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-13 01:40:14 +11:00
										 |  |  | 	if (sa && (sa->spacetype != type)) { | 
					
						
							|  |  |  | 		newsa->flag |= AREA_FLAG_TEMP_TYPE; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		newsa->flag &= ~AREA_FLAG_TEMP_TYPE; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Fix a bunch of temp full-screen glitches
Steps to reproduce fixed glitches were:
* Change any editor to be file browser from menu, Ctrl+O *from the file browser area*, Esc -> area reset to what it was before changing to file browser initially
* Ctrl+O from any area, F12, Esc -> returns to initial editor in full-screen (expected is file browser in full-screen)
Fixes T46229
Core of the fix is removing old area from spacedata list when going back to previous area (see ED_area_prevspace -> BKE_spacedata_remove). Also, when creating a new temp area we now don't exit old area anymore (needed so SpaceFile->op is kept, but it also makes sense in general)
Aaand finally removes some ugly hacks.
Tested quite a bit, so I think it's safe to apply (besides of remark below), just would like to get things double checked and confirmed. After all, this full-screen stuff finally starts to feel like it's working :P
Note, there's still a memory leak when quitting Blender with temp area open. Haven't found out how to solve yet, but it's not that important for review anyway.
Reviewers: campbellbarton, brecht
Reviewed By: brecht
Subscribers: plyczkowski, Blendify
Maniphest Tasks: T46229
Differential Revision: https://developer.blender.org/D1531
											
										 
											2016-02-29 16:18:42 +01:00
										 |  |  | 	ED_area_newspace(C, newsa, type, (newsa->flag & AREA_FLAG_TEMP_TYPE)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-06 00:42:36 +00:00
										 |  |  | 	return newsa; | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-08 15:59:32 +02:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * \a was_prev_temp for the case previous space was a temporary fullscreen as well | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
											  
											
												Fix a bunch of temp full-screen glitches
Steps to reproduce fixed glitches were:
* Change any editor to be file browser from menu, Ctrl+O *from the file browser area*, Esc -> area reset to what it was before changing to file browser initially
* Ctrl+O from any area, F12, Esc -> returns to initial editor in full-screen (expected is file browser in full-screen)
Fixes T46229
Core of the fix is removing old area from spacedata list when going back to previous area (see ED_area_prevspace -> BKE_spacedata_remove). Also, when creating a new temp area we now don't exit old area anymore (needed so SpaceFile->op is kept, but it also makes sense in general)
Aaand finally removes some ugly hacks.
Tested quite a bit, so I think it's safe to apply (besides of remark below), just would like to get things double checked and confirmed. After all, this full-screen stuff finally starts to feel like it's working :P
Note, there's still a memory leak when quitting Blender with temp area open. Haven't found out how to solve yet, but it's not that important for review anyway.
Reviewers: campbellbarton, brecht
Reviewed By: brecht
Subscribers: plyczkowski, Blendify
Maniphest Tasks: T46229
Differential Revision: https://developer.blender.org/D1531
											
										 
											2016-02-29 16:18:42 +01:00
										 |  |  | void ED_screen_full_prevspace(bContext *C, ScrArea *sa) | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-09-10 20:23:17 +02:00
										 |  |  | 	BLI_assert(sa->full); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-28 02:32:52 +01:00
										 |  |  | 	if (sa->flag & AREA_FLAG_STACKED_FULLSCREEN) { | 
					
						
							|  |  |  | 		/* stacked fullscreen -> only go back to previous screen and don't toggle out of fullscreen */ | 
					
						
							|  |  |  | 		ED_area_prevspace(C, sa); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2015-09-10 20:23:17 +02:00
										 |  |  | 		ED_screen_restore_temp_type(C, sa); | 
					
						
							| 
									
										
										
										
											2015-01-24 22:53:22 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-28 02:32:52 +01:00
										 |  |  | void ED_screen_restore_temp_type(bContext *C, ScrArea *sa) | 
					
						
							| 
									
										
										
										
											2015-01-13 01:40:14 +11:00
										 |  |  | { | 
					
						
							|  |  |  | 	/* incase nether functions below run */ | 
					
						
							|  |  |  | 	ED_area_tag_redraw(sa); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (sa->flag & AREA_FLAG_TEMP_TYPE) { | 
					
						
							|  |  |  | 		ED_area_prevspace(C, sa); | 
					
						
							|  |  |  | 		sa->flag &= ~AREA_FLAG_TEMP_TYPE; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-28 02:32:52 +01:00
										 |  |  | 	if (sa->full) { | 
					
						
							| 
									
										
										
										
											2015-01-13 01:40:14 +11:00
										 |  |  | 		ED_screen_state_toggle(C, CTX_wm_window(C), sa, SCREENMAXIMIZED); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | /* restore a screen / area back to default operation, after temp fullscreen modes */ | 
					
						
							|  |  |  | void ED_screen_full_restore(bContext *C, ScrArea *sa) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	wmWindow *win = CTX_wm_window(C); | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 	SpaceLink *sl = sa->spacedata.first; | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 	bScreen *screen = CTX_wm_screen(C); | 
					
						
							|  |  |  | 	short state = (screen ? screen->state : SCREENMAXIMIZED); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-28 02:32:52 +01:00
										 |  |  | 	/* if fullscreen area has a temporary space (such as a file browser or fullscreen render
 | 
					
						
							|  |  |  | 	 * overlaid on top of an existing setup) then return to the previous space */ | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 	if (sl->next) { | 
					
						
							| 
									
										
										
										
											2015-01-28 02:32:52 +01:00
										 |  |  | 		if (sa->flag & AREA_FLAG_TEMP_TYPE) { | 
					
						
							| 
									
										
											  
											
												Fix a bunch of temp full-screen glitches
Steps to reproduce fixed glitches were:
* Change any editor to be file browser from menu, Ctrl+O *from the file browser area*, Esc -> area reset to what it was before changing to file browser initially
* Ctrl+O from any area, F12, Esc -> returns to initial editor in full-screen (expected is file browser in full-screen)
Fixes T46229
Core of the fix is removing old area from spacedata list when going back to previous area (see ED_area_prevspace -> BKE_spacedata_remove). Also, when creating a new temp area we now don't exit old area anymore (needed so SpaceFile->op is kept, but it also makes sense in general)
Aaand finally removes some ugly hacks.
Tested quite a bit, so I think it's safe to apply (besides of remark below), just would like to get things double checked and confirmed. After all, this full-screen stuff finally starts to feel like it's working :P
Note, there's still a memory leak when quitting Blender with temp area open. Haven't found out how to solve yet, but it's not that important for review anyway.
Reviewers: campbellbarton, brecht
Reviewed By: brecht
Subscribers: plyczkowski, Blendify
Maniphest Tasks: T46229
Differential Revision: https://developer.blender.org/D1531
											
										 
											2016-02-29 16:18:42 +01:00
										 |  |  | 			ED_screen_full_prevspace(C, sa); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 			ED_screen_state_toggle(C, win, sa, state); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-04-01 01:58:15 +11:00
										 |  |  | 		/* warning: 'sa' may be freed */ | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	/* otherwise just tile the area again */ | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 		ED_screen_state_toggle(C, win, sa, state); | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-01 01:58:15 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * this function toggles: if area is maximized/full then the parent will be restored | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \warning \a sa may be freed. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const short state) | 
					
						
							| 
									
										
										
										
											2008-12-17 19:40:19 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-06-06 15:50:24 +02:00
										 |  |  | 	Main *bmain = CTX_data_main(C); | 
					
						
							| 
									
										
										
										
											2015-11-17 11:32:15 +11:00
										 |  |  | 	wmWindowManager *wm = CTX_wm_manager(C); | 
					
						
							| 
									
										
										
										
											2008-12-17 19:40:19 +00:00
										 |  |  | 	bScreen *sc, *oldscreen; | 
					
						
							| 
									
										
										
										
											2009-11-05 20:51:36 +00:00
										 |  |  | 	ARegion *ar; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (sa) { | 
					
						
							| 
									
										
										
										
											2009-11-05 20:51:36 +00:00
										 |  |  | 		/* ensure we don't have a button active anymore, can crash when
 | 
					
						
							| 
									
										
										
										
											2012-03-03 16:31:46 +00:00
										 |  |  | 		 * switching screens with tooltip open because region and tooltip | 
					
						
							|  |  |  | 		 * are no longer in the same screen */ | 
					
						
							| 
									
										
										
										
											2015-11-17 11:32:15 +11:00
										 |  |  | 		for (ar = sa->regionbase.first; ar; ar = ar->next) { | 
					
						
							| 
									
										
										
										
											2014-11-09 21:20:40 +01:00
										 |  |  | 			UI_blocklist_free(C, &ar->uiblocks); | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-17 11:32:15 +11:00
										 |  |  | 			if (ar->regiontimer) { | 
					
						
							|  |  |  | 				WM_event_remove_timer(wm, NULL, ar->regiontimer); | 
					
						
							|  |  |  | 				ar->regiontimer = NULL; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-31 15:26:51 +00:00
										 |  |  | 		/* prevent hanging header prints */ | 
					
						
							|  |  |  | 		ED_area_headerprint(sa, NULL); | 
					
						
							| 
									
										
										
										
											2009-11-05 20:51:36 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (sa && sa->full) { | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 		/* restoring back to SCREENNORMAL */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sc = sa->full;       /* the old screen to restore */ | 
					
						
							|  |  |  | 		oldscreen = win->screen; /* the one disappearing */ | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 		sc->state = SCREENNORMAL; | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-06 15:56:01 +02:00
										 |  |  | 		/* find old area to restore from */ | 
					
						
							| 
									
										
										
										
											2017-09-06 17:21:58 +02:00
										 |  |  | 		ScrArea *fullsa = NULL; | 
					
						
							| 
									
										
										
										
											2017-09-06 15:56:01 +02:00
										 |  |  | 		for (ScrArea *old = sc->areabase.first; old; old = old->next) { | 
					
						
							|  |  |  | 			/* area to restore from is always first */ | 
					
						
							|  |  |  | 			if (old->full && !fullsa) { | 
					
						
							|  |  |  | 				fullsa = old; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* clear full screen state */ | 
					
						
							|  |  |  | 			old->full = NULL; | 
					
						
							|  |  |  | 			old->flag &= ~AREA_TEMP_INFO; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		sa->flag &= ~AREA_TEMP_INFO; | 
					
						
							|  |  |  | 		sa->full = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (fullsa == NULL) { | 
					
						
							| 
									
										
										
										
											2012-03-31 00:59:17 +00:00
										 |  |  | 			if (G.debug & G_DEBUG) | 
					
						
							|  |  |  | 				printf("%s: something wrong in areafullscreen\n", __func__); | 
					
						
							| 
									
										
										
										
											2010-11-09 14:54:59 +00:00
										 |  |  | 			return NULL; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 		if (state == SCREENFULL) { | 
					
						
							|  |  |  | 			/* restore the old side panels/header visibility */ | 
					
						
							|  |  |  | 			for (ar = sa->regionbase.first; ar; ar = ar->next) { | 
					
						
							|  |  |  | 				ar->flag = ar->flagfullscreen; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-06 15:56:01 +02:00
										 |  |  | 		ED_area_data_swap(fullsa, sa); | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-09 14:54:59 +00:00
										 |  |  | 		/* animtimer back */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sc->animtimer = oldscreen->animtimer; | 
					
						
							|  |  |  | 		oldscreen->animtimer = NULL; | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-09 14:54:59 +00:00
										 |  |  | 		ED_screen_set(C, sc); | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-15 16:37:03 +01:00
										 |  |  | 		BKE_libblock_free(CTX_data_main(C), oldscreen); | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-14 01:29:17 +01:00
										 |  |  | 		/* After we've restored back to SCREENNORMAL, we have to wait with
 | 
					
						
							|  |  |  | 		 * screen handling as it uses the area coords which aren't updated yet. | 
					
						
							|  |  |  | 		 * Without doing so, the screen handling gets wrong area coords, | 
					
						
							|  |  |  | 		 * which in worst case can lead to crashes (see T43139) */ | 
					
						
							|  |  |  | 		sc->skip_handling = true; | 
					
						
							| 
									
										
										
										
											2008-12-17 19:40:19 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 		/* change from SCREENNORMAL to new state */ | 
					
						
							| 
									
										
										
										
											2009-01-20 19:03:26 +00:00
										 |  |  | 		ScrArea *newa; | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		char newname[MAX_ID_NAME - 2]; | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		oldscreen = win->screen; | 
					
						
							| 
									
										
										
										
											2008-12-18 02:56:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 		oldscreen->state = state; | 
					
						
							|  |  |  | 		BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name + 2, "nonnormal"); | 
					
						
							| 
									
										
										
										
											2018-06-06 15:50:24 +02:00
										 |  |  | 		sc = ED_screen_add(bmain, win, oldscreen->scene, newname); | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 		sc->state = state; | 
					
						
							| 
									
										
										
										
											2015-02-11 20:01:21 +01:00
										 |  |  | 		sc->redraws_flag = oldscreen->redraws_flag; | 
					
						
							| 
									
										
										
										
											2016-08-01 22:57:12 +02:00
										 |  |  | 		sc->temp = oldscreen->temp; | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-22 12:57:53 +00:00
										 |  |  | 		/* timer */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sc->animtimer = oldscreen->animtimer; | 
					
						
							|  |  |  | 		oldscreen->animtimer = NULL; | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-26 11:43:27 +00:00
										 |  |  | 		/* use random area when we have no active one, e.g. when the
 | 
					
						
							| 
									
										
										
										
											2012-03-03 16:31:46 +00:00
										 |  |  | 		 * mouse is outside of the window and we open a file browser */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (!sa) | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			sa = oldscreen->areabase.first; | 
					
						
							| 
									
										
										
										
											2009-10-26 11:43:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 		if (state == SCREENMAXIMIZED) { | 
					
						
							|  |  |  | 			/* returns the top small area */ | 
					
						
							|  |  |  | 			newa = area_split(sc, (ScrArea *)sc->areabase.first, 'h', 0.99f, 1); | 
					
						
							| 
									
										
											  
											
												Fix a bunch of temp full-screen glitches
Steps to reproduce fixed glitches were:
* Change any editor to be file browser from menu, Ctrl+O *from the file browser area*, Esc -> area reset to what it was before changing to file browser initially
* Ctrl+O from any area, F12, Esc -> returns to initial editor in full-screen (expected is file browser in full-screen)
Fixes T46229
Core of the fix is removing old area from spacedata list when going back to previous area (see ED_area_prevspace -> BKE_spacedata_remove). Also, when creating a new temp area we now don't exit old area anymore (needed so SpaceFile->op is kept, but it also makes sense in general)
Aaand finally removes some ugly hacks.
Tested quite a bit, so I think it's safe to apply (besides of remark below), just would like to get things double checked and confirmed. After all, this full-screen stuff finally starts to feel like it's working :P
Note, there's still a memory leak when quitting Blender with temp area open. Haven't found out how to solve yet, but it's not that important for review anyway.
Reviewers: campbellbarton, brecht
Reviewed By: brecht
Subscribers: plyczkowski, Blendify
Maniphest Tasks: T46229
Differential Revision: https://developer.blender.org/D1531
											
										 
											2016-02-29 16:18:42 +01:00
										 |  |  | 			ED_area_newspace(C, newa, SPACE_INFO, false); | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			/* copy area */ | 
					
						
							|  |  |  | 			newa = newa->prev; | 
					
						
							|  |  |  | 			ED_area_data_swap(newa, sa); | 
					
						
							|  |  |  | 			sa->flag |= AREA_TEMP_INFO; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			sa->full = oldscreen; | 
					
						
							|  |  |  | 			newa->full = oldscreen; | 
					
						
							|  |  |  | 			newa->next->full = oldscreen; // XXX
 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else if (state == SCREENFULL) { | 
					
						
							|  |  |  | 			newa = (ScrArea *)sc->areabase.first; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* copy area */ | 
					
						
							|  |  |  | 			ED_area_data_swap(newa, sa); | 
					
						
							|  |  |  | 			newa->flag = sa->flag; /* mostly for AREA_FLAG_WASFULLSCREEN */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* temporarily hide the side panels/header */ | 
					
						
							|  |  |  | 			for (ar = newa->regionbase.first; ar; ar = ar->next) { | 
					
						
							|  |  |  | 				ar->flagfullscreen = ar->flag; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if (ELEM(ar->regiontype, | 
					
						
							|  |  |  | 				         RGN_TYPE_UI, | 
					
						
							|  |  |  | 				         RGN_TYPE_HEADER, | 
					
						
							|  |  |  | 				         RGN_TYPE_TOOLS)) | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					ar->flag |= RGN_FLAG_HIDDEN; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2008-12-17 19:40:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 15:05:44 -03:00
										 |  |  | 			sa->full = oldscreen; | 
					
						
							|  |  |  | 			newa->full = oldscreen; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			BLI_assert(false); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-03-08 16:36:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-07 19:37:29 +00:00
										 |  |  | 		ED_screen_set(C, sc); | 
					
						
							| 
									
										
										
										
											2008-12-17 19:40:19 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* XXX bad code: setscreen() ends with first area active. fullscreen render assumes this too */ | 
					
						
							| 
									
										
										
										
											2008-12-18 02:56:48 +00:00
										 |  |  | 	CTX_wm_area_set(C, sc->areabase.first); | 
					
						
							| 
									
										
										
										
											2008-12-17 19:40:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-26 11:43:27 +00:00
										 |  |  | 	return sc->areabase.first; | 
					
						
							| 
									
										
										
										
											2008-12-17 19:40:19 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-12 00:44:26 +00:00
										 |  |  | /* update frame rate info for viewport drawing */ | 
					
						
							|  |  |  | void ED_refresh_viewport_fps(bContext *C) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	wmTimer *animtimer = CTX_wm_screen(C)->animtimer; | 
					
						
							|  |  |  | 	Scene *scene = CTX_data_scene(C); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-12 00:44:26 +00:00
										 |  |  | 	/* is anim playback running? */ | 
					
						
							|  |  |  | 	if (animtimer && (U.uiflag & USER_SHOW_FPS)) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		ScreenFrameRateInfo *fpsi = scene->fps_info; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-12 00:44:26 +00:00
										 |  |  | 		/* if there isn't any info, init it first */ | 
					
						
							|  |  |  | 		if (fpsi == NULL) | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			fpsi = scene->fps_info = MEM_callocN(sizeof(ScreenFrameRateInfo), "refresh_viewport_fps fps_info"); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-12 00:44:26 +00:00
										 |  |  | 		/* update the values */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		fpsi->redrawtime = fpsi->lredrawtime; | 
					
						
							|  |  |  | 		fpsi->lredrawtime = animtimer->ltime; | 
					
						
							| 
									
										
										
										
											2010-02-12 00:44:26 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-10-21 05:46:41 +00:00
										 |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2010-02-12 00:44:26 +00:00
										 |  |  | 		/* playback stopped or shouldn't be running */ | 
					
						
							|  |  |  | 		if (scene->fps_info) | 
					
						
							|  |  |  | 			MEM_freeN(scene->fps_info); | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		scene->fps_info = NULL; | 
					
						
							| 
									
										
										
										
											2010-02-12 00:44:26 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | /* redraws: uses defines from stime->redraws
 | 
					
						
							| 
									
										
										
										
											2009-07-07 07:29:21 +00:00
										 |  |  |  * enable: 1 - forward on, -1 - backwards on, 0 - off | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2010-07-19 11:25:23 +00:00
										 |  |  | void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync, int enable) | 
					
						
							| 
									
										
										
										
											2008-12-21 19:58:25 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	bScreen *screen = CTX_wm_screen(C); | 
					
						
							|  |  |  | 	wmWindowManager *wm = CTX_wm_manager(C); | 
					
						
							|  |  |  | 	wmWindow *win = CTX_wm_window(C); | 
					
						
							|  |  |  | 	Scene *scene = CTX_data_scene(C); | 
					
						
							| 
									
										
										
										
											2012-05-25 12:56:29 +00:00
										 |  |  | 	bScreen *stopscreen = ED_screen_animation_playing(wm); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-25 12:37:11 +00:00
										 |  |  | 	if (stopscreen) { | 
					
						
							|  |  |  | 		WM_event_remove_timer(wm, win, stopscreen->animtimer); | 
					
						
							|  |  |  | 		stopscreen->animtimer = NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (enable) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		ScreenAnimData *sad = MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData"); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		screen->animtimer = WM_event_add_timer(wm, win, TIMER0, (1.0 / FPS)); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sad->ar = CTX_wm_region(C); | 
					
						
							| 
									
										
										
										
											2012-03-08 17:40:55 +00:00
										 |  |  | 		/* if startframe is larger than current frame, we put currentframe on startframe.
 | 
					
						
							| 
									
										
										
										
											2012-03-09 18:28:30 +00:00
										 |  |  | 		 * note: first frame then is not drawn! (ton) */ | 
					
						
							| 
									
										
										
										
											2012-09-10 14:00:01 +00:00
										 |  |  | 		if (PRVRANGEON) { | 
					
						
							|  |  |  | 			if (scene->r.psfra > scene->r.cfra) { | 
					
						
							|  |  |  | 				sad->sfra = scene->r.cfra; | 
					
						
							|  |  |  | 				scene->r.cfra = scene->r.psfra; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else | 
					
						
							|  |  |  | 				sad->sfra = scene->r.cfra; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			if (scene->r.sfra > scene->r.cfra) { | 
					
						
							|  |  |  | 				sad->sfra = scene->r.cfra; | 
					
						
							|  |  |  | 				scene->r.cfra = scene->r.sfra; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else | 
					
						
							|  |  |  | 				sad->sfra = scene->r.cfra; | 
					
						
							| 
									
										
										
										
											2012-03-08 17:40:55 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sad->redraws = redraws; | 
					
						
							|  |  |  | 		sad->refresh = refresh; | 
					
						
							|  |  |  | 		sad->flag |= (enable < 0) ? ANIMPLAY_FLAG_REVERSE : 0; | 
					
						
							|  |  |  | 		sad->flag |= (sync == 0) ? ANIMPLAY_FLAG_NO_SYNC : (sync == 1) ? ANIMPLAY_FLAG_SYNC : 0; | 
					
						
							| 
									
										
										
										
											2016-06-03 11:46:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		ScrArea *sa = CTX_wm_area(C); | 
					
						
							| 
									
										
										
										
											2016-10-22 15:00:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		char spacetype = -1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (sa) | 
					
						
							|  |  |  | 			spacetype = sa->spacetype; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		sad->from_anim_edit = (ELEM(spacetype, SPACE_IPO, SPACE_ACTION, SPACE_NLA, SPACE_TIME)); | 
					
						
							| 
									
										
										
										
											2016-06-03 11:46:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		screen->animtimer->customdata = sad; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
  Only the region 'windows' are drawn, not headers, toolbars,
  channel views, etc.
  The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
  progressing frame numbers
- For now: if you choose to play 3D views, it also redraws 
  the TimeLine. Seems to be good convention, but probably
  better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
  to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
  no options yet; just plays active region + all 3D windows now.
  Options will follow, based on reviews.
  Also ESC won't work for now, just press ALT+A again.
											
										 
											2009-05-21 13:33:04 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-05-25 12:37:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
  Only the region 'windows' are drawn, not headers, toolbars,
  channel views, etc.
  The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
  progressing frame numbers
- For now: if you choose to play 3D views, it also redraws 
  the TimeLine. Seems to be good convention, but probably
  better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
  to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
  no options yet; just plays active region + all 3D windows now.
  Options will follow, based on reviews.
  Also ESC won't work for now, just press ALT+A again.
											
										 
											2009-05-21 13:33:04 +00:00
										 |  |  | 	/* notifier catched by top header, for button */ | 
					
						
							| 
									
										
										
										
											2012-05-25 12:37:11 +00:00
										 |  |  | 	WM_event_add_notifier(C, NC_SCREEN | ND_ANIMPLAY, NULL); | 
					
						
							| 
									
										
										
										
											2008-12-21 19:58:25 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-16 23:37:46 +00:00
										 |  |  | /* helper for screen_animation_play() - only to be used for TimeLine */ | 
					
						
							|  |  |  | static ARegion *time_top_left_3dwindow(bScreen *screen) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	ARegion *aret = NULL; | 
					
						
							| 
									
										
										
										
											2009-08-16 23:37:46 +00:00
										 |  |  | 	ScrArea *sa; | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	int min = 10000; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	for (sa = screen->areabase.first; sa; sa = sa->next) { | 
					
						
							|  |  |  | 		if (sa->spacetype == SPACE_VIEW3D) { | 
					
						
							| 
									
										
										
										
											2009-08-16 23:37:46 +00:00
										 |  |  | 			ARegion *ar; | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			for (ar = sa->regionbase.first; ar; ar = ar->next) { | 
					
						
							|  |  |  | 				if (ar->regiontype == RGN_TYPE_WINDOW) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 					if (ar->winrct.xmin - ar->winrct.ymin < min) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 						aret = ar; | 
					
						
							|  |  |  | 						min = ar->winrct.xmin - ar->winrct.ymin; | 
					
						
							| 
									
										
										
										
											2009-08-16 23:37:46 +00:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return aret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Timeline addition: Display cached frames
This started off doing pointcache debugging but it's also very useful for users too.
Previously it was very hard to see the state of the system when you're working caches
such as physics point cache - is it baked? which frames are cached? is it out of date?
Now, for better feedback, cached frames are drawn for the active object at the bottom 
of the timeline - a semitransparent area shows the entire cache extents, and more 
solid blocks on top show the frames that are cached. Darker versions indicate it's 
using a disk cache.
It can be disabled in general in the timeline View -> Caches menu, or by each individual
system that can be shown.
There's still a bit to do on this, behaviour needs to be clarified still eg. deciding what
shows when it's out of date, or when it's been played back but not cached, etc. etc. 
Part of this is due to a lack of definition in the point cache system itself, so we should
try and clean up/clarify this behaviour and what it means to users, at the same time.
Also would be interested in extending this to other caches such as fluid cache, 
sequencer memory cache etc. in the future, too.
											
										 
											2010-06-22 02:29:52 +00:00
										 |  |  | void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh) | 
					
						
							| 
									
										
										
										
											2009-08-16 23:37:46 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (screen && screen->animtimer) { | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		wmTimer *wt = screen->animtimer; | 
					
						
							|  |  |  | 		ScreenAnimData *sad = wt->customdata; | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		sad->redraws = redraws; | 
					
						
							|  |  |  | 		sad->refresh = refresh; | 
					
						
							|  |  |  | 		sad->ar = NULL; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (redraws & TIME_REGION) | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 			sad->ar = time_top_left_3dwindow(screen); | 
					
						
							| 
									
										
										
										
											2009-08-16 23:37:46 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-02 09:34:32 +00:00
										 |  |  | /* results in fully updated anim system
 | 
					
						
							|  |  |  |  * screen can be NULL */ | 
					
						
							| 
									
										
										
										
											2012-05-25 12:37:11 +00:00
										 |  |  | void ED_update_for_newframe(Main *bmain, Scene *scene, int UNUSED(mute)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	wmWindowManager *wm = bmain->wm.first; | 
					
						
							|  |  |  | 	wmWindow *window; | 
					
						
							|  |  |  | 	int layers = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-16 19:49:33 +00:00
										 |  |  | #ifdef DURIAN_CAMERA_SWITCH
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 	void *camera = BKE_scene_camera_switch_find(scene); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (camera && scene->camera != camera) { | 
					
						
							| 
									
										
										
										
											2010-04-23 08:39:10 +00:00
										 |  |  | 		bScreen *sc; | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		scene->camera = camera; | 
					
						
							| 
									
										
										
										
											2010-04-23 08:39:10 +00:00
										 |  |  | 		/* are there cameras in the views that are not in the scene? */ | 
					
						
							| 
									
										
										
										
											2012-05-08 15:43:59 +00:00
										 |  |  | 		for (sc = bmain->screen.first; sc; sc = sc->id.next) { | 
					
						
							| 
									
										
										
										
											2010-04-23 08:39:10 +00:00
										 |  |  | 			BKE_screen_view3d_scene_sync(sc); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-12-16 19:49:33 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-07 12:55:18 +00:00
										 |  |  | 	ED_clip_update_frame(bmain, scene->r.cfra); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-25 12:37:11 +00:00
										 |  |  | 	/* get layers from all windows */ | 
					
						
							|  |  |  | 	for (window = wm->windows.first; window; window = window->next) | 
					
						
							|  |  |  | 		layers |= BKE_screen_visible_layers(window->screen, scene); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-04 17:40:50 +00:00
										 |  |  | 	/* this function applies the changes too */ | 
					
						
							| 
									
										
										
										
											2013-12-26 17:24:42 +06:00
										 |  |  | 	BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, layers); | 
					
						
							| 
									
										
										
										
											2015-11-01 12:32:04 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-04 17:40:50 +00:00
										 |  |  | 	/* composite */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (scene->use_nodes && scene->nodetree) | 
					
						
							| 
									
										
										
										
											2009-02-04 17:40:50 +00:00
										 |  |  | 		ntreeCompositTagAnimated(scene->nodetree); | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-04 17:40:50 +00:00
										 |  |  | 	/* update animated texture nodes */ | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		Tex *tex; | 
					
						
							| 
									
										
										
										
											2017-05-19 22:18:54 +10:00
										 |  |  | 		for (tex = bmain->tex.first; tex; tex = tex->id.next) { | 
					
						
							| 
									
										
										
										
											2012-03-11 19:09:01 +00:00
										 |  |  | 			if (tex->use_nodes && tex->nodetree) { | 
					
						
							|  |  |  | 				ntreeTexTagAnimated(tex->nodetree); | 
					
						
							| 
									
										
										
										
											2009-02-04 17:40:50 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-05-19 22:18:54 +10:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-02-04 17:40:50 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-04 09:31:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-04 17:40:50 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-06 10:40:12 -03:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * return true if any active area requires to see in 3D | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | bool ED_screen_stereo3d_required(bScreen *screen) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	ScrArea *sa; | 
					
						
							|  |  |  | 	Scene *sce = screen->scene; | 
					
						
							|  |  |  | 	const bool is_multiview = (sce->r.scemode & R_MULTIVIEW) != 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (sa = screen->areabase.first; sa; sa = sa->next) { | 
					
						
							|  |  |  | 		switch (sa->spacetype) { | 
					
						
							|  |  |  | 			case SPACE_VIEW3D: | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				View3D *v3d; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if (!is_multiview) | 
					
						
							|  |  |  | 					continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				v3d = sa->spacedata.first; | 
					
						
							|  |  |  | 				if (v3d->camera && v3d->stereo3d_camera == STEREO_3D_ID) { | 
					
						
							|  |  |  | 					ARegion *ar; | 
					
						
							|  |  |  | 					for (ar = sa->regionbase.first; ar; ar = ar->next) { | 
					
						
							|  |  |  | 						if (ar->regiondata && ar->regiontype == RGN_TYPE_WINDOW) { | 
					
						
							|  |  |  | 							RegionView3D *rv3d = ar->regiondata; | 
					
						
							|  |  |  | 							if (rv3d->persp == RV3D_CAMOB) { | 
					
						
							|  |  |  | 								return true; | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			case SPACE_IMAGE: | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				SpaceImage *sima; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				/* images should always show in stereo, even if
 | 
					
						
							|  |  |  | 				 * the file doesn't have views enabled */ | 
					
						
							|  |  |  | 				sima = sa->spacedata.first; | 
					
						
							| 
									
										
										
										
											2015-10-11 01:14:02 +02:00
										 |  |  | 				if (sima->image && BKE_image_is_stereo(sima->image) && | 
					
						
							| 
									
										
										
										
											2015-04-06 10:40:12 -03:00
										 |  |  | 				    (sima->iuser.flag & IMA_SHOW_STEREO)) | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			case SPACE_NODE: | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				SpaceNode *snode; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if (!is_multiview) | 
					
						
							|  |  |  | 					continue; | 
					
						
							| 
									
										
										
										
											2009-02-04 17:40:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-06 10:40:12 -03:00
										 |  |  | 				snode = sa->spacedata.first; | 
					
						
							|  |  |  | 				if ((snode->flag & SNODE_BACKDRAW) && ED_node_is_compositor(snode)) { | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			case SPACE_SEQ: | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				SpaceSeq *sseq; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if (!is_multiview) | 
					
						
							|  |  |  | 					continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				sseq = sa->spacedata.first; | 
					
						
							|  |  |  | 				if (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW)) { | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if (sseq->draw_flag & SEQ_DRAW_BACKDROP) { | 
					
						
							|  |  |  | 					return true; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } |