🍎 let Cocoa handle keeping the aspect ratio whenever the edges are dragged
This commit is contained in:
		
					parent
					
						
							
								f441ba2694
							
						
					
				
			
			
				commit
				
					
						8f7a04f9c3
					
				
			
		
					 1 changed files with 4 additions and 15 deletions
				
			
		| 
						 | 
					@ -141,22 +141,11 @@ bool ScopedDisableResize::disable_resize_ = false;
 | 
				
			||||||
    newSize.width =
 | 
					    newSize.width =
 | 
				
			||||||
        roundf((frameSize.height - extraHeightPlusFrame) * aspectRatio +
 | 
					        roundf((frameSize.height - extraHeightPlusFrame) * aspectRatio +
 | 
				
			||||||
               extraWidthPlusFrame);
 | 
					               extraWidthPlusFrame);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    // If the new width is less than the frame size use it as the primary
 | 
					 | 
				
			||||||
    // constraint. This ensures that the value returned by this method will
 | 
					 | 
				
			||||||
    // never be larger than the users requested window size.
 | 
					 | 
				
			||||||
    if (newSize.width <= frameSize.width) {
 | 
					 | 
				
			||||||
    newSize.height =
 | 
					    newSize.height =
 | 
				
			||||||
        roundf((newSize.width - extraWidthPlusFrame) / aspectRatio +
 | 
					        roundf((newSize.width - extraWidthPlusFrame) / aspectRatio +
 | 
				
			||||||
               extraHeightPlusFrame);
 | 
					               extraHeightPlusFrame);
 | 
				
			||||||
    } else {
 | 
					
 | 
				
			||||||
      newSize.height =
 | 
					    [sender setAspectRatio:NSMakeSize(newSize.width, newSize.height)];
 | 
				
			||||||
          roundf((frameSize.width - extraWidthPlusFrame) / aspectRatio +
 | 
					 | 
				
			||||||
                 extraHeightPlusFrame);
 | 
					 | 
				
			||||||
      newSize.width =
 | 
					 | 
				
			||||||
          roundf((newSize.height - extraHeightPlusFrame) * aspectRatio +
 | 
					 | 
				
			||||||
                 extraWidthPlusFrame);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return newSize;
 | 
					  return newSize;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue