-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathAppDelegate.m
More file actions
64 lines (50 loc) · 1.99 KB
/
AppDelegate.m
File metadata and controls
64 lines (50 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// AppDelegate.m
// FFmpegTutorial-macOS
//
// Created by Matt Reach on 2020/11/18.
//
#import "AppDelegate.h"
#import "NSNavigationController.h"
#import "RootViewController.h"
@interface AppDelegate ()
@property (nonatomic, strong) NSWindowController *rootWinController;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
NSWindow *window = [[NSWindow alloc] initWithContentRect:CGRectZero styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:YES];
window.titleVisibility = NSWindowTitleHidden;
window.titlebarAppearsTransparent = YES;
window.styleMask |= NSWindowStyleMaskFullSizeContentView;
[window setMinSize:CGSizeMake(300, 300)];
NSWindowController *rootWinController = [[NSWindowController alloc] initWithWindow:window];
RootViewController *rootViewController = [[RootViewController alloc] init];
NSNavigationController *navController = [[NSNavigationController alloc] initWithRootViewController:rootViewController];
window.contentViewController = navController;
window.movableByWindowBackground = YES;
[window center];
[window makeKeyAndOrderFront:nil];
self.rootWinController = rootWinController;
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
{
return YES;
}
- (void)applicationWillTerminate:(NSNotification *)aNotification
{
// Insert code here to tear down your application
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag
{
if (self.rootWinController) {
if (self.rootWinController.window.isMiniaturized) {
[self.rootWinController.window deminiaturize:nil];
} else if (!self.rootWinController.window.isVisible) {
[self.rootWinController showWindow:nil];
}
}
return YES;
}
@end