diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_screen.h | 3 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 20 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 1 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 85 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_intern.h | 5 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 91 | ||||
-rw-r--r-- | source/blender/editors/space_text/space_text.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 9 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_cursors.c | 54 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_cursors.h | 3 |
12 files changed, 157 insertions, 133 deletions
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 5a679b6475f..bb3188de511 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -37,6 +37,7 @@ struct bScreen; struct ARegion; struct wmNotifier; struct wmWindowManager; +struct wmWindow; struct ListBase; /* spacetype has everything stored to get an editor working, it gets initialized via @@ -69,6 +70,8 @@ typedef struct SpaceType { void (*operatortypes)(void); /* add default items to WM keymap */ void (*keymap)(struct wmWindowManager *); + /* sets default cursor per region */ + void (*cursor)(struct wmWindow *win, struct ARegion *ar); /* region type definitions */ ListBase regiontypes; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index d84932c82fe..3c9172b8a28 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -209,14 +209,12 @@ static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_int_set(op->ptr, "deltax", 0); RNA_int_set(op->ptr, "deltay", 0); -#if 0 // XXX - enable this when cursors are working properly if (v2d->keepofs & V2D_LOCKOFS_X) - WM_set_cursor(C, BC_NS_SCROLLCURSOR); + WM_cursor_modal(C->window, BC_NS_SCROLLCURSOR); else if (v2d->keepofs & V2D_LOCKOFS_Y) - WM_set_cursor(C, BC_EW_SCROLLCURSOR); + WM_cursor_modal(C->window, BC_EW_SCROLLCURSOR); else - WM_set_cursor(C, BC_NSEW_SCROLLCURSOR); -#endif // XXX - enable this when cursors are working properly + WM_cursor_modal(C->window, BC_NSEW_SCROLLCURSOR); /* add temp handler */ WM_event_add_modal_handler(C, &C->window->handlers, op); @@ -251,7 +249,7 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty)); view_pan_exit(C, op); - //WM_set_cursor(C, CURSOR_STD); // XXX - enable this when cursors are working properly + WM_cursor_restore(C->window); return OPERATOR_FINISHED; } @@ -689,14 +687,12 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_float_set(op->ptr, "deltax", 0); RNA_float_set(op->ptr, "deltay", 0); -#if 0 // XXX - enable this when cursors are working properly if (v2d->keepofs & V2D_LOCKOFS_X) - WM_set_cursor(C, BC_NS_SCROLLCURSOR); + WM_cursor_modal(C->window, BC_NS_SCROLLCURSOR); else if (v2d->keepofs & V2D_LOCKOFS_Y) - WM_set_cursor(C, BC_EW_SCROLLCURSOR); + WM_cursor_modal(C->window, BC_EW_SCROLLCURSOR); else - WM_set_cursor(C, BC_NSEW_SCROLLCURSOR); -#endif // XXX - enable this when cursors are working properly + WM_cursor_modal(C->window, BC_NSEW_SCROLLCURSOR); /* add temp handler */ WM_event_add_modal_handler(C, &C->window->handlers, op); @@ -784,7 +780,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) /* free customdata */ view_zoomdrag_exit(C, op); - //WM_set_cursor(C, CURSOR_STD); // XXX - enable this when cursors are working properly + WM_cursor_restore(C->window); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index fc6ed8cee54..da7c38819a2 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -503,6 +503,7 @@ static void newspace(bContext *C, ScrArea *sa, int type) sa->spacetype= type; sa->butspacetype= type; + sa->type= st; /* check previously stored space */ for (sl= sa->spacedata.first; sl; sl= sl->next) diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 1c0b8932d94..2cf480dc204 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -236,6 +236,39 @@ void removenotused_scredges(bScreen *sc) } } +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; +} + + + /* adds no space data */ static ScrArea *screen_addarea(bScreen *sc, ScrVert *v1, ScrVert *v2, ScrVert *v3, ScrVert *v4, short headertype, short spacetype) { @@ -962,6 +995,8 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) if(G.f & G_DEBUG) printf("set screen\n"); win->screen->do_refresh= 0; + /* cursor types too */ + ED_screen_set_subwinactive(win); } /* file read, set all screens, ... */ @@ -1017,6 +1052,29 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) C->window= prevwin; } +/* case when on area-edge or in azones */ +static void screen_cursor_set(wmWindow *win, wmEvent *event) +{ + ScrArea *sa; + + for(sa= win->screen->areabase.first; sa; sa= sa->next) + if(is_in_area_actionzone(sa, event->x, event->y)) + break; + + if(sa) { + WM_cursor_set(win, CURSOR_EDIT); + } + else { + ScrEdge *actedge= screen_find_active_scredge(win->screen, event->x, event->y); + + if (actedge && scredge_is_horizontal(actedge)) { + WM_cursor_set(win, CURSOR_Y_MOVE); + } else { + WM_cursor_set(win, CURSOR_X_MOVE); + } + } +} + /* called in wm_event_system.c. sets state var in screen */ void ED_screen_set_subwinactive(wmWindow *win) @@ -1024,15 +1082,16 @@ void ED_screen_set_subwinactive(wmWindow *win) if(win->screen) { wmEvent *event= win->eventstate; ScrArea *sa; + ARegion *ar; int oldswin= win->screen->subwinactive; for(sa= win->screen->areabase.first; sa; sa= sa->next) { if(event->x > sa->totrct.xmin && event->x < sa->totrct.xmax) if(event->y > sa->totrct.ymin && event->y < sa->totrct.ymax) - break; + if(NULL==is_in_area_actionzone(sa, event->x, event->y)) + break; } if(sa) { - ARegion *ar; for(ar= sa->regionbase.first; ar; ar= ar->next) { if(BLI_in_rcti(&ar->winrct, event->x, event->y)) win->screen->subwinactive= ar->swinid; @@ -1043,9 +1102,8 @@ void ED_screen_set_subwinactive(wmWindow *win) /* check for redraw headers */ if(oldswin!=win->screen->subwinactive) { - + for(sa= win->screen->areabase.first; sa; sa= sa->next) { - ARegion *ar; int do_draw= 0; for(ar= sa->regionbase.first; ar; ar= ar->next) @@ -1059,6 +1117,25 @@ void ED_screen_set_subwinactive(wmWindow *win) } } } + + /* cursors, for time being set always on edges, otherwise aregion doesnt switch */ + if(win->screen->subwinactive==win->screen->mainwin) { + screen_cursor_set(win, event); + } + else if(oldswin!=win->screen->subwinactive) { + /* cursor space type switching */ + for(sa= win->screen->areabase.first; sa; sa= sa->next) { + for(ar= sa->regionbase.first; ar; ar= ar->next) { + if(ar->swinid==win->screen->subwinactive) { + if(sa->type->cursor) + sa->type->cursor(win, ar); + else + WM_cursor_set(win, CURSOR_STD); + } + } + + } + } } } diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index d228748d873..855fe7c9b50 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -46,6 +46,11 @@ void removenotused_scrverts(bScreen *sc); void removedouble_scrverts(bScreen *sc); void removedouble_scredges(bScreen *sc); void removenotused_scredges(bScreen *sc); +int scredge_is_horizontal(ScrEdge *se); +ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my); + +AZone *is_in_area_actionzone(ScrArea *sa, int x, int y); + #endif /* ED_SCREEN_INTERN_H */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 1f7563b4824..d16ad075bf3 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -118,7 +118,7 @@ static ScrArea *screen_areahascursor(bScreen *scr, int x, int y) } -static AZone *is_in_area_actionzone(ScrArea *sa, int x, int y) +AZone *is_in_area_actionzone(ScrArea *sa, int x, int y) { AZone *az= NULL; int i= 0; @@ -232,78 +232,6 @@ void ED_SCR_OT_actionzone(wmOperatorType *ot) ot->poll= ED_operator_areaactive; } -/* ****************** cursor near edge operator ********************************* */ - -static int scredge_is_horizontal(ScrEdge *se) -{ - return (se->v1->vec.y == se->v2->vec.y); -} - -static 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; -} - - -/* operator cb */ -static int screen_cursor_test(bContext *C, wmOperator *op, wmEvent *event) -{ - if (C->screen->subwinactive==C->screen->mainwin) { - ScrEdge *actedge= screen_find_active_scredge(C->screen, event->x, event->y); - - if (actedge && scredge_is_horizontal(actedge)) { - WM_set_cursor(C, CURSOR_Y_MOVE); - } else { - WM_set_cursor(C, CURSOR_X_MOVE); - } - } - else { - 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 OPERATOR_PASS_THROUGH; -} - -static void ED_SCR_OT_cursor_type(wmOperatorType *ot) -{ - ot->name= "Cursor type"; - ot->idname= "ED_SCR_OT_cursor_type"; - - ot->invoke= screen_cursor_test; - ot->poll= ED_operator_screenactive; -} - - /* *********** Rip area operator ****************** */ @@ -1224,12 +1152,6 @@ static int region_split_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int region_split_invoke(bContext *C, wmOperator *op, wmEvent *evt) -{ - return region_split_exec(C, op); -} - - void ED_SCR_OT_region_split(wmOperatorType *ot) { PropertyRNA *prop; @@ -1240,8 +1162,6 @@ void ED_SCR_OT_region_split(wmOperatorType *ot) /* api callbacks */ ot->exec= region_split_exec; - ot->invoke= region_split_invoke; - ot->poll= ED_operator_areaactive; prop= RNA_def_property(ot->srna, "dir", PROP_ENUM, PROP_NONE); @@ -1346,7 +1266,6 @@ void ED_SCR_OT_border_select(wmOperatorType *ot) void ED_operatortypes_screen(void) { /* generic UI stuff */ - WM_operatortype_append(ED_SCR_OT_cursor_type); WM_operatortype_append(ED_SCR_OT_actionzone); WM_operatortype_append(ED_SCR_OT_repeat_last); @@ -1367,9 +1286,7 @@ void ED_operatortypes_screen(void) void ED_keymap_screen(wmWindowManager *wm) { ListBase *keymap= WM_keymap_listbase(wm, "Screen", 0, 0); - wmKeymapItem *kmi; - WM_keymap_verify_item(keymap, "ED_SCR_OT_cursor_type", MOUSEMOVE, 0, 0, 0); WM_keymap_verify_item(keymap, "ED_SCR_OT_actionzone", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "ED_SCR_OT_area_move", LEFTMOUSE, KM_PRESS, 0, 0); @@ -1378,10 +1295,8 @@ void ED_keymap_screen(wmWindowManager *wm) WM_keymap_verify_item(keymap, "ED_SCR_OT_area_rip", RKEY, KM_PRESS, KM_ALT, 0); /* tests */ - kmi= WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "dir", 'h'); - kmi= WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "dir", 'v'); + RNA_enum_set(WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, 0, 0)->ptr, "dir", 'h'); + RNA_enum_set(WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "dir", 'v'); WM_keymap_add_item(keymap, "ED_SCR_OT_region_flip", F5KEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "ED_SCR_OT_repeat_last", F4KEY, KM_PRESS, 0, 0); } diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 54ec53b2434..5b52e43d0f2 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -153,12 +153,20 @@ static void text_main_area_draw(const bContext *C, ARegion *ar) /* scrollers? */ } -void text_operatortypes(void) +static void text_operatortypes(void) { } -void text_keymap(struct wmWindowManager *wm) +static void text_cursor(wmWindow *win, ARegion *ar) +{ + if(ar->regiontype==RGN_TYPE_WINDOW) + WM_cursor_set(win, BC_TEXTEDITCURSOR); + else + WM_cursor_set(win, CURSOR_STD); +} + +static void text_keymap(struct wmWindowManager *wm) { } @@ -209,6 +217,7 @@ void ED_spacetype_text(void) st->init= text_init; st->duplicate= text_duplicate; st->operatortypes= text_operatortypes; + st->cursor= text_cursor; st->keymap= text_keymap; /* regions: main window */ diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index b278f83706a..b0fdcee2c04 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -55,10 +55,11 @@ void WM_read_autosavefile(struct bContext *C); void WM_write_autosave (struct bContext *C); /* mouse cursors */ -void WM_init_cursor_data (void); -void WM_set_cursor (struct bContext *C, int curs); -void WM_waitcursor (struct bContext *C, int val); -void WM_timecursor (struct bContext *C, int nr); +void WM_cursor_set (struct wmWindow *win, int curs); +void WM_cursor_modal (struct wmWindow *win, int curs); +void WM_cursor_restore (struct wmWindow *win); +void WM_cursor_wait (struct wmWindow *win, int val); +void WM_timecursor (struct wmWindow *win, int nr); /* keymap and handlers */ wmKeymapItem *WM_keymap_set_item (ListBase *lb, char *idname, short type, diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index e4299b8949b..8b4ddd786e0 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -86,15 +86,12 @@ static void window_set_custom_cursor_ex(wmWindow *win, BCursor *cursor, int useB /* Cursor Globals */ static BCursor *BlenderCursor[BC_NUMCURSORS]; /*Points to static BCursor Structs */ -static short CurrentCursor=-1, LastCursor=-1; -void WM_set_cursor(bContext *C, int curs) +void WM_cursor_set(wmWindow *win, int curs) { - wmWindow *win= C->window; if (win==NULL) return; /* Can't set custom cursor before Window init */ - win->cursor= curs; - + if (curs==CURSOR_NONE) { GHOST_SetCursorVisibility(win->ghostwin, 0); return; @@ -102,18 +99,14 @@ void WM_set_cursor(bContext *C, int curs) GHOST_SetCursorVisibility(win->ghostwin, 1); - LastCursor=CurrentCursor; - CurrentCursor=curs; - - /* previous cursor? */ - if (curs==LASTCURSOR) curs=LastCursor; + win->cursor= curs; /* detect if we use system cursor or Blender cursor */ if(curs>=BC_GHOST_CURSORS) { GHOST_SetCursorShape(win->ghostwin, convert_cursor(curs)); } else { - if ((curs<LASTCURSOR)||(curs>=BC_NUMCURSORS)) return; + if ((curs<SYSCURSOR) || (curs>=BC_NUMCURSORS)) return; if (curs==SYSCURSOR) { /* System default Cursor */ GHOST_SetCursorShape(win->ghostwin, convert_cursor(CURSOR_STD)); @@ -127,18 +120,34 @@ void WM_set_cursor(bContext *C, int curs) } } -void WM_waitcursor(bContext *C, int val) +static int LastCursor=-1; /* global, assumed we only have one */ + +void WM_cursor_modal(wmWindow *win, int val) { - if(C->window) { - if(val) { - WM_set_cursor(C, CURSOR_WAIT); - } else { - WM_set_cursor(C, LASTCURSOR); - } + if(LastCursor == -1) + LastCursor = win->cursor; + WM_cursor_set(win, val); +} + +void WM_cursor_restore(wmWindow *win) +{ + if(LastCursor != -1) + WM_cursor_set(win, LastCursor); + LastCursor = -1; +} + + +void WM_cursor_wait(wmWindow *win, int val) +{ + if(val) { + WM_cursor_modal(win, CURSOR_WAIT); + } else { + WM_cursor_restore(win); } } -void WM_timecursor(bContext *C, int nr) +/* afer this you can call restore too */ +void WM_timecursor(wmWindow *win, int nr) { /* 10 8x8 digits */ static char number_bitmaps[10][8]= { @@ -157,6 +166,9 @@ void WM_timecursor(bContext *C, int nr) unsigned char bitmap[16][2]; int i, idx; + if(LastCursor != -1) + LastCursor= win->cursor; + memset(&bitmap, 0x00, sizeof(bitmap)); memset(&mask, 0xFF, sizeof(mask)); @@ -171,7 +183,7 @@ void WM_timecursor(bContext *C, int nr) nr/= 10; } - window_set_custom_cursor(C->window, mask, bitmap, 7, 7); + window_set_custom_cursor(win, mask, bitmap, 7, 7); } @@ -217,7 +229,7 @@ are for */ #define BEGIN_CURSOR_BLOCK { #define END_CURSOR_BLOCK } -void WM_init_cursor_data(void){ +void wm_init_cursor_data(void){ /********************** NW_ARROW Cursor **************************/ BEGIN_CURSOR_BLOCK diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index a083edf826a..6aa8c980456 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -648,7 +648,8 @@ void wm_event_do_handlers(bContext *C) int doit= 0; /* XXX to solve, here screen handlers? */ - ED_screen_set_subwinactive(win); /* state variables in screen */ + if(!wm_event_always_pass(event)) + ED_screen_set_subwinactive(win); /* state variables in screen */ for(sa= win->screen->areabase.first; sa; sa= sa->next) { if(wm_event_always_pass(event) || wm_event_prev_inside_i(event, &sa->totrct)) { diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index db37f0754a0..4d170ceeb46 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -74,6 +74,8 @@ #include "WM_api.h" #include "WM_types.h" + +#include "wm_cursors.h" #include "wm_event_system.h" #include "wm.h" #include "wm_files.h" @@ -110,6 +112,7 @@ void WM_init(bContext *C) { wm_ghost_init(C); /* note: it assigns C to ghost! */ + wm_init_cursor_data(); wm_operatortype_init(); set_free_windowmanager_cb(wm_close_and_free); /* library.c */ diff --git a/source/blender/windowmanager/wm_cursors.h b/source/blender/windowmanager/wm_cursors.h index 73ff6ccc19e..e3f0e846b7a 100644 --- a/source/blender/windowmanager/wm_cursors.h +++ b/source/blender/windowmanager/wm_cursors.h @@ -32,6 +32,8 @@ #ifndef WM_CURSORS_H #define WM_CURSORS_H +void wm_init_cursor_data(void); + #define BC_GHOST_CURSORS 1000 /* old cursors */ @@ -72,7 +74,6 @@ typedef struct BCursor { } BCursor; -#define LASTCURSOR -2 #define SYSCURSOR -1 enum { BC_NW_ARROWCURSOR=0, |