mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-25 23:57:53 +03:00
Added InputEvent::MouseWheel event. Also added onMouseWheel event for Node.
Enabled wheel scroll momentum for macOS on ecode.
This commit is contained in:
@@ -68,6 +68,8 @@ class EE_API EventDispatcher {
|
||||
|
||||
void sendMouseDown( Node* toNode, const Vector2i& pos, const Uint32 flags );
|
||||
|
||||
void sendMouseWheel( const Vector2f& offset, bool flipped );
|
||||
|
||||
const Uint32& getPressTrigger() const;
|
||||
|
||||
const Uint32& getLastPressTrigger() const;
|
||||
|
||||
@@ -495,6 +495,8 @@ class EE_API Node : public Transformable {
|
||||
|
||||
virtual Uint32 onMouseLeave( const Vector2i& position, const Uint32& flags );
|
||||
|
||||
virtual Uint32 onMouseWheel( const Vector2f& offset, bool flipped );
|
||||
|
||||
virtual Uint32 onCalculateDrag( const Vector2f& position, const Uint32& flags );
|
||||
|
||||
void onClose();
|
||||
|
||||
@@ -76,6 +76,14 @@ class InputEvent {
|
||||
Int16 x, y; /** The X/Y coordinates of the mouse at press time */
|
||||
};
|
||||
|
||||
struct WheelEvent {
|
||||
enum Direction { Normal, Flipped };
|
||||
Uint32 which;
|
||||
Float x;
|
||||
Float y;
|
||||
Direction direction;
|
||||
};
|
||||
|
||||
/** Touch finger motion/finger event structure */
|
||||
struct FingerEvent {
|
||||
Uint32 timestamp;
|
||||
@@ -204,6 +212,7 @@ class InputEvent {
|
||||
FileDropped,
|
||||
TextDropped,
|
||||
TextEditing,
|
||||
MouseWheel,
|
||||
EventUser,
|
||||
EventCount = EventUser - 1
|
||||
};
|
||||
@@ -233,6 +242,7 @@ class InputEvent {
|
||||
TextEditingEvent textediting;
|
||||
QuitEvent quit;
|
||||
UserEvent user;
|
||||
WheelEvent wheel;
|
||||
SysWMEvent syswm;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -66,6 +66,11 @@ void EventDispatcher::inputCallback( InputEvent* event ) {
|
||||
sendTextEditing( event->textediting.text, event->textediting.start,
|
||||
event->textediting.length );
|
||||
break;
|
||||
case InputEvent::MouseWheel:
|
||||
sendMouseWheel( { event->wheel.x, event->wheel.y },
|
||||
event->wheel.direction == InputEvent::WheelEvent::Normal ? true
|
||||
: false );
|
||||
break;
|
||||
case InputEvent::SysWM:
|
||||
case InputEvent::VideoResize:
|
||||
case InputEvent::VideoExpose: {
|
||||
@@ -253,6 +258,15 @@ void EventDispatcher::sendKeyDown( const Keycode& keyCode, const Scancode& scanc
|
||||
}
|
||||
}
|
||||
|
||||
void EventDispatcher::sendMouseWheel( const Vector2f& offset, bool flipped ) {
|
||||
Node* node = mFocusNode;
|
||||
while ( NULL != node ) {
|
||||
if ( node->isEnabled() && node->onMouseWheel( offset, flipped ) )
|
||||
break;
|
||||
node = node->getParent();
|
||||
}
|
||||
}
|
||||
|
||||
void EventDispatcher::sendMsg( Node* node, const Uint32& Msg, const Uint32& Flags ) {
|
||||
NodeMessage tMsg( node, Msg, Flags );
|
||||
node->messagePost( &tMsg );
|
||||
|
||||
@@ -397,6 +397,10 @@ Uint32 Node::onMouseLeave( const Vector2i& Pos, const Uint32& Flags ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
Uint32 Node::onMouseWheel( const Vector2f& offset, bool flipped ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
Uint32 Node::onCalculateDrag( const Vector2f&, const Uint32& ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -357,6 +357,22 @@ void InputSDL::sendEvent( const SDL_Event& SDLEvent ) {
|
||||
|
||||
event.Type = InputEvent::MouseButtonUp;
|
||||
event.button.state = 0;
|
||||
processEvent( &event );
|
||||
|
||||
event.Type = InputEvent::MouseWheel;
|
||||
event.wheel.which = SDLEvent.wheel.which;
|
||||
event.wheel.direction = SDLEvent.wheel.direction == SDL_MOUSEWHEEL_NORMAL
|
||||
? InputEvent::WheelEvent::Normal
|
||||
: InputEvent::WheelEvent::Flipped;
|
||||
|
||||
#if SDL_VERSION_ATLEAST( 2, 0, 18 )
|
||||
event.wheel.x = SDLEvent.wheel.preciseX;
|
||||
event.wheel.y = SDLEvent.wheel.preciseY;
|
||||
#else
|
||||
event.wheel.x = SDLEvent.wheel.x;
|
||||
event.wheel.y = SDLEvent.wheel.y;
|
||||
#endif
|
||||
processEvent( &event );
|
||||
break;
|
||||
}
|
||||
case SDL_FINGERMOTION: {
|
||||
|
||||
@@ -3287,6 +3287,7 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe
|
||||
#endif
|
||||
#if EE_PLATFORM == EE_PLATFORM_MACOS
|
||||
macOS_CreateApplicationMenus();
|
||||
macOS_EnableScrollMomentum();
|
||||
|
||||
mThreadPool->run( [this]() {
|
||||
// Checks if the default shell path contains more paths
|
||||
|
||||
@@ -7,6 +7,8 @@ extern "C" {
|
||||
|
||||
void macOS_CreateApplicationMenus();
|
||||
|
||||
void macOS_EnableScrollMomentum();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -63,3 +63,7 @@ macOS_CreateApplicationMenus(void)
|
||||
|
||||
[NSApp setWindowsMenu:windowMenu];
|
||||
}
|
||||
|
||||
void macOS_EnableScrollMomentum() {
|
||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"AppleMomentumScrollSupported"];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user