diff options
author | Nathan Letwory <nathan@letworyinteractive.com> | 2008-01-17 08:33:54 +0300 |
---|---|---|
committer | Nathan Letwory <nathan@letworyinteractive.com> | 2008-01-17 08:33:54 +0300 |
commit | 0e476af66e54f72884a2a407fba91cf2c1688193 (patch) | |
tree | 0539cf1e893cb40f99041f0aefda409991bca24c /source/blender/editors | |
parent | 7e14c5d119470c066fd76325dced68486117d91a (diff) |
* Start ActionZone support for areas. This is bScreen level stuff to be able to do funky stuff.
Right now 2 AZones are defined for each new ScrArea, and mouse over is now detected. Enter ugly triangle.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_screen_types.h | 63 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 99 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 42 |
3 files changed, 200 insertions, 4 deletions
diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h new file mode 100644 index 00000000000..ee19210b74d --- /dev/null +++ b/source/blender/editors/include/ED_screen_types.h @@ -0,0 +1,63 @@ +/** + * $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. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef ED_SCREEN_TYPES_H__ +#define ED_SCREEN_TYPES_H__ + +typedef struct AZone { + struct AZone *next, *prev; + int type; + int flag; + int action; + int pos; + short x1, y1, x2, y2; +} AZone; + +#define MAX_AZONES 8 + + +/* actionzone type */ +#define AZONE_TRI 1 +#define AZONE_QUAD 2 + +/* actionzone action */ +#define AZONE_SPLIT 1 +#define AZONE_JOIN 2 +#define AZONE_DRAG 3 + +/* actionzone pos */ +#define AZONE_S 1 +#define AZONE_SW 2 +#define AZONE_W 3 +#define AZONE_NW 4 +#define AZONE_N 5 +#define AZONE_NE 6 +#define AZONE_E 7 +#define AZONE_SE 8 + +#endif /* ED_SCREEN_TYPES_H__ */ diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index e12bd82c627..188e4be72e2 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -41,6 +41,7 @@ #include "ED_area.h" #include "ED_screen.h" +#include "ED_screen_types.h" #include "WM_api.h" #include "WM_types.h" @@ -259,6 +260,95 @@ static void area_calc_totrct(ScrArea *sa, int sizex, int sizey) sa->winy= sa->totrct.ymax-sa->totrct.ymin+1; } +void area_azone_initialize(ScrArea *sa) { + AZone *az; + if(sa->actionzones.first==NULL) { + printf("area_azone_initialize\n"); + /* set action zones - should these actually be ARegions? With these we can easier check area hotzones */ + az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + BLI_addtail(&(sa->actionzones), az); + az->type= AZONE_TRI; + az->x1= sa->v1->vec.x+1; + az->y1= sa->v1->vec.y+1; + az->x2= sa->v1->vec.x+HEADERY; + az->y2= sa->v1->vec.y+HEADERY; + az->pos= AZONE_SW; + az->action= AZONE_SPLIT; + + az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + BLI_addtail(&(sa->actionzones), az); + az->type= AZONE_TRI; + az->x1= sa->v3->vec.x-1; + az->y1= sa->v3->vec.y-1; + az->x2= sa->v3->vec.x-HEADERY; + az->y2= sa->v3->vec.y-HEADERY; + az->pos= AZONE_NE; + az->action= AZONE_DRAG; + + /*az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + BLI_addtail(&sa->azones, az); + az->type= AZONE_TRI; + az->x1= as->v1->vec.x; + az->y1= as->v1->vec.y; + az->x2= as->v1->vec.x+HEADERY; + az->y2= as->v1->vec.y+HEADERY; + + az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + BLI_addtail(&sa->azones, az); + az->type= AZONE_TRI; + az->x1= as->v1->vec.x; + az->y1= as->v1->vec.y; + az->x2= as->v1->vec.x+HEADERY; + az->y2= as->v1->vec.y+HEADERY; + + az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + BLI_addtail(&sa->azones, az); + az->type= AZONE_QUAD; + az->x1= as->v1->vec.x; + az->y1= as->v1->vec.y; + az->x2= as->v1->vec.x+HEADERY; + az->y2= as->v1->vec.y+HEADERY; + + az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + BLI_addtail(&sa->azones, az); + az->type= AZONE_QUAD; + az->x1= as->v1->vec.x; + az->y1= as->v1->vec.y; + az->x2= as->v1->vec.x+HEADERY; + az->y2= as->v1->vec.y+HEADERY; + + az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + BLI_addtail(&sa->azones, az); + az->type= AZONE_QUAD; + az->x1= as->v1->vec.x; + az->y1= as->v1->vec.y; + az->x2= as->v1->vec.x+HEADERY; + az->y2= as->v1->vec.y+HEADERY; + + az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + BLI_addtail(&sa->azones, az); + az->type= AZONE_QUAD; + az->x1= as->v1->vec.x; + az->y1= as->v1->vec.y; + az->x2= as->v1->vec.x+HEADERY; + az->y2= as->v1->vec.y+HEADERY;*/ + } + + for(az= sa->actionzones.first; az; az= az->next) { + if(az->pos==AZONE_SW) { + az->x1= sa->v1->vec.x+1; + az->y1= sa->v1->vec.y+1; + az->x2= sa->v1->vec.x+HEADERY; + az->y2= sa->v1->vec.y+HEADERY; + } else if (az->pos==AZONE_NE) { + az->x1= sa->v3->vec.x-1; + az->y1= sa->v3->vec.y-1; + az->x2= sa->v3->vec.x-HEADERY; + az->y2= sa->v3->vec.y-HEADERY; + } + } +} + /* called in screen_refresh, or screens_init */ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) { @@ -294,6 +384,8 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) else wm_subwindow_position(win, ar->swinid, &ar->winrct); } + + area_azone_initialize(sa); } /* sa2 to sa1, we swap spaces for fullscreen to keep all allocated data */ @@ -303,6 +395,7 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) { Panel *pa1, *pa2, *patab; ARegion *ar; + AZone *az; sa1->headertype= sa2->headertype; sa1->spacetype= sa2->spacetype; @@ -342,6 +435,12 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) for(ar= sa1->regionbase.first; ar; ar= ar->next) ar->swinid= 0; + /* azones */ + BLI_freelistN(&sa1->actionzones); + BLI_duplicatelist(&sa1->actionzones, &sa2->actionzones); + for(az= sa1->actionzones.first; az; az= az->next) + az->flag= 0; + /* scripts */ BPY_free_scriptlink(&sa1->scriptlink); sa1->scriptlink= sa2->scriptlink; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index fc15a14a974..acf21e63d5a 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -27,6 +27,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_arithb.h" #include "BKE_global.h" #include "BKE_library.h" @@ -43,7 +44,7 @@ #include "ED_area.h" #include "ED_screen.h" - +#include "ED_screen_types.h" #include "wm_subwindow.h" @@ -141,6 +142,23 @@ static ScrArea *screen_areahascursor(bScreen *scr, int x, int y) return sa; } +static AZone *is_in_area_actionzone(ScrArea *sa, int x, int y) +{ + AZone *az= NULL; + int i= 0; + + for(az= sa->actionzones.first, i= 0; az; az= az->next, i++) { + if(az->type == AZONE_TRI) { + if(IsPointInTri2DInts(az->x1, az->y1, az->x2, az->y2, x, y)) break; + } + if(az->type == AZONE_QUAD) { + if(az->x1 < x && x < az->x2 && az->y1 < y && y < az->y2) break; + } + } + + return az; +} + static void removedouble_scrverts(bScreen *sc) { ScrVert *v1, *verg; @@ -353,6 +371,7 @@ static void select_connected_scredge(bScreen *sc, ScrEdge *edge) static ScrArea *screen_addarea(bScreen *sc, ScrVert *v1, ScrVert *v2, ScrVert *v3, ScrVert *v4, short headertype, short spacetype) { + AZone *az= NULL; ScrArea *sa= MEM_callocN(sizeof(ScrArea), "addscrarea"); sa->v1= v1; sa->v2= v2; @@ -699,6 +718,7 @@ void screen_test_scale(bScreen *sc, int winsizex, int winsizey) static void drawscredge_area(ScrArea *sa) { + AZone *az; short x1= sa->v1->vec.x; short xa1= x1+HEADERY; short y1= sa->v1->vec.y; @@ -725,8 +745,9 @@ static void drawscredge_area(ScrArea *sa) sdrawline(x1, y1, x2, y1); /* temporary viz for 'action corner' */ - sdrawtrifill(x1, y1, xa1, ya1, .2, .2, .2); - + for(az= sa->actionzones.first; az; az= az->next) { + if(az->type==AZONE_TRI) sdrawtrifill(az->x1, az->y1, az->x2, az->y2, .2, .2, .2); + } } void ED_screen_do_listen(bScreen *screen, wmNotifier *note) @@ -740,6 +761,12 @@ void ED_screen_do_listen(bScreen *screen, wmNotifier *note) case WM_NOTE_SCREEN_CHANGED: screen->do_draw= screen->do_refresh= 1; break; + case WM_NOTE_AREA_SPLIT: + printf("WM_NOTE_AREA_SPLIT\n"); + break; + case WM_NOTE_AREA_DRAG: + printf("WM_NOTE_AREA_DRAG\n"); + break; } } @@ -841,7 +868,14 @@ int screen_cursor_test(bContext *C, wmOperator *op, wmEvent *event) WM_set_cursor(C, CURSOR_X_MOVE); } } else { - WM_set_cursor(C, CURSOR_STD); + ScrArea *sa= NULL; + AZone *az= NULL; + for(sa= C->screen->areabase.first; sa; sa= sa->next) { + az= is_in_area_actionzone(sa, event->x, event->y); + if(az!=NULL) break; + } + if(az!=NULL) WM_set_cursor(C, CURSOR_EDIT); + else WM_set_cursor(C, CURSOR_STD); } return 1; |