mirror of
https://github.com/zakk4223/CocoaSplit.git
synced 2026-05-21 06:46:14 -06:00
Added source menu item to restore the aspect ratio to the input AR
This commit is contained in:
parent
448f51b44b
commit
5978c7f85e
4 changed files with 63 additions and 1 deletions
Binary file not shown.
|
|
@ -245,6 +245,9 @@ typedef enum resize_style_t {
|
|||
-(void)autoCenter:(NSRect)containerRect;
|
||||
-(void)autoSize;
|
||||
-(void)layerUpdated;
|
||||
-(void)resetAspectRatio;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1938,6 +1938,33 @@ static NSArray *_sourceTypes = nil;
|
|||
}
|
||||
|
||||
|
||||
-(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 @@ static NSArray *_sourceTypes = nil;
|
|||
height = width/inputAR;
|
||||
delta_h = height - oldLayout.size.height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (self.layer)
|
||||
|
|
|
|||
|
|
@ -283,10 +283,15 @@
|
|||
} 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)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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue