New "Gesture Manager" system.
This is a first implementation of the "gesture manager" system,
the idea is put the WM in a automatic draw mode so we can
implement different "Gesture types" to draw different class
of data (lasso, bound box, etc).
The gesture data is passed through the data field of the notifiers,
i think that we can change this to something like:
WM_gesture_init(C, data); /* put the data in the context. */
while() {
/* send WM_NOTE_GESTURE_CHANGED to update screen */
}
/* send event and free the data in the context. */
WM_gesture_end(C);
Also i add a new operator and event to test the gesture manager.
The new operator is the "border select" function, just press BKEY
in the window and LMB or ESCKEY to exit.
In the case of LMB you can see a print in the console about the
BORDERSELECT event.
All this still need a lot of work, comment are welcome.
This commit is contained in:
@@ -51,8 +51,9 @@ void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct
|
||||
/* screens */
|
||||
void ED_screens_initialize(struct wmWindowManager *wm);
|
||||
void ED_screen_draw(struct wmWindow *win);
|
||||
void ED_screen_gesture(struct wmWindow *win);
|
||||
void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win);
|
||||
void ED_screen_do_listen(bScreen *screen, struct wmNotifier *note);
|
||||
void ED_screen_do_listen(struct wmWindow *win, struct wmNotifier *note);
|
||||
bScreen *ED_screen_duplicate(struct wmWindow *win, bScreen *sc);
|
||||
void ED_screen_set_subwinactive(struct wmWindow *win);
|
||||
|
||||
|
||||
@@ -50,6 +50,20 @@
|
||||
|
||||
#include "screen_intern.h" /* own module include */
|
||||
|
||||
/* ******************* gesture manager ******************* */
|
||||
void ed_gesture_draw_rect(wmWindow *win)
|
||||
{
|
||||
wmGestureRect *rect= (wmGestureRect *)win->gesture;
|
||||
sdrawbox(rect->x1, rect->y1, rect->x2, rect->y2);
|
||||
}
|
||||
|
||||
void ed_gesture_update(wmWindow *win)
|
||||
{
|
||||
wmGesture *gesture= (wmGesture *)win->gesture;
|
||||
if(gesture->type==GESTURE_RECT)
|
||||
ed_gesture_draw_rect(win);
|
||||
}
|
||||
|
||||
/* ******************* screen vert, edge, area managing *********************** */
|
||||
|
||||
static ScrVert *screen_addvert(bScreen *sc, short x, short y)
|
||||
@@ -752,16 +766,16 @@ static void drawscredge_area(ScrArea *sa)
|
||||
}
|
||||
}
|
||||
|
||||
void ED_screen_do_listen(bScreen *screen, wmNotifier *note)
|
||||
void ED_screen_do_listen(wmWindow *win, wmNotifier *note)
|
||||
{
|
||||
|
||||
/* generic notes */
|
||||
switch(note->type) {
|
||||
case WM_NOTE_WINDOW_REDRAW:
|
||||
screen->do_draw= 1;
|
||||
win->screen->do_draw= 1;
|
||||
break;
|
||||
case WM_NOTE_SCREEN_CHANGED:
|
||||
screen->do_draw= screen->do_refresh= 1;
|
||||
win->screen->do_draw= win->screen->do_refresh= 1;
|
||||
break;
|
||||
case WM_NOTE_AREA_SPLIT:
|
||||
printf("WM_NOTE_AREA_SPLIT\n");
|
||||
@@ -769,6 +783,11 @@ void ED_screen_do_listen(bScreen *screen, wmNotifier *note)
|
||||
case WM_NOTE_AREA_DRAG:
|
||||
printf("WM_NOTE_AREA_DRAG\n");
|
||||
break;
|
||||
case WM_NOTE_GESTURE_CHANGED:
|
||||
printf("WM_NOTE_GESTURE_CHANGED\n");
|
||||
win->screen->do_gesture= 1;
|
||||
win->gesture= WM_gesture_dup((wmGesture *) note->data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -786,6 +805,18 @@ void ED_screen_draw(wmWindow *win)
|
||||
win->screen->do_draw= 0;
|
||||
}
|
||||
|
||||
void ED_screen_gesture(wmWindow *win)
|
||||
{
|
||||
printf("gesture draw screen\n");
|
||||
|
||||
if(win->gesture) {
|
||||
ed_gesture_update(win);
|
||||
MEM_freeN(win->gesture);
|
||||
win->gesture= NULL;
|
||||
}
|
||||
win->screen->do_gesture= 0;
|
||||
}
|
||||
|
||||
/* make this screen usable */
|
||||
/* for file read and first use, for scaling window, area moves */
|
||||
void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
|
||||
@@ -997,7 +1028,7 @@ static int move_areas_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static int move_areas_exit(bContext *C, wmOperator *op)
|
||||
{
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0);
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
|
||||
|
||||
/* this makes sure aligned edges will result in aligned grabbing */
|
||||
removedouble_scrverts(C->screen);
|
||||
@@ -1045,7 +1076,7 @@ static int move_areas_modal (bContext *C, wmOperator *op, wmEvent *event)
|
||||
op->delta= event->y - op->veci.y;
|
||||
|
||||
move_areas_exec(C, op);
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0);
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
|
||||
break;
|
||||
|
||||
case LEFTMOUSE:
|
||||
@@ -1133,7 +1164,7 @@ static int split_area_exit(bContext *C, wmOperator *op)
|
||||
op->customdata = NULL;
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0);
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
|
||||
|
||||
/* this makes sure aligned edges will result in aligned grabbing */
|
||||
removedouble_scrverts(C->screen);
|
||||
@@ -1167,7 +1198,7 @@ static int split_initintern(bContext *C, wmOperator *op, sAreaSplitData *sd)
|
||||
/* select newly created edge */
|
||||
select_connected_scredge(C->screen, sd->nedge);
|
||||
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0);
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1321,7 +1352,7 @@ static int split_area_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
} else if (sd->state==SPLIT_DONE) {
|
||||
/* shouldn't get here anymore */
|
||||
}
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0);
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
|
||||
break;
|
||||
case LEFTMOUSE:
|
||||
if(event->val==0) { /* mouse up => confirm if not near/on starting edge */
|
||||
@@ -1585,7 +1616,7 @@ static int join_areas_modal (bContext *C, wmOperator *op, wmEvent *event)
|
||||
case LEFTMOUSE:
|
||||
if(event->val==0) {
|
||||
join_areas_exec(C, op);
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0);
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
|
||||
join_areas_exit(C, op);
|
||||
WM_event_remove_modal_handler(&C->window->handlers, op);
|
||||
}
|
||||
@@ -1616,4 +1647,3 @@ void ED_SCR_OT_join_areas(wmOperatorType *ot)
|
||||
|
||||
ot->poll= ED_operator_screen_mainwinactive;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@ typedef struct bScreen {
|
||||
short full, winid; /* winid from WM, starts with 1 */
|
||||
short do_draw; /* notifier for drawing edges */
|
||||
short do_refresh; /* notifier for scale screen, changed screen, etc */
|
||||
short do_gesture; /* notifier for gesture draw. */
|
||||
short pad[3];
|
||||
|
||||
short mainwin; /* screensize subwindow, for screenedges and global menus */
|
||||
short subwinactive; /* active subwindow */
|
||||
|
||||
@@ -97,7 +97,7 @@ typedef struct wmWindow {
|
||||
ListBase handlers; /* window+screen handlers, overriding all queues */
|
||||
|
||||
ListBase subwindows; /* opengl stuff for sub windows, see notes in wm_subwindow.c */
|
||||
|
||||
void *gesture; /* gesture stuff. */
|
||||
} wmWindow;
|
||||
|
||||
#
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
struct bContext;
|
||||
struct wmEvent;
|
||||
struct wmEventHandler;
|
||||
struct wmGesture;
|
||||
|
||||
/* general API */
|
||||
void WM_setprefsize (int stax, int stay, int sizx, int sizy);
|
||||
@@ -67,8 +68,9 @@ struct wmEventHandler *WM_event_add_keymap_handler(ListBase *keymap, ListBase *h
|
||||
struct wmEventHandler *WM_event_add_modal_handler(ListBase *handlers, wmOperator *op);
|
||||
void WM_event_remove_modal_handler(ListBase *handlers, wmOperator *op);
|
||||
|
||||
void WM_event_add_notifier(wmWindowManager *wm, wmWindow *window, int swinid, int type,
|
||||
int value);
|
||||
void WM_event_add_notifier(wmWindowManager *wm, wmWindow *window,
|
||||
int swinid, int type,
|
||||
int value, void *data);
|
||||
|
||||
|
||||
/* operator api, default callbacks */
|
||||
@@ -132,6 +134,11 @@ int OP_get_float_array(wmOperator *op, char *name, float *array, short *len);
|
||||
**/
|
||||
void OP_free_property(wmOperator *op);
|
||||
|
||||
/* Gesture manager API */
|
||||
struct wmGesture *WM_gesture_new(int type);
|
||||
struct wmGesture *WM_gesture_dup(struct wmGesture *from);
|
||||
void WM_gesture_send(wmWindow *win, struct wmGesture *gesture);
|
||||
|
||||
/* OpenGL wrappers, mimicing opengl syntax */
|
||||
void wmLoadMatrix (wmWindow *win, float mat[][4]);
|
||||
void wmGetMatrix (wmWindow *win, float mat[][4]);
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "wm_cursors.h"
|
||||
#include "wm_event_types.h"
|
||||
#include "wm_gesture_types.h"
|
||||
|
||||
/* ************** wmOperatorType ************************ */
|
||||
|
||||
@@ -105,9 +106,21 @@ enum {
|
||||
WM_NOTE_OBJECT_CHANGED,
|
||||
WM_NOTE_AREA_SPLIT,
|
||||
WM_NOTE_AREA_DRAG,
|
||||
WM_NOTE_GESTURE_CHANGED,
|
||||
WM_NOTE_LAST
|
||||
};
|
||||
|
||||
/* ************** Gesture Manager data ************** */
|
||||
typedef struct wmGestureRect {
|
||||
/* always this first!! */
|
||||
wmGesture gesture;
|
||||
|
||||
short x1, x2;
|
||||
short y1, y2;
|
||||
} wmGestureRect;
|
||||
|
||||
#define GESTURE_RECT 0
|
||||
|
||||
/* ************** custom wmEvent data ************** */
|
||||
|
||||
#define DEV_STYLUS 1
|
||||
@@ -120,6 +133,10 @@ typedef struct wmTabletData {
|
||||
float Ytilt; /* as above */
|
||||
} wmTabletData;
|
||||
|
||||
typedef struct wmBorderSelect {
|
||||
short x1, y1;
|
||||
short x2, y2;
|
||||
} wmBorderSelect;
|
||||
|
||||
/* *************** migrated stuff, clean later? ******************************** */
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ static void wm_window_keymap(wmWindowManager *wm)
|
||||
WM_keymap_verify_item(&wm->windowkeymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_verify_item(&wm->windowkeymap, "WM_OT_window_fullscreen_toggle", FKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_verify_item(&wm->windowkeymap, "WM_OT_exit_blender", QKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_verify_item(&wm->windowkeymap, "WM_OT_border_select", BKEY, KM_PRESS, 0, 0);
|
||||
}
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
/* ************ event management ************** */
|
||||
|
||||
static void wm_event_add(wmWindow *win, wmEvent *event_to_add)
|
||||
void wm_event_add(wmWindow *win, wmEvent *event_to_add)
|
||||
{
|
||||
wmEvent *event= MEM_callocN(sizeof(wmEvent), "event");
|
||||
|
||||
@@ -90,7 +90,7 @@ void wm_event_free_all(wmWindow *win)
|
||||
/* ********************* notifiers, listeners *************** */
|
||||
|
||||
/* win and swinid are optional context limitors */
|
||||
void WM_event_add_notifier(wmWindowManager *wm, wmWindow *window, int swinid, int type, int value)
|
||||
void WM_event_add_notifier(wmWindowManager *wm, wmWindow *window, int swinid, int type, int value, void *data)
|
||||
{
|
||||
wmNotifier *note= MEM_callocN(sizeof(wmNotifier), "notifier");
|
||||
|
||||
@@ -100,6 +100,7 @@ void WM_event_add_notifier(wmWindowManager *wm, wmWindow *window, int swinid, in
|
||||
note->swinid= swinid;
|
||||
note->type= type;
|
||||
note->value= value;
|
||||
note->data= data;
|
||||
}
|
||||
|
||||
static wmNotifier *wm_notifier_next(wmWindowManager *wm)
|
||||
@@ -126,7 +127,7 @@ void wm_event_do_notifiers(bContext *C)
|
||||
if(win->screen==NULL)
|
||||
continue;
|
||||
printf("notifier win %d screen %s\n", win->winid, win->screen->id.name+2);
|
||||
ED_screen_do_listen(win->screen, note);
|
||||
ED_screen_do_listen(win, note);
|
||||
|
||||
for(sa= win->screen->areabase.first; sa; sa= sa->next) {
|
||||
ARegion *ar= sa->regionbase.first;
|
||||
@@ -138,6 +139,8 @@ void wm_event_do_notifiers(bContext *C)
|
||||
}
|
||||
}
|
||||
}
|
||||
if(note->data)
|
||||
MEM_freeN(note->data);
|
||||
MEM_freeN(note);
|
||||
}
|
||||
}
|
||||
@@ -151,7 +154,9 @@ static int wm_draw_update_test_window(wmWindow *win)
|
||||
return 1;
|
||||
if(win->screen->do_draw)
|
||||
return 1;
|
||||
|
||||
if(win->screen->do_gesture)
|
||||
return 1;
|
||||
|
||||
for(sa= win->screen->areabase.first; sa; sa= sa->next) {
|
||||
ARegion *ar= sa->regionbase.first;
|
||||
|
||||
@@ -201,6 +206,9 @@ void wm_draw_update(bContext *C)
|
||||
if(win->screen->do_draw)
|
||||
ED_screen_draw(win);
|
||||
|
||||
if(win->screen->do_gesture)
|
||||
ED_screen_gesture(win);
|
||||
|
||||
wm_window_swap_buffers(win);
|
||||
}
|
||||
}
|
||||
@@ -301,21 +309,23 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
||||
event->keymap_idname= km->idname; /* weak, but allows interactive callback to not use rawkey */
|
||||
|
||||
action= wm_handler_operator_call(C, handler, event);
|
||||
if(action==WM_HANDLER_BREAK)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(action==WM_HANDLER_BREAK)
|
||||
break;
|
||||
}
|
||||
else {
|
||||
/* modal, swallows all */
|
||||
action= wm_handler_operator_call(C, handler, event);
|
||||
if(action==WM_HANDLER_BREAK)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* modal+blocking handler */
|
||||
if(handler->flag & WM_HANDLER_BLOCKING)
|
||||
action= WM_HANDLER_BREAK;
|
||||
|
||||
if(action==WM_HANDLER_BREAK)
|
||||
break;
|
||||
|
||||
}
|
||||
return action;
|
||||
}
|
||||
@@ -341,6 +351,9 @@ void wm_event_do_handlers(bContext *C)
|
||||
while( (event=wm_event_next(win)) ) {
|
||||
int action;
|
||||
|
||||
if(event->type==BORDERSELECT)
|
||||
printf("BORDERSELECT Event!!\n");
|
||||
|
||||
/* MVC demands to not draw in event handlers... for now we leave it */
|
||||
/* it also updates context (win, screen) */
|
||||
wm_window_make_drawable(C, win);
|
||||
|
||||
95
source/blender/windowmanager/intern/wm_gesture.c
Normal file
95
source/blender/windowmanager/intern/wm_gesture.c
Normal file
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* $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 *****
|
||||
*/
|
||||
|
||||
#include "DNA_windowmanager_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "BIF_gl.h"
|
||||
#include "BIF_glutil.h"
|
||||
|
||||
|
||||
wmGesture *WM_gesture_new(int type)
|
||||
{
|
||||
wmGesture *gesture= NULL;
|
||||
wmGestureRect *rect;
|
||||
|
||||
if(type==GESTURE_RECT) {
|
||||
gesture= rect= MEM_mallocN(sizeof(wmGestureRect), "gesture rect new");
|
||||
gesture->type= type;
|
||||
rect->x1= 0;
|
||||
rect->y1= 0;
|
||||
rect->x2= 1;
|
||||
rect->y2= 1;
|
||||
}
|
||||
return(gesture);
|
||||
}
|
||||
|
||||
void wm_gesture_rect_copy(wmGestureRect *to, wmGestureRect *from)
|
||||
{
|
||||
to->x1= from->x1;
|
||||
to->x2= from->x2;
|
||||
to->y1= from->y1;
|
||||
to->y2= from->y2;
|
||||
}
|
||||
|
||||
wmGesture *WM_gesture_dup(wmGesture *from)
|
||||
{
|
||||
wmGesture *to= WM_gesture_new(from->type);
|
||||
|
||||
if(from->type==GESTURE_RECT)
|
||||
wm_gesture_rect_copy((wmGestureRect *) to, (wmGestureRect *) from);
|
||||
return (to);
|
||||
}
|
||||
|
||||
void WM_gesture_send(wmWindow *win, wmGesture *gesture)
|
||||
{
|
||||
wmGestureRect *rect;
|
||||
wmBorderSelect *wmbor;
|
||||
wmEvent event;
|
||||
|
||||
if(gesture->type==GESTURE_RECT) {
|
||||
rect= (wmGestureRect*)gesture;
|
||||
|
||||
wmbor= MEM_mallocN(sizeof(wmBorderSelect), "border select");
|
||||
wmbor->x1= rect->x1;
|
||||
wmbor->y1= rect->y1;
|
||||
wmbor->x2= rect->x2;
|
||||
wmbor->y2= rect->y2;
|
||||
|
||||
event.type= BORDERSELECT;
|
||||
event.custom= EVT_GESTURE;
|
||||
event.customdata= wmbor;
|
||||
wm_event_add(win, &event);
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,110 @@ static void WM_OT_exit_blender(wmOperatorType *ot)
|
||||
ot->poll= WM_operator_winactive;
|
||||
}
|
||||
|
||||
/* ************ window / screen border operator definitions ************** */
|
||||
/*
|
||||
* This is and example of global operator working with
|
||||
* the gesture system.
|
||||
*/
|
||||
static int border_select_init(bContext *C, wmOperator *op)
|
||||
{
|
||||
OP_set_int(op, "start_x", op->veci.x);
|
||||
OP_set_int(op, "start_y", op->veci.y);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int border_select_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmGestureRect *rect;
|
||||
int x, y;
|
||||
|
||||
OP_get_int(op, "start_x", &x);
|
||||
OP_get_int(op, "start_y", &y);
|
||||
|
||||
rect= (wmGestureRect *) WM_gesture_new(GESTURE_RECT);
|
||||
rect->x1= x;
|
||||
rect->y1= y;
|
||||
rect->x2= op->veci.x;
|
||||
rect->y2= op->veci.y;
|
||||
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_GESTURE_CHANGED, 0, rect);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int border_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
/* operator arguments and storage. */
|
||||
op->properties= NULL;
|
||||
op->veci.x= event->x;
|
||||
op->veci.y= event->y;
|
||||
|
||||
if(0==border_select_init(C, op))
|
||||
return 1;
|
||||
|
||||
/* add temp handler */
|
||||
WM_event_add_modal_handler(&C->window->handlers, op);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int border_select_exit(bContext *C, wmOperator *op)
|
||||
{
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
|
||||
OP_free_property(op);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int border_select_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
switch(event->type) {
|
||||
case MOUSEMOVE:
|
||||
op->veci.x= event->x;
|
||||
op->veci.y= event->y;
|
||||
border_select_exec(C, op);
|
||||
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
|
||||
break;
|
||||
case LEFTMOUSE:
|
||||
if(event->val==0) {
|
||||
wmGestureRect *rect;
|
||||
int x, y;
|
||||
|
||||
OP_get_int(op, "start_x", &x);
|
||||
OP_get_int(op, "start_y", &y);
|
||||
|
||||
rect= (wmGestureRect *) WM_gesture_new(GESTURE_RECT);
|
||||
rect->x1= x;
|
||||
rect->y1= y;
|
||||
rect->x2= op->veci.x;
|
||||
rect->y2= op->veci.y;
|
||||
WM_gesture_send(C->window, (wmGesture *) rect);
|
||||
MEM_freeN(rect);
|
||||
|
||||
border_select_exit(C, op);
|
||||
WM_event_remove_modal_handler(&C->window->handlers, op);
|
||||
}
|
||||
break;
|
||||
case ESCKEY:
|
||||
WM_event_remove_modal_handler(&C->window->handlers, op);
|
||||
border_select_exit(C, op);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void WM_OT_border_select(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Border select";
|
||||
ot->idname= "WM_OT_border_select";
|
||||
|
||||
ot->init= border_select_init;
|
||||
ot->invoke= border_select_invoke;
|
||||
ot->modal= border_select_modal;
|
||||
ot->exec= border_select_exec;
|
||||
ot->exit= border_select_exit;
|
||||
|
||||
ot->poll= WM_operator_winactive;
|
||||
}
|
||||
|
||||
#define ADD_OPTYPE(opfunc) ot= MEM_callocN(sizeof(wmOperatorType), "operatortype"); \
|
||||
opfunc(ot); \
|
||||
BLI_addtail(&global_ops, ot)
|
||||
@@ -145,8 +248,9 @@ void wm_operatortype_init(void)
|
||||
|
||||
ADD_OPTYPE(WM_OT_window_duplicate);
|
||||
ADD_OPTYPE(WM_OT_save_homefile);
|
||||
ADD_OPTYPE(WM_OT_window_fullscreen_toggle);
|
||||
ADD_OPTYPE(WM_OT_window_fullscreen_toggle);
|
||||
ADD_OPTYPE(WM_OT_exit_blender);
|
||||
ADD_OPTYPE(WM_OT_border_select);
|
||||
}
|
||||
|
||||
/* wrapped to get property from a operator. */
|
||||
|
||||
@@ -406,7 +406,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
|
||||
printf("ghost redraw\n");
|
||||
|
||||
wm_window_make_drawable(C, win);
|
||||
WM_event_add_notifier(C->wm, win, 0, WM_NOTE_WINDOW_REDRAW, 0);
|
||||
WM_event_add_notifier(C->wm, win, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -446,13 +446,13 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
|
||||
}
|
||||
|
||||
wm_window_make_drawable(C, win);
|
||||
WM_event_add_notifier(C->wm, win, 0, WM_NOTE_SCREEN_CHANGED, 0);
|
||||
WM_event_add_notifier(C->wm, win, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if(type==GHOST_kEventKeyDown) // XXX debug
|
||||
WM_event_add_notifier(C->wm, win, 0, WM_NOTE_WINDOW_REDRAW, 0);
|
||||
WM_event_add_notifier(C->wm, win, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
|
||||
wm_event_add_ghostevent(win, type, data);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
void wm_event_add(wmWindow *win, wmEvent *event_to_add);
|
||||
void wm_event_free_all (wmWindow *win);
|
||||
wmEvent *wm_event_next (wmWindow *win);
|
||||
void wm_event_free_handlers (ListBase *lb);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
/* custom data type */
|
||||
#define EVT_TABLET 1
|
||||
#define EVT_GESTURE 2
|
||||
|
||||
#define MOUSEX 0x004
|
||||
#define MOUSEY 0x005
|
||||
@@ -252,5 +253,8 @@
|
||||
#define REDRAWMARKER 0x4040 /* all views that display markers */
|
||||
#define REDRAWVIEW3D_IMAGE 0x4041
|
||||
|
||||
/* **************** BLENDER GESTURE EVENTS ********************* */
|
||||
#define BORDERSELECT 0x5000
|
||||
|
||||
#endif /* WM_EVENT_TYPES_H */
|
||||
|
||||
|
||||
38
source/blender/windowmanager/wm_gesture_types.h
Normal file
38
source/blender/windowmanager/wm_gesture_types.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* $Id: wm_gesture_types.h
|
||||
*
|
||||
* ***** 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 WM_GESTURE_TYPES_H
|
||||
#define WM_GESTURE_TYPES_H
|
||||
|
||||
typedef struct wmGesture {
|
||||
/* gesture type. */
|
||||
short type;
|
||||
} wmGesture;
|
||||
|
||||
#endif /* WM_GESTURE_TYPES_H */
|
||||
|
||||
Reference in New Issue
Block a user