Revamp Mini Window shortcuts.
Fix deprecation warnings. Set max and min size for content view in code.CQTexperiment
parent
5a1c398291
commit
78d8c0050c
|
@ -170,7 +170,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
[[miniWindow standardWindowButton:NSWindowZoomButton] setHidden:YES];
|
||||
// Restore mini mode
|
||||
[self setMiniMode:[[NSUserDefaults standardUserDefaults] boolForKey:@"miniMode"]];
|
||||
|
||||
|
|
|
@ -584,12 +584,10 @@
|
|||
</window>
|
||||
<window title="Cog" separatorStyle="none" allowsToolTipsWhenApplicationIsInactive="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="Mini Window" animationBehavior="default" titlebarAppearsTransparent="YES" toolbarStyle="expanded" id="2234" userLabel="Mini Window (Window)" customClass="MiniWindow">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<rect key="contentRect" x="192" y="547" width="480" height="1"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
|
||||
<value key="minSize" type="size" width="280" height="1"/>
|
||||
<value key="maxSize" type="size" width="600" height="1"/>
|
||||
<rect key="contentRect" x="192" y="547" width="480" height="0.0"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1792" height="1095"/>
|
||||
<view key="contentView" hidden="YES" wantsLayer="YES" id="2235">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="1"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="0.0"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
</view>
|
||||
<toolbar key="toolbar" implicitIdentifier="35998ECE-5AD8-429E-8479-657249B22C9C" displayMode="iconOnly" sizeMode="regular" id="2222" userLabel="Mini Toolbar">
|
||||
|
|
|
@ -8,27 +8,23 @@
|
|||
|
||||
#import "MiniWindow.h"
|
||||
|
||||
|
||||
@implementation MiniWindow
|
||||
|
||||
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
|
||||
{
|
||||
self = [super initWithContentRect:contentRect styleMask:windowStyle backing:bufferingType defer:deferCreation];
|
||||
if (self)
|
||||
{
|
||||
[self setShowsResizeIndicator:NO];
|
||||
[self setExcludedFromWindowsMenu:YES];
|
||||
self = [super initWithContentRect:contentRect styleMask:windowStyle backing:bufferingType defer:deferCreation];
|
||||
if (self)
|
||||
{
|
||||
[self setShowsResizeIndicator:NO];
|
||||
[self setExcludedFromWindowsMenu:YES];
|
||||
[[self standardWindowButton:NSWindowZoomButton] setEnabled:NO];
|
||||
// Disallow height resize.
|
||||
[self setContentMinSize:NSMakeSize(280, 0)];
|
||||
[self setContentMaxSize:NSMakeSize(CGFLOAT_MAX, 0)];
|
||||
[self setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)proposedFrameSize {
|
||||
// Do not allow height to change
|
||||
proposedFrameSize.height = [self frame].size.height;
|
||||
|
||||
return proposedFrameSize;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)toggleToolbarShown:(id)sender {
|
||||
|
@ -37,39 +33,51 @@
|
|||
}
|
||||
|
||||
- (void)keyDown:(NSEvent *)e {
|
||||
unsigned int modifiers = [e modifierFlags] & (NSCommandKeyMask | NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask);
|
||||
NSString *characters = [e characters];
|
||||
unichar c;
|
||||
BOOL modifiersUsed =
|
||||
([e modifierFlags] & (NSEventModifierFlagShift |
|
||||
NSEventModifierFlagControl |
|
||||
NSEventModifierFlagOption |
|
||||
NSEventModifierFlagCommand)) ? YES : NO;
|
||||
NSString *characters = [e charactersIgnoringModifiers];
|
||||
|
||||
if ([characters length] != 1)
|
||||
if (modifiersUsed || [characters length] != 1)
|
||||
{
|
||||
[super keyDown:e];
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c = [characters characterAtIndex:0];
|
||||
if (modifiers == 0 && c == ' ')
|
||||
{
|
||||
[playbackController playPauseResume:self];
|
||||
}
|
||||
else if (modifiers == 0 && (c == NSEnterCharacter || c == NSCarriageReturnCharacter))
|
||||
{
|
||||
[playbackController play:self];
|
||||
}
|
||||
else if (modifiers == 0 && c == NSLeftArrowFunctionKey)
|
||||
{
|
||||
[playbackController eventSeekBackward:self];
|
||||
}
|
||||
else if (modifiers == 0 && c == NSRightArrowFunctionKey)
|
||||
{
|
||||
[playbackController eventSeekForward:self];
|
||||
}
|
||||
else
|
||||
{
|
||||
[super keyDown:e];
|
||||
}
|
||||
|
||||
unichar c = [characters characterAtIndex:0];
|
||||
switch (c) {
|
||||
case 0x20: // Spacebar
|
||||
[playbackController playPauseResume:self];
|
||||
break;
|
||||
|
||||
case NSEnterCharacter:
|
||||
case NSCarriageReturnCharacter:
|
||||
[playbackController play:self];
|
||||
break;
|
||||
|
||||
case NSLeftArrowFunctionKey:
|
||||
[playbackController eventSeekBackward:self];
|
||||
break;
|
||||
|
||||
case NSRightArrowFunctionKey:
|
||||
[playbackController eventSeekForward:self];
|
||||
break;
|
||||
|
||||
case NSUpArrowFunctionKey:
|
||||
[playbackController volumeUp:self];
|
||||
break;
|
||||
|
||||
case NSDownArrowFunctionKey:
|
||||
[playbackController volumeDown:self];
|
||||
break;
|
||||
|
||||
default:
|
||||
[super keyDown:e];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue