OSDN Git Service

72b1c6da371d7486ec16d747c0219e1cf3148c29
[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 NSTextField         * fVidRateField;
115     IBOutlet NSPopUpButton       * fVidRatePopUp;
116     IBOutlet NSTextField         * fVidEncoderField;
117     IBOutlet NSPopUpButton       * fVidEncoderPopUp;
118     IBOutlet NSTextField         * fVidQualityField;
119     IBOutlet NSTextField         * fVidQualityRFLabel;
120     IBOutlet NSTextField         * fVidQualityRFField;
121     IBOutlet NSMatrix            * fVidQualityMatrix;
122     IBOutlet NSButtonCell        * fVidTargetCell;
123     IBOutlet NSTextField         * fVidTargetSizeField;
124     IBOutlet NSButtonCell        * fVidBitrateCell;
125     IBOutlet NSTextField         * fVidBitrateField;
126     IBOutlet NSButtonCell        * fVidConstantCell;
127     IBOutlet NSSlider            * fVidQualitySlider;
128     IBOutlet NSButton            * fVidTwoPassCheck;
129     IBOutlet NSButton            * fVidTurboPassCheck;
130         
131         /* Status read out fileds for picture sizing */
132     IBOutlet NSTextField         * fPictureSizeField;
133     IBOutlet NSTextField         * fPictureCroppingField;
134         
135     /* Status read out fileds for video filters */
136     IBOutlet NSTextField         * fVideoFiltersField;
137         
138         /* Picture variables */
139         int                        PicOrigOutputWidth;
140         int                        PicOrigOutputHeight;
141         int                        AutoCropTop;
142         int                        AutoCropBottom;
143         int                        AutoCropLeft;
144         int                        AutoCropRight;
145     /* Subtitles box */
146     IBOutlet NSTextField         * fSubField;
147     IBOutlet NSPopUpButton       * fSubPopUp;
148         IBOutlet NSButton            * fSubForcedCheck;
149     
150     
151     IBOutlet NSTableView         * fSubtitlesTable;
152         HBSubtitles                  * fSubtitlesDelegate;
153     IBOutlet NSButton            * fBrowseSrtFileButton;
154     
155         
156     /* Audio box */
157     /* Track Labels */
158     IBOutlet NSTextField         * fAudSourceLabel;
159     IBOutlet NSTextField         * fAudCodecLabel;
160     IBOutlet NSTextField         * fAudMixdownLabel;
161     IBOutlet NSTextField         * fAudSamplerateLabel;
162     IBOutlet NSTextField         * fAudBitrateLabel;
163     IBOutlet NSTextField         * fAudDrcLabel;
164     
165     IBOutlet NSTextField         * fAudTrack1Label;
166     IBOutlet NSTextField         * fAudTrack2Label;
167     IBOutlet NSTextField         * fAudTrack3Label;
168     IBOutlet NSTextField         * fAudTrack4Label;
169     
170     /* Source Audio PopUps */
171     IBOutlet NSPopUpButton       * fAudLang1PopUp;
172     IBOutlet NSPopUpButton       * fAudLang2PopUp;
173     IBOutlet NSPopUpButton       * fAudLang3PopUp;
174     IBOutlet NSPopUpButton       * fAudLang4PopUp;
175     
176     /* Codec Popups */
177     IBOutlet NSPopUpButton       * fAudTrack1CodecPopUp;
178     IBOutlet NSPopUpButton       * fAudTrack2CodecPopUp;
179     IBOutlet NSPopUpButton       * fAudTrack3CodecPopUp;
180     IBOutlet NSPopUpButton       * fAudTrack4CodecPopUp;
181     
182         /* Mixdown PopUps */
183         IBOutlet NSPopUpButton       * fAudTrack1MixPopUp;
184     IBOutlet NSPopUpButton       * fAudTrack2MixPopUp;
185     IBOutlet NSPopUpButton       * fAudTrack3MixPopUp;
186     IBOutlet NSPopUpButton       * fAudTrack4MixPopUp;
187         
188     /* Samplerate PopUps */
189         IBOutlet NSPopUpButton       * fAudTrack1RatePopUp;
190     IBOutlet NSPopUpButton       * fAudTrack2RatePopUp;
191     IBOutlet NSPopUpButton       * fAudTrack3RatePopUp;
192     IBOutlet NSPopUpButton       * fAudTrack4RatePopUp;
193     
194     /* Bitrate PopUps */
195     IBOutlet NSPopUpButton       * fAudTrack1BitratePopUp;
196     IBOutlet NSPopUpButton       * fAudTrack2BitratePopUp;
197     IBOutlet NSPopUpButton       * fAudTrack3BitratePopUp;
198     IBOutlet NSPopUpButton       * fAudTrack4BitratePopUp;
199     
200     /* Dynamic Range Compression */
201     IBOutlet NSSlider            * fAudTrack1DrcSlider;
202     IBOutlet NSTextField         * fAudTrack1DrcField;
203     IBOutlet NSSlider            * fAudTrack2DrcSlider;
204     IBOutlet NSTextField         * fAudTrack2DrcField;
205     IBOutlet NSSlider            * fAudTrack3DrcSlider;
206     IBOutlet NSTextField         * fAudTrack3DrcField;
207     IBOutlet NSSlider            * fAudTrack4DrcSlider;
208     IBOutlet NSTextField         * fAudTrack4DrcField;
209     
210     /* Chapters box */
211     IBOutlet NSButton            * fCreateChapterMarkers;
212     IBOutlet NSTableView         * fChapterTable;
213         IBOutlet NSButton            * fLoadChaptersButton;
214         IBOutlet NSButton            * fSaveChaptersButton;
215         IBOutlet NSTableColumn       * fChapterTableNameColumn;
216         ChapterTitles                * fChapterTitlesDelegate;
217         
218     /* Bottom */
219     IBOutlet NSTextField         * fStatusField;
220     IBOutlet NSProgressIndicator * fRipIndicator;
221         BOOL                           fRipIndicatorShown;
222     
223     /* Queue File variables */
224     NSString                     * QueueFile;
225         NSMutableArray               * QueueFileArray;
226     int                            currentQueueEncodeIndex; // Used to track the currently encoding queueu item
227     
228         /* User Preset variables here */
229         HBPresets                    * fPresetsBuiltin;
230         IBOutlet NSDrawer            * fPresetDrawer;
231         IBOutlet NSTextField         * fPresetNewName;
232         IBOutlet NSTextField         * fPresetNewDesc;
233         IBOutlet NSPopUpButton       * fPresetNewPicSettingsPopUp;
234     IBOutlet NSButton            * fPresetNewPicFiltersCheck;
235     IBOutlet NSButton            * fPresetNewFolderCheck;
236         IBOutlet NSTextField         * fPresetSelectedDisplay;
237         
238         NSString                     * AppSupportDirectory;
239         NSString                     * UserPresetsFile;
240         NSMutableArray               * UserPresets;
241         NSMutableArray               * UserPresetssortedArray;
242         NSMutableDictionary          * chosenPreset;
243     int                            curUserPresetChosenNum;
244          
245         NSMutableDictionary          *presetHbDefault; // this is 1 in "Default" preset key
246         NSMutableDictionary          *presetUserDefault;// this is 2 in "Default" preset key
247     NSMutableDictionary          *presetUserDefaultParent;
248     NSMutableDictionary          *presetUserDefaultParentParent;
249     int                           presetCurrentBuiltInCount; // keeps track of the current number of built in presets
250     IBOutlet NSPanel             * fAddPresetPanel;
251         
252     /* NSOutline View for the presets */
253     NSArray                      *fDraggedNodes;
254     IBOutlet HBPresetsOutlineView * fPresetsOutlineView;
255     IBOutlet NSButton            * fPresetsAdd;
256         IBOutlet NSButton            * fPresetsDelete;
257     IBOutlet NSPopUpButton       * fPresetsActionButton;
258
259     hb_handle_t                  * fHandle;
260     
261     /* Queue variables */
262     hb_handle_t              * fQueueEncodeLibhb;           // libhb for HB Encoding
263         hb_title_t                   * fTitle;
264     hb_title_t                   * fQueueEncodeTitle;
265     int                          fEncodingQueueItem;     // corresponds to the index of fJobGroups encoding item
266     int                          fPendingCount;         // Number of various kinds of job groups in fJobGroups.
267     int                          fCompletedCount;
268     int                          fCanceledCount;
269     int                          fWorkingCount;
270     
271     int                          fqueueEditRescanItemNum; // queue array item to be reloaded into the main window
272     
273     
274     /* integer to set to determine the previous state
275                 of encode 0==idle, 1==encoding, 2==cancelled*/
276     int                            fEncodeState;
277         int                            currentScanCount;
278         int                            currentSuccessfulScanCount;
279     BOOL                           SuccessfulScan;
280     BOOL                           applyQueueToScan;
281         NSString                      * currentSource;
282     NSString                     * browsedSourceDisplayName;
283     
284     double                         dockIconProgress;
285 }
286
287 - (IBAction) showAboutPanel:(id)sender;
288
289 - (void) writeToActivityLog:(const char *) format, ...;
290 - (IBAction) browseSources: (id) sender;
291 - (void) browseSourcesDone: (NSOpenPanel *) sheet
292                 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
293 - (IBAction) showSourceTitleScanPanel: (id) sender;
294 - (IBAction) closeSourceTitleScanPanel: (id) sender;  
295 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
296 - (IBAction) showNewScan: (id) sender;
297
298
299 - (IBAction) cancelScanning:(id)sender;
300
301 - (void)     updateUI: (NSTimer *) timer;
302 - (void)     enableUI: (bool) enable;
303 - (IBAction) encodeStartStopPopUpChanged: (id) sender;
304 - (IBAction) titlePopUpChanged: (id) sender;
305 - (IBAction) chapterPopUpChanged: (id) sender;
306 - (IBAction) startEndSecValueChanged: (id) sender;
307 - (IBAction) startEndFrameValueChanged: (id) sender;
308
309
310 - (IBAction) formatPopUpChanged: (id) sender;
311 - (IBAction) videoEncoderPopUpChanged: (id) sender;
312 - (IBAction) autoSetM4vExtension: (id) sender;
313 - (IBAction) twoPassCheckboxChanged: (id) sender;
314 - (IBAction) videoFrameRateChanged: (id) sender;
315 - (IBAction) audioAddAudioTrackCodecs: (id)sender;
316 - (IBAction) audioCodecsPopUpChanged: (id) sender;
317 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender;
318 - (IBAction) addAllAudioTracksToPopUp: (id) sender;
319 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound;
320 - (IBAction) audioTrackPopUpChanged: (id) sender;
321 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
322 - (IBAction) audioTrackMixdownChanged: (id) sender;
323 - (void) prepareJob;
324 - (IBAction) browseFile: (id) sender;
325 - (void)     browseFileDone: (NSSavePanel *) sheet
326                  returnCode: (int) returnCode contextInfo: (void *) contextInfo;
327
328 - (IBAction) videoMatrixChanged: (id) sender;
329
330 - (IBAction) qualitySliderChanged: (id) sender;
331 - (void) setupQualitySlider;
332
333 - (IBAction) audioDRCSliderChanged: (id) sender;
334 - (IBAction) browseImportSrtFile: (id) sender;
335 - (void) browseImportSrtFileDone: (NSSavePanel *) sheet
336                      returnCode: (int) returnCode contextInfo: (void *) contextInfo;
337
338 - (IBAction) showPicturePanel: (id) sender;
339 - (void) picturePanelFullScreen;
340 - (void) picturePanelWindowed;
341 - (IBAction) showPreviewWindow: (id) sender;
342 - (void)pictureSettingsDidChange;
343 - (IBAction) calculatePictureSizing: (id) sender;
344 - (IBAction) openMainWindow: (id) sender;
345
346 /* Queue File Stuff */
347 - (void) loadQueueFile;
348 - (NSDictionary *)createQueueFileItem;
349 - (void)saveQueueFileItem;
350 - (void) incrementQueueItemDone:(int) queueItemDoneIndexNum;
351 - (void) performNewQueueScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
352 - (void) processNewQueueEncode;
353 - (void) clearQueueEncodedItems;
354 /* Queue Editing */
355 - (IBAction)applyQueueSettingsToMainWindow:(id)sender;
356 - (IBAction)rescanQueueItemToMainWindow:(NSString *) scanPath scanTitleNum: (int) scanTitleNum selectedQueueItem: (int) selectedQueueItem;
357
358
359 - (void) removeQueueFileItem:(int) queueItemToRemove;
360 - (void) clearQueueAllItems;
361 - (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
362 - (void)getQueueStats;
363 - (void)setQueueEncodingItemsAsPending;
364 - (IBAction) addToQueue: (id) sender;
365 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
366                            returnCode: (int) returnCode contextInfo: (void *) contextInfo;
367 - (void)     doAddToQueue;
368
369 - (IBAction) showQueueWindow:(id)sender;
370
371 - (IBAction)showPreferencesWindow:(id)sender;
372
373 - (IBAction) Rip: (id) sender;
374 - (void)     overWriteAlertDone: (NSWindow *) sheet
375                      returnCode: (int) returnCode contextInfo: (void *) contextInfo;
376 - (void)     doRip;
377
378 - (IBAction) Cancel: (id) sender;
379 - (void)     doCancelCurrentJob;
380 - (void) doCancelCurrentJobAndStop;
381 - (IBAction) Pause: (id) sender;
382
383 - (IBAction) calculateBitrate: (id) sender;
384 - (void) controlTextDidChange: (NSNotification *) notification;
385
386 - (IBAction) openHomepage: (id) sender;
387 - (IBAction) openForums:   (id) sender;
388 - (IBAction) openUserGuide:   (id) sender;
389
390 // Preset Methods Here
391     
392 /* These are required by the NSOutlineView Datasource Delegate */
393 /* We use this to deterimine children of an item */
394 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
395 /* We use this to determine if an item should be expandable */
396 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
397 /* used to specify the number of levels to show for each item */
398 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
399 /* Used to tell the outline view which information is to be displayed per item */
400 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
401 /* Use to customize the font and display characteristics of the title cell */
402 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
403 /* We use this to edit the name field in the outline view */
404 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
405 /* We use this to provide tooltips for the items in the presets outline view */
406 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
407 - (void) checkBuiltInsForUpdates;
408 /* We use this to actually select the preset and act accordingly */
409 - (IBAction)selectPreset:(id)sender;    
410
411 /* Export / Import Presets */
412 - (IBAction) browseExportPresetFile: (id) sender;
413 - (void) browseExportPresetFileDone: (NSSavePanel *) sheet
414              returnCode: (int) returnCode contextInfo: (void *) contextInfo;
415              
416 - (IBAction) browseImportPresetFile: (id) sender;
417 - (void) browseImportPresetDone: (NSSavePanel *) sheet
418                    returnCode: (int) returnCode contextInfo: (void *) contextInfo;
419
420 /* Manage User presets */    
421 - (void) loadPresets;
422 - (IBAction) customSettingUsed: (id) sender;
423 - (IBAction) showAddPresetPanel: (id) sender;
424 - (IBAction) closeAddPresetPanel: (id) sender;
425 - (NSDictionary *)createPreset;
426
427 - (IBAction) revertPictureSizeToMax:(id)sender;
428
429 - (IBAction)setDefaultPreset:(id)sender;
430 - (IBAction)selectDefaultPreset:(id)sender;
431 - (void) savePreset;
432 - (void)sortPresets;
433 - (IBAction)addFactoryPresets:(id)sender;
434 - (IBAction)deleteFactoryPresets:(id)sender;
435 - (IBAction)addUserPreset:(id)sender;
436 - (void)addPreset;
437 - (IBAction)insertPreset:(id)sender;
438 - (IBAction)deletePreset:(id)sender;
439 - (IBAction)getDefaultPresets:(id)sender;
440
441 -(void)sendToMetaX:(NSString *) filePath;
442 // Growl methods
443 - (NSDictionary *) registrationDictionaryForGrowl;
444 -(void)showGrowlDoneNotification:(NSString *) filePath;
445 - (IBAction)showDebugOutputPanel:(id)sender;
446 - (void)setupToolbar;
447
448 - (void) prepareJobForPreview;
449 - (void) remindUserOfSleepOrShutdown;
450
451 - (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
452
453 - (int) hbInstances;
454
455 // Chapter files methods
456 - (IBAction) browseForChapterFile: (id) sender;
457 - (void)     browseForChapterFileDone: (NSOpenPanel *) sheet
458                  returnCode: (int) returnCode contextInfo: (void *) contextInfo;
459
460 - (IBAction) browseForChapterFileSave: (id) sender;
461 - (void)     browseForChapterFileSaveDone: (NSSavePanel *) sheet
462                  returnCode: (int) returnCode contextInfo: (void *) contextInfo;
463
464 @end
465