2008-01-07 18:03:41 +00:00
|
|
|
/**
|
|
|
|
* $Id:
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
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>
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "MEM_guardedalloc.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
|
|
|
#include "DNA_vec_types.h"
|
2008-12-21 19:58:25 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2008-12-22 12:57:53 +00:00
|
|
|
#include "DNA_screen_types.h"
|
2009-02-04 17:40:50 +00:00
|
|
|
#include "DNA_texture_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
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_library.h"
|
|
|
|
#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 "BKE_utildefines.h"
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "ED_screen.h"
|
2008-01-17 05:33:54 +00:00
|
|
|
#include "ED_screen_types.h"
|
2008-01-15 19:28:57 +00:00
|
|
|
|
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"
|
|
|
|
|
|
|
|
#include "screen_intern.h" /* own module include */
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
ScrVert *sv= MEM_callocN(sizeof(ScrVert), "addscrvert");
|
|
|
|
sv->vec.x= x;
|
|
|
|
sv->vec.y= y;
|
|
|
|
|
|
|
|
BLI_addtail(&sc->vertbase, sv);
|
|
|
|
return sv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sortscrvert(ScrVert **v1, ScrVert **v2)
|
|
|
|
{
|
|
|
|
ScrVert *tmp;
|
|
|
|
|
|
|
|
if (*v1 > *v2) {
|
|
|
|
tmp= *v1;
|
|
|
|
*v1= *v2;
|
|
|
|
*v2= tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2)
|
|
|
|
{
|
|
|
|
ScrEdge *se= MEM_callocN(sizeof(ScrEdge), "addscredge");
|
|
|
|
|
|
|
|
sortscrvert(&v1, &v2);
|
|
|
|
se->v1= v1;
|
|
|
|
se->v2= v2;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
sortscrvert(&v1, &v2);
|
|
|
|
for (se= sc->edgebase.first; se; se= se->next)
|
|
|
|
if(se->v1==v1 && se->v2==v2)
|
|
|
|
return se;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
verg= sc->vertbase.first;
|
|
|
|
while(verg) {
|
|
|
|
if(verg->newv==NULL) { /* !!! */
|
|
|
|
v1= verg->next;
|
|
|
|
while(v1) {
|
|
|
|
if(v1->newv==NULL) { /* !?! */
|
|
|
|
if(v1->vec.x==verg->vec.x && v1->vec.y==verg->vec.y) {
|
|
|
|
/* printf("doublevert\n"); */
|
|
|
|
v1->newv= verg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
v1= v1->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
verg= verg->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* replace pointers in edges and faces */
|
|
|
|
se= sc->edgebase.first;
|
|
|
|
while(se) {
|
|
|
|
if(se->v1->newv) se->v1= se->v1->newv;
|
|
|
|
if(se->v2->newv) se->v2= se->v2->newv;
|
|
|
|
/* edges changed: so.... */
|
|
|
|
sortscrvert(&(se->v1), &(se->v2));
|
|
|
|
se= se->next;
|
|
|
|
}
|
|
|
|
sa= sc->areabase.first;
|
|
|
|
while(sa) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove */
|
|
|
|
verg= sc->vertbase.first;
|
|
|
|
while(verg) {
|
|
|
|
v1= verg->next;
|
|
|
|
if(verg->newv) {
|
|
|
|
BLI_remlink(&sc->vertbase, verg);
|
|
|
|
MEM_freeN(verg);
|
|
|
|
}
|
|
|
|
verg= v1;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* we assume edges are ok */
|
|
|
|
|
|
|
|
se= sc->edgebase.first;
|
|
|
|
while(se) {
|
|
|
|
se->v1->flag= 1;
|
|
|
|
se->v2->flag= 1;
|
|
|
|
se= se->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
sv= sc->vertbase.first;
|
|
|
|
while(sv) {
|
|
|
|
svn= sv->next;
|
|
|
|
if(sv->flag==0) {
|
|
|
|
BLI_remlink(&sc->vertbase, sv);
|
|
|
|
MEM_freeN(sv);
|
|
|
|
}
|
|
|
|
else sv->flag= 0;
|
|
|
|
sv= svn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* compare */
|
|
|
|
verg= sc->edgebase.first;
|
|
|
|
while(verg) {
|
|
|
|
se= verg->next;
|
|
|
|
while(se) {
|
|
|
|
sn= se->next;
|
|
|
|
if(verg->v1==se->v1 && verg->v2==se->v2) {
|
|
|
|
BLI_remlink(&sc->edgebase, se);
|
|
|
|
MEM_freeN(se);
|
|
|
|
}
|
|
|
|
se= sn;
|
|
|
|
}
|
|
|
|
verg= verg->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
int a=0;
|
|
|
|
|
|
|
|
/* sets flags when edge is used in area */
|
|
|
|
sa= sc->areabase.first;
|
|
|
|
while(sa) {
|
|
|
|
se= screen_findedge(sc, sa->v1, sa->v2);
|
2008-01-15 23:08:10 +00:00
|
|
|
if(se==0) printf("error: area %d edge 1 doesn't exist\n", a);
|
2008-01-07 18:03:41 +00:00
|
|
|
else se->flag= 1;
|
|
|
|
se= screen_findedge(sc, sa->v2, sa->v3);
|
2008-01-15 23:08:10 +00:00
|
|
|
if(se==0) printf("error: area %d edge 2 doesn't exist\n", a);
|
2008-01-07 18:03:41 +00:00
|
|
|
else se->flag= 1;
|
|
|
|
se= screen_findedge(sc, sa->v3, sa->v4);
|
2008-01-15 23:08:10 +00:00
|
|
|
if(se==0) printf("error: area %d edge 3 doesn't exist\n", a);
|
2008-01-07 18:03:41 +00:00
|
|
|
else se->flag= 1;
|
|
|
|
se= screen_findedge(sc, sa->v4, sa->v1);
|
2008-01-15 23:08:10 +00:00
|
|
|
if(se==0) printf("error: area %d edge 4 doesn't exist\n", a);
|
2008-01-07 18:03:41 +00:00
|
|
|
else se->flag= 1;
|
|
|
|
sa= sa->next;
|
|
|
|
a++;
|
|
|
|
}
|
|
|
|
se= sc->edgebase.first;
|
|
|
|
while(se) {
|
|
|
|
sen= se->next;
|
|
|
|
if(se->flag==0) {
|
|
|
|
BLI_remlink(&sc->edgebase, se);
|
|
|
|
MEM_freeN(se);
|
|
|
|
}
|
|
|
|
else se->flag= 0;
|
|
|
|
se= sen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-15 16:54:47 +00:00
|
|
|
int scredge_is_horizontal(ScrEdge *se)
|
|
|
|
{
|
|
|
|
return (se->v1->vec.y == se->v2->vec.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my)
|
|
|
|
{
|
|
|
|
ScrEdge *se;
|
|
|
|
|
|
|
|
for (se= sc->edgebase.first; se; se= se->next) {
|
|
|
|
if (scredge_is_horizontal(se)) {
|
|
|
|
short min, max;
|
|
|
|
min= MIN2(se->v1->vec.x, se->v2->vec.x);
|
|
|
|
max= MAX2(se->v1->vec.x, se->v2->vec.x);
|
|
|
|
|
|
|
|
if (abs(my-se->v1->vec.y)<=2 && mx>=min && mx<=max)
|
|
|
|
return se;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
short min, max;
|
|
|
|
min= MIN2(se->v1->vec.y, se->v2->vec.y);
|
|
|
|
max= MAX2(se->v1->vec.y, se->v2->vec.y);
|
|
|
|
|
|
|
|
if (abs(mx-se->v1->vec.x)<=2 && my>=min && my<=max)
|
|
|
|
return se;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
ScrArea *sa= MEM_callocN(sizeof(ScrArea), "addscrarea");
|
|
|
|
sa->v1= v1;
|
|
|
|
sa->v2= v2;
|
|
|
|
sa->v3= v3;
|
|
|
|
sa->v4= v4;
|
|
|
|
sa->headertype= headertype;
|
2008-12-11 19:35:27 +00:00
|
|
|
sa->spacetype= sa->butspacetype= spacetype;
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
BLI_addtail(&sc->areabase, sa);
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2008-12-14 17:48:52 +00:00
|
|
|
|
|
|
|
ED_area_exit(C, sa);
|
|
|
|
|
2008-01-14 20:46:42 +00:00
|
|
|
BKE_screen_area_free(sa);
|
2008-12-14 17:48:52 +00: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 */
|
|
|
|
static short testsplitpoint(wmWindow *win, ScrArea *sa, char dir, float fac)
|
|
|
|
{
|
|
|
|
short x, y;
|
|
|
|
|
|
|
|
// area big enough?
|
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
|
|
|
if(dir=='v' && (sa->v4->vec.x- sa->v1->vec.x <= 2*AREAMINX)) return 0;
|
|
|
|
if(dir=='h' && (sa->v2->vec.y- sa->v1->vec.y <= 2*AREAMINY)) return 0;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
// to be sure
|
|
|
|
if(fac<0.0) fac= 0.0;
|
|
|
|
if(fac>1.0) fac= 1.0;
|
|
|
|
|
|
|
|
if(dir=='h') {
|
|
|
|
y= sa->v1->vec.y+ fac*(sa->v2->vec.y- sa->v1->vec.y);
|
|
|
|
|
|
|
|
if(y- sa->v1->vec.y < AREAMINY)
|
|
|
|
y= sa->v1->vec.y+ AREAMINY;
|
|
|
|
else if(sa->v2->vec.y- y < AREAMINY)
|
|
|
|
y= sa->v2->vec.y- AREAMINY;
|
|
|
|
else y-= (y % AREAGRID);
|
|
|
|
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
x= sa->v1->vec.x+ fac*(sa->v4->vec.x- sa->v1->vec.x);
|
|
|
|
|
|
|
|
if(x- sa->v1->vec.x < AREAMINX)
|
|
|
|
x= sa->v1->vec.x+ AREAMINX;
|
|
|
|
else if(sa->v4->vec.x- x < AREAMINX)
|
|
|
|
x= sa->v4->vec.x- AREAMINX;
|
|
|
|
else x-= (x % AREAGRID);
|
|
|
|
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrArea *area_split(wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac)
|
|
|
|
{
|
|
|
|
ScrArea *newa=NULL;
|
|
|
|
ScrVert *sv1, *sv2;
|
|
|
|
short split;
|
|
|
|
|
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
|
|
|
if(sa==NULL) return NULL;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
split= testsplitpoint(win, sa, dir, fac);
|
|
|
|
if(split==0) return NULL;
|
|
|
|
|
|
|
|
if(dir=='h') {
|
|
|
|
/* new vertices */
|
|
|
|
sv1= screen_addvert(sc, sa->v1->vec.x, split);
|
|
|
|
sv2= screen_addvert(sc, sa->v4->vec.x, split);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
|
|
|
/* new areas: top */
|
|
|
|
newa= screen_addarea(sc, sv1, sa->v2, sa->v3, sv2, sa->headertype, sa->spacetype);
|
|
|
|
area_copy_data(newa, sa, 0);
|
|
|
|
|
|
|
|
/* area below */
|
|
|
|
sa->v2= sv1;
|
|
|
|
sa->v3= sv2;
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* new vertices */
|
|
|
|
sv1= screen_addvert(sc, split, sa->v1->vec.y);
|
|
|
|
sv2= screen_addvert(sc, split, sa->v2->vec.y);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
|
|
|
/* new areas: left */
|
|
|
|
newa= screen_addarea(sc, sa->v1, sa->v2, sv2, sv1, sa->headertype, sa->spacetype);
|
|
|
|
area_copy_data(newa, sa, 0);
|
|
|
|
|
|
|
|
/* area right */
|
|
|
|
sa->v1= sv1;
|
|
|
|
sa->v2= sv2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove double vertices en edges */
|
|
|
|
removedouble_scrverts(sc);
|
|
|
|
removedouble_scredges(sc);
|
|
|
|
removenotused_scredges(sc);
|
|
|
|
|
|
|
|
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 */
|
2009-07-24 12:43:59 +00:00
|
|
|
bScreen *ED_screen_add(wmWindow *win, Scene *scene, char *name)
|
2008-01-07 18:03:41 +00:00
|
|
|
{
|
|
|
|
bScreen *sc;
|
|
|
|
ScrVert *sv1, *sv2, *sv3, *sv4;
|
|
|
|
|
|
|
|
sc= alloc_libblock(&G.main->screen, ID_SCR, name);
|
2009-01-04 14:14:06 +00:00
|
|
|
sc->scene= scene;
|
2008-11-18 13:51:02 +00:00
|
|
|
sc->do_refresh= 1;
|
2009-02-07 19:37:29 +00:00
|
|
|
sc->winid= win->winid;
|
2008-11-18 13:51:02 +00:00
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
sv1= screen_addvert(sc, 0, 0);
|
|
|
|
sv2= screen_addvert(sc, 0, win->sizey-1);
|
|
|
|
sv3= screen_addvert(sc, win->sizex-1, win->sizey-1);
|
|
|
|
sv4= screen_addvert(sc, win->sizex-1, 0);
|
|
|
|
|
|
|
|
screen_addedge(sc, sv1, sv2);
|
|
|
|
screen_addedge(sc, sv2, sv3);
|
|
|
|
screen_addedge(sc, sv3, sv4);
|
|
|
|
screen_addedge(sc, sv4, sv1);
|
|
|
|
|
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);
|
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;
|
|
|
|
|
|
|
|
/* free contents of 'to', is from blenkernel screen.c */
|
|
|
|
free_screen(to);
|
|
|
|
|
|
|
|
BLI_duplicatelist(&to->vertbase, &from->vertbase);
|
|
|
|
BLI_duplicatelist(&to->edgebase, &from->edgebase);
|
|
|
|
BLI_duplicatelist(&to->areabase, &from->areabase);
|
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
|
|
|
to->regionbase.first= to->regionbase.last= NULL;
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
s2= to->vertbase.first;
|
|
|
|
for(s1= from->vertbase.first; s1; s1= s1->next, s2= s2->next) {
|
|
|
|
s1->newv= s2;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(se= to->edgebase.first; se; se= se->next) {
|
|
|
|
se->v1= se->v1->newv;
|
|
|
|
se->v2= se->v2->newv;
|
|
|
|
sortscrvert(&(se->v1), &(se->v2));
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
sa->spacedata.first= sa->spacedata.last= NULL;
|
|
|
|
sa->regionbase.first= sa->regionbase.last= NULL;
|
2008-01-17 16:22:37 +00:00
|
|
|
sa->actionzones.first= sa->actionzones.last= NULL;
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
area_copy_data(sa, saf, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* put at zero (needed?) */
|
|
|
|
for(s1= from->vertbase.first; s1; s1= s1->next)
|
|
|
|
s1->newv= NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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 */
|
2008-11-19 16:28:11 +00:00
|
|
|
int area_getorientation(bScreen *screen, 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;
|
|
|
|
|
|
|
|
if(sa==NULL || sb==NULL) return -1;
|
|
|
|
|
|
|
|
sav1= sa->v1;
|
|
|
|
sav2= sa->v2;
|
|
|
|
sav3= sa->v3;
|
|
|
|
sav4= sa->v4;
|
|
|
|
sbv1= sb->v1;
|
|
|
|
sbv2= sb->v2;
|
|
|
|
sbv3= sb->v3;
|
|
|
|
sbv4= sb->v4;
|
2008-01-14 20:46:42 +00:00
|
|
|
|
|
|
|
if(sav1==sbv4 && sav2==sbv3) { /* sa to right of sb = W */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if(sav2==sbv1 && sav3==sbv4) { /* sa to bottom of sb = N */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if(sav3==sbv2 && sav4==sbv1) { /* sa to left of sb = E */
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
else if(sav1==sbv2 && sav4==sbv3) { /* sa on top of sb = S*/
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
* used by the split, join operators
|
|
|
|
*/
|
2008-12-14 17:48:52 +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;
|
2008-01-14 20:46:42 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
dir = area_getorientation(scr, sa1, sa2);
|
|
|
|
/*printf("dir is : %i \n", dir);*/
|
2008-06-19 19:09:21 +00:00
|
|
|
|
|
|
|
if (dir < 0)
|
|
|
|
{
|
|
|
|
if (sa1 ) sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
|
|
|
|
if (sa2 ) sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dir == 0) {
|
|
|
|
sa1->v1= sa2->v1;
|
|
|
|
sa1->v2= sa2->v2;
|
|
|
|
screen_addedge(scr, sa1->v2, sa1->v3);
|
|
|
|
screen_addedge(scr, sa1->v1, sa1->v4);
|
|
|
|
}
|
|
|
|
else if(dir == 1) {
|
|
|
|
sa1->v2= sa2->v2;
|
|
|
|
sa1->v3= sa2->v3;
|
|
|
|
screen_addedge(scr, sa1->v1, sa1->v2);
|
|
|
|
screen_addedge(scr, sa1->v3, sa1->v4);
|
|
|
|
}
|
|
|
|
else if(dir == 2) {
|
|
|
|
sa1->v3= sa2->v3;
|
|
|
|
sa1->v4= sa2->v4;
|
|
|
|
screen_addedge(scr, sa1->v2, sa1->v3);
|
|
|
|
screen_addedge(scr, sa1->v1, sa1->v4);
|
|
|
|
}
|
|
|
|
else if(dir == 3) {
|
|
|
|
sa1->v1= sa2->v1;
|
|
|
|
sa1->v4= sa2->v4;
|
|
|
|
screen_addedge(scr, sa1->v1, sa1->v2);
|
|
|
|
screen_addedge(scr, sa1->v3, sa1->v4);
|
|
|
|
}
|
|
|
|
|
2008-12-14 17:48:52 +00:00
|
|
|
screen_delarea(C, scr, sa2);
|
2008-06-19 19:09:21 +00:00
|
|
|
removedouble_scrverts(scr);
|
|
|
|
sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* select connected, only in the right direction */
|
|
|
|
/* 'dir' is the direction of EDGE */
|
|
|
|
|
|
|
|
if(edge->v1->vec.x==edge->v2->vec.x) dir= 'v';
|
|
|
|
else dir= 'h';
|
|
|
|
|
|
|
|
sv= sc->vertbase.first;
|
|
|
|
while(sv) {
|
|
|
|
sv->flag = 0;
|
|
|
|
sv= sv->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
edge->v1->flag= 1;
|
|
|
|
edge->v2->flag= 1;
|
|
|
|
|
|
|
|
oneselected= 1;
|
|
|
|
while(oneselected) {
|
|
|
|
se= sc->edgebase.first;
|
|
|
|
oneselected= 0;
|
|
|
|
while(se) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
if(dir=='v') if(se->v1->vec.x==se->v2->vec.x) {
|
|
|
|
se->v1->flag= se->v2->flag= 1;
|
|
|
|
oneselected= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
se= se->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
/* test if screen vertices should be scaled */
|
2008-11-19 16:28:11 +00:00
|
|
|
static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
|
2008-01-07 18:03:41 +00:00
|
|
|
{
|
|
|
|
ScrVert *sv=NULL;
|
2008-12-14 17:48:52 +00:00
|
|
|
ScrArea *sa;
|
2008-01-10 17:38:17 +00:00
|
|
|
int sizex, sizey;
|
2008-01-07 18:03:41 +00:00
|
|
|
float facx, facy, tempf, min[2], max[2];
|
|
|
|
|
|
|
|
/* calculate size */
|
|
|
|
min[0]= min[1]= 10000.0f;
|
|
|
|
max[0]= max[1]= 0.0f;
|
|
|
|
|
|
|
|
for(sv= sc->vertbase.first; sv; sv= sv->next) {
|
|
|
|
min[0]= MIN2(min[0], sv->vec.x);
|
|
|
|
min[1]= MIN2(min[1], sv->vec.y);
|
|
|
|
max[0]= MAX2(max[0], sv->vec.x);
|
|
|
|
max[1]= MAX2(max[1], sv->vec.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* always make 0.0 left under */
|
|
|
|
for(sv= sc->vertbase.first; sv; sv= sv->next) {
|
|
|
|
sv->vec.x -= min[0];
|
|
|
|
sv->vec.y -= min[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
sizex= max[0]-min[0];
|
|
|
|
sizey= max[1]-min[1];
|
|
|
|
|
|
|
|
if(sizex!= winsizex || sizey!= winsizey) {
|
|
|
|
facx= winsizex;
|
|
|
|
facx/= (float)sizex;
|
|
|
|
facy= winsizey;
|
|
|
|
facy/= (float)sizey;
|
|
|
|
|
|
|
|
/* make sure it fits! */
|
|
|
|
for(sv= sc->vertbase.first; sv; sv= sv->next) {
|
|
|
|
tempf= ((float)sv->vec.x)*facx;
|
|
|
|
sv->vec.x= (short)(tempf+0.5);
|
|
|
|
sv->vec.x+= AREAGRID-1;
|
|
|
|
sv->vec.x-= (sv->vec.x % AREAGRID);
|
|
|
|
|
|
|
|
CLAMP(sv->vec.x, 0, winsizex);
|
|
|
|
|
|
|
|
tempf= ((float)sv->vec.y )*facy;
|
|
|
|
sv->vec.y= (short)(tempf+0.5);
|
|
|
|
sv->vec.y+= AREAGRID-1;
|
|
|
|
sv->vec.y-= (sv->vec.y % AREAGRID);
|
|
|
|
|
|
|
|
CLAMP(sv->vec.y, 0, winsizey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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... */
|
2008-12-14 10:52:48 +00:00
|
|
|
|
|
|
|
/* make each window at least HEADERY high */
|
|
|
|
for(sa= sc->areabase.first; sa; sa= sa->next) {
|
|
|
|
int headery= HEADERY+1;
|
|
|
|
|
|
|
|
if(sa->v1->vec.y+headery > sa->v2->vec.y) {
|
|
|
|
/* lower edge */
|
|
|
|
ScrEdge *se= screen_findedge(sc, sa->v4, sa->v1);
|
|
|
|
if(se && sa->v1!=sa->v2 ) {
|
|
|
|
int yval;
|
|
|
|
|
|
|
|
select_connected_scredge(sc, se);
|
|
|
|
|
|
|
|
/* all selected vertices get the right offset */
|
|
|
|
yval= sa->v2->vec.y-headery;
|
|
|
|
sv= sc->vertbase.first;
|
|
|
|
while(sv) {
|
|
|
|
/* if is a collapsed area */
|
|
|
|
if(sv!=sa->v2 && sv!=sa->v3) {
|
|
|
|
if(sv->flag) sv->vec.y= yval;
|
|
|
|
}
|
|
|
|
sv= sv->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* *********************** DRAWING **************************************** */
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define SCR_BACK 0.55
|
|
|
|
#define SCR_ROUND 12
|
|
|
|
|
2008-01-21 21:36:02 +00:00
|
|
|
/* draw vertical shape visualising future joining (left as well
|
|
|
|
* right direction of future joining) */
|
|
|
|
static void draw_horizontal_join_shape(ScrArea *sa, char dir)
|
|
|
|
{
|
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
|
|
|
vec2f points[10];
|
2008-01-21 21:36:02 +00:00
|
|
|
short i;
|
|
|
|
float w, h;
|
|
|
|
float width = sa->v3->vec.x - sa->v1->vec.x;
|
|
|
|
float height = sa->v3->vec.y - sa->v1->vec.y;
|
|
|
|
|
|
|
|
if(height<width) {
|
|
|
|
h = height/8;
|
|
|
|
w = height/4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
h = width/8;
|
|
|
|
w = width/4;
|
|
|
|
}
|
|
|
|
|
|
|
|
points[0].x = sa->v1->vec.x;
|
|
|
|
points[0].y = sa->v1->vec.y + height/2;
|
|
|
|
|
|
|
|
points[1].x = sa->v1->vec.x;
|
|
|
|
points[1].y = sa->v1->vec.y;
|
|
|
|
|
|
|
|
points[2].x = sa->v4->vec.x - w;
|
|
|
|
points[2].y = sa->v4->vec.y;
|
|
|
|
|
|
|
|
points[3].x = sa->v4->vec.x - w;
|
|
|
|
points[3].y = sa->v4->vec.y + height/2 - 2*h;
|
|
|
|
|
|
|
|
points[4].x = sa->v4->vec.x - 2*w;
|
|
|
|
points[4].y = sa->v4->vec.y + height/2;
|
|
|
|
|
|
|
|
points[5].x = sa->v4->vec.x - w;
|
|
|
|
points[5].y = sa->v4->vec.y + height/2 + 2*h;
|
|
|
|
|
|
|
|
points[6].x = sa->v3->vec.x - w;
|
|
|
|
points[6].y = sa->v3->vec.y;
|
|
|
|
|
|
|
|
points[7].x = sa->v2->vec.x;
|
|
|
|
points[7].y = sa->v2->vec.y;
|
|
|
|
|
|
|
|
points[8].x = sa->v4->vec.x;
|
|
|
|
points[8].y = sa->v4->vec.y + height/2 - h;
|
|
|
|
|
|
|
|
points[9].x = sa->v4->vec.x;
|
|
|
|
points[9].y = sa->v4->vec.y + height/2 + h;
|
|
|
|
|
|
|
|
if(dir=='l') {
|
|
|
|
/* when direction is left, then we flip direction of arrow */
|
|
|
|
float cx = sa->v1->vec.x + width;
|
|
|
|
for(i=0;i<10;i++) {
|
|
|
|
points[i].x -= cx;
|
|
|
|
points[i].x = -points[i].x;
|
|
|
|
points[i].x += sa->v1->vec.x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
glBegin(GL_POLYGON);
|
|
|
|
for(i=0;i<5;i++)
|
|
|
|
glVertex2f(points[i].x, points[i].y);
|
|
|
|
glEnd();
|
|
|
|
glBegin(GL_POLYGON);
|
|
|
|
for(i=4;i<8;i++)
|
|
|
|
glVertex2f(points[i].x, points[i].y);
|
|
|
|
glVertex2f(points[0].x, points[0].y);
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glRectf(points[2].x, points[2].y, points[8].x, points[8].y);
|
|
|
|
glRectf(points[6].x, points[6].y, points[9].x, points[9].y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw vertical shape visualising future joining (up/down direction) */
|
|
|
|
static void draw_vertical_join_shape(ScrArea *sa, char dir)
|
|
|
|
{
|
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
|
|
|
vec2f points[10];
|
2008-01-21 21:36:02 +00:00
|
|
|
short i;
|
|
|
|
float w, h;
|
|
|
|
float width = sa->v3->vec.x - sa->v1->vec.x;
|
|
|
|
float height = sa->v3->vec.y - sa->v1->vec.y;
|
|
|
|
|
|
|
|
if(height<width) {
|
|
|
|
h = height/4;
|
|
|
|
w = height/8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
h = width/4;
|
|
|
|
w = width/8;
|
|
|
|
}
|
|
|
|
|
|
|
|
points[0].x = sa->v1->vec.x + width/2;
|
|
|
|
points[0].y = sa->v3->vec.y;
|
|
|
|
|
|
|
|
points[1].x = sa->v2->vec.x;
|
|
|
|
points[1].y = sa->v2->vec.y;
|
|
|
|
|
|
|
|
points[2].x = sa->v1->vec.x;
|
|
|
|
points[2].y = sa->v1->vec.y + h;
|
|
|
|
|
|
|
|
points[3].x = sa->v1->vec.x + width/2 - 2*w;
|
|
|
|
points[3].y = sa->v1->vec.y + h;
|
|
|
|
|
|
|
|
points[4].x = sa->v1->vec.x + width/2;
|
|
|
|
points[4].y = sa->v1->vec.y + 2*h;
|
|
|
|
|
|
|
|
points[5].x = sa->v1->vec.x + width/2 + 2*w;
|
|
|
|
points[5].y = sa->v1->vec.y + h;
|
|
|
|
|
|
|
|
points[6].x = sa->v4->vec.x;
|
|
|
|
points[6].y = sa->v4->vec.y + h;
|
|
|
|
|
|
|
|
points[7].x = sa->v3->vec.x;
|
|
|
|
points[7].y = sa->v3->vec.y;
|
|
|
|
|
|
|
|
points[8].x = sa->v1->vec.x + width/2 - w;
|
|
|
|
points[8].y = sa->v1->vec.y;
|
|
|
|
|
|
|
|
points[9].x = sa->v1->vec.x + width/2 + w;
|
|
|
|
points[9].y = sa->v1->vec.y;
|
|
|
|
|
|
|
|
if(dir=='u') {
|
|
|
|
/* when direction is up, then we flip direction of arrow */
|
|
|
|
float cy = sa->v1->vec.y + height;
|
|
|
|
for(i=0;i<10;i++) {
|
|
|
|
points[i].y -= cy;
|
|
|
|
points[i].y = -points[i].y;
|
|
|
|
points[i].y += sa->v1->vec.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
glBegin(GL_POLYGON);
|
|
|
|
for(i=0;i<5;i++)
|
|
|
|
glVertex2f(points[i].x, points[i].y);
|
|
|
|
glEnd();
|
|
|
|
glBegin(GL_POLYGON);
|
|
|
|
for(i=4;i<8;i++)
|
|
|
|
glVertex2f(points[i].x, points[i].y);
|
|
|
|
glVertex2f(points[0].x, points[0].y);
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glRectf(points[2].x, points[2].y, points[8].x, points[8].y);
|
|
|
|
glRectf(points[6].x, points[6].y, points[9].x, points[9].y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw join shape due to direction of joining */
|
|
|
|
static void draw_join_shape(ScrArea *sa, char dir)
|
|
|
|
{
|
|
|
|
if(dir=='u' || dir=='d')
|
|
|
|
draw_vertical_join_shape(sa, dir);
|
|
|
|
else
|
|
|
|
draw_horizontal_join_shape(sa, dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw screen area darker with arrow (visualisation of future joining) */
|
|
|
|
static void scrarea_draw_shape_dark(ScrArea *sa, char dir)
|
|
|
|
{
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glColor4ub(0, 0, 0, 50);
|
|
|
|
draw_join_shape(sa, dir);
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw screen area ligher with arrow shape ("eraser" of previous dark shape) */
|
|
|
|
static void scrarea_draw_shape_light(ScrArea *sa, char dir)
|
|
|
|
{
|
|
|
|
glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA);
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
/* value 181 was hardly computed: 181~105 */
|
|
|
|
glColor4ub(255, 255, 255, 50);
|
|
|
|
/* draw_join_shape(sa, dir); */
|
|
|
|
glRecti(sa->v1->vec.x, sa->v1->vec.y, sa->v3->vec.x, sa->v3->vec.y);
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
2009-05-22 15:02:32 +00:00
|
|
|
static void drawscredge_area_draw(int sizex, int sizey, short x1, short y1, short x2, short y2, short a)
|
2008-01-07 18:03:41 +00:00
|
|
|
{
|
|
|
|
/* right border area */
|
2009-05-22 15:02:32 +00:00
|
|
|
if(x2<sizex-1)
|
|
|
|
sdrawline(x2+a, y1, x2+a, y2);
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
/* left border area */
|
2009-05-22 15:02:32 +00:00
|
|
|
if(x1>0) /* otherwise it draws the emboss of window over */
|
|
|
|
sdrawline(x1+a, y1, x1+a, y2);
|
2008-01-16 19:49:34 +00:00
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
/* top border area */
|
2009-05-22 15:02:32 +00:00
|
|
|
if(y2<sizey-1)
|
|
|
|
sdrawline(x1, y2+a, x2, y2+a);
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
/* bottom border area */
|
2009-05-22 15:02:32 +00:00
|
|
|
if(y1>0)
|
|
|
|
sdrawline(x1, y1+a, x2, y1+a);
|
2008-01-16 19:49:34 +00:00
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 15:02:32 +00:00
|
|
|
/** screen edges drawing **/
|
|
|
|
static void drawscredge_area(ScrArea *sa, int sizex, int sizey, int center)
|
|
|
|
{
|
|
|
|
short x1= sa->v1->vec.x;
|
|
|
|
short y1= sa->v1->vec.y;
|
|
|
|
short x2= sa->v3->vec.x;
|
|
|
|
short y2= sa->v3->vec.y;
|
|
|
|
short a, rt;
|
|
|
|
|
|
|
|
rt= CLAMPIS(G.rt, 0, 16);
|
|
|
|
|
|
|
|
if(center==0) {
|
|
|
|
cpack(0x505050);
|
|
|
|
for(a=-rt; a<=rt; a++)
|
|
|
|
if(a!=0)
|
|
|
|
drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, a);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cpack(0x0);
|
|
|
|
drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* ****************** EXPORTED API TO OTHER MODULES *************************** */
|
|
|
|
|
|
|
|
bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc)
|
|
|
|
{
|
|
|
|
bScreen *newsc;
|
|
|
|
|
|
|
|
if(sc->full != SCREENNORMAL) return NULL; /* XXX handle this case! */
|
|
|
|
|
|
|
|
/* make new empty screen: */
|
2009-07-24 12:43:59 +00:00
|
|
|
newsc= ED_screen_add(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 */
|
|
|
|
static void region_cursor_set(wmWindow *win, int swinid)
|
|
|
|
{
|
|
|
|
ScrArea *sa= win->screen->areabase.first;
|
|
|
|
|
|
|
|
for(;sa; sa= sa->next) {
|
|
|
|
ARegion *ar= sa->regionbase.first;
|
|
|
|
for(;ar; ar= ar->next) {
|
|
|
|
if(ar->swinid == swinid) {
|
|
|
|
if(ar->type && ar->type->cursor)
|
|
|
|
ar->type->cursor(win, sa, ar);
|
|
|
|
else
|
|
|
|
WM_cursor_set(win, CURSOR_STD);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2008-01-19 17:54:05 +00:00
|
|
|
void ED_screen_do_listen(wmWindow *win, wmNotifier *note)
|
2008-01-07 18:03:41 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/* generic notes */
|
2008-12-27 16:09:56 +00:00
|
|
|
switch(note->category) {
|
2009-02-07 10:00:46 +00:00
|
|
|
case NC_WM:
|
|
|
|
if(note->data==ND_FILEREAD)
|
|
|
|
win->screen->do_draw= 1;
|
|
|
|
break;
|
2008-12-27 16:09:56 +00:00
|
|
|
case NC_WINDOW:
|
2008-01-19 17:54:05 +00:00
|
|
|
win->screen->do_draw= 1;
|
2008-01-10 17:38:17 +00:00
|
|
|
break;
|
2008-12-27 16:09:56 +00:00
|
|
|
case NC_SCREEN:
|
|
|
|
if(note->action==NA_EDITED)
|
|
|
|
win->screen->do_draw= win->screen->do_refresh= 1;
|
2009-01-04 19:17:34 +00:00
|
|
|
case NC_SCENE:
|
|
|
|
if(note->data==ND_MODE)
|
|
|
|
region_cursor_set(win, note->swinid);
|
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
|
|
|
}
|
|
|
|
|
2008-12-16 12:28:00 +00:00
|
|
|
/* only for edge lines between areas, and the blended join arrows */
|
2008-01-07 18:03:41 +00:00
|
|
|
void ED_screen_draw(wmWindow *win)
|
|
|
|
{
|
|
|
|
ScrArea *sa;
|
2008-01-21 21:36:02 +00:00
|
|
|
ScrArea *sa1=NULL;
|
|
|
|
ScrArea *sa2=NULL;
|
|
|
|
int dir = -1;
|
|
|
|
int dira = -1;
|
|
|
|
|
2008-12-19 14:14:43 +00:00
|
|
|
wmSubWindowSet(win, win->screen->mainwin);
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2008-01-21 21:36:02 +00:00
|
|
|
for(sa= win->screen->areabase.first; sa; sa= sa->next) {
|
|
|
|
if (sa->flag & AREA_FLAG_DRAWJOINFROM) sa1 = sa;
|
|
|
|
if (sa->flag & AREA_FLAG_DRAWJOINTO) sa2 = sa;
|
2009-05-22 15:02:32 +00:00
|
|
|
drawscredge_area(sa, win->sizex, win->sizey, 0);
|
2008-01-21 21:36:02 +00:00
|
|
|
}
|
2009-05-22 15:02:32 +00:00
|
|
|
for(sa= win->screen->areabase.first; sa; sa= sa->next)
|
|
|
|
drawscredge_area(sa, win->sizex, win->sizey, 1);
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* blended join arrow */
|
2008-01-21 21:36:02 +00:00
|
|
|
if (sa1 && sa2) {
|
|
|
|
dir = area_getorientation(win->screen, sa1, sa2);
|
|
|
|
if (dir >= 0) {
|
|
|
|
switch(dir) {
|
|
|
|
case 0: /* W */
|
|
|
|
dir = 'r';
|
|
|
|
dira = 'l';
|
|
|
|
break;
|
|
|
|
case 1: /* N */
|
|
|
|
dir = 'd';
|
|
|
|
dira = 'u';
|
|
|
|
break;
|
|
|
|
case 2: /* E */
|
|
|
|
dir = 'l';
|
|
|
|
dira = 'r';
|
|
|
|
break;
|
|
|
|
case 3: /* S */
|
|
|
|
dir = 'u';
|
|
|
|
dira = 'd';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
scrarea_draw_shape_dark(sa2, dir);
|
|
|
|
scrarea_draw_shape_light(sa1, dira);
|
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2009-02-07 15:44:16 +00:00
|
|
|
// if(G.f & G_DEBUG) printf("draw screen\n");
|
2008-01-07 18:03:41 +00:00
|
|
|
win->screen->do_draw= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
|
|
|
ScrArea *sa;
|
2008-12-06 16:22:21 +00:00
|
|
|
rcti winrct= {0, win->sizex-1, 0, win->sizey-1};
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
screen_test_scale(win->screen, win->sizex, win->sizey);
|
|
|
|
|
|
|
|
if(win->screen->mainwin==0)
|
|
|
|
win->screen->mainwin= wm_subwindow_open(win, &winrct);
|
|
|
|
else
|
|
|
|
wm_subwindow_position(win, win->screen->mainwin, &winrct);
|
|
|
|
|
|
|
|
for(sa= win->screen->areabase.first; sa; sa= sa->next) {
|
2008-12-10 13:56:54 +00:00
|
|
|
/* set spacetype and region callbacks, calls init() */
|
|
|
|
/* sets subwindows for regions, adds handlers */
|
2008-01-07 18:03:41 +00:00
|
|
|
ED_area_initialize(wm, win, 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
|
|
|
|
2008-12-22 12:57:53 +00:00
|
|
|
/* wake up animtimer */
|
|
|
|
if(win->screen->animtimer)
|
|
|
|
WM_event_window_timer_sleep(win, win->screen->animtimer, 0);
|
|
|
|
|
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
|
|
|
if(G.f & G_DEBUG) printf("set screen\n");
|
2008-01-07 18:03:41 +00:00
|
|
|
win->screen->do_refresh= 0;
|
2008-12-23 02:07:13 +00:00
|
|
|
|
|
|
|
win->screen->context= ed_screen_context;
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* file read, set all screens, ... */
|
|
|
|
void ED_screens_initialize(wmWindowManager *wm)
|
|
|
|
{
|
|
|
|
wmWindow *win;
|
|
|
|
|
|
|
|
for(win= wm->windows.first; win; win= win->next) {
|
|
|
|
|
|
|
|
if(win->screen==NULL)
|
|
|
|
win->screen= G.main->screen.first;
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2008-12-18 02:56:48 +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
|
|
|
|
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);
|
2008-12-18 14:53:39 +00:00
|
|
|
if(ar->swinid)
|
|
|
|
wm_subwindow_close(CTX_wm_window(C), ar->swinid);
|
|
|
|
ar->swinid= 0;
|
|
|
|
|
2008-12-21 17:18:36 +00:00
|
|
|
if(ar->headerstr)
|
|
|
|
MEM_freeN(ar->headerstr);
|
|
|
|
ar->headerstr= NULL;
|
|
|
|
|
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)
|
|
|
|
{
|
2008-12-18 02:56:48 +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;
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
CTX_wm_area_set(C, 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
|
|
|
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
|
|
|
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)
|
|
|
|
{
|
2008-12-18 02:56:48 +00:00
|
|
|
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);
|
2008-12-17 19:40:19 +00:00
|
|
|
|
2008-12-22 12:57:53 +00:00
|
|
|
if(screen->animtimer)
|
|
|
|
WM_event_remove_window_timer(window, screen->animtimer);
|
|
|
|
screen->animtimer= NULL;
|
|
|
|
|
2009-02-07 19:37:29 +00:00
|
|
|
if(screen->mainwin)
|
|
|
|
wm_subwindow_close(window, screen->mainwin);
|
|
|
|
screen->mainwin= 0;
|
|
|
|
screen->subwinactive= 0;
|
|
|
|
|
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
|
|
|
for(ar= screen->regionbase.first; ar; ar= ar->next)
|
|
|
|
ED_region_exit(C, ar);
|
|
|
|
|
|
|
|
for(sa= screen->areabase.first; sa; sa= sa->next)
|
|
|
|
ED_area_exit(C, sa);
|
|
|
|
|
2009-02-07 19:37:29 +00:00
|
|
|
/* mark it available for use for other windows */
|
|
|
|
screen->winid= 0;
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
CTX_wm_window_set(C, prevwin);
|
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 */
|
2008-12-15 16:54:47 +00:00
|
|
|
static void screen_cursor_set(wmWindow *win, wmEvent *event)
|
|
|
|
{
|
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
|
|
|
AZone *az= NULL;
|
2008-12-15 16:54:47 +00:00
|
|
|
ScrArea *sa;
|
|
|
|
|
|
|
|
for(sa= win->screen->areabase.first; sa; sa= sa->next)
|
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
|
|
|
if((az=is_in_area_actionzone(sa, event->x, event->y)))
|
2008-12-15 16:54:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if(sa) {
|
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
|
|
|
if(az->type==AZONE_AREA)
|
|
|
|
WM_cursor_set(win, CURSOR_EDIT);
|
|
|
|
else if(az->type==AZONE_REGION) {
|
|
|
|
if(az->x1==az->x2)
|
|
|
|
WM_cursor_set(win, CURSOR_X_MOVE);
|
|
|
|
else
|
|
|
|
WM_cursor_set(win, CURSOR_Y_MOVE);
|
|
|
|
}
|
2008-12-15 16:54:47 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ScrEdge *actedge= screen_find_active_scredge(win->screen, event->x, event->y);
|
|
|
|
|
2008-12-17 15:51:32 +00:00
|
|
|
if (actedge) {
|
|
|
|
if(scredge_is_horizontal(actedge))
|
|
|
|
WM_cursor_set(win, CURSOR_Y_MOVE);
|
|
|
|
else
|
|
|
|
WM_cursor_set(win, CURSOR_X_MOVE);
|
2008-12-15 16:54:47 +00:00
|
|
|
}
|
2008-12-17 15:51:32 +00:00
|
|
|
else
|
|
|
|
WM_cursor_set(win, CURSOR_STD);
|
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 */
|
2008-12-15 18:43:18 +00:00
|
|
|
void ED_screen_set_subwinactive(wmWindow *win, wmEvent *event)
|
2008-01-10 17:38:17 +00:00
|
|
|
{
|
|
|
|
if(win->screen) {
|
2008-12-15 18:43:18 +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;
|
2008-12-15 18:43:18 +00:00
|
|
|
int oldswin= scr->subwinactive;
|
|
|
|
|
|
|
|
for(sa= scr->areabase.first; sa; sa= sa->next) {
|
2008-01-10 17:38:17 +00:00
|
|
|
if(event->x > sa->totrct.xmin && event->x < sa->totrct.xmax)
|
|
|
|
if(event->y > sa->totrct.ymin && event->y < sa->totrct.ymax)
|
2008-12-15 16:54:47 +00:00
|
|
|
if(NULL==is_in_area_actionzone(sa, event->x, event->y))
|
|
|
|
break;
|
2008-01-10 17:38:17 +00:00
|
|
|
}
|
|
|
|
if(sa) {
|
|
|
|
for(ar= sa->regionbase.first; ar; ar= ar->next) {
|
|
|
|
if(BLI_in_rcti(&ar->winrct, event->x, event->y))
|
2008-12-15 18:43:18 +00:00
|
|
|
scr->subwinactive= ar->swinid;
|
2008-01-10 17:38:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2008-12-15 18:43:18 +00:00
|
|
|
scr->subwinactive= scr->mainwin;
|
2008-01-10 17:38:17 +00:00
|
|
|
|
2008-12-10 17:58:18 +00:00
|
|
|
/* check for redraw headers */
|
2008-12-15 18:43:18 +00:00
|
|
|
if(oldswin!=scr->subwinactive) {
|
2008-12-15 16:54:47 +00:00
|
|
|
|
2008-12-15 18:43:18 +00:00
|
|
|
for(sa= scr->areabase.first; sa; sa= sa->next) {
|
2008-12-10 17:58:18 +00:00
|
|
|
int do_draw= 0;
|
|
|
|
|
|
|
|
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
2008-12-15 18:43:18 +00:00
|
|
|
if(ar->swinid==oldswin || ar->swinid==scr->subwinactive)
|
2008-12-10 17:58:18 +00:00
|
|
|
do_draw= 1;
|
|
|
|
|
2008-12-11 14:59:57 +00:00
|
|
|
if(do_draw) {
|
2008-12-10 17:58:18 +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
|
|
|
}
|
|
|
|
}
|
2008-12-15 16:54:47 +00:00
|
|
|
|
|
|
|
/* cursors, for time being set always on edges, otherwise aregion doesnt switch */
|
2008-12-15 18:43:18 +00:00
|
|
|
if(scr->subwinactive==scr->mainwin) {
|
2008-12-15 16:54:47 +00:00
|
|
|
screen_cursor_set(win, event);
|
|
|
|
}
|
2008-12-15 18:43:18 +00:00
|
|
|
else if(oldswin!=scr->subwinactive) {
|
2009-01-04 19:17:34 +00:00
|
|
|
region_cursor_set(win, scr->subwinactive);
|
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)
|
|
|
|
{
|
2008-12-18 02:56:48 +00:00
|
|
|
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
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
if(sc && sa) {
|
2008-12-10 17:58:18 +00:00
|
|
|
ARegion *ar;
|
2008-12-18 02:56:48 +00:00
|
|
|
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
|
|
|
if(ar->swinid == sc->subwinactive)
|
2008-12-10 17:58:18 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2008-12-17 17:33:45 +00:00
|
|
|
|
|
|
|
/* operator call, WM + Window + screen already existed before */
|
|
|
|
/* Do NOT call in area/region queues! */
|
2009-02-07 19:37:29 +00:00
|
|
|
void ED_screen_set(bContext *C, bScreen *sc)
|
2008-12-17 17:33:45 +00:00
|
|
|
{
|
2009-02-07 19:37:29 +00:00
|
|
|
wmWindow *win= CTX_wm_window(C);
|
2008-12-22 12:57:53 +00:00
|
|
|
bScreen *oldscreen= CTX_wm_screen(C);
|
2009-02-07 19:37:29 +00:00
|
|
|
ID *id;
|
|
|
|
|
|
|
|
/* validate screen, it's called with notifier reference */
|
|
|
|
for(id= CTX_data_main(C)->screen.first; id; id= id->next)
|
|
|
|
if(sc == (bScreen *)id)
|
|
|
|
break;
|
|
|
|
if(id==NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* check for valid winid */
|
|
|
|
if(sc->winid!=0 && sc->winid!=win->winid)
|
|
|
|
return;
|
2008-12-22 12:57:53 +00:00
|
|
|
|
2008-12-17 17:33:45 +00:00
|
|
|
if(sc->full) { /* find associated full */
|
|
|
|
bScreen *sc1;
|
2009-02-07 19:37:29 +00:00
|
|
|
for(sc1= CTX_data_main(C)->screen.first; sc1; sc1= sc1->id.next) {
|
2008-12-17 17:33:45 +00:00
|
|
|
ScrArea *sa= sc1->areabase.first;
|
|
|
|
if(sa->full==sc) {
|
|
|
|
sc= sc1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-22 12:57:53 +00:00
|
|
|
if (oldscreen != sc) {
|
|
|
|
wmTimer *wt= oldscreen->animtimer;
|
|
|
|
|
|
|
|
/* we put timer to sleep, so screen_exit has to think there's no timer */
|
|
|
|
oldscreen->animtimer= NULL;
|
|
|
|
if(wt)
|
2009-01-06 19:49:45 +00:00
|
|
|
WM_event_window_timer_sleep(win, wt, 1);
|
2008-12-22 12:57:53 +00:00
|
|
|
|
2009-01-06 19:49:45 +00:00
|
|
|
ED_screen_exit(C, win, oldscreen);
|
2008-12-22 12:57:53 +00:00
|
|
|
oldscreen->animtimer= wt;
|
|
|
|
|
2009-01-06 19:49:45 +00:00
|
|
|
win->screen= sc;
|
|
|
|
CTX_wm_window_set(C, win); // stores C->wm.screen... hrmf
|
2008-12-17 17:33:45 +00:00
|
|
|
|
2009-02-07 19:37:29 +00:00
|
|
|
/* prevent multiwin errors */
|
|
|
|
sc->winid= win->winid;
|
|
|
|
|
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);
|
2009-06-06 13:35:04 +00:00
|
|
|
|
|
|
|
/* makes button hilites work */
|
|
|
|
WM_event_add_mousemove(C);
|
2008-12-17 17:33:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
static int ed_screen_used(wmWindowManager *wm, bScreen *sc)
|
|
|
|
{
|
|
|
|
wmWindow *win;
|
|
|
|
|
|
|
|
for(win=wm->windows.first; win; win=win->next)
|
|
|
|
if(win->screen == sc)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only call outside of area/region loops */
|
|
|
|
void ED_screen_delete(bContext *C, bScreen *sc)
|
|
|
|
{
|
|
|
|
Main *bmain= CTX_data_main(C);
|
|
|
|
wmWindowManager *wm= CTX_wm_manager(C);
|
|
|
|
wmWindow *win= CTX_wm_window(C);
|
|
|
|
bScreen *newsc;
|
|
|
|
int delete= 1;
|
|
|
|
|
|
|
|
/* screen can only be in use by one window at a time, so as
|
|
|
|
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 */
|
|
|
|
|
|
|
|
for(newsc= sc->id.prev; newsc; newsc=newsc->id.prev)
|
|
|
|
if(!ed_screen_used(wm, newsc))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if(!newsc) {
|
|
|
|
for(newsc= sc->id.next; newsc; newsc=newsc->id.next)
|
|
|
|
if(!ed_screen_used(wm, newsc))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!newsc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ED_screen_set(C, newsc);
|
|
|
|
|
|
|
|
if(delete && win->screen != sc)
|
|
|
|
free_libblock(&bmain->screen, sc);
|
|
|
|
}
|
|
|
|
|
2009-02-08 12:16:35 +00:00
|
|
|
/* only call outside of area/region loops */
|
|
|
|
void ED_screen_set_scene(bContext *C, Scene *scene)
|
|
|
|
{
|
|
|
|
bScreen *sc;
|
|
|
|
bScreen *curscreen= CTX_wm_screen(C);
|
|
|
|
|
|
|
|
for(sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) {
|
|
|
|
if((U.flag & USER_SCENEGLOBAL) || sc==curscreen) {
|
|
|
|
|
|
|
|
if(scene != sc->scene) {
|
|
|
|
/* all areas endlocalview */
|
|
|
|
// XXX ScrArea *sa= sc->areabase.first;
|
|
|
|
// while(sa) {
|
|
|
|
// endlocalview(sa);
|
|
|
|
// sa= sa->next;
|
|
|
|
// }
|
|
|
|
sc->scene= scene;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// copy_view3d_lock(0); /* space.c */
|
|
|
|
|
|
|
|
/* are there cameras in the views that are not in the scene? */
|
|
|
|
for(sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) {
|
|
|
|
if( (U.flag & USER_SCENEGLOBAL) || sc==curscreen) {
|
|
|
|
ScrArea *sa= sc->areabase.first;
|
|
|
|
while(sa) {
|
|
|
|
SpaceLink *sl= sa->spacedata.first;
|
|
|
|
while(sl) {
|
|
|
|
if(sl->spacetype==SPACE_VIEW3D) {
|
|
|
|
View3D *v3d= (View3D*) sl;
|
|
|
|
if (!v3d->camera || !object_in_scene(v3d->camera, scene)) {
|
|
|
|
v3d->camera= scene_find_camera(sc->scene);
|
|
|
|
// XXX if (sc==curscreen) handle_view3d_lock();
|
|
|
|
if (!v3d->camera && v3d->persp==V3D_CAMOB)
|
|
|
|
v3d->persp= V3D_PERSP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sl= sl->next;
|
|
|
|
}
|
|
|
|
sa= sa->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CTX_data_scene_set(C, scene);
|
|
|
|
set_scene_bg(scene);
|
|
|
|
|
|
|
|
ED_update_for_newframe(C, 1);
|
|
|
|
|
|
|
|
/* complete redraw */
|
|
|
|
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/* only call outside of area/region loops */
|
|
|
|
void ED_screen_delete_scene(bContext *C, Scene *scene)
|
|
|
|
{
|
|
|
|
Main *bmain= CTX_data_main(C);
|
|
|
|
Scene *newscene;
|
|
|
|
|
|
|
|
if(scene->id.prev)
|
|
|
|
newscene= scene->id.prev;
|
|
|
|
else if(scene->id.next)
|
|
|
|
newscene= scene->id.next;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
ED_screen_set_scene(C, newscene);
|
|
|
|
|
|
|
|
unlink_scene(bmain, scene, newscene);
|
|
|
|
}
|
|
|
|
|
2008-12-17 19:40:19 +00:00
|
|
|
/* this function toggles: if area is full then the parent will be restored */
|
2009-02-04 17:40:50 +00:00
|
|
|
void ed_screen_fullarea(bContext *C, ScrArea *sa)
|
2008-12-17 19:40:19 +00:00
|
|
|
{
|
|
|
|
bScreen *sc, *oldscreen;
|
|
|
|
|
2009-01-20 19:03:26 +00:00
|
|
|
if(sa==NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(sa->full) {
|
|
|
|
short fulltype;
|
|
|
|
|
|
|
|
sc= sa->full; /* the old screen to restore */
|
2008-12-18 02:56:48 +00:00
|
|
|
oldscreen= CTX_wm_screen(C); /* the one disappearing */
|
2008-12-17 19:40:19 +00:00
|
|
|
|
|
|
|
fulltype = sc->full;
|
|
|
|
|
|
|
|
/* refuse to go out of SCREENAUTOPLAY as long as G_FLAGS_AUTOPLAY
|
|
|
|
is set */
|
|
|
|
|
|
|
|
if (fulltype != SCREENAUTOPLAY || (G.flags & G_FILE_AUTOPLAY) == 0) {
|
2009-01-20 19:03:26 +00:00
|
|
|
ScrArea *old;
|
|
|
|
|
2008-12-17 19:40:19 +00:00
|
|
|
sc->full= 0;
|
|
|
|
|
|
|
|
/* find old area */
|
|
|
|
for(old= sc->areabase.first; old; old= old->next)
|
|
|
|
if(old->full) break;
|
|
|
|
if(old==NULL) {
|
|
|
|
printf("something wrong in areafullscreen\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// old feature described below (ton)
|
|
|
|
// in autoplay screens the headers are disabled by
|
|
|
|
// default. So use the old headertype instead
|
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
area_copy_data(old, sa, 1); /* 1 = swap spacelist */
|
2008-12-17 19:40:19 +00:00
|
|
|
|
|
|
|
old->full= NULL;
|
|
|
|
|
2008-12-22 12:57:53 +00:00
|
|
|
/* animtimer back */
|
|
|
|
sc->animtimer= oldscreen->animtimer;
|
|
|
|
oldscreen->animtimer= NULL;
|
|
|
|
|
2009-02-07 19:37:29 +00:00
|
|
|
ED_screen_set(C, sc);
|
2008-12-17 19:40:19 +00:00
|
|
|
|
|
|
|
free_screen(oldscreen);
|
2009-02-08 12:16:35 +00:00
|
|
|
free_libblock(&CTX_data_main(C)->screen, oldscreen);
|
2008-12-17 19:40:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2009-01-20 19:03:26 +00:00
|
|
|
ScrArea *newa;
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
oldscreen= CTX_wm_screen(C);
|
|
|
|
|
2008-12-17 19:40:19 +00:00
|
|
|
/* is there only 1 area? */
|
2009-02-04 17:40:50 +00:00
|
|
|
if(oldscreen->areabase.first==oldscreen->areabase.last) return;
|
2008-12-17 19:40:19 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
oldscreen->full = SCREENFULL;
|
2008-12-17 19:40:19 +00:00
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
sc= ED_screen_add(CTX_wm_window(C), CTX_data_scene(C), "temp");
|
2009-02-07 19:37:29 +00:00
|
|
|
sc->full = SCREENFULL; // XXX
|
2008-12-17 19:40:19 +00:00
|
|
|
|
2008-12-22 12:57:53 +00:00
|
|
|
/* timer */
|
|
|
|
sc->animtimer= oldscreen->animtimer;
|
|
|
|
oldscreen->animtimer= NULL;
|
|
|
|
|
2008-12-17 19:40:19 +00:00
|
|
|
/* returns the top small area */
|
2008-12-18 02:56:48 +00:00
|
|
|
newa= area_split(CTX_wm_window(C), sc, (ScrArea *)sc->areabase.first, 'h', 0.99f);
|
2009-01-06 18:14:37 +00:00
|
|
|
ED_area_newspace(C, newa, SPACE_INFO);
|
2008-12-17 19:40:19 +00:00
|
|
|
|
|
|
|
/* copy area */
|
|
|
|
newa= newa->prev;
|
2009-02-04 17:40:50 +00:00
|
|
|
area_copy_data(newa, sa, 1); /* 1 = swap spacelist */
|
2008-12-17 19:40:19 +00:00
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
sa->full= oldscreen;
|
2008-12-17 19:40:19 +00:00
|
|
|
newa->full= oldscreen;
|
2009-02-07 19:37:29 +00:00
|
|
|
newa->next->full= oldscreen; // XXX
|
2008-12-17 19:40:19 +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
|
|
|
|
|
|
|
/* XXX retopo_force_update(); */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-02-08 12:16:35 +00:00
|
|
|
int ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
|
2009-01-06 18:52:18 +00:00
|
|
|
{
|
2009-02-08 12:16:35 +00:00
|
|
|
if(sa==NULL)
|
|
|
|
return 0;
|
|
|
|
|
2009-01-06 18:52:18 +00:00
|
|
|
if(sa->full==0)
|
2009-02-04 17:40:50 +00:00
|
|
|
ed_screen_fullarea(C, sa);
|
2009-01-06 18:52:18 +00:00
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
/* CTX_wm_area(C) is new area */
|
2009-01-06 18:52:18 +00:00
|
|
|
ED_area_newspace(C, CTX_wm_area(C), type);
|
2009-02-08 12:16:35 +00:00
|
|
|
|
|
|
|
return 1;
|
2009-01-06 18:52:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ED_screen_full_prevspace(bContext *C)
|
|
|
|
{
|
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
|
|
|
|
|
|
|
ED_area_prevspace(C);
|
|
|
|
|
|
|
|
if(sa->full)
|
2009-02-04 17:40:50 +00:00
|
|
|
ed_screen_fullarea(C, sa);
|
2009-01-06 18:52:18 +00:00
|
|
|
}
|
|
|
|
|
2009-07-07 07:29:21 +00:00
|
|
|
/* redraws: uses defines from stime->redraws
|
|
|
|
* enable: 1 - forward on, -1 - backwards on, 0 - off
|
|
|
|
*/
|
2009-08-16 20:37:22 +00:00
|
|
|
void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable)
|
2008-12-21 19:58:25 +00:00
|
|
|
{
|
2008-12-22 12:57:53 +00:00
|
|
|
bScreen *screen= CTX_wm_screen(C);
|
|
|
|
wmWindow *win= CTX_wm_window(C);
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
2008-12-21 19:58:25 +00:00
|
|
|
|
2008-12-22 12:57:53 +00:00
|
|
|
if(screen->animtimer)
|
|
|
|
WM_event_remove_window_timer(win, screen->animtimer);
|
|
|
|
screen->animtimer= NULL;
|
2008-12-21 19:58:25 +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
|
|
|
if(enable) {
|
2009-08-17 22:27:08 +00:00
|
|
|
struct ScreenAnimData *sad= MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData");
|
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
|
|
|
|
2008-12-26 13:29:47 +00:00
|
|
|
screen->animtimer= WM_event_add_window_timer(win, TIMER0, (1.0/FPS));
|
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
|
|
|
sad->ar= CTX_wm_region(C);
|
|
|
|
sad->redraws= redraws;
|
2009-08-17 10:39:03 +00:00
|
|
|
sad->flag |= (enable < 0)? ANIMPLAY_FLAG_REVERSE: 0;
|
|
|
|
sad->flag |= (sync == 0)? ANIMPLAY_FLAG_NO_SYNC: (sync == 1)? ANIMPLAY_FLAG_SYNC: 0;
|
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
|
|
|
screen->animtimer->customdata= sad;
|
|
|
|
|
|
|
|
}
|
|
|
|
/* notifier catched by top header, for button */
|
|
|
|
WM_event_add_notifier(C, NC_SCREEN|ND_ANIMPLAY, screen);
|
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)
|
|
|
|
{
|
|
|
|
ARegion *aret= NULL;
|
|
|
|
ScrArea *sa;
|
|
|
|
int min= 10000;
|
|
|
|
|
|
|
|
for(sa= screen->areabase.first; sa; sa= sa->next) {
|
|
|
|
if(sa->spacetype==SPACE_VIEW3D) {
|
|
|
|
ARegion *ar;
|
|
|
|
for(ar= sa->regionbase.first; ar; ar= ar->next) {
|
|
|
|
if(ar->regiontype==RGN_TYPE_WINDOW) {
|
|
|
|
if(ar->winrct.xmin - ar->winrct.ymin < min) {
|
|
|
|
aret= ar;
|
|
|
|
min= ar->winrct.xmin - ar->winrct.ymin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_screen_animation_timer_update(bContext *C, int redraws)
|
|
|
|
{
|
|
|
|
bScreen *screen= CTX_wm_screen(C);
|
|
|
|
|
|
|
|
if(screen && screen->animtimer) {
|
|
|
|
wmTimer *wt= screen->animtimer;
|
|
|
|
ScreenAnimData *sad= wt->customdata;
|
|
|
|
|
|
|
|
sad->redraws= redraws;
|
|
|
|
sad->ar= NULL;
|
|
|
|
if(redraws & TIME_REGION)
|
|
|
|
sad->ar= time_top_left_3dwindow(screen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
/* results in fully updated anim system */
|
|
|
|
void ED_update_for_newframe(const bContext *C, int mute)
|
|
|
|
{
|
|
|
|
bScreen *screen= CTX_wm_screen(C);
|
|
|
|
Scene *scene= screen->scene;
|
|
|
|
|
|
|
|
//extern void audiostream_scrub(unsigned int frame); /* seqaudio.c */
|
|
|
|
|
|
|
|
/* this function applies the changes too */
|
|
|
|
/* XXX future: do all windows */
|
2009-09-14 12:26:34 +00:00
|
|
|
scene_update_for_newframe(scene, BKE_screen_visible_layers(screen)); /* BKE_scene.h */
|
2009-02-04 17:40:50 +00:00
|
|
|
|
2009-08-16 22:49:17 +00:00
|
|
|
//if ( (CFRA>1) && (!mute) && (scene->r.audio.flag & AUDIO_SCRUB))
|
2009-02-04 17:40:50 +00:00
|
|
|
// audiostream_scrub( CFRA );
|
|
|
|
|
|
|
|
/* 3d window, preview */
|
|
|
|
//BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
|
|
|
|
|
|
|
|
/* all movie/sequence images */
|
|
|
|
//BIF_image_update_frame();
|
|
|
|
|
|
|
|
/* composite */
|
|
|
|
if(scene->use_nodes && scene->nodetree)
|
|
|
|
ntreeCompositTagAnimated(scene->nodetree);
|
|
|
|
|
|
|
|
/* update animated texture nodes */
|
|
|
|
{
|
|
|
|
Tex *tex;
|
2009-02-08 12:16:35 +00:00
|
|
|
for(tex= CTX_data_main(C)->tex.first; tex; tex= tex->id.next)
|
2009-02-04 17:40:50 +00:00
|
|
|
if( tex->use_nodes && tex->nodetree ) {
|
|
|
|
ntreeTexTagAnimated( tex->nodetree );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|