From the OFTL:

Arrows-move-cursor is back!
It now works for any running modal operator that doesn't handle own
arrow keys. Might need to become more restricted though, some modal
ops don't need it. Want to investigate that still where conflicts are.
This commit is contained in:
Ton Roosendaal 2011-03-07 14:56:19 +00:00
parent c9685af1ff
commit 2818add586
5 changed files with 37 additions and 38 deletions

@ -198,26 +198,6 @@ static void EM_backbuf_checkAndSelectTFaces(Mesh *me, int select)
} }
} }
#if 0
void arrows_move_cursor(unsigned short event)
{
short mval[2];
getmouseco_sc(mval);
if(event==UPARROWKEY) {
warp_pointer(mval[0], mval[1]+1);
} else if(event==DOWNARROWKEY) {
warp_pointer(mval[0], mval[1]-1);
} else if(event==LEFTARROWKEY) {
warp_pointer(mval[0]-1, mval[1]);
} else if(event==RIGHTARROWKEY) {
warp_pointer(mval[0]+1, mval[1]);
}
}
#endif
/* *********************** GESTURE AND LASSO ******************* */ /* *********************** GESTURE AND LASSO ******************* */
static int view3d_selectable_data(bContext *C) static int view3d_selectable_data(bContext *C)

@ -54,22 +54,10 @@
#include "RNA_access.h" #include "RNA_access.h"
//#include "BIF_editview.h" /* arrows_move_cursor */
#include "BIF_gl.h" #include "BIF_gl.h"
#include "BIF_glutil.h" #include "BIF_glutil.h"
//#include "BIF_mywindow.h"
//#include "BIF_resources.h"
//#include "BIF_screen.h"
//#include "BIF_space.h" /* undo */
//#include "BIF_toets.h" /* persptoetsen */
//#include "BIF_mywindow.h" /* warp_pointer */
//#include "BIF_toolbox.h" /* notice */
//#include "BIF_editmesh.h"
//#include "BIF_editsima.h"
//#include "BIF_editparticle.h"
#include "BKE_nla.h" #include "BKE_nla.h"
//#include "BKE_bad_level_calls.h"/* popmenu and error */
#include "BKE_bmesh.h" #include "BKE_bmesh.h"
#include "BKE_context.h" #include "BKE_context.h"
#include "BKE_constraint.h" #include "BKE_constraint.h"
@ -78,8 +66,6 @@
#include "BKE_pointcache.h" #include "BKE_pointcache.h"
#include "BKE_unit.h" #include "BKE_unit.h"
//#include "BSE_view.h"
#include "ED_image.h" #include "ED_image.h"
#include "ED_keyframing.h" #include "ED_keyframing.h"
#include "ED_screen.h" #include "ED_screen.h"
@ -551,9 +537,6 @@ wmKeyMap* transform_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, 0, 0, TFM_MODAL_ADD_SNAP); WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, 0, 0, TFM_MODAL_ADD_SNAP);
WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, KM_ALT, 0, TFM_MODAL_REMOVE_SNAP); WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, KM_ALT, 0, TFM_MODAL_REMOVE_SNAP);
WM_modalkeymap_add_item(keymap, UPARROWKEY, KM_PRESS, 0, 0, NUM_MODAL_INCREMENT_UP);
WM_modalkeymap_add_item(keymap, DOWNARROWKEY, KM_PRESS, 0, 0, NUM_MODAL_INCREMENT_DOWN);
WM_modalkeymap_add_item(keymap, PAGEUPKEY, KM_PRESS, 0, 0, TFM_MODAL_PROPSIZE_UP); WM_modalkeymap_add_item(keymap, PAGEUPKEY, KM_PRESS, 0, 0, TFM_MODAL_PROPSIZE_UP);
WM_modalkeymap_add_item(keymap, PAGEDOWNKEY, KM_PRESS, 0, 0, TFM_MODAL_PROPSIZE_DOWN); WM_modalkeymap_add_item(keymap, PAGEDOWNKEY, KM_PRESS, 0, 0, TFM_MODAL_PROPSIZE_DOWN);
WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, 0, 0, TFM_MODAL_PROPSIZE_UP); WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, 0, 0, TFM_MODAL_PROPSIZE_UP);
@ -1070,7 +1053,6 @@ int transformEvent(TransInfo *t, wmEvent *event)
// Snapping events // Snapping events
t->redraw |= handleSnapping(t, event); t->redraw |= handleSnapping(t, event);
//arrows_move_cursor(event->type);
} }
else if (event->val==KM_RELEASE) { else if (event->val==KM_RELEASE) {
switch (event->type){ switch (event->type){

@ -47,6 +47,7 @@
#include "BKE_main.h" #include "BKE_main.h"
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h"
#include "wm_cursors.h" #include "wm_cursors.h"
/* XXX this still is mess from old code */ /* XXX this still is mess from old code */
@ -211,6 +212,29 @@ void WM_cursor_ungrab(wmWindow *win)
} }
} }
/* give it a modal keymap one day? */
int wm_cursor_arrow_move(wmWindow *win, wmEvent *event)
{
if(win && event->val==KM_PRESS) {
if(event->type==UPARROWKEY) {
WM_cursor_warp(win, event->x, event->y+1);
return 1;
} else if(event->type==DOWNARROWKEY) {
WM_cursor_warp(win, event->x, event->y-1);
return 1;
} else if(event->type==LEFTARROWKEY) {
WM_cursor_warp(win, event->x-1, event->y);
return 1;
} else if(event->type==RIGHTARROWKEY) {
WM_cursor_warp(win, event->x+1, event->y);
return 1;
}
}
return 0;
}
/* afer this you can call restore too */ /* afer this you can call restore too */
void WM_timecursor(wmWindow *win, int nr) void WM_timecursor(wmWindow *win, int nr)
{ {

@ -1557,6 +1557,9 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
} }
} }
} }
if(action == (WM_HANDLER_BREAK|WM_HANDLER_MODAL))
wm_cursor_arrow_move(CTX_wm_window(C), event);
return action; return action;
} }
@ -1939,11 +1942,13 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
WM_event_fileselect_event(C, op, full?EVT_FILESELECT_FULL_OPEN:EVT_FILESELECT_OPEN); WM_event_fileselect_event(C, op, full?EVT_FILESELECT_FULL_OPEN:EVT_FILESELECT_OPEN);
} }
#if 0
/* lets not expose struct outside wm? */ /* lets not expose struct outside wm? */
static void WM_event_set_handler_flag(wmEventHandler *handler, int flag) static void WM_event_set_handler_flag(wmEventHandler *handler, int flag)
{ {
handler->flag= flag; handler->flag= flag;
} }
#endif
wmEventHandler *WM_event_add_modal_handler(bContext *C, wmOperator *op) wmEventHandler *WM_event_add_modal_handler(bContext *C, wmOperator *op)
{ {
@ -2089,11 +2094,13 @@ void WM_event_remove_area_handler(ListBase *handlers, void *area)
} }
} }
#if 0
static void WM_event_remove_handler(ListBase *handlers, wmEventHandler *handler) static void WM_event_remove_handler(ListBase *handlers, wmEventHandler *handler)
{ {
BLI_remlink(handlers, handler); BLI_remlink(handlers, handler);
wm_event_free_handler(handler); wm_event_free_handler(handler);
} }
#endif
void WM_event_add_mousemove(bContext *C) void WM_event_add_mousemove(bContext *C)
{ {

@ -116,5 +116,11 @@ enum {
#define SMALL_CURSOR 0 #define SMALL_CURSOR 0
#define BIG_CURSOR 1 #define BIG_CURSOR 1
struct wmWindow;
struct wmEvent;
int wm_cursor_arrow_move(struct wmWindow *win, struct wmEvent *event);
#endif /* WM_CURSORS_H */ #endif /* WM_CURSORS_H */