Version 2.0.2をタグにコピー
@@ -0,0 +1,9 @@ | ||
1 | +フォルダについて | |
2 | +documents エンドユーザー用説明書等が入っています。 | |
3 | +source Objective-Cソースファイルが入っています。 | |
4 | +resource Objective-Cソース以外のファイル(リソース)が入っています。 | |
5 | + | |
6 | + | |
7 | +コンパイルについて | |
8 | + resourceフォルダに入っている「ANMovieSaverForXcode314.xcodeproj」をダブルクリックし、Xcodeを起動してください。 | |
9 | + コンパイルすると、「~/Library/Screen Savers」フォルダにビルド結果ができあがります。 |
@@ -0,0 +1,23 @@ | ||
1 | +// | |
2 | +// NSMovieViewAdditions.h | |
3 | +// ANMovieSaver | |
4 | +// | |
5 | +// Copyright (c) 2001-2006 AOKINAO. All rights reserved. | |
6 | +// | |
7 | +/*! | |
8 | + @header NSMovieViewAdditions | |
9 | + @abstract NSMovieViewに機能を追加 | |
10 | + @discussion (description) | |
11 | +*/ | |
12 | + | |
13 | +#import <AppKit/AppKit.h> | |
14 | +#import <QuickTime/QuickTime.h> | |
15 | + | |
16 | +/*! | |
17 | + @category NSMovieView | |
18 | + @abstract (brief description) | |
19 | + @discussion (comprehensive description) | |
20 | +*/ | |
21 | +@interface NSMovieView (ANMovieView) | |
22 | +- (BOOL) isMovieDone; | |
23 | +@end |
@@ -0,0 +1,98 @@ | ||
1 | +// | |
2 | +// ANMovieSaverView.h | |
3 | +// ANMovieSaver | |
4 | +// | |
5 | +// Copyright (c) 2001-2009 AOKINAO. All rights reserved. | |
6 | +// | |
7 | +/*! | |
8 | + @header ANMovieSaverView | |
9 | +*/ | |
10 | + | |
11 | +#import <ScreenSaver/ScreenSaver.h> | |
12 | +#import <QTKit/QTMovie.h> | |
13 | +#import <QTKit/QTMovieView.h> | |
14 | +#import "ANMovieSaverDefaults.h" | |
15 | + | |
16 | +/*! | |
17 | + @class ANMovieSaverView | |
18 | + @abstract スクリーンセーバ本体クラス. | |
19 | + @discussion スクリーンセーバ本体クラス.システム環境設定のオプションパネルとのやりとりを行う。 | |
20 | +*/ | |
21 | +@interface ANMovieSaverView : ScreenSaverView | |
22 | +{ | |
23 | + // nibの各部品 | |
24 | + IBOutlet id backgroundColorWell; // カラーウェル | |
25 | + IBOutlet id backgroundRadioButton; // 背景を何にするかのラジオボタン | |
26 | + IBOutlet id configSheet; // 設定シート | |
27 | + IBOutlet id displayImageCheckBox; // 背景イメージを表示するかどうかのチェックボックス | |
28 | + IBOutlet id displayPreviewCheckBox; // プレビューを表示するかどうかのチェックボックス | |
29 | + IBOutlet id displayUnderWindowCheckBox; // ウィンドウの下に表示するかどうかのチェックボックス | |
30 | + IBOutlet id imageFileNameTextField; | |
31 | + IBOutlet id imageFractionSlider; | |
32 | + IBOutlet id imagePreviewImageView; | |
33 | + IBOutlet id imageSelectButton; | |
34 | + IBOutlet id imageSizePopUpButton; | |
35 | + IBOutlet id movieFileNameTextField; | |
36 | + IBOutlet QTMovieView* moviePreviewMovieView; | |
37 | + IBOutlet id movieSizePopUpButton; | |
38 | + IBOutlet id movieVolumeSlider; | |
39 | + IBOutlet id movieRandomPlayCheckBox; // ランダム再生するかどうか | |
40 | + IBOutlet id mynameText; | |
41 | + IBOutlet id folderImageView; | |
42 | + | |
43 | + ANMovieSaverDefaults* defaults; // 初期設定値にアクセスするためのオブジェクト | |
44 | + int movieIndex; // movieArray中の再生するムービーの番号 | |
45 | + NSArray* movieTypes; // ムービーの拡張子、タイプなどを保存する | |
46 | + NSMutableArray* movieArray; // ムービーファイルリスト | |
47 | + QTMovieView* mainMovieView; // スクリーンセーバ起動時に表示するムービービュー | |
48 | + BOOL isFirstTime; | |
49 | + BOOL isPlaying; | |
50 | + BOOL isMute; | |
51 | + | |
52 | +} | |
53 | + | |
54 | +/*! | |
55 | + @method calcRectWithMagnificationSize:originalRect:at: | |
56 | + @abstract ムービーを表示するときのRectを計算する。 | |
57 | + @discussion ムービーを表示するときのRectを計算する。SIZEで指定された拡大率とスクリーンの大きさを元に、実際の拡大率を計算する。 | |
58 | + @param magnificationSize 拡大率。SIZEを指定する。 | |
59 | + @param originalRect 拡大すべきムービーの本来の大きさを表すNSRect | |
60 | + @parama screenRect ムービーを表示するスクリーンの大きさ | |
61 | + @return 画面に表示すべきRect | |
62 | +*/ | |
63 | +- (NSRect)calcRectWithMagnificationSize:(SIZE)magnificationSize originalRect:(NSRect)originalRect at:(NSRect)frameRect; | |
64 | + | |
65 | +/*! | |
66 | + @method displayMovie | |
67 | + @abstract (brief description) | |
68 | + @discussion (comprehensive description) | |
69 | +*/ | |
70 | +- (void)displayMovie:(NSString *)fileName frame:(NSRect)rect; | |
71 | + | |
72 | +/*! | |
73 | + @method makeMovieFileList | |
74 | + @abstract ムービーファイルの一覧表を作成する | |
75 | + @discussion [defaults movieFilePath]を元に、ファイル名一覧を作り、movieArrayに入れる。ファイルが存在しない場合はArrayは空になるが、nilではない。 | |
76 | +*/ | |
77 | +- (void)makeMovieFileList; | |
78 | + | |
79 | +@end | |
80 | + | |
81 | +/*! | |
82 | + @category ANMovieSaverView | |
83 | + @abstract システム設定上のシートとの連携をするカテゴリ | |
84 | +*/ | |
85 | +@interface ANMovieSaverView (Controller) | |
86 | +- (IBAction)changeColor:(id)sender; | |
87 | +- (IBAction)changeImageFraction:(id)sender; | |
88 | +- (IBAction)changeImageSize:(id)sender; | |
89 | +- (IBAction)changeMovieSize:(id)sender; | |
90 | +- (IBAction)changeMovieVolume:(id)sender; | |
91 | +- (IBAction)closeSheet:(id)sender; | |
92 | +- (IBAction)selectBackground:(id)sender; | |
93 | +- (IBAction)selectImageFile:(id)sender; | |
94 | +- (IBAction)selectMovieFile:(id)sender; | |
95 | +- (IBAction)toggleDisplayImage:(id)sender; | |
96 | +- (IBAction)toggleDisplayUnderWindow:(id)sender; | |
97 | +- (IBAction)toggleRandomPlay:(id)sender; // ランダム再生するかどうか | |
98 | +@end |
@@ -0,0 +1,367 @@ | ||
1 | +// | |
2 | +// ANMovieSaverDefaults.m | |
3 | +// ANMovieSaver | |
4 | +// | |
5 | +// Copyright (c) 2001-2009 AOKINAO. All rights reserved. | |
6 | +// | |
7 | +// ANMovieSaverの初期設定値(ディスクに保存される値)の管理をするクラス | |
8 | +// | |
9 | + | |
10 | +#import "ANMovieSaverDefaults.h" | |
11 | + | |
12 | +// 定数の定義 | |
13 | +#define MOVIESAVERPREF @"jp.aokinao.ANMovieSaver" | |
14 | +#define BACKGROUNDTYPE @"BackgroundType" | |
15 | +#define COLORBLUEPREF @"ColorBlue" | |
16 | +#define COLORGREENPREF @"ColorGreen" | |
17 | +#define COLORREDPREF @"ColorRed" | |
18 | +#define DISPLAYIMAGEPREF @"DisplayImage" | |
19 | +#define IMAGEFILENAMEPREF @"ImageFilePath" | |
20 | +#define IMAGEMAGNIFICATIONPREF @"ImageMagnification" | |
21 | +#define IMAGEFRACTIONPREF @"ImageFraction" | |
22 | +#define MOVIEFILENAMEPREF @"MovieFileName" | |
23 | +#define MOVIEMAGNIFICATIONPREF @"MovieMagnification" | |
24 | +#define MOVIEVOLUMEPREF @"MovieVolume" | |
25 | +#define PREVIEWPREF @"Preview" | |
26 | +#define DISPLAYUNDERWINDOW @"DisplayUnderWindow" | |
27 | +#define RANDOMPLAY @"RandomPlay" | |
28 | + | |
29 | +@implementation ANMovieSaverDefaults | |
30 | + | |
31 | +// 初期化 | |
32 | +- (id)init | |
33 | +{ | |
34 | + self = [super init]; | |
35 | + if (self) { | |
36 | + // デフォルト値を設定する | |
37 | + backgroundType = BG_NORMAL; // 背景は標準 | |
38 | + backgroundRed = 1.0; // 背景色は白 | |
39 | + backgroundGreen = 1.0; // 背景色は白 | |
40 | + backgroundBlue = 1.0; // 背景色は白 | |
41 | + isDisplayImage = NO; // 背景画像は表示しない | |
42 | + imageFilePath = [[NSString alloc] init]; // 背景画像ファイル名は空 | |
43 | + imageFraction = 1.0; // 背景画像の不透明度は1.0 | |
44 | + imageMagnification = NORMAL; // 背景画像の拡大率は通常 | |
45 | + movieFilePath = [[NSString alloc] init]; // ムービーファイル名は空 | |
46 | + movieVolume = 1.0; // ムービーの音量は1.0 | |
47 | + movieMagnification = NORMAL; // ムービーの拡大率は通常 | |
48 | + isDisplayUnderWindow = NO; // ウィンドウの下に表示しない | |
49 | + isRandomPlay = NO; // シャッフル再生しない | |
50 | + } | |
51 | + return(self); | |
52 | +} | |
53 | + | |
54 | +// 解放 | |
55 | +- (void)dealloc | |
56 | +{ | |
57 | + [imageFilePath release]; | |
58 | + [movieFilePath release]; | |
59 | + | |
60 | + [super dealloc]; | |
61 | +} | |
62 | + | |
63 | +// 背景種別を返す | |
64 | +- (BACKGROUND)backgroundType | |
65 | +{ | |
66 | + return backgroundType; | |
67 | +} | |
68 | + | |
69 | +// 背景色を返す | |
70 | +- (float)backgroundRed | |
71 | +{ | |
72 | + return backgroundRed; | |
73 | +} | |
74 | + | |
75 | +// 背景色を返す | |
76 | +- (float)backgroundGreen | |
77 | +{ | |
78 | + return backgroundGreen; | |
79 | +} | |
80 | + | |
81 | +// 背景色を返す | |
82 | +- (float)backgroundBlue | |
83 | +{ | |
84 | + return backgroundBlue; | |
85 | +} | |
86 | + | |
87 | +// 背景色を返す | |
88 | +- (NSColor *)backgroundColor | |
89 | +{ | |
90 | + return [NSColor colorWithCalibratedRed:backgroundRed green:backgroundGreen blue:backgroundBlue alpha:1.0]; | |
91 | +} | |
92 | + | |
93 | +// 背景画像を利用するかどうかを返す | |
94 | +- (BOOL)isDisplayImage | |
95 | +{ | |
96 | + return isDisplayImage; | |
97 | +} | |
98 | + | |
99 | +// 背景画像のファイル名を返す | |
100 | +- (NSString *)imageFilePath | |
101 | +{ | |
102 | + return imageFilePath; | |
103 | +} | |
104 | + | |
105 | +// 背景画像の不透明度を返す | |
106 | +- (float)imageFraction | |
107 | +{ | |
108 | + return imageFraction; | |
109 | +} | |
110 | + | |
111 | +// 背景画像の拡大率を返す | |
112 | +- (SIZE)imageMagnification | |
113 | +{ | |
114 | + return imageMagnification; | |
115 | +} | |
116 | + | |
117 | +// ムービーのファイル名を返す | |
118 | +- (NSString *)movieFilePath | |
119 | +{ | |
120 | + return movieFilePath; | |
121 | +} | |
122 | + | |
123 | +// ムービーの音量を返す | |
124 | +- (float)movieVolume | |
125 | +{ | |
126 | + return movieVolume; | |
127 | +} | |
128 | + | |
129 | +// ムービーの拡大率を返す | |
130 | +- (SIZE)movieMagnification | |
131 | +{ | |
132 | + return movieMagnification; | |
133 | +} | |
134 | + | |
135 | +// ウィンドウの下に表示するかどうかを返す | |
136 | +- (BOOL)isDisplayUnderWindow | |
137 | +{ | |
138 | + return isDisplayUnderWindow; | |
139 | +} | |
140 | + | |
141 | +// ランダム再生するかどうかを返す | |
142 | +- (BOOL)isRandomPlay | |
143 | +{ | |
144 | + return isRandomPlay; | |
145 | +} | |
146 | + | |
147 | + | |
148 | +// 背景種別を設定する | |
149 | +- (void)setBackgroundType:(BACKGROUND)type | |
150 | +{ | |
151 | + if (type < BG_NORMAL || BG_DESKTOP < type) { | |
152 | + backgroundType = BG_NORMAL; | |
153 | + } else { | |
154 | + backgroundType = type; | |
155 | + } | |
156 | +} | |
157 | + | |
158 | +// 背景色を設定する | |
159 | +- (void)setBackgroundRed:(float)red | |
160 | +{ | |
161 | + if (red < 0.0) { | |
162 | + red = 0.0; | |
163 | + } else if (1.0 < red) { | |
164 | + red = 1.0; | |
165 | + } | |
166 | + backgroundRed = red; | |
167 | +} | |
168 | + | |
169 | +// 背景色を設定する | |
170 | +- (void)setBackgroundGreen:(float)green | |
171 | +{ | |
172 | + if (green < 0.0) { | |
173 | + green = 0.0; | |
174 | + } else if (1.0 < green) { | |
175 | + green = 1.0; | |
176 | + } | |
177 | + backgroundGreen = green; | |
178 | +} | |
179 | + | |
180 | +// 背景色を設定する | |
181 | +- (void)setBackgroundBlue:(float)blue | |
182 | +{ | |
183 | + if (blue < 0.0) { | |
184 | + blue = 0.0; | |
185 | + } else if (1.0 < blue) { | |
186 | + blue = 1.0; | |
187 | + } | |
188 | + backgroundBlue = blue; | |
189 | +} | |
190 | + | |
191 | +// 背景色を設定する | |
192 | +- (void)setBackgroundColorRed:(float)red green:(float)green blue:(float)blue | |
193 | +{ | |
194 | + [self setBackgroundRed:red]; | |
195 | + [self setBackgroundGreen:green]; | |
196 | + [self setBackgroundBlue:blue]; | |
197 | +} | |
198 | + | |
199 | +// 背景色を設定する | |
200 | +- (void)setBackgroundColor:(NSColor *)color | |
201 | +{ | |
202 | + [self setBackgroundRed:[color redComponent]]; | |
203 | + [self setBackgroundGreen:[color greenComponent]]; | |
204 | + [self setBackgroundBlue:[color blueComponent]]; | |
205 | +} | |
206 | + | |
207 | +// 背景画像を表示するか設定する | |
208 | +- (void)setIsDisplayImage:(BOOL)display | |
209 | +{ | |
210 | + isDisplayImage = display; | |
211 | +} | |
212 | + | |
213 | +// 背景画像のファイル名を設定する | |
214 | +- (void)setImageFilePath:(NSString *)path | |
215 | +{ | |
216 | + if (imageFilePath != path) { | |
217 | + [imageFilePath release]; // 事前に使っていたファイルパスを解放する | |
218 | + imageFilePath = [path retain]; // 新しいファイルパスに設定する | |
219 | + } | |
220 | +} | |
221 | + | |
222 | +// 背景画像の不透明度を設定する | |
223 | +- (void)setImageFraction:(float)bacgroundfraction | |
224 | +{ | |
225 | + if (bacgroundfraction < 0.0) { | |
226 | + imageFraction = 0.0; | |
227 | + } else if (1.0 < bacgroundfraction) { | |
228 | + imageFraction = 1.0; | |
229 | + } else { | |
230 | + imageFraction = bacgroundfraction; | |
231 | + } | |
232 | +} | |
233 | + | |
234 | +// 背景画像の拡大率を設定する | |
235 | +- (void)setImageMagnification:(SIZE)magnification | |
236 | +{ | |
237 | + if (magnification < HALF || FULL < magnification) { | |
238 | + imageMagnification = NORMAL; | |
239 | + } else { | |
240 | + imageMagnification = magnification; | |
241 | + } | |
242 | +} | |
243 | + | |
244 | +// ムービーのファイル名を設定する | |
245 | +- (void)setMovieFilePath:(NSString *)path | |
246 | +{ | |
247 | + if (movieFilePath != path) { | |
248 | + [movieFilePath release]; // 事前に使っていたファイルパスを解放する | |
249 | + movieFilePath = [path retain]; // 新しいファイルパスに設定する | |
250 | + } | |
251 | +} | |
252 | + | |
253 | +// ムービーの音量を設定する | |
254 | +- (void)setMovieVolume:(float)volume | |
255 | +{ | |
256 | + if (volume < 0.0) { | |
257 | + movieVolume = 0.0; | |
258 | + } else if (1.0 < volume) { | |
259 | + movieVolume = 1.0; | |
260 | + } else { | |
261 | + movieVolume = volume; | |
262 | + } | |
263 | +} | |
264 | + | |
265 | +// ムービーの拡大率を設定する | |
266 | +- (void)setMovieMagnification:(SIZE)magnification | |
267 | +{ | |
268 | + if (magnification < HALF || FULL < magnification) { | |
269 | + magnification = NORMAL; | |
270 | + } | |
271 | + movieMagnification = magnification; | |
272 | +} | |
273 | + | |
274 | +// ムービーをウィンドウより下で再生するかどうかを設定する | |
275 | +- (void)setIsDisplayUnderWindow:(BOOL)display | |
276 | +{ | |
277 | + isDisplayUnderWindow = display; | |
278 | +} | |
279 | + | |
280 | +// シャッフル再生するかどうかを設定する | |
281 | +- (void)setIsRandomPlay:(BOOL)randomplay | |
282 | +{ | |
283 | + isRandomPlay = randomplay; | |
284 | +} | |
285 | + | |
286 | +// 初期設定ファイルから初期データを読み出す | |
287 | +- (void)loadDefaults | |
288 | +{ | |
289 | + // 変数の定義 | |
290 | + ScreenSaverDefaults *theSaverDefault; // 初期設定の呼び出し用 | |
291 | + | |
292 | + | |
293 | + theSaverDefault = [ScreenSaverDefaults defaultsForModuleWithName:MOVIESAVERPREF]; | |
294 | + | |
295 | + if (theSaverDefault) { | |
296 | + // 背景色関連 | |
297 | + [self setBackgroundType:[theSaverDefault integerForKey:BACKGROUNDTYPE]]; | |
298 | + [self setBackgroundRed:[theSaverDefault floatForKey:COLORREDPREF]]; | |
299 | + [self setBackgroundGreen:[theSaverDefault floatForKey:COLORGREENPREF]]; | |
300 | + [self setBackgroundBlue:[theSaverDefault floatForKey:COLORBLUEPREF]]; | |
301 | + [self setIsDisplayUnderWindow:[theSaverDefault boolForKey:DISPLAYUNDERWINDOW]]; | |
302 | + [self setIsRandomPlay:[theSaverDefault boolForKey:RANDOMPLAY]]; | |
303 | + | |
304 | + // 背景画像関連 | |
305 | + if ([theSaverDefault stringForKey:IMAGEFILENAMEPREF]) { // 画像ファイルが指定されているときの処理 | |
306 | + [self setIsDisplayImage:[theSaverDefault boolForKey:DISPLAYIMAGEPREF]]; | |
307 | + [self setImageFilePath:[theSaverDefault stringForKey:IMAGEFILENAMEPREF]]; | |
308 | + [self setImageMagnification:[theSaverDefault floatForKey:IMAGEMAGNIFICATIONPREF]]; | |
309 | + [self setImageFraction:[theSaverDefault floatForKey:IMAGEFRACTIONPREF]]; | |
310 | + } else { // 画像ファイルが指定されていないときの処理 | |
311 | + [self setIsDisplayImage:NO]; // 背景画像は表示しない | |
312 | + [self setImageFilePath:[NSString string]]; // 背景画像ファイル名は空 | |
313 | + [self setImageFraction:1.0]; // 背景画像の不透明度は1.0 | |
314 | + [self setImageMagnification:NORMAL]; // 背景画像の拡大率は通常 | |
315 | + } | |
316 | + | |
317 | + // ムービー関連 | |
318 | + if ([theSaverDefault stringForKey:MOVIEFILENAMEPREF]) { // ムービーファイルが指定されているときの処理 | |
319 | + [self setMovieFilePath:[theSaverDefault stringForKey:MOVIEFILENAMEPREF]]; | |
320 | + [self setMovieMagnification:[theSaverDefault floatForKey:MOVIEMAGNIFICATIONPREF]]; | |
321 | + [self setMovieVolume:[theSaverDefault floatForKey:MOVIEVOLUMEPREF]]; | |
322 | + } else { | |
323 | + // ムービーファイルが指定されていないときの処理 | |
324 | + [self setMovieFilePath:[NSString string]]; // ムービーファイル名は空 | |
325 | + [self setMovieVolume:1.0]; // ムービーの音量は1.0 | |
326 | + [self setMovieMagnification:NORMAL]; // ムービーの拡大率は通常 | |
327 | + } | |
328 | + } | |
329 | +} | |
330 | + | |
331 | +// 初期設定ファイルに初期データを書き込む | |
332 | +- (void)saveDefaults | |
333 | +{ | |
334 | + // 変数の定義 | |
335 | + ScreenSaverDefaults *theSaverDefault; // 初期設定の呼び出し用 | |
336 | + | |
337 | + theSaverDefault = [ScreenSaverDefaults defaultsForModuleWithName:MOVIESAVERPREF]; | |
338 | + | |
339 | + if (theSaverDefault) { | |
340 | + // 背景関連 | |
341 | + [theSaverDefault setInteger:[self backgroundType] forKey:BACKGROUNDTYPE]; | |
342 | + [theSaverDefault setFloat:[self backgroundRed] forKey:COLORREDPREF]; | |
343 | + [theSaverDefault setFloat:[self backgroundGreen] forKey:COLORGREENPREF]; | |
344 | + [theSaverDefault setFloat:[self backgroundBlue] forKey:COLORBLUEPREF]; | |
345 | + [theSaverDefault setBool:[self isDisplayUnderWindow] forKey:DISPLAYUNDERWINDOW]; | |
346 | + [theSaverDefault setBool:[self isRandomPlay] forKey:RANDOMPLAY]; | |
347 | + | |
348 | + // 背景画像関連 | |
349 | + if ([[self imageFilePath] length] > 0) { | |
350 | + [theSaverDefault setBool:[self isDisplayImage] forKey:DISPLAYIMAGEPREF]; | |
351 | + [theSaverDefault setObject:[self imageFilePath] forKey:IMAGEFILENAMEPREF]; | |
352 | + [theSaverDefault setFloat:[self imageFraction] forKey:IMAGEFRACTIONPREF]; | |
353 | + [theSaverDefault setInteger:[self imageMagnification] forKey:IMAGEMAGNIFICATIONPREF]; | |
354 | + } | |
355 | + | |
356 | + // ムービー関係 | |
357 | + if ([[self movieFilePath] length] > 0) { | |
358 | + [theSaverDefault setObject:[self movieFilePath] forKey:MOVIEFILENAMEPREF]; | |
359 | + [theSaverDefault setInteger:[self movieMagnification] forKey:MOVIEMAGNIFICATIONPREF]; | |
360 | + [theSaverDefault setFloat:[self movieVolume] forKey:MOVIEVOLUMEPREF]; | |
361 | + } | |
362 | + | |
363 | + [theSaverDefault synchronize]; | |
364 | + } | |
365 | +} | |
366 | + | |
367 | +@end |
@@ -0,0 +1,19 @@ | ||
1 | +// | |
2 | +// NSMovieViewAdditions.m | |
3 | +// ANMovieSaver | |
4 | +// | |
5 | +// Copyright (c) 2001-2004 AOKINAO. All rights reserved. | |
6 | +// | |
7 | +// NSMovieViewに機能を追加 | |
8 | +// | |
9 | + | |
10 | +#import "NSMovieViewAdditions.h" | |
11 | + | |
12 | +@implementation NSMovieView (ANMovieView) | |
13 | + | |
14 | +// 再生が終了したかどうか | |
15 | +- (BOOL)isMovieDone { | |
16 | + return IsMovieDone([[self movie] QTMovie]); | |
17 | +} | |
18 | + | |
19 | +@end |
@@ -0,0 +1,396 @@ | ||
1 | +// | |
2 | +// ANMovieSaverView.m | |
3 | +// ANMovieSaver | |
4 | +// | |
5 | +// Copyright (c) 2001-2009 AOKINAO. All rights reserved. | |
6 | +// | |
7 | +// ANMovieSaverのスクリーンセーバ本体クラス | |
8 | +// | |
9 | + | |
10 | +#import "ANMovieSaverView.h" | |
11 | + | |
12 | +@implementation ANMovieSaverView | |
13 | + | |
14 | +- (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview | |
15 | +{ | |
16 | + self = [super initWithFrame:frame isPreview:isPreview]; // スーパークラスの初期化 | |
17 | + if (self != nil) { // スーパークラスの初期化に成功したときの処理 | |
18 | + | |
19 | + // 初期設定値を読み込む | |
20 | + defaults = [[ANMovieSaverDefaults alloc] init]; | |
21 | + [defaults loadDefaults]; | |
22 | + | |
23 | + // ムービーの一覧表を作成する | |
24 | + //isExistMovie = NO; | |
25 | + movieIndex = 0; | |
26 | + movieTypes = [[QTMovie movieFileTypes:QTIncludeCommonTypes] retain]; | |
27 | + | |
28 | + srand(time(NULL)); | |
29 | + movieArray = [[NSMutableArray alloc] initWithCapacity:256]; // 空のリストを作成する | |
30 | + [self makeMovieFileList]; // 再生するムービーの一覧表を作成する | |
31 | + mainMovieView = [[QTMovieView alloc] initWithFrame:frame]; | |
32 | + isFirstTime = YES; | |
33 | + isPlaying = NO; | |
34 | + } | |
35 | + | |
36 | + return self; | |
37 | +} | |
38 | + | |
39 | +-(void)startAnimation | |
40 | +{ | |
41 | + NSScreen* theScreen; | |
42 | + NSScreen* theMainScreen; | |
43 | + | |
44 | + [super startAnimation]; | |
45 | + | |
46 | + if (!isPlaying) { | |
47 | + [self display]; | |
48 | + } | |
49 | +} | |
50 | + | |
51 | +- (void) dealloc { | |
52 | + | |
53 | + [[mainMovieView movie] stop]; | |
54 | + [mainMovieView removeFromSuperview]; // mainMovieViewをスーパークラスからはずす | |
55 | + [mainMovieView release]; // ムービービューをリリース | |
56 | + [movieArray release]; // ムービーリストをリリース | |
57 | + [movieTypes release]; | |
58 | + [defaults release]; // 初期設定データをリリース | |
59 | + | |
60 | + [super dealloc]; | |
61 | +} | |
62 | + | |
63 | +-(void)stopAnimation | |
64 | +{ | |
65 | + [[mainMovieView movie] stop]; // ムービーの再生を止める | |
66 | + isPlaying = NO; | |
67 | + [super stopAnimation]; | |
68 | +} | |
69 | + | |
70 | + | |
71 | ++(BOOL)performGammaFade | |
72 | +{ | |
73 | + return(NO); | |
74 | +} | |
75 | + | |
76 | +// 設定シートを持つかどうか | |
77 | +-(BOOL)hasConfigureSheet | |
78 | +{ | |
79 | + return YES; | |
80 | +} | |
81 | + | |
82 | + | |
83 | +/* | |
84 | +-(void)animateOneFrame | |
85 | +{ | |
86 | +} | |
87 | +*/ | |
88 | + | |
89 | +// 描画 | |
90 | +-(void)drawRect:(NSRect)rect | |
91 | +{ | |
92 | + //NSLog(@"DrawRect(%4.2f, %4.2f)-(%4.2f, %4.2f)", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); | |
93 | + | |
94 | + // 背景の表示 ***************************************** | |
95 | + if ([self isPreview]) { // プレビューの場合 | |
96 | + [[NSColor whiteColor] set]; // 白で塗りつぶす | |
97 | + NSRectFill(rect); | |
98 | + } else { // プレビューではない場合 | |
99 | + switch ([defaults backgroundType]) { | |
100 | + case BG_NORMAL:// 通常画面 | |
101 | + break; | |
102 | + case BG_COLOR: // 色で塗りつぶす | |
103 | + [[defaults backgroundColor] set]; | |
104 | + NSRectFill(rect); | |
105 | + break; | |
106 | + case BG_DESKTOP: // 画面を残す | |
107 | + [[self window] setOpaque:NO]; // スクリーンセーバーウィンドウ自体を透明にする | |
108 | + NSRectFillUsingOperation(rect, NSCompositeClear); | |
109 | + break; | |
110 | + } | |
111 | + | |
112 | + } | |
113 | + | |
114 | + // イメージの表示 ***************************************** | |
115 | + if (([[defaults imageFilePath] length] > 0) && [defaults isDisplayImage]) { // 背景画像ファイル名が指定してありかつ背景画像を表示するよう指定してある場合 | |
116 | + // 変数の定義 | |
117 | + NSRect theOriginalImageRect; // イメージの原寸 | |
118 | + NSRect theDistinationImageRect; // イメージの表示サイズ | |
119 | + NSImage* theImage; // イメージ | |
120 | + NSGraphicsContext* theGraphicsContext; // グラフィックコンテキスト | |
121 | + | |
122 | + | |
123 | + theImage = [[NSImage alloc] initWithContentsOfFile:[defaults imageFilePath]]; // 画像の読み込み | |
124 | + if (theImage != nil) { | |
125 | + theOriginalImageRect = NSMakeRect(0.0, 0.0, [theImage size].width, [theImage size].height); // 画像のサイズを得る | |
126 | + | |
127 | + theDistinationImageRect = [self calcRectWithMagnificationSize:[defaults imageMagnification] originalRect:theOriginalImageRect at:rect]; // 拡大縮小したときの大きさを計算する | |
128 | + theDistinationImageRect = SSCenteredRectInRect(theDistinationImageRect, rect); // イメージを画面の中心に表示するよう調整する | |
129 | + | |
130 | + // 画像を描画する | |
131 | + theGraphicsContext= [NSGraphicsContext currentContext]; | |
132 | + [theGraphicsContext setImageInterpolation:NSImageInterpolationHigh]; // 高品質な補間を行う | |
133 | + [theImage drawInRect:theDistinationImageRect fromRect:theOriginalImageRect operation:NSCompositeSourceOver fraction:[defaults imageFraction]]; // 拡大縮小しつつ表示する | |
134 | + [theImage release]; | |
135 | + } | |
136 | + } | |
137 | + | |
138 | + if (!isPlaying) { | |
139 | + // ムービーの表示 ***************************************** | |
140 | + if ([movieArray count] > 0) { // ムービーが存在する | |
141 | + NSString *theFilePath; | |
142 | + if (movieIndex >= [movieArray count]) { | |
143 | + movieIndex = 0; | |
144 | + } | |
145 | + theFilePath = [movieArray objectAtIndex:movieIndex]; | |
146 | + [self displayMovie:theFilePath frame:rect]; | |
147 | + movieIndex++; | |
148 | + } | |
149 | + } | |
150 | +} | |
151 | + | |
152 | + | |
153 | +//設定シートを表示する | |
154 | +-(NSWindow*)configureSheet | |
155 | +{ | |
156 | + // 変数の定義 | |
157 | + NSFileManager *theFileManager; | |
158 | + | |
159 | + | |
160 | + [NSBundle loadNibNamed:@"ANMovieSaver" owner:self]; //設定シートの指定 | |
161 | + | |
162 | + theFileManager = [NSFileManager defaultManager]; | |
163 | + | |
164 | + // 設定シートに背景色関連の初期値を表示する | |
165 | + [backgroundRadioButton selectCellWithTag:[defaults backgroundType]]; | |
166 | + [backgroundColorWell setColor:[defaults backgroundColor]]; | |
167 | + | |
168 | + if ([defaults backgroundType] == BG_COLOR) { | |
169 | + [backgroundColorWell setEnabled:YES]; | |
170 | + } else { | |
171 | + [backgroundColorWell setEnabled:NO]; | |
172 | + } | |
173 | + | |
174 | + if ([defaults backgroundType] == BG_DESKTOP) { | |
175 | + [displayUnderWindowCheckBox setEnabled:YES]; | |
176 | + } else { | |
177 | + [displayUnderWindowCheckBox setEnabled:NO]; | |
178 | + } | |
179 | + | |
180 | + // 設定シートにイメージ関連の初期値を表示する | |
181 | + [displayImageCheckBox setState:[defaults isDisplayImage]]; | |
182 | + if ([defaults isDisplayImage] == YES) { | |
183 | + [imageSelectButton setEnabled:YES]; | |
184 | + [imageSizePopUpButton setEnabled:YES]; | |
185 | + [imageFractionSlider setEnabled:YES]; | |
186 | + } else { | |
187 | + [imageSelectButton setEnabled:NO]; | |
188 | + [imageSizePopUpButton setEnabled:NO]; | |
189 | + [imageFractionSlider setEnabled:NO]; | |
190 | + } | |
191 | + | |
192 | + if ([[defaults imageFilePath] length] > 0) { | |
193 | + NSImage *theImage; | |
194 | + [imageFileNameTextField setStringValue:[theFileManager displayNameAtPath:[defaults imageFilePath]]]; // ファイル名を表示する | |
195 | + [imageSizePopUpButton selectItemAtIndex:[defaults imageMagnification]]; // サイズポップアップの設定 | |
196 | + [imageFractionSlider setFloatValue:[defaults imageFraction]]; | |
197 | + theImage = [[NSImage alloc] initWithContentsOfFile:[defaults imageFilePath]]; | |
198 | + [imagePreviewImageView setImage:theImage]; | |
199 | + [theImage release]; | |
200 | + } | |
201 | + | |
202 | + // 設定シートにムービー関連の初期値を表示する | |
203 | + if ([[defaults movieFilePath] length] > 0) { | |
204 | + NSURL* theMovieURL; | |
205 | + id theMovie; | |
206 | + NSError* theError; | |
207 | + | |
208 | + [movieFileNameTextField setStringValue:[theFileManager displayNameAtPath:[defaults movieFilePath]]]; // ファイル名を表示する | |
209 | + [movieSizePopUpButton selectItemAtIndex:[defaults movieMagnification]]; // サイズポップアップの設定 | |
210 | + [movieVolumeSlider setFloatValue:[defaults movieVolume]]; // 音量スライダーの設定 | |
211 | + | |
212 | + // 現在設定されているムービーデータを設定シートのプレビュー画面に表示 | |
213 | + theMovieURL = [NSURL fileURLWithPath:[defaults movieFilePath]]; // ムービーのパスをURLに直す | |
214 | + theMovie = [QTMovie movieWithURL:theMovieURL error:&theError]; // ムービーを設定する | |
215 | + if (theMovie == nil) { // ムービーが無かった場合(フォルダ)の処理 | |
216 | + NSImage* theFolderImage; | |
217 | + [movieRandomPlayCheckBox setEnabled:YES]; // ランダムチェックボックスを指定可能にする | |
218 | + [moviePreviewMovieView setHidden:YES]; // ムービープレビューを非表示にする | |
219 | + theFolderImage = [[NSWorkspace sharedWorkspace] iconForFile: [defaults movieFilePath]]; | |
220 | + [theFolderImage setSize:NSMakeSize(128, 128)]; | |
221 | + [folderImageView setImage:theFolderImage]; // フォルダのイメージを表示する | |
222 | + } else { // ムービーの場合の処理 | |
223 | + [moviePreviewMovieView setMovie:theMovie]; | |
224 | + [moviePreviewMovieView display]; // setMovieしただけでは表示されないので、強制的にdisplayする。 | |
225 | + [moviePreviewMovieView gotoPosterFrame:self]; | |
226 | + [movieRandomPlayCheckBox setEnabled:NO]; // ランダムチェックボックスを指定不可にする | |
227 | + [moviePreviewMovieView setHidden:NO]; // ムービープレビューを表示する | |
228 | + } | |
229 | + } | |
230 | + | |
231 | + [displayUnderWindowCheckBox setState:[defaults isDisplayUnderWindow]]; | |
232 | + [movieRandomPlayCheckBox setState:[defaults isRandomPlay]]; | |
233 | + | |
234 | + | |
235 | + return configSheet; | |
236 | +} | |
237 | + | |
238 | + | |
239 | +// 拡大縮小後のNSRectを求める | |
240 | +- (NSRect)calcRectWithMagnificationSize:(SIZE)magnificationSize originalRect:(NSRect)originalRect at:(NSRect)frameRect { | |
241 | + float theMagnificationWidth; | |
242 | + float theMagnificationHeight; | |
243 | + NSSize theResizedSize; | |
244 | + NSRect theRect; | |
245 | + | |
246 | + | |
247 | + if ([self isPreview]) { // プレビューの場合の処理、プレビュー領域の大きさとスクリーンの大きさの比を設定する. | |
248 | + NSRect theScreenRect; // スクリーンの大きさ | |
249 | + theScreenRect = [[NSScreen mainScreen] frame]; // 画面の大きさ | |
250 | + theMagnificationWidth = NSWidth(frameRect) / NSWidth(theScreenRect); | |
251 | + theMagnificationHeight = NSHeight(frameRect) / NSHeight(theScreenRect); | |
252 | + if (theMagnificationWidth < theMagnificationHeight) { | |
253 | + theResizedSize.height = NSHeight(originalRect) * theMagnificationWidth; | |
254 | + theResizedSize.width = NSWidth(originalRect) * theMagnificationWidth; | |
255 | + } else { | |
256 | + theResizedSize.height = NSHeight(originalRect) * theMagnificationHeight; | |
257 | + theResizedSize.width = NSWidth(originalRect) * theMagnificationHeight; | |
258 | + } | |
259 | + } else { // プレビューでない場合 | |
260 | + theResizedSize.height = NSHeight(originalRect); | |
261 | + theResizedSize.width = NSWidth(originalRect); | |
262 | + } | |
263 | + | |
264 | + switch (magnificationSize) { | |
265 | + case HALF: | |
266 | + theResizedSize.width = theResizedSize.width / 2.0; | |
267 | + theResizedSize.height = theResizedSize.height / 2.0; | |
268 | + break; | |
269 | + case DOUBLE: | |
270 | + theResizedSize.width = theResizedSize.width * 2.0; | |
271 | + theResizedSize.height = theResizedSize.height * 2.0; | |
272 | + break; | |
273 | + case FULL: | |
274 | + theMagnificationWidth = NSWidth(frameRect) / NSWidth(originalRect); | |
275 | + theMagnificationHeight = NSHeight(frameRect) / NSHeight(originalRect); | |
276 | + if (theMagnificationWidth < theMagnificationHeight) { | |
277 | + theResizedSize.height = NSHeight(originalRect) * theMagnificationWidth; | |
278 | + theResizedSize.width = NSWidth(originalRect) * theMagnificationWidth; | |
279 | + } else { | |
280 | + theResizedSize.height = NSHeight(originalRect) * theMagnificationHeight; | |
281 | + theResizedSize.width = NSWidth(originalRect) * theMagnificationHeight; | |
282 | + } | |
283 | + default: | |
284 | + break; | |
285 | + } | |
286 | + | |
287 | + theRect = NSMakeRect(0.0, 0.0, theResizedSize.width, theResizedSize.height); | |
288 | + | |
289 | + return theRect; | |
290 | +} | |
291 | + | |
292 | +// ムービーを表示する | |
293 | +- (void)displayMovie:(NSString *)fileName frame:(NSRect)rect | |
294 | +{ | |
295 | + QTMovie* theMovie; // ムービーファイル | |
296 | + NSError* theError; | |
297 | + NSRect theMovieMagnificatedRect; // ムービーの拡大縮小後のサイズ | |
298 | + NSSize theOriginalMovieSize; // ムービーのオリジナルサイズ | |
299 | + NSRect theOriginalMovieRect; // ムービービューサイズ | |
300 | + NSRect theViewRect; // フレームのサイズ(プレビュー時にrectが正しい値を得られないので、取り直す) | |
301 | + | |
302 | + | |
303 | + theMovie = [QTMovie movieWithFile:fileName error:&theError]; // ムービーを呼び出す | |
304 | + theOriginalMovieSize = [[theMovie attributeForKey:QTMovieNaturalSizeAttribute] sizeValue]; // ムービーのオリジナルサイズ | |
305 | + theOriginalMovieRect = NSMakeRect(0.0, 0.0, theOriginalMovieSize.width, theOriginalMovieSize.height); // ムービーのオリジナルRect | |
306 | + theViewRect = [self frame]; | |
307 | + //NSLog(@"theViewRect(%4.2f, %4.2f)-(%4.2f, %4.2f)", theViewRect.origin.x, theViewRect.origin.y, theViewRect.size.width, theViewRect.size.height); | |
308 | + theMovieMagnificatedRect = [self calcRectWithMagnificationSize:[defaults movieMagnification] originalRect:theOriginalMovieRect at:theViewRect]; // 拡大縮小後のムービーの大きさを得る | |
309 | + //NSLog(@"MovieSize(%4.2f, %4.2f)-(%4.2f, %4.2f)", theMovieMagnificatedRect.origin.x, theMovieMagnificatedRect.origin.y, theMovieMagnificatedRect.size.width, theMovieMagnificatedRect.size.height); | |
310 | + | |
311 | + if (isFirstTime) { | |
312 | + // 初めて呼び出された | |
313 | + isFirstTime = NO; | |
314 | + } else { // 2回目以降 | |
315 | + [[NSNotificationCenter defaultCenter] removeObserver:self name:QTMovieDidEndNotification object:theMovie]; // ノーティフィケーションをはずす | |
316 | + [[mainMovieView movie] stop]; // ムービーの再生を止める | |
317 | + [mainMovieView removeFromSuperview]; // 既に表示されているmainMovieViewをいったんはずす | |
318 | + } | |
319 | + | |
320 | + [mainMovieView setMovie:theMovie]; // ムービービューにムービーをセットする | |
321 | + [mainMovieView setControllerVisible:NO]; //コントローラを消去 | |
322 | + | |
323 | + if (theViewRect.origin.x == 0 && theViewRect.origin.y == 0) { | |
324 | + [[mainMovieView movie] setVolume:[defaults movieVolume]]; | |
325 | + } else { | |
326 | + [[mainMovieView movie] setVolume:0]; | |
327 | + } | |
328 | + [mainMovieView setFrame:SSCenteredRectInRect(theMovieMagnificatedRect, theViewRect)]; // ムービービューを中央に配置する | |
329 | + | |
330 | + [self addSubview:mainMovieView]; // ムービービューを画面に表示する | |
331 | + if (![self isPreview]) { // プレビューでない場合 | |
332 | + if (([defaults backgroundType] == BG_DESKTOP) && ([defaults isDisplayUnderWindow] == YES)) { | |
333 | + [[self window] setLevel:kCGDesktopWindowLevel]; | |
334 | + } | |
335 | + } | |
336 | + | |
337 | + // 再生する | |
338 | + [[mainMovieView movie] play]; | |
339 | + isPlaying = YES; | |
340 | + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieDidEnd:) name:QTMovieDidEndNotification object:theMovie]; | |
341 | + | |
342 | + | |
343 | +} | |
344 | + | |
345 | +-(void) movieDidEnd:(NSNotification*)aNotification { | |
346 | + isPlaying = NO; | |
347 | + [self display]; | |
348 | +} | |
349 | + | |
350 | + | |
351 | +/*! | |
352 | + @method makeMovieFileList | |
353 | + @abstract ムービーファイルの一覧表を作成する | |
354 | + @discussion [defaults movieFilePath]を元に、ファイル名一覧を作り、movieArrayに入れる。ファイルが存在しない場合はArrayは空になるが、nilではない。 | |
355 | +*/ | |
356 | +- (void)makeMovieFileList | |
357 | +{ | |
358 | + BOOL isDir; | |
359 | + NSFileManager *theFileManager; | |
360 | + int theIndex; | |
361 | + | |
362 | + | |
363 | + [movieArray removeAllObjects]; // 過去のリストを捨てる | |
364 | + | |
365 | + theFileManager = [NSFileManager defaultManager]; // デフォルトのファイルマネージャーを得る | |
366 | + if ([theFileManager fileExistsAtPath:[defaults movieFilePath] isDirectory:&isDir]) { // ユーザーが指定したファイルまたはディレクトリが存在する場合の処理 | |
367 | + if (isDir) { // 指定したファイルパスがディレクトリの場合の処理 | |
368 | + NSString *theFileName; // ファイル名 | |
369 | + NSArray *theFileArray; // ファイル一覧 | |
370 | + theFileArray = [theFileManager subpathsAtPath:[defaults movieFilePath]]; // ファイル一覧を得る | |
371 | + if (theFileArray != nil) { // ファイル一覧を得ることができた場合の処理 | |
372 | + for (theIndex = 0; theIndex < [theFileArray count]; theIndex++) { // ファイル一覧のすべてのファイルに対し、 | |
373 | + theFileName = [theFileArray objectAtIndex:theIndex]; // 順番にファイル名を得る | |
374 | + if ([movieTypes containsObject:[theFileName pathExtension]] || [@"'MooV'" isEqualToString:NSHFSTypeOfFile(theFileName)]) { // そのファイルがムービーなら | |
375 | + [movieArray addObject:[NSString stringWithString:[[defaults movieFilePath] stringByAppendingPathComponent:theFileName]]]; // movieArrayに追加 | |
376 | + } | |
377 | + } | |
378 | + if ([movieArray count] > 1) { // ムービーファイルが2個以上あるなら | |
379 | + [movieArray sortUsingSelector:@selector(compare:)]; // アルファベット順にソートする | |
380 | + if ([defaults isRandomPlay]) { // ランダム再生が指定されている場合は、順序を変える。 | |
381 | + int theSwapNumber; | |
382 | + for (theIndex = 0; theIndex < [movieArray count]; theIndex++) { // movieArrayの全てのムービーファイルについて | |
383 | + theSwapNumber = arc4random() % [movieArray count]; // 0 〜 movieArray要素数-1 の乱数を得る | |
384 | + [movieArray exchangeObjectAtIndex:theIndex withObjectAtIndex:theSwapNumber]; | |
385 | + } | |
386 | + } | |
387 | + } | |
388 | + } | |
389 | + } else { // 指定したファイルパスがファイルの場合の処理 | |
390 | + [movieArray addObject:[NSString stringWithString:[defaults movieFilePath]]]; // そのファイルをmovieArrayに追加 | |
391 | + } | |
392 | + | |
393 | + } | |
394 | +} | |
395 | + | |
396 | +@end |
@@ -0,0 +1,105 @@ | ||
1 | +// | |
2 | +// ANMovieSaverDefaults.h | |
3 | +// ANMovieSaver | |
4 | +// | |
5 | +// Copyright (c) 2001-2009 AOKINAO. All rights reserved. | |
6 | +// | |
7 | +/*! | |
8 | + @header ANMovieSaverDefaults | |
9 | + @abstract ANMovieSaverの初期設定値(ディスクに保存される値)の管理をするクラス | |
10 | +*/ | |
11 | + | |
12 | +#import <AppKit/AppKit.h> | |
13 | +#import <ScreenSaver/ScreenSaverDefaults.h> | |
14 | + | |
15 | +/*! | |
16 | + @enum SIZE | |
17 | + @abstract ムービーあるいは背景画像を表示するときの拡大率 | |
18 | + @discussion ムービーあるいは背景画像を表示するときの拡大率 | |
19 | + @constant HALF ムービーあるいは画像を、本来の大きさの半分の大きさで表示 | |
20 | + @constant NORMAL 本来の大きさで表示 | |
21 | + @constant DOUBLE 本来の2倍の大きさで表示 | |
22 | + @constant FULL 画面(モニタ)の大きさに合わせて表示 | |
23 | + */ | |
24 | +typedef enum { | |
25 | + HALF, | |
26 | + NORMAL, | |
27 | + DOUBLE, | |
28 | + FULL | |
29 | +} SIZE; | |
30 | + | |
31 | +/*! | |
32 | + @enum BACKGROUND | |
33 | + @abstract ムービーの背景 | |
34 | + @discussion どのような背景を表示するかの定数 | |
35 | + @constant BG_NORMAL スクリーンセーバのデフォルトの背景。 | |
36 | + @constant BG_COLOR 単色で塗りつぶす | |
37 | + @constant BG_DESKTOP デスクトップをそのまま残す | |
38 | + */ | |
39 | +typedef enum { | |
40 | + BG_NORMAL, | |
41 | + BG_COLOR, | |
42 | + BG_DESKTOP | |
43 | +} BACKGROUND; | |
44 | + | |
45 | +/*! | |
46 | + @class ANMovieSaverDefaults | |
47 | + @abstract ANMovieSaverの初期設定値(ディスクに保存される値)の管理をするクラス | |
48 | +*/ | |
49 | +@interface ANMovieSaverDefaults : NSObject { | |
50 | + // 初期設定として保存される変数 | |
51 | + BACKGROUND backgroundType; // 背景色の種別 | |
52 | + float backgroundRed; // 背景色 | |
53 | + float backgroundGreen; // 背景色 | |
54 | + float backgroundBlue; // 背景色 | |
55 | + BOOL isDisplayImage; // イメージを表示するかどうか | |
56 | + NSString *imageFilePath; // イメージファイル名 | |
57 | + float imageFraction; // イメージの不透明度 | |
58 | + SIZE imageMagnification; // イメージの拡大率 | |
59 | + NSString *movieFilePath; // ムービーファイル名(パス) | |
60 | + float movieVolume; // 音量 | |
61 | + SIZE movieMagnification; // ムービー拡大率 | |
62 | + BOOL isDisplayUnderWindow; // ウィンドウの下で表示するかどうか | |
63 | + BOOL isRandomPlay; // ランダム再生するかどうか | |
64 | +} | |
65 | +- (id)init; | |
66 | +- (void)dealloc; | |
67 | + | |
68 | + // 初期設定値を参照する | |
69 | +- (BACKGROUND)backgroundType; | |
70 | +- (float)backgroundRed; | |
71 | +- (float)backgroundGreen; | |
72 | +- (float)backgroundBlue; | |
73 | +- (NSColor *)backgroundColor; | |
74 | +- (BOOL)isDisplayImage; | |
75 | +- (NSString *)imageFilePath; | |
76 | +- (float)imageFraction; | |
77 | +- (SIZE)imageMagnification; | |
78 | +- (NSString *)movieFilePath; | |
79 | +- (float)movieVolume; | |
80 | +- (SIZE)movieMagnification; | |
81 | +- (BOOL)isDisplayUnderWindow; | |
82 | +- (BOOL)isRandomPlay; | |
83 | + | |
84 | + // 初期設定値を設定する | |
85 | +- (void)setBackgroundType:(BACKGROUND)type; | |
86 | +- (void)setBackgroundRed:(float)red; | |
87 | +- (void)setBackgroundGreen:(float)green; | |
88 | +- (void)setBackgroundBlue:(float)blue; | |
89 | +- (void)setBackgroundColorRed:(float)red green:(float)green blue:(float)blue; | |
90 | +- (void)setBackgroundColor:(NSColor *)color; | |
91 | +- (void)setIsDisplayImage:(BOOL)display; | |
92 | +- (void)setImageFilePath:(NSString *)path; | |
93 | +- (void)setImageFraction:(float)bacgroundfraction; | |
94 | +- (void)setImageMagnification:(SIZE)magnification; | |
95 | +- (void)setMovieFilePath:(NSString *)path; | |
96 | +- (void)setMovieVolume:(float)volume; | |
97 | +- (void)setMovieMagnification:(SIZE)magnification; | |
98 | +- (void)setIsDisplayUnderWindow:(BOOL)display; | |
99 | +- (void)setIsRandomPlay:(BOOL)randomplay; | |
100 | + | |
101 | + // 初期設定値をファイルから読みだし・書き込み | |
102 | +- (void)loadDefaults; | |
103 | +- (void)saveDefaults; | |
104 | + | |
105 | +@end |
@@ -0,0 +1,176 @@ | ||
1 | +// | |
2 | +// ANMovieSaverController.m | |
3 | +// ANMovieSaver | |
4 | +// | |
5 | +// Copyright (c) 2001-2009 AOKINAO. All rights reserved. | |
6 | +// | |
7 | +// ANMovieSaverの設定シートとのコントローラカテゴリ | |
8 | +// | |
9 | + | |
10 | +#import "ANMovieSaverView.h" | |
11 | + | |
12 | +@implementation ANMovieSaverView (Controller) | |
13 | + | |
14 | +// 背景色を変える | |
15 | +- (IBAction)changeColor:(id)sender | |
16 | +{ | |
17 | + [defaults setBackgroundColor:[sender color]]; | |
18 | +} | |
19 | + | |
20 | +// イメージの不透明度を変える | |
21 | +- (IBAction)changeImageFraction:(id)sender | |
22 | +{ | |
23 | + [defaults setImageFraction:[sender floatValue]]; | |
24 | +} | |
25 | + | |
26 | +// イメージサイズを変える | |
27 | +- (IBAction)changeImageSize:(id)sender | |
28 | +{ | |
29 | + [defaults setImageMagnification:[sender indexOfSelectedItem]]; | |
30 | +} | |
31 | + | |
32 | +// ムービーサイズを変える | |
33 | +- (IBAction)changeMovieSize:(id)sender | |
34 | +{ | |
35 | + [defaults setMovieMagnification:[sender indexOfSelectedItem]]; | |
36 | +} | |
37 | + | |
38 | +// 音量を変える | |
39 | +- (IBAction)changeMovieVolume:(id)sender | |
40 | +{ | |
41 | + [defaults setMovieVolume:[sender floatValue]]; | |
42 | +} | |
43 | + | |
44 | +// 設定シートを閉じる | |
45 | +-(IBAction)closeSheet:(id)sender | |
46 | +{ | |
47 | + | |
48 | + [[moviePreviewMovieView movie] stop]; | |
49 | + [defaults saveDefaults]; // 設定を保存する | |
50 | + [self makeMovieFileList]; // ムービーファイルの一覧表を更新する | |
51 | + | |
52 | + // シートを閉じる | |
53 | + [NSApp endSheet:configSheet]; | |
54 | + isPlaying = NO; | |
55 | + [self display]; | |
56 | +} | |
57 | + | |
58 | +// イメージファイル選択ボタンを押したときの処理 | |
59 | +// オープンパネルを開き、イメージの選択を促す。イメージファイルが選択されたらdefaultsに保存し、設定シートに反映する。 | |
60 | +-(IBAction)selectImageFile:(id)sender | |
61 | +{ | |
62 | + // 変数の定義 | |
63 | + NSArray* theTypes; // 拡張子 | |
64 | + NSOpenPanel* theOpenPanel; // ファイルオープンパネル | |
65 | + int theOpenPanelState; | |
66 | + | |
67 | + // オープンパネルを開く | |
68 | + theTypes = [NSImage imageFileTypes]; // ファイルタイプ・拡張子を指定する | |
69 | + theOpenPanel = [NSOpenPanel openPanel]; // ファイル選択パネルを定義する | |
70 | + theOpenPanelState = [theOpenPanel runModalForDirectory:[defaults imageFilePath] file:[[NSFileManager defaultManager] displayNameAtPath:[defaults imageFilePath]] types:theTypes]; // 最後に選択したファイルを選択するした状態でモーダルオープンパネルを開く。 | |
71 | + | |
72 | + // オープンパネルから戻ってきたときの処理 | |
73 | + if (theOpenPanelState == NSOKButton) { // OKボタンが押された | |
74 | + NSImage* theSelectedImage; | |
75 | + | |
76 | + [defaults setImageFilePath:[theOpenPanel filename]]; // ファイルパスの保存 | |
77 | + [imageFileNameTextField setStringValue:[[NSFileManager defaultManager] displayNameAtPath:[defaults imageFilePath]]]; // ファイル名を表示 | |
78 | + theSelectedImage = [[NSImage alloc] initWithContentsOfFile:[defaults imageFilePath]]; // イメージファイルを設定する | |
79 | + [imagePreviewImageView setImage:theSelectedImage]; // イメージビューにイメージを指定 | |
80 | + [theSelectedImage release]; | |
81 | + } | |
82 | +} | |
83 | + | |
84 | +// ムービーファイル選択ボタンを押したときの処理 | |
85 | +-(IBAction)selectMovieFile:(id)sender | |
86 | +{ | |
87 | + // 変数の定義 | |
88 | + NSOpenPanel* theOpenPanel; // ファイルオープンパネル | |
89 | + int theOpenPanelState; | |
90 | + | |
91 | + // オープンパネルを開く | |
92 | + theOpenPanel = [NSOpenPanel openPanel]; | |
93 | + [theOpenPanel setCanChooseDirectories:YES]; // ディレクトリも選択可 | |
94 | + theOpenPanelState = [theOpenPanel runModalForDirectory:[defaults movieFilePath] file:[[NSFileManager defaultManager] displayNameAtPath:[defaults movieFilePath]] types:movieTypes]; // 最後に選択したファイルを選択するした状態でモーダルオープンパネルを開く。 | |
95 | + | |
96 | + // オープンパネルから戻ってきたときの処理 | |
97 | + if (theOpenPanelState == NSOKButton) { // OKボタンが押された | |
98 | + id theSelectedMovie; | |
99 | + NSError* theError; | |
100 | + | |
101 | + [[moviePreviewMovieView movie] stop]; // 現在再生しているムービーを停止する | |
102 | + | |
103 | + [defaults setMovieFilePath:[theOpenPanel filename]]; // ファイル名の設定 | |
104 | + //[self makeMovieFileList]; // ムービーファイルの一覧表を更新する | |
105 | + [movieFileNameTextField setStringValue:[[NSFileManager defaultManager] displayNameAtPath:[defaults movieFilePath]]]; // ファイル名を表示 | |
106 | + theSelectedMovie = [QTMovie movieWithFile:[defaults movieFilePath] error:&theError]; // ムービーを設定する | |
107 | + if (theSelectedMovie) { // ファイルの場合 | |
108 | + [moviePreviewMovieView setMovie:theSelectedMovie]; // ムービービューにムービーを指定 | |
109 | + [moviePreviewMovieView display]; // setMovieしただけでは表示されないので、強制的にdisplayする。 | |
110 | + [moviePreviewMovieView gotoPosterFrame:self]; | |
111 | + [movieRandomPlayCheckBox setEnabled:NO]; // ランダムチェックボックスを指定不可にする | |
112 | + [moviePreviewMovieView setHidden:NO]; // ムービープレビューを表示する | |
113 | + } else { // フォルダの場合 | |
114 | + NSImage* theFolderImage; | |
115 | + [movieRandomPlayCheckBox setEnabled:YES]; // ランダムチェックボックスを指定可能にする | |
116 | + [moviePreviewMovieView setHidden:YES]; // ムービープレビューを非表示にする | |
117 | + theFolderImage = [[NSWorkspace sharedWorkspace] iconForFile: [defaults movieFilePath]]; | |
118 | + [theFolderImage setSize:NSMakeSize(128, 128)]; | |
119 | + [folderImageView setImage:theFolderImage]; // フォルダのイメージを表示する | |
120 | + } | |
121 | + [configSheet display]; | |
122 | + } | |
123 | +} | |
124 | + | |
125 | + | |
126 | +// 背景を指定する | |
127 | +- (IBAction)selectBackground:(id)sender | |
128 | +{ | |
129 | + BACKGROUND theType; | |
130 | + | |
131 | + theType = [sender selectedTag]; | |
132 | + [defaults setBackgroundType:theType]; | |
133 | + | |
134 | + if (theType == BG_NORMAL) { | |
135 | + [backgroundColorWell setEnabled:NO]; | |
136 | + [displayUnderWindowCheckBox setEnabled:NO]; | |
137 | + } else if (theType == BG_COLOR) { | |
138 | + [backgroundColorWell setEnabled:YES]; | |
139 | + [displayUnderWindowCheckBox setEnabled:NO]; | |
140 | + } else { | |
141 | + [backgroundColorWell setEnabled:NO]; | |
142 | + [displayUnderWindowCheckBox setEnabled:YES]; | |
143 | + } | |
144 | +} | |
145 | + | |
146 | + | |
147 | +// イメージを表示するかどうか指定する | |
148 | +- (IBAction)toggleDisplayImage:(id)sender | |
149 | +{ | |
150 | + if ([sender state] == YES) { | |
151 | + [defaults setIsDisplayImage:YES]; | |
152 | + [imageSelectButton setEnabled:YES]; | |
153 | + [imageSizePopUpButton setEnabled:YES]; | |
154 | + [imageFractionSlider setEnabled:YES]; | |
155 | + } else { | |
156 | + [defaults setIsDisplayImage:NO]; | |
157 | + [imageSelectButton setEnabled:NO]; | |
158 | + [imageSizePopUpButton setEnabled:NO]; | |
159 | + [imageFractionSlider setEnabled:NO]; | |
160 | + } | |
161 | +} | |
162 | + | |
163 | + | |
164 | +// ウィンドウの下に表示するかどうかを指定する | |
165 | +- (IBAction)toggleDisplayUnderWindow:(id)sender | |
166 | +{ | |
167 | + [defaults setIsDisplayUnderWindow:[sender state]]; | |
168 | +} | |
169 | + | |
170 | +// ムービーをランダムに再生するかどうか | |
171 | +- (IBAction)toggleRandomPlay:(id)sender | |
172 | +{ | |
173 | + [defaults setIsRandomPlay:[sender state]]; | |
174 | +} | |
175 | + | |
176 | +@end |
@@ -0,0 +1,28 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
3 | +<plist version="1.0"> | |
4 | +<dict> | |
5 | + <key>CFBundleDevelopmentRegion</key> | |
6 | + <string>English</string> | |
7 | + <key>CFBundleExecutable</key> | |
8 | + <string>${EXECUTABLE_NAME}</string> | |
9 | + <key>CFBundleIconFile</key> | |
10 | + <string></string> | |
11 | + <key>CFBundleIdentifier</key> | |
12 | + <string>jp.aokinao.ANMovieSaver</string> | |
13 | + <key>CFBundleInfoDictionaryVersion</key> | |
14 | + <string>6.0</string> | |
15 | + <key>CFBundleName</key> | |
16 | + <string>${PRODUCT_NAME}</string> | |
17 | + <key>CFBundlePackageType</key> | |
18 | + <string>BNDL</string> | |
19 | + <key>CFBundleShortVersionString</key> | |
20 | + <string>2.0.2</string> | |
21 | + <key>CFBundleSignature</key> | |
22 | + <string>????</string> | |
23 | + <key>CFBundleVersion</key> | |
24 | + <string>AN Movie Saver 2.0.2</string> | |
25 | + <key>NSPrincipalClass</key> | |
26 | + <string>ANMovieSaverView</string> | |
27 | +</dict> | |
28 | +</plist> |