feat: add rotate gesture for macOS (#19294)

* feat: add rotate gesture for macOS

* docs: document change

* refactor: rename 'rotate' -> 'rotate-gesture'

* refactor: const float -> float

* forgot one 🤦‍♂️
This commit is contained in:
Erick Zhao 2019-07-23 12:42:26 -07:00 committed by Charles Kerr
parent 2e3d757f46
commit 2c383b51c1
7 changed files with 29 additions and 0 deletions

View file

@ -246,6 +246,10 @@ void TopLevelWindow::OnWindowSwipe(const std::string& direction) {
Emit("swipe", direction);
}
void TopLevelWindow::OnWindowRotateGesture(float rotation) {
Emit("rotate-gesture", rotation);
}
void TopLevelWindow::OnWindowSheetBegin() {
Emit("sheet-begin");
}

View file

@ -73,6 +73,7 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
void OnWindowScrollTouchBegin() override;
void OnWindowScrollTouchEnd() override;
void OnWindowSwipe(const std::string& direction) override;
void OnWindowRotateGesture(float rotation) override;
void OnWindowSheetBegin() override;
void OnWindowSheetEnd() override;
void OnWindowEnterFullScreen() override;

View file

@ -513,6 +513,11 @@ void NativeWindow::NotifyWindowSwipe(const std::string& direction) {
observer.OnWindowSwipe(direction);
}
void NativeWindow::NotifyWindowRotateGesture(float rotation) {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowRotateGesture(rotation);
}
void NativeWindow::NotifyWindowSheetBegin() {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowSheetBegin();

View file

@ -256,6 +256,7 @@ class NativeWindow : public base::SupportsUserData,
void NotifyWindowScrollTouchBegin();
void NotifyWindowScrollTouchEnd();
void NotifyWindowSwipe(const std::string& direction);
void NotifyWindowRotateGesture(float rotation);
void NotifyWindowSheetBegin();
void NotifyWindowSheetEnd();
void NotifyWindowEnterFullScreen();

View file

@ -78,6 +78,7 @@ class NativeWindowObserver : public base::CheckedObserver {
virtual void OnWindowScrollTouchBegin() {}
virtual void OnWindowScrollTouchEnd() {}
virtual void OnWindowSwipe(const std::string& direction) {}
virtual void OnWindowRotateGesture(float rotation) {}
virtual void OnWindowSheetBegin() {}
virtual void OnWindowSheetEnd() {}
virtual void OnWindowEnterFullScreen() {}

View file

@ -72,6 +72,10 @@ bool ScopedDisableResize::disable_resize_ = false;
}
}
- (void)rotateWithEvent:(NSEvent*)event {
shell_->NotifyWindowRotateGesture(event.rotation);
}
- (NSRect)contentRectForFrameRect:(NSRect)frameRect {
if (shell_->has_frame())
return [super contentRectForFrameRect:frameRect];