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:
		
					parent
					
						
							
								2e3d757f46
							
						
					
				
			
			
				commit
				
					
						2c383b51c1
					
				
			
		
					 7 changed files with 29 additions and 0 deletions
				
			
		| 
						 | 
					@ -614,6 +614,19 @@ Returns:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Emitted on 3-finger swipe. Possible directions are `up`, `right`, `down`, `left`.
 | 
					Emitted on 3-finger swipe. Possible directions are `up`, `right`, `down`, `left`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#### Event: 'rotate-gesture' _macOS_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Returns:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* `event` Event
 | 
				
			||||||
 | 
					* `rotation` Float
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Emitted on trackpad rotation gesture. Continually emitted until rotation gesture is
 | 
				
			||||||
 | 
					ended. The `rotation` value on each emission is the angle in degrees rotated since
 | 
				
			||||||
 | 
					the last emission. The last emitted event upon a rotation gesture will always be of
 | 
				
			||||||
 | 
					value `0`. Counter-clockwise rotation values are positive, while clockwise ones are
 | 
				
			||||||
 | 
					negative.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### Event: 'sheet-begin' _macOS_
 | 
					#### Event: 'sheet-begin' _macOS_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Emitted when the window opens a sheet.
 | 
					Emitted when the window opens a sheet.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -246,6 +246,10 @@ void TopLevelWindow::OnWindowSwipe(const std::string& direction) {
 | 
				
			||||||
  Emit("swipe", direction);
 | 
					  Emit("swipe", direction);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TopLevelWindow::OnWindowRotateGesture(float rotation) {
 | 
				
			||||||
 | 
					  Emit("rotate-gesture", rotation);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TopLevelWindow::OnWindowSheetBegin() {
 | 
					void TopLevelWindow::OnWindowSheetBegin() {
 | 
				
			||||||
  Emit("sheet-begin");
 | 
					  Emit("sheet-begin");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,6 +73,7 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
 | 
				
			||||||
  void OnWindowScrollTouchBegin() override;
 | 
					  void OnWindowScrollTouchBegin() override;
 | 
				
			||||||
  void OnWindowScrollTouchEnd() override;
 | 
					  void OnWindowScrollTouchEnd() override;
 | 
				
			||||||
  void OnWindowSwipe(const std::string& direction) override;
 | 
					  void OnWindowSwipe(const std::string& direction) override;
 | 
				
			||||||
 | 
					  void OnWindowRotateGesture(float rotation) override;
 | 
				
			||||||
  void OnWindowSheetBegin() override;
 | 
					  void OnWindowSheetBegin() override;
 | 
				
			||||||
  void OnWindowSheetEnd() override;
 | 
					  void OnWindowSheetEnd() override;
 | 
				
			||||||
  void OnWindowEnterFullScreen() override;
 | 
					  void OnWindowEnterFullScreen() override;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -513,6 +513,11 @@ void NativeWindow::NotifyWindowSwipe(const std::string& direction) {
 | 
				
			||||||
    observer.OnWindowSwipe(direction);
 | 
					    observer.OnWindowSwipe(direction);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void NativeWindow::NotifyWindowRotateGesture(float rotation) {
 | 
				
			||||||
 | 
					  for (NativeWindowObserver& observer : observers_)
 | 
				
			||||||
 | 
					    observer.OnWindowRotateGesture(rotation);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void NativeWindow::NotifyWindowSheetBegin() {
 | 
					void NativeWindow::NotifyWindowSheetBegin() {
 | 
				
			||||||
  for (NativeWindowObserver& observer : observers_)
 | 
					  for (NativeWindowObserver& observer : observers_)
 | 
				
			||||||
    observer.OnWindowSheetBegin();
 | 
					    observer.OnWindowSheetBegin();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -256,6 +256,7 @@ class NativeWindow : public base::SupportsUserData,
 | 
				
			||||||
  void NotifyWindowScrollTouchBegin();
 | 
					  void NotifyWindowScrollTouchBegin();
 | 
				
			||||||
  void NotifyWindowScrollTouchEnd();
 | 
					  void NotifyWindowScrollTouchEnd();
 | 
				
			||||||
  void NotifyWindowSwipe(const std::string& direction);
 | 
					  void NotifyWindowSwipe(const std::string& direction);
 | 
				
			||||||
 | 
					  void NotifyWindowRotateGesture(float rotation);
 | 
				
			||||||
  void NotifyWindowSheetBegin();
 | 
					  void NotifyWindowSheetBegin();
 | 
				
			||||||
  void NotifyWindowSheetEnd();
 | 
					  void NotifyWindowSheetEnd();
 | 
				
			||||||
  void NotifyWindowEnterFullScreen();
 | 
					  void NotifyWindowEnterFullScreen();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,6 +78,7 @@ class NativeWindowObserver : public base::CheckedObserver {
 | 
				
			||||||
  virtual void OnWindowScrollTouchBegin() {}
 | 
					  virtual void OnWindowScrollTouchBegin() {}
 | 
				
			||||||
  virtual void OnWindowScrollTouchEnd() {}
 | 
					  virtual void OnWindowScrollTouchEnd() {}
 | 
				
			||||||
  virtual void OnWindowSwipe(const std::string& direction) {}
 | 
					  virtual void OnWindowSwipe(const std::string& direction) {}
 | 
				
			||||||
 | 
					  virtual void OnWindowRotateGesture(float rotation) {}
 | 
				
			||||||
  virtual void OnWindowSheetBegin() {}
 | 
					  virtual void OnWindowSheetBegin() {}
 | 
				
			||||||
  virtual void OnWindowSheetEnd() {}
 | 
					  virtual void OnWindowSheetEnd() {}
 | 
				
			||||||
  virtual void OnWindowEnterFullScreen() {}
 | 
					  virtual void OnWindowEnterFullScreen() {}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,6 +72,10 @@ bool ScopedDisableResize::disable_resize_ = false;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- (void)rotateWithEvent:(NSEvent*)event {
 | 
				
			||||||
 | 
					  shell_->NotifyWindowRotateGesture(event.rotation);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- (NSRect)contentRectForFrameRect:(NSRect)frameRect {
 | 
					- (NSRect)contentRectForFrameRect:(NSRect)frameRect {
 | 
				
			||||||
  if (shell_->has_frame())
 | 
					  if (shell_->has_frame())
 | 
				
			||||||
    return [super contentRectForFrameRect:frameRect];
 | 
					    return [super contentRectForFrameRect:frameRect];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue