diff --git a/CocoaSplit.xcodeproj/project.xcworkspace/xcuserdata/zakk.xcuserdatad/UserInterfaceState.xcuserstate b/CocoaSplit.xcodeproj/project.xcworkspace/xcuserdata/zakk.xcuserdatad/UserInterfaceState.xcuserstate index 51b5d417..3fe482a7 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.h b/CocoaSplit/InputSource.h index 4f3b2ce7..b0ad94ff 100644 --- a/CocoaSplit/InputSource.h +++ b/CocoaSplit/InputSource.h @@ -245,6 +245,9 @@ typedef enum resize_style_t { -(void)autoCenter:(NSRect)containerRect; -(void)autoSize; -(void)layerUpdated; +-(void)resetAspectRatio; + + diff --git a/CocoaSplit/InputSource.m b/CocoaSplit/InputSource.m index 7301609a..2eafbc0e 100644 --- a/CocoaSplit/InputSource.m +++ b/CocoaSplit/InputSource.m @@ -1938,6 +1938,33 @@ -(void) directSize:(CGFloat)width height:(CGFloat)height } +-(void)resetAspectRatio +{ + + + if (!self.videoInput || NSEqualSizes(NSZeroSize, self.videoInput.captureSize)) + { + return; + } + + CGFloat height = self.height; + CGFloat width = self.width; + + CGFloat inputAR = self.videoInput.captureSize.width / self.videoInput.captureSize.height; + if (height > width) + { + width = inputAR * height; + } else { + height = width/inputAR; + } + + resize_style resizeSave = self.resizeType; + self.resizeType = kResizeTop | kResizeRight | kResizeFree; + [self updateSize:width height:height]; + self.resizeType = resizeSave; +} + + -(void) updateSize:(CGFloat)width height:(CGFloat)height { @@ -1962,7 +1989,6 @@ -(void) updateSize:(CGFloat)width height:(CGFloat)height height = width/inputAR; delta_h = height - oldLayout.size.height; } - } if (self.layer) diff --git a/CocoaSplit/PreviewView.m b/CocoaSplit/PreviewView.m index 045c6a7f..419786f4 100644 --- a/CocoaSplit/PreviewView.m +++ b/CocoaSplit/PreviewView.m @@ -283,10 +283,15 @@ -(void) buildSettingsMenu } else { tmp = [self.sourceSettingsMenu insertItemWithTitle:@"Attach to underlying input" action:@selector(subLayerInputSource:) keyEquivalent:@"" atIndex:idx++]; } + + tmp.target = self; + + tmp = [self.sourceSettingsMenu insertItemWithTitle:@"Reset to source AR" action:@selector(resetSourceAR:) keyEquivalent:@"" atIndex:idx++]; tmp.target = self; } + -(void)doLayoutMidi:(id)sender { if (self.sourceLayout) @@ -1167,6 +1172,34 @@ -(void)setSourceAsTimer:(id)sender } + +-(void)resetSourceAR:(id)sender +{ + InputSource *toReset = nil; + + if (sender) + { + if ([sender isKindOfClass:[NSMenuItem class]]) + { + NSMenuItem *item = (NSMenuItem *)sender; + toReset = (InputSource *)item.representedObject; + } else if ([sender isKindOfClass:[InputSource class]]) { + toReset = (InputSource *)sender; + } + } + + if (!toReset) + { + toReset = self.selectedSource; + } + + if (toReset) + { + [((InputSource *)toReset) resetAspectRatio]; + } +} + + -(void)detachSource:(id)sender { InputSource *toDetach = nil;