Switch to a single OS X swipe event with a direction argument

This commit is contained in:
James Wheare 2016-03-23 15:20:11 +00:00
parent 03319a5426
commit 8482109dea
7 changed files with 21 additions and 64 deletions

View file

@ -243,20 +243,8 @@ void Window::OnWindowScrollTouchEnd() {
Emit("scroll-touch-end");
}
void Window::OnWindowSwipeUp() {
Emit("swipe-up");
}
void Window::OnWindowSwipeRight() {
Emit("swipe-right");
}
void Window::OnWindowSwipeDown() {
Emit("swipe-down");
}
void Window::OnWindowSwipeLeft() {
Emit("swipe-left");
void Window::OnWindowSwipe(const std::string& direction) {
Emit("swipe", direction);
}
void Window::OnWindowEnterHtmlFullScreen() {

View file

@ -69,10 +69,7 @@ class Window : public mate::TrackableObject<Window>,
void OnWindowMoved() override;
void OnWindowScrollTouchBegin() override;
void OnWindowScrollTouchEnd() override;
void OnWindowSwipeUp() override;
void OnWindowSwipeRight() override;
void OnWindowSwipeDown() override;
void OnWindowSwipeLeft() override;
void OnWindowSwipe(const std::string& direction) override;
void OnWindowEnterFullScreen() override;
void OnWindowLeaveFullScreen() override;
void OnWindowEnterHtmlFullScreen() override;

View file

@ -480,24 +480,9 @@ void NativeWindow::NotifyWindowScrollTouchEnd() {
OnWindowScrollTouchEnd());
}
void NativeWindow::NotifyWindowSwipeUp() {
void NativeWindow::NotifyWindowSwipe(const std::string& direction) {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
OnWindowSwipeUp());
}
void NativeWindow::NotifyWindowSwipeRight() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
OnWindowSwipeRight());
}
void NativeWindow::NotifyWindowSwipeDown() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
OnWindowSwipeDown());
}
void NativeWindow::NotifyWindowSwipeLeft() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
OnWindowSwipeLeft());
OnWindowSwipe(direction));
}
void NativeWindow::NotifyWindowLeaveFullScreen() {

View file

@ -221,10 +221,7 @@ class NativeWindow : public base::SupportsUserData,
void NotifyWindowMoved();
void NotifyWindowScrollTouchBegin();
void NotifyWindowScrollTouchEnd();
void NotifyWindowSwipeUp();
void NotifyWindowSwipeRight();
void NotifyWindowSwipeDown();
void NotifyWindowSwipeLeft();
void NotifyWindowSwipe(const std::string& direction);
void NotifyWindowEnterFullScreen();
void NotifyWindowLeaveFullScreen();
void NotifyWindowEnterHtmlFullScreen();

View file

@ -268,15 +268,15 @@ bool ScopedDisableResize::disable_resize_ = false;
// NSWindow overrides.
- (void)swipeWithEvent:(NSEvent *)event {
if (event.deltaY == 1.0) {
shell_->NotifyWindowSwipeUp();
} else if (event.deltaX == -1.0) {
shell_->NotifyWindowSwipeRight();
} else if (event.deltaY == -1.0) {
shell_->NotifyWindowSwipeDown();
} else if (event.deltaX == 1.0) {
shell_->NotifyWindowSwipeLeft();
}
if (event.deltaY == 1.0) {
shell_->NotifyWindowSwipe("up");
} else if (event.deltaX == -1.0) {
shell_->NotifyWindowSwipe("right");
} else if (event.deltaY == -1.0) {
shell_->NotifyWindowSwipe("down");
} else if (event.deltaX == 1.0) {
shell_->NotifyWindowSwipe("left");
}
}
- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen*)screen {

View file

@ -58,10 +58,7 @@ class NativeWindowObserver {
virtual void OnWindowMoved() {}
virtual void OnWindowScrollTouchBegin() {}
virtual void OnWindowScrollTouchEnd() {}
virtual void OnWindowSwipeUp() {}
virtual void OnWindowSwipeRight() {}
virtual void OnWindowSwipeDown() {}
virtual void OnWindowSwipeLeft() {}
virtual void OnWindowSwipe(const std::string& direction) {}
virtual void OnWindowEnterFullScreen() {}
virtual void OnWindowLeaveFullScreen() {}
virtual void OnWindowEnterHtmlFullScreen() {}

View file

@ -322,21 +322,14 @@ Emitted when scroll wheel event phase has begun.
Emitted when scroll wheel event phase has ended.
### Event: 'swipe-up' _OS X_
### Event: 'swipe' _OS X_
Emitted on 3-finger swipe up.
Returns:
### Event: 'swipe-right' _OS X_
* `event` Event
* `direction` String
Emitted on 3-finger swipe right.
### Event: 'swipe-down' _OS X_
Emitted on 3-finger swipe down.
### Event: 'swipe-left' _OS X_
Emitted on 3-finger swipe left.
Emitted on 3-finger swipe. Possible directions are `up`, `right`, `down`, `left`.
## Methods