OSDN Git Service

b4a94f29546343d5fdbffe26a4033f41579f5a0c
[handbrake-jp/handbrake-jp-git.git] / macosx / Controller.h
1 /* $Id: Controller.h,v 1.35 2005/08/01 14:29:50 titer Exp $
2
3    This file is part of the HandBrake source code.
4    Homepage: <http://handbrake.fr/>.
5    It may be used under the terms of the GNU General Public License. */
6
7 #import <Cocoa/Cocoa.h>
8 #import <Growl/Growl.h>
9
10 #include "hb.h"
11
12 #import "ChapterTitles.h"
13 #import "HBSubtitles.h"
14 #import "PictureController.h"
15 #import "HBPreviewController.h"
16 #import "HBQueueController.h"
17 #import "HBAdvancedController.h"
18 #import "HBPreferencesController.h"
19 #import "HBPresets.h"
20
21 @class HBOutputPanelController;
22
23 /* We subclass NSView so that our drags show both the icon as well as PresetName columns */
24 @interface HBPresetsOutlineView : NSOutlineView
25 {
26
27 BOOL                        fIsDragging;
28
29 }
30 @end
31
32 @interface HBController : NSObject <GrowlApplicationBridgeDelegate>
33 {
34     NSImage                      * fApplicationIcon;
35     IBOutlet NSWindow            * fWindow;
36
37     /* Main Menu Outlets */
38     NSMenuItem                   * fOpenSourceTitleMMenu;
39     
40     /* Source Title Scan Outlets */
41     IBOutlet NSPanel              * fScanSrcTitlePanel;
42     IBOutlet NSTextField          * fScanSrcTitlePathField;
43     IBOutlet NSTextField          * fSrcDsplyNameTitleScan;
44     IBOutlet NSTextField          * fScanSrcTitleNumField;
45     IBOutlet NSButton             * fScanSrcTitleCancelButton;
46     IBOutlet NSButton             * fScanSrcTitleOpenButton;
47
48     
49     /* Picture Settings */
50     PictureController            * fPictureController;
51     
52     /* Picture Preview */
53     PreviewController            * fPreviewController;
54     
55     /* Advanced options tab */
56     HBAdvancedController         * fAdvancedOptions;
57         IBOutlet NSBox               * fAdvancedView;
58     
59     HBPreferencesController      * fPreferencesController;
60     
61     /* Queue panel */
62     HBQueueController            * fQueueController;
63     IBOutlet NSTextField         * fQueueStatus;
64     
65     /* Output panel */
66     HBOutputPanelController       *outputPanel;
67         
68     /* Source box */
69         IBOutlet NSProgressIndicator * fScanIndicator;
70         NSString                     * sourceDisplayName;
71     IBOutlet NSTextField         * fSrcDVD2Field;
72     IBOutlet NSTextField         * fSrcTitleField;
73     IBOutlet NSPopUpButton       * fSrcTitlePopUp;
74     
75     
76     /* lib dvd nav specific */
77     IBOutlet NSTextField         * fSrcAngleLabel;
78     IBOutlet NSPopUpButton       * fSrcAnglePopUp;
79     
80     /* Source start and end points */
81     IBOutlet NSPopUpButton       * fEncodeStartStopPopUp;
82     /* pts based start / stop */
83     IBOutlet NSTextField         * fSrcTimeStartEncodingField;
84     IBOutlet NSTextField         * fSrcTimeEndEncodingField;
85     /* frame based based start / stop */
86     IBOutlet NSTextField         * fSrcFrameStartEncodingField;
87     IBOutlet NSTextField         * fSrcFrameEndEncodingField;
88     
89     IBOutlet NSTextField         * fSrcChapterField;
90     IBOutlet NSPopUpButton       * fSrcChapterStartPopUp;
91     IBOutlet NSTextField         * fSrcChapterToField;
92     IBOutlet NSPopUpButton       * fSrcChapterEndPopUp;
93     
94     /* Source duration information */
95     IBOutlet NSTextField         * fSrcDuration1Field;
96     IBOutlet NSTextField         * fSrcDuration2Field;
97         
98     /* Destination box */
99     IBOutlet NSTextField         * fDstFormatField;
100         IBOutlet NSPopUpButton       * fDstFormatPopUp;
101         
102     IBOutlet NSTextField         * fDstFile1Field;
103     IBOutlet NSTextField         * fDstFile2Field;
104     IBOutlet NSButton            * fDstBrowseButton;
105     /* MP4 Options */
106     // Creates 64 bit mp4's that allow file sizes over 4gb
107     IBOutlet NSButton            * fDstMp4LargeFileCheck;
108     // Optimizes mp4's for http
109     IBOutlet NSButton            * fDstMp4HttpOptFileCheck;
110     // Creates iPod compatible mp4's (add ipod uuid atom)
111     IBOutlet NSButton            * fDstMp4iPodFileCheck;
112         
113     /* Video box */
114     IBOutlet NSButton            * fFrameratePfrCheck;
115     
116     IBOutlet NSTextField         * fVidRateField;
117     IBOutlet NSPopUpButton       * fVidRatePopUp;
118     IBOutlet NSTextField         * fVidEncoderField;
119     IBOutlet NSPopUpButton       * fVidEncoderPopUp;
120     IBOutlet NSTextField         * fVidQualityField;
121     IBOutlet NSTextField         * fVidQualityRFLabel;
122     IBOutlet NSTextField         * fVidQualityRFField;
123     IBOutlet NSMatrix            * fVidQualityMatrix;
124     IBOutlet NSButtonCell        * fVidTargetCell;
125     IBOutlet NSTextField         * fVidTargetSizeField;
126     IBOutlet NSButtonCell        * fVidBitrateCell;
127     IBOutlet NSTextField         * fVidBitrateField;
128     IBOutlet NSButtonCell        * fVidConstantCell;
129     IBOutlet NSSlider            * fVidQualitySlider;
130     IBOutlet NSButton            * fVidTwoPassCheck;
131     IBOutlet NSButton            * fVidTurboPassCheck;
132         
133         /* Status read out fileds for picture sizing */
134     IBOutlet NSTextField         * fPictureSizeField;
135     IBOutlet NSTextField         * fPictureCroppingField;
136         
137     /* Status read out fileds for video filters */
138     IBOutlet NSTextField         * fVideoFiltersField;
139         
140         /* Picture variables */
141         int                        PicOrigOutputWidth;
142         int                        PicOrigOutputHeight;
143         int                        AutoCropTop;
144         int                        AutoCropBottom;
145         int                        AutoCropLeft;
146         int                        AutoCropRight;
147     /* Subtitles box */
148     IBOutlet NSTextField         * fSubField;
149     IBOutlet NSPopUpButton       * fSubPopUp;
150         IBOutlet NSButton            * fSubForcedCheck;
151     
152     
153     IBOutlet NSTableView         * fSubtitlesTable;
154         HBSubtitles                  * fSubtitlesDelegate;
155     IBOutlet NSButton            * fBrowseSrtFileButton;
156     
157         
158     /* Audio box */
159     /* Track Labels */
160     IBOutlet NSTextField         * fAudSourceLabel;
161     IBOutlet NSTextField         * fAudCodecLabel;
162     IBOutlet NSTextField         * fAudMixdownLabel;
163     IBOutlet NSTextField         * fAudSamplerateLabel;
164     IBOutlet NSTextField         * fAudBitrateLabel;
165     IBOutlet NSTextField         * fAudDrcLabel;
166     
167     IBOutlet NSTextField         * fAudTrack1Label;
168     IBOutlet NSTextField         * fAudTrack2Label;
169     IBOutlet NSTextField         * fAudTrack3Label;
170     IBOutlet NSTextField         * fAudTrack4Label;
171     
172     /* Source Audio PopUps */
173     IBOutlet NSPopUpButton       * fAudLang1PopUp;
174     IBOutlet NSPopUpButton       * fAudLang2PopUp;
175     IBOutlet NSPopUpButton       * fAudLang3PopUp;
176     IBOutlet NSPopUpButton       * fAudLang4PopUp;
177     
178     /* Codec Popups */
179     IBOutlet NSPopUpButton       * fAudTrack1CodecPopUp;
180     IBOutlet NSPopUpButton       * fAudTrack2CodecPopUp;
181     IBOutlet NSPopUpButton       * fAudTrack3CodecPopUp;
182     IBOutlet NSPopUpButton       * fAudTrack4CodecPopUp;
183     
184         /* Mixdown PopUps */
185         IBOutlet NSPopUpButton       * fAudTrack1MixPopUp;
186     IBOutlet NSPopUpButton       * fAudTrack2MixPopUp;
187     IBOutlet NSPopUpButton       * fAudTrack3MixPopUp;
188     IBOutlet NSPopUpButton       * fAudTrack4MixPopUp;
189         
190     /* Samplerate PopUps */
191         IBOutlet NSPopUpButton       * fAudTrack1RatePopUp;
192     IBOutlet NSPopUpButton       * fAudTrack2RatePopUp;
193     IBOutlet NSPopUpButton       * fAudTrack3RatePopUp;
194     IBOutlet NSPopUpButton       * fAudTrack4RatePopUp;
195     
196     /* Bitrate PopUps */
197     IBOutlet NSPopUpButton       * fAudTrack1BitratePopUp;
198     IBOutlet NSPopUpButton       * fAudTrack2BitratePopUp;
199     IBOutlet NSPopUpButton       * fAudTrack3BitratePopUp;
200     IBOutlet NSPopUpButton       * fAudTrack4BitratePopUp;
201     
202     /* Dynamic Range Compression */
203     IBOutlet NSSlider            * fAudTrack1DrcSlider;
204     IBOutlet NSTextField         * fAudTrack1DrcField;
205     IBOutlet NSSlider            * fAudTrack2DrcSlider;
206     IBOutlet NSTextField         * fAudTrack2DrcField;
207     IBOutlet NSSlider            * fAudTrack3DrcSlider;
208     IBOutlet NSTextField         * fAudTrack3DrcField;
209     IBOutlet NSSlider            * fAudTrack4DrcSlider;
210     IBOutlet NSTextField         * fAudTrack4DrcField;
211     
212     /* Chapters box */
213     IBOutlet NSButton            * fCreateChapterMarkers;
214     IBOutlet NSTableView         * fChapterTable;
215         IBOutlet NSButton            * fLoadChaptersButton;
216         IBOutlet NSButton            * fSaveChaptersButton;
217         IBOutlet NSTableColumn       * fChapterTableNameColumn;
218         ChapterTitles                * fChapterTitlesDelegate;
219         
220     /* Bottom */
221     IBOutlet NSTextField         * fStatusField;
222     IBOutlet NSProgressIndicator * fRipIndicator;
223         BOOL                           fRipIndicatorShown;
224     
225     /* Queue File variables */
226     NSString                     * QueueFile;
227         NSMutableArray               * QueueFileArray;
228     int                            currentQueueEncodeIndex; // Used to track the currently encoding queueu item
229     
230         /* User Preset variables here */
231         HBPresets                    * fPresetsBuiltin;
232         IBOutlet NSDrawer            * fPresetDrawer;
233         IBOutlet NSTextField         * fPresetNewName;
234         IBOutlet NSTextField         * fPresetNewDesc;
235         IBOutlet NSPopUpButton       * fPresetNewPicSettingsPopUp;
236     IBOutlet NSButton            * fPresetNewPicFiltersCheck;
237     IBOutlet NSButton            * fPresetNewFolderCheck;
238         IBOutlet NSTextField         * fPresetSelectedDisplay;
239         
240         NSString                     * AppSupportDirectory;
241         NSString                     * UserPresetsFile;
242         NSMutableArray               * UserPresets;
243         NSMutableArray               * UserPresetssortedArray;
244         NSMutableDictionary          * chosenPreset;
245     int                            curUserPresetChosenNum;
246          
247         NSMutableDictionary          *presetHbDefault; // this is 1 in "Default" preset key
248         NSMutableDictionary          *presetUserDefault;// this is 2 in "Default" preset key
249     NSMutableDictionary          *presetUserDefaultParent;
250     NSMutableDictionary          *presetUserDefaultParentParent;
251     int                           presetCurrentBuiltInCount; // keeps track of the current number of built in presets
252     IBOutlet NSPanel             * fAddPresetPanel;
253         
254     /* NSOutline View for the presets */
255     NSArray                      *fDraggedNodes;
256     IBOutlet HBPresetsOutlineView * fPresetsOutlineView;
257     IBOutlet NSButton            * fPresetsAdd;
258         IBOutlet NSButton            * fPresetsDelete;
259     IBOutlet NSPopUpButton       * fPresetsActionButton;
260
261     hb_handle_t                  * fHandle;
262     
263     /* Queue variables */
264     hb_handle_t              * fQueueEncodeLibhb;           // libhb for HB Encoding
265         hb_title_t                   * fTitle;
266     hb_title_t                   * fQueueEncodeTitle;
267     int                          fEncodingQueueItem;     // corresponds to the index of fJobGroups encoding item
268     int                          fPendingCount;         // Number of various kinds of job groups in fJobGroups.
269     int                          fCompletedCount;
270     int                          fCanceledCount;
271     int                          fWorkingCount;
272     
273     int                          fqueueEditRescanItemNum; // queue array item to be reloaded into the main window
274     
275     
276     /* integer to set to determine the previous state
277                 of encode 0==idle, 1==encoding, 2==cancelled*/
278     int                            fEncodeState;
279         int                            currentScanCount;
280         int                            currentSuccessfulScanCount;
281     BOOL                           SuccessfulScan;
282     BOOL                           applyQueueToScan;
283         NSString                      * currentSource;
284     NSString                     * browsedSourceDisplayName;
285     
286     double                         dockIconProgress;
287 }
288
289 - (IBAction) showAboutPanel:(id)sender;
290
291 - (void) writeToActivityLog:(const char *) format, ...;
292 - (IBAction) browseSources: (id) sender;
293 - (void) browseSourcesDone: (NSOpenPanel *) sheet
294                 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
295 - (IBAction) showSourceTitleScanPanel: (id) sender;
296 - (IBAction) closeSourceTitleScanPanel: (id) sender;  
297 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
298 - (IBAction) showNewScan: (id) sender;
299
300
301 - (IBAction) cancelScanning:(id)sender;
302
303 - (void)     updateUI: (NSTimer *) timer;
304 - (void)     enableUI: (bool) enable;
305 - (IBAction) encodeStartStopPopUpChanged: (id) sender;
306 - (IBAction) titlePopUpChanged: (id) sender;
307 - (IBAction) chapterPopUpChanged: (id) sender;
308 - (IBAction) startEndSecValueChanged: (id) sender;
309 - (IBAction) startEndFrameValueChanged: (id) sender;
310
311
312 - (IBAction) formatPopUpChanged: (id) sender;
313 - (IBAction) videoEncoderPopUpChanged: (id) sender;
314 - (IBAction) autoSetM4vExtension: (id) sender;
315 - (IBAction) twoPassCheckboxChanged: (id) sender;
316 - (IBAction) videoFrameRateChanged: (id) sender;
317 - (IBAction) audioAddAudioTrackCodecs: (id)sender;
318 - (IBAction) audioCodecsPopUpChanged: (id) sender;
319 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender;
320 - (IBAction) addAllAudioTracksToPopUp: (id) sender;
321 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound;
322 - (IBAction) audioTrackPopUpChanged: (id) sender;
323 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
324 - (IBAction) audioTrackMixdownChanged: (id) sender;
325 - (void) prepareJob;
326 - (IBAction) browseFile: (id) sender;
327 - (void)     browseFileDone: (NSSavePanel *) sheet
328                  returnCode: (int) returnCode contextInfo: (void *) contextInfo;
329
330 - (IBAction) videoMatrixChanged: (id) sender;
331
332 - (IBAction) qualitySliderChanged: (id) sender;
333 - (void) setupQualitySlider;
334
335 - (IBAction) audioDRCSliderChanged: (id) sender;
336 - (IBAction) browseImportSrtFile: (id) sender;
337 - (void) browseImportSrtFileDone: (NSSavePanel *) sheet
338                      returnCode: (int) returnCode contextInfo: (void *) contextInfo;
339
340 - (IBAction) showPicturePanel: (id) sender;
341 - (void) picturePanelFullScreen;
342 - (void) picturePanelWindowed;
343 - (IBAction) showPreviewWindow: (id) sender;
344 - (void)pictureSettingsDidChange;
345 - (IBAction) calculatePictureSizing: (id) sender;
346 - (IBAction) openMainWindow: (id) sender;
347
348 /* Queue File Stuff */
349 - (void) loadQueueFile;
350 - (NSDictionary *)createQueueFileItem;
351 - (void)saveQueueFileItem;
352 - (void) incrementQueueItemDone:(int) queueItemDoneIndexNum;
353 - (void) performNewQueueScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
354 - (void) processNewQueueEncode;
355 - (void) clearQueueEncodedItems;
356 /* Queue Editing */
357 - (IBAction)applyQueueSettingsToMainWindow:(id)sender;
358 - (IBAction)rescanQueueItemToMainWindow:(NSString *) scanPath scanTitleNum: (int) scanTitleNum selectedQueueItem: (int) selectedQueueItem;
359
360
361 - (void) removeQueueFileItem:(int) queueItemToRemove;
362 - (void) clearQueueAllItems;
363 - (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
364 - (void)getQueueStats;
365 - (void)setQueueEncodingItemsAsPending;
366 - (IBAction) addToQueue: (id) sender;
367 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
368                            returnCode: (int) returnCode contextInfo: (void *) contextInfo;
369 - (void)     doAddToQueue;
370
371 - (IBAction) showQueueWindow:(id)sender;
372
373 - (IBAction)showPreferencesWindow:(id)sender;
374
375 - (IBAction) Rip: (id) sender;
376 - (void)     overWriteAlertDone: (NSWindow *) sheet
377                      returnCode: (int) returnCode contextInfo: (void *) contextInfo;
378 - (void)     doRip;
379
380 - (IBAction) Cancel: (id) sender;
381 - (void)     doCancelCurrentJob;
382 - (void) doCancelCurrentJobAndStop;
383 - (IBAction) Pause: (id) sender;
384
385 - (IBAction) calculateBitrate: (id) sender;
386 - (void) controlTextDidChange: (NSNotification *) notification;
387
388 - (IBAction) openHomepage: (id) sender;
389 - (IBAction) openForums:   (id) sender;
390 - (IBAction) openUserGuide:   (id) sender;
391
392 // Preset Methods Here
393     
394 /* These are required by the NSOutlineView Datasource Delegate */
395 /* We use this to deterimine children of an item */
396 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
397 /* We use this to determine if an item should be expandable */
398 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
399 /* used to specify the number of levels to show for each item */
400 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
401 /* Used to tell the outline view which information is to be displayed per item */
402 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
403 /* Use to customize the font and display characteristics of the title cell */
404 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
405 /* We use this to edit the name field in the outline view */
406 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
407 /* We use this to provide tooltips for the items in the presets outline view */
408 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
409 - (void) checkBuiltInsForUpdates;
410 /* We use this to actually select the preset and act accordingly */
411 - (IBAction)selectPreset:(id)sender;    
412
413 /* Export / Import Presets */
414 - (IBAction) browseExportPresetFile: (id) sender;
415 - (void) browseExportPresetFileDone: (NSSavePanel *) sheet
416              returnCode: (int) returnCode contextInfo: (void *) contextInfo;
417              
418 - (IBAction) browseImportPresetFile: (id) sender;
419 - (void) browseImportPresetDone: (NSSavePanel *) sheet
420                    returnCode: (int) returnCode contextInfo: (void *) contextInfo;
421
422 /* Manage User presets */    
423 - (void) loadPresets;
424 - (IBAction) customSettingUsed: (id) sender;
425 - (IBAction) showAddPresetPanel: (id) sender;
426 - (IBAction) closeAddPresetPanel: (id) sender;
427 - (NSDictionary *)createPreset;
428
429 - (IBAction) revertPictureSizeToMax:(id)sender;
430
431 - (IBAction)setDefaultPreset:(id)sender;
432 - (IBAction)selectDefaultPreset:(id)sender;
433 - (void) savePreset;
434 - (void)sortPresets;
435 - (IBAction)addFactoryPresets:(id)sender;
436 - (IBAction)deleteFactoryPresets:(id)sender;
437 - (IBAction)addUserPreset:(id)sender;
438 - (void)addPreset;
439 - (IBAction)insertPreset:(id)sender;
440 - (IBAction)deletePreset:(id)sender;
441 - (IBAction)getDefaultPresets:(id)sender;
442
443 -(void)sendToMetaX:(NSString *) filePath;
444 // Growl methods
445 - (NSDictionary *) registrationDictionaryForGrowl;
446 -(void)showGrowlDoneNotification:(NSString *) filePath;
447 - (IBAction)showDebugOutputPanel:(id)sender;
448 - (void)setupToolbar;
449
450 - (void) prepareJobForPreview;
451 - (void) remindUserOfSleepOrShutdown;
452
453 - (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
454
455 - (int) hbInstances;
456
457 // Chapter files methods
458 - (IBAction) browseForChapterFile: (id) sender;
459 - (void)     browseForChapterFileDone: (NSOpenPanel *) sheet
460                  returnCode: (int) returnCode contextInfo: (void *) contextInfo;
461
462 - (IBAction) browseForChapterFileSave: (id) sender;
463 - (void)     browseForChapterFileSaveDone: (NSSavePanel *) sheet
464                  returnCode: (int) returnCode contextInfo: (void *) contextInfo;
465
466 @end
467