diff --git a/CocoaSplit.xcodeproj/project.xcworkspace/xcuserdata/zakk.xcuserdatad/UserInterfaceState.xcuserstate b/CocoaSplit.xcodeproj/project.xcworkspace/xcuserdata/zakk.xcuserdatad/UserInterfaceState.xcuserstate index 2be50997..51b5d417 100644 Binary files a/CocoaSplit.xcodeproj/project.xcworkspace/xcuserdata/zakk.xcuserdatad/UserInterfaceState.xcuserstate and b/CocoaSplit.xcodeproj/project.xcworkspace/xcuserdata/zakk.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/CocoaSplit/InputSource.m b/CocoaSplit/InputSource.m index d1f34ad3..7301609a 100644 --- a/CocoaSplit/InputSource.m +++ b/CocoaSplit/InputSource.m @@ -1880,9 +1880,7 @@ static NSArray *_sourceTypes = nil; if (NSContainsRect(containerRect, myRect)) { - CGFloat newX = (containerRect.origin.x + containerRect.size.width/2) - myRect.size.width/2; - CGFloat newY = (containerRect.origin.y + containerRect.size.height/2) - myRect.size.height/2; - [self positionOrigin:newX y:newY]; + [self autoFit]; } else { //We're bigger than the container! Set ourselves to the exact same size and origin [self directSize:containerRect.size.width height:containerRect.size.height]; @@ -1894,20 +1892,13 @@ static NSArray *_sourceTypes = nil; -(void)autoFit { - NSMutableDictionary *newConstraints = [NSMutableDictionary dictionary]; - - [self initDictionaryForConstraints:newConstraints]; - - newConstraints[@"HorizontalCenter"][@"attr"] = @(kCAConstraintMidX); - newConstraints[@"Width"][@"attr"] = @(kCAConstraintWidth); - newConstraints[@"VerticalCenter"][@"attr"] = @(kCAConstraintMidY); - newConstraints[@"Height"][@"attr"] = @(kCAConstraintHeight); - self.constraintMap = newConstraints; - - [self buildLayerConstraints]; - //self.layer.bounds = self.layer.superlayer.bounds; - //self.layer.position = CGPointMake(self.layer.bounds.size.width/2, self.layer.bounds.size.height/2); - + float wr = self.size.width / self.canvas_width; + float hr = self.size.height / self.canvas_height; + float ratio = (hr < wr ? wr : hr); + [self directSize:self.size.width / ratio height:self.size.height / ratio]; + CGFloat newX = (self.canvas_width/2) - self.layer.bounds.size.width/2; + CGFloat newY = (self.canvas_height/2) - self.layer.bounds.size.height/2; + [self positionOrigin:newX y:newY]; } @@ -1958,13 +1949,19 @@ static NSArray *_sourceTypes = nil; CGFloat delta_w, delta_h; delta_w = width - oldLayout.size.width; delta_h = height - oldLayout.size.height; - //Preserve aspect ratio on resize. Take the dimension with the biggest change, and fit the other dimension to it + //Preserve aspect ratio on resize. Take the largest dimension and figure out hte other one if (self.videoInput && !NSEqualSizes(self.videoInput.captureSize, NSZeroSize) && !(self.resizeType & kResizeFree) && !(self.resizeType & kResizeCrop)) { CGFloat inputAR = oldLayout.size.width / oldLayout.size.height; - height = width/inputAR; - delta_h = height - oldLayout.size.height; + if (height > width) + { + width = inputAR * height; + delta_w = width - oldLayout.size.width; + } else { + height = width/inputAR; + delta_h = height - oldLayout.size.height; + } } diff --git a/CocoaSplit/PreviewView.m b/CocoaSplit/PreviewView.m index 55d7d46a..045c6a7f 100644 --- a/CocoaSplit/PreviewView.m +++ b/CocoaSplit/PreviewView.m @@ -751,10 +751,7 @@ if (self.isResizing) { - if (0) - { - } else { - + if (theEvent.modifierFlags & NSAlternateKeyMask) { self.resizeType |= kResizeCenter; @@ -797,7 +794,6 @@ [self.selectedSource updateSize:new_width height:new_height]; - } } else { @@ -821,7 +817,6 @@ -(void)adjustDeltas:(CGFloat *)dx dy:(CGFloat *)dy { - return; InputSource *superInput = self.selectedSource.parentInput; NSPoint c_lb_snap; @@ -868,6 +863,10 @@ int snap_idx = 3; for (InputSource *src in srcs) { + if (src == self.selectedSource) + { + continue; + } NSRect srect = src.globalLayoutPosition; c_snaps[snap_idx++] = srect.origin; c_snaps[snap_idx++] = NSMakePoint(NSMaxX(srect), NSMaxY(srect));