forked from samiamwork/Movist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFullScreener.m
267 lines (214 loc) · 7.56 KB
/
FullScreener.m
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
//
// Movist
//
// Copyright 2006 ~ 2008 Yong-Hoe Kim. All rights reserved.
// Yong-Hoe Kim <[email protected]>
//
// This file is part of Movist.
//
// Movist is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Movist is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#import "FullScreener.h"
#import "MMovieView.h"
#import "MainWindow.h"
#import "FullWindow.h"
#import "PlayPanel.h"
#import "UserDefaults.h"
@interface FullScreener (NoEffectTransition)
- (void)beginNoEffectTransition;
- (void)endNoEffectTransition;
@end
@interface FullScreener (FadeTransition)
- (void)beginFadeTransition:(float)fadeDuration;
- (void)endFadeTransition:(float)fadeDuration;
@end
@interface FullScreener (AnimationTransition)
- (void)initAnimationTransition;
- (void)beginAnimationTransition;
- (void)endAnimationTransition;
@end
////////////////////////////////////////////////////////////////////////////////
#pragma mark -
@implementation FullScreener
- (id)initWithMainWindow:(MainWindow*)mainWindow
playPanel:(PlayPanel*)playPanel
{
//TRACE(@"%s", __PRETTY_FUNCTION__);
if (self = [super init]) {
_mainWindow = [mainWindow retain];
_movieView = [[_mainWindow movieView] retain];
_playPanel = [playPanel retain];
_fullWindow = [[FullWindow alloc] initWithScreen:[_mainWindow screen]
playPanel:_playPanel];
_movieViewRect = [_movieView frame];
_autoShowDock = TRUE;
_mainMenuAndDockIsHidden = FALSE;
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
_effect = [defaults integerForKey:MFullScreenEffectKey];
#if defined(AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER)
if ([_mainWindow userSpaceScaleFactor] != 1.0 &&
_effect == FS_EFFECT_ANIMATION) {
_effect = FS_EFFECT_NONE;
}
#endif
[self initAnimationTransition];
if ([defaults boolForKey:MFullScreenBlackScreensKey] &&
1 < [[NSScreen screens] count]) {
NSMutableArray* screens = [NSMutableArray arrayWithArray:[NSScreen screens]];
[screens removeObject:[_mainWindow screen]]; // except current screen
_blackScreenFader = [[ScreenFader alloc] initWithScreens:screens];
}
}
return self;
}
- (void)dealloc
{
//TRACE(@"%s", __PRETTY_FUNCTION__);
[_blackScreenFader release];
[_fullWindow release];
[_mainWindow release];
[_movieView release];
[_movieURL release];
[super dealloc];
}
////////////////////////////////////////////////////////////////////////////////
#pragma mark -
- (FullWindow*)fullWindow { return _fullWindow; }
- (void)setMovieURL:(NSURL*)movieURL
{
//TRACE(@"%s \"%@\"", __PRETTY_FUNCTION__, [movieURL absoluteString]);
[movieURL retain], [_movieURL release], _movieURL = movieURL;
[_fullWindow setMovieURL:_movieURL];
[_playPanel setMovieURL:_movieURL];
if ([self isNavigation]) {
[_fullWindow selectMovie:movieURL];
}
}
- (void)setAutoShowDock:(BOOL)autoShow
{
_autoShowDock = autoShow;
}
#define SCREEN_FADE_DURATION 0.25
#define FADE_EFFECT_DURATION 0.5
#define NAV_FADE_DURATION 1.0
- (void)beginBlackScreens { [_blackScreenFader fadeOut:SCREEN_FADE_DURATION]; }
- (void)endBlackScreens { [_blackScreenFader fadeIn:SCREEN_FADE_DURATION]; }
////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark full-screen
- (BOOL)isFullScreen { return ![self isDesktopBackground] && ![self isNavigating]; }
- (void)beginFullScreen
{
//TRACE(@"%s", __PRETTY_FUNCTION__);
if (_blackScreenFader) {
[self beginBlackScreens];
}
BOOL subtitleVisible = [_movieView subtitleVisible];
[_movieView setSubtitleVisible:FALSE];
_fullScreenFromDesktopBackground = [self isDesktopBackground];
if (_fullScreenFromDesktopBackground) {
[self beginFullScreenFromDesktopBackground];
}
else {
switch (_effect) {
case FS_EFFECT_FADE :
[self beginFadeTransition:FADE_EFFECT_DURATION];
break;
case FS_EFFECT_ANIMATION :
[self beginAnimationTransition];
break;
default : // FS_EFFECT_NONE
[self beginNoEffectTransition];
break;
}
}
[_movieView setSubtitleVisible:subtitleVisible];
[_fullWindow setAcceptsMouseMovedEvents:TRUE];
}
- (void)endFullScreen
{
//TRACE(@"%s", __PRETTY_FUNCTION__);
[_fullWindow setAcceptsMouseMovedEvents:FALSE];
[_playPanel orderOut:self]; // immediately without fade-effect
BOOL subtitleVisible = [_movieView subtitleVisible];
[_movieView setSubtitleVisible:FALSE];
if (_fullScreenFromDesktopBackground) {
[self endFullScreenToDesktopBackground];
}
else {
switch (_effect) {
case FS_EFFECT_FADE :
[self endFadeTransition:FADE_EFFECT_DURATION];
break;
case FS_EFFECT_ANIMATION :
[self endAnimationTransition];
break;
default : // FS_EFFECT_NONE
[self endNoEffectTransition];
break;
}
}
[_movieView setSubtitleVisible:subtitleVisible];
if (_blackScreenFader) {
[self endBlackScreens];
}
}
- (void)autoHidePlayPanel { [_playPanel autoHidePanel]; }
////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark desktop-background
- (BOOL)isDesktopBackground { return ([_fullWindow level] == DesktopWindowLevel); }
- (void)beginDesktopBackground
{
[_fullWindow setLevel:DesktopWindowLevel];
[self attachMovieViewToFullWindow];
[_fullWindow addChildWindow:_mainWindow ordered:NSWindowBelow];
[_mainWindow flushWindow];
[_fullWindow flushWindow];
}
- (void)endDesktopBackground
{
[_fullWindow removeChildWindow:_mainWindow];
[_fullWindow setLevel:NSNormalWindowLevel];
[self detachMovieViewFromFullWindow];
}
////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark navigation
- (BOOL)isNavigation { return [_fullWindow isNavigation]; }
- (BOOL)isNavigating { return [_fullWindow isNavigating]; }
- (BOOL)isPreviewing { return [_fullWindow isPreviewing]; }
- (void)beginNavigation
{
if (_blackScreenFader) {
[self beginBlackScreens];
}
[self beginFadeTransition:NAV_FADE_DURATION];
[_fullWindow setAcceptsMouseMovedEvents:TRUE];
}
- (void)endNavigation
{
[_fullWindow setAcceptsMouseMovedEvents:FALSE];
[self endFadeTransition:NAV_FADE_DURATION];
if (_blackScreenFader) {
[self endBlackScreens];
}
}
- (void)selectUpper { [_fullWindow selectUpper]; }
- (void)selectLower { [_fullWindow selectLower]; }
- (void)selectCurrent { [_fullWindow selectMovie:_movieURL]; }
- (void)openCurrent { [_fullWindow openCurrent]; }
- (BOOL)closeCurrent { return [_fullWindow closeCurrent]; }
- (BOOL)canCloseCurrent { return [_fullWindow canCloseCurrent]; }
@end