#733 partial: Adds rotation gesture event on MacOS
This commit is contained in:
parent
2953db58c7
commit
3049e6394a
@ -407,7 +407,13 @@ enum Fl_Event { // events
|
|||||||
/** A zoom event (ctrl/+/-/0/ or cmd/+/-/0/) was processed.
|
/** A zoom event (ctrl/+/-/0/ or cmd/+/-/0/) was processed.
|
||||||
Use Fl::add_handler() to be notified of this event.
|
Use Fl::add_handler() to be notified of this event.
|
||||||
*/
|
*/
|
||||||
FL_ZOOM_EVENT = 27
|
FL_ZOOM_EVENT = 27,
|
||||||
|
/** The user has made a rotation gesture (Mac OS platform only).
|
||||||
|
The Fl::event_dy() method can be used to find the rotation amount,
|
||||||
|
Fl::event_x() and Fl::event_y() are set as well.
|
||||||
|
This event is sent to the window's handle method.
|
||||||
|
*/
|
||||||
|
FL_ROTATE_GESTURE = 28
|
||||||
// DEV NOTE: Keep this list in sync with FL/names.h
|
// DEV NOTE: Keep this list in sync with FL/names.h
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -73,9 +73,10 @@ const char * const fl_eventnames[] =
|
|||||||
"FL_FULLSCREEN",
|
"FL_FULLSCREEN",
|
||||||
"FL_ZOOM_GESTURE",
|
"FL_ZOOM_GESTURE",
|
||||||
"FL_ZOOM_EVENT",
|
"FL_ZOOM_EVENT",
|
||||||
"FL_EVENT_28", // not yet defined, just in case it /will/ be defined ...
|
"FL_ROTATE_GESTURE",
|
||||||
"FL_EVENT_29", // not yet defined, just in case it /will/ be defined ...
|
"FL_EVENT_29", // not yet defined, just in case it /will/ be defined ...
|
||||||
"FL_EVENT_30" // not yet defined, just in case it /will/ be defined ...
|
"FL_EVENT_30", // not yet defined, just in case it /will/ be defined ...
|
||||||
|
"FL_EVENT_31" // not yet defined, just in case it /will/ be defined ...
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -965,6 +965,32 @@ static void cocoaMagnifyHandler(NSEvent *theEvent)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cocoa Rotate Gesture Handler
|
||||||
|
*/
|
||||||
|
static void cocoaRotateHandler(NSEvent *theEvent)
|
||||||
|
{
|
||||||
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||||
|
fl_lock_function();
|
||||||
|
Fl_Window *window = (Fl_Window*)[(FLWindow*)[theEvent window] getFl_Window];
|
||||||
|
if ( !window->shown() ) {
|
||||||
|
fl_unlock_function();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Fl::first_window(window);
|
||||||
|
Fl::e_dy = [theEvent rotation]*1000;
|
||||||
|
if ( Fl::e_dy) {
|
||||||
|
NSPoint pos = [theEvent locationInWindow];
|
||||||
|
pos.y = window->h() - pos.y;
|
||||||
|
NSUInteger mods = [theEvent modifierFlags];
|
||||||
|
mods_to_e_state( mods );
|
||||||
|
update_e_xy_and_e_xy_root([theEvent window]);
|
||||||
|
Fl::handle( FL_ROTATE_GESTURE, window );
|
||||||
|
}
|
||||||
|
fl_unlock_function();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cocoa Mouse Button Handler
|
* Cocoa Mouse Button Handler
|
||||||
*/
|
*/
|
||||||
@ -2439,6 +2465,9 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
|
|||||||
- (void)magnifyWithEvent:(NSEvent *)theEvent {
|
- (void)magnifyWithEvent:(NSEvent *)theEvent {
|
||||||
cocoaMagnifyHandler(theEvent);
|
cocoaMagnifyHandler(theEvent);
|
||||||
}
|
}
|
||||||
|
- (void)rotateWithEvent:(NSEvent *)theEvent {
|
||||||
|
cocoaRotateHandler(theEvent);
|
||||||
|
}
|
||||||
- (void)keyDown:(NSEvent *)theEvent {
|
- (void)keyDown:(NSEvent *)theEvent {
|
||||||
//NSLog(@"keyDown:%@",[theEvent characters]);
|
//NSLog(@"keyDown:%@",[theEvent characters]);
|
||||||
fl_lock_function();
|
fl_lock_function();
|
||||||
|
@ -43,11 +43,22 @@ int handle(int e) {
|
|||||||
return (e == FL_SHORTCUT); // eat all keystrokes
|
return (e == FL_SHORTCUT); // eat all keystrokes
|
||||||
}
|
}
|
||||||
|
|
||||||
int MyWindow::handle(int msg) {
|
int MyWindow::handle(int event) {
|
||||||
if (msg==FL_MOUSEWHEEL) {
|
static int r = 0;
|
||||||
roller_x->value( roller_x->value() + Fl::e_dx * roller_x->step() );
|
switch (event) {
|
||||||
roller_y->value( roller_y->value() + Fl::e_dy * roller_y->step() );
|
case FL_MOUSEWHEEL: {
|
||||||
return 1;
|
int x = (int)(w_scroll->xvalue() - Fl::event_dx());
|
||||||
|
int y = (int)(w_scroll->yvalue() - Fl::event_dy());
|
||||||
|
w_scroll->value( (double)(x&31), (double)(y&31) );
|
||||||
|
return 1; }
|
||||||
|
case FL_ZOOM_GESTURE: {
|
||||||
|
int z = (int)(w_zoom->yvalue() + Fl::event_dy());
|
||||||
|
w_zoom->value( (double)(z&255), (double)(z&255) );
|
||||||
|
return 1; }
|
||||||
|
case FL_ROTATE_GESTURE: {
|
||||||
|
r = r - (Fl::event_dy()/100.0);
|
||||||
|
w_rotate->value( (double)(r&1023) );
|
||||||
|
return 1; }
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ snap {
|
|||||||
Function {make_window()} {open
|
Function {make_window()} {open
|
||||||
} {
|
} {
|
||||||
Fl_Window my_window {open
|
Fl_Window my_window {open
|
||||||
xywh {448 339 495 215} type Double
|
xywh {407 352 550 215} type Double
|
||||||
code0 {\#include "keyboard.h"}
|
code0 {\#include "keyboard.h"}
|
||||||
class MyWindow visible
|
class MyWindow visible
|
||||||
} {
|
} {
|
||||||
@ -690,8 +690,8 @@ Function {make_window()} {open
|
|||||||
xywh {15 20 170 30} labelsize 9 align 5
|
xywh {15 20 170 30} labelsize 9 align 5
|
||||||
}
|
}
|
||||||
Fl_Box {} {
|
Fl_Box {} {
|
||||||
label {Fl::event_state():} selected
|
label {Fl::event_state():}
|
||||||
xywh {400 15 80 0} labelsize 9 align 5
|
xywh {400 0 80 15} labelsize 9 align 22
|
||||||
}
|
}
|
||||||
Fl_Output text_output {
|
Fl_Output text_output {
|
||||||
label {Fl::event_text():}
|
label {Fl::event_text():}
|
||||||
@ -709,15 +709,30 @@ Function {make_window()} {open
|
|||||||
callback key_cb
|
callback key_cb
|
||||||
xywh {420 70 20 20} labelsize 10
|
xywh {420 70 20 20} labelsize 10
|
||||||
}
|
}
|
||||||
Fl_Dial roller_x {
|
Fl_Box {} {
|
||||||
label {x:}
|
label {Gestures:}
|
||||||
callback wheel_cb
|
xywh {493 0 50 15} labelsize 9 align 22
|
||||||
xywh {440 70 20 20} box ROUND_UP_BOX selection_color 49 labelsize 9 align 5 step 0.1
|
|
||||||
}
|
}
|
||||||
Fl_Dial roller_y {
|
Fl_Box w_scroll {
|
||||||
label {y:}
|
label Mousewheel selected
|
||||||
callback wheel_cb
|
xywh {495 20 40 40} box DOWN_BOX selection_color 8 labelsize 8 align 2
|
||||||
xywh {460 70 20 20} box ROUND_UP_BOX selection_color 49 labelsize 9 align 5 step 0.1
|
code0 {\#include <FL/Fl_Positioner.H>}
|
||||||
|
code1 {w_scroll->xbounds(0.0, 32.0); w_scroll->ybounds(0.0, 32.0);}
|
||||||
|
code2 {w_scroll->value(16.0, 16.0);}
|
||||||
|
class Fl_Positioner
|
||||||
|
}
|
||||||
|
Fl_Box w_zoom {
|
||||||
|
label Zoom
|
||||||
|
tooltip {the zoom gestures is not supported on all platforms} xywh {495 75 40 40} box DOWN_BOX selection_color 8 labelsize 8 align 2
|
||||||
|
code0 {\#include <FL/Fl_Positioner.H>}
|
||||||
|
code1 {w_zoom->xbounds(0.0, 256.0); w_zoom->ybounds(256.0, 0.0);}
|
||||||
|
code2 {w_zoom->value(128.0, 128.0);}
|
||||||
|
class Fl_Positioner
|
||||||
|
}
|
||||||
|
Fl_Dial w_rotate {
|
||||||
|
label Rotate
|
||||||
|
tooltip {the rotation gestures is not supported on all platforms} xywh {495 130 40 40} box ROUND_DOWN_BOX selection_color 49 labelsize 8 maximum 1023 step 1
|
||||||
|
code1 {w_rotate->angles(0, 360);}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user