OSDN Git Service

d4524169f45eeeb90948196a45bfbed22a968d8f
[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         ChapterTitles                * fChapterTitlesDelegate;
214         
215     /* Bottom */
216     IBOutlet NSTextField         * fStatusField;
217     IBOutlet NSProgressIndicator * fRipIndicator;
218         BOOL                           fRipIndicatorShown;
219     
220     /* Queue File variables */
221     NSString                     * QueueFile;
222         NSMutableArray               * QueueFileArray;
223     int                            currentQueueEncodeIndex; // Used to track the currently encoding queueu item
224     
225         /* User Preset variables here */
226         HBPresets                    * fPresetsBuiltin;
227         IBOutlet NSDrawer            * fPresetDrawer;
228         IBOutlet NSTextField         * fPresetNewName;
229         IBOutlet NSTextField         * fPresetNewDesc;
230         IBOutlet NSPopUpButton       * fPresetNewPicSettingsPopUp;
231     IBOutlet NSButton            * fPresetNewPicFiltersCheck;
232     IBOutlet NSButton            * fPresetNewFolderCheck;
233         IBOutlet NSTextField         * fPresetSelectedDisplay;
234         
235         NSString                     * AppSupportDirectory;
236         NSString                     * UserPresetsFile;
237         NSMutableArray               * UserPresets;
238         NSMutableArray               * UserPresetssortedArray;
239         NSMutableDictionary          * chosenPreset;
240     int                            curUserPresetChosenNum;
241          
242         NSMutableDictionary          *presetHbDefault; // this is 1 in "Default" preset key
243         NSMutableDictionary          *presetUserDefault;// this is 2 in "Default" preset key
244     NSMutableDictionary          *presetUserDefaultParent;
245     NSMutableDictionary          *presetUserDefaultParentParent;
246     int                           presetCurrentBuiltInCount; // keeps track of the current number of built in presets
247     IBOutlet NSPanel             * fAddPresetPanel;
248         
249     /* NSOutline View for the presets */
250     NSArray                      *fDraggedNodes;
251     IBOutlet HBPresetsOutlineView * fPresetsOutlineView;
252     IBOutlet NSButton            * fPresetsAdd;
253         IBOutlet NSButton            * fPresetsDelete;
254     IBOutlet NSPopUpButton       * fPresetsActionButton;
255
256     hb_handle_t                  * fHandle;
257     
258     /* Queue variables */
259     hb_handle_t              * fQueueEncodeLibhb;           // libhb for HB Encoding
260         hb_title_t                   * fTitle;
261     hb_title_t                   * fQueueEncodeTitle;
262     int                          fEncodingQueueItem;     // corresponds to the index of fJobGroups encoding item
263     int                          fPendingCount;         // Number of various kinds of job groups in fJobGroups.
264     int                          fCompletedCount;
265     int                          fCanceledCount;
266     int                          fWorkingCount;
267     
268     int                          fqueueEditRescanItemNum; // queue array item to be reloaded into the main window
269     
270     
271     /* integer to set to determine the previous state
272                 of encode 0==idle, 1==encoding, 2==cancelled*/
273     int                            fEncodeState;
274         int                            currentScanCount;
275         int                            currentSuccessfulScanCount;
276     BOOL                           SuccessfulScan;
277     BOOL                           applyQueueToScan;
278         NSString                      * currentSource;
279     NSString                     * browsedSourceDisplayName;
280     
281     double                         dockIconProgress;
282 }
283
284 - (IBAction) showAboutPanel:(id)sender;
285
286 - (void) writeToActivityLog:(const char *) format, ...;
287 - (IBAction) browseSources: (id) sender;
288 - (void) browseSourcesDone: (NSOpenPanel *) sheet
289                 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
290 - (IBAction) showSourceTitleScanPanel: (id) sender;
291 - (IBAction) closeSourceTitleScanPanel: (id) sender;  
292 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
293 - (IBAction) showNewScan: (id) sender;
294
295
296 - (IBAction) cancelScanning:(id)sender;
297
298 - (void)     updateUI: (NSTimer *) timer;
299 - (void)     enableUI: (bool) enable;
300 - (IBAction) encodeStartStopPopUpChanged: (id) sender;
301 - (IBAction) titlePopUpChanged: (id) sender;
302 - (IBAction) chapterPopUpChanged: (id) sender;
303 - (IBAction) startEndSecValueChanged: (id) sender;
304 - (IBAction) startEndFrameValueChanged: (id) sender;
305
306
307 - (IBAction) formatPopUpChanged: (id) sender;
308 - (IBAction) videoEncoderPopUpChanged: (id) sender;
309 - (IBAction) autoSetM4vExtension: (id) sender;
310 - (IBAction) twoPassCheckboxChanged: (id) sender;
311 - (IBAction) videoFrameRateChanged: (id) sender;
312 - (IBAction) audioAddAudioTrackCodecs: (id)sender;
313 - (IBAction) audioCodecsPopUpChanged: (id) sender;
314 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender;
315 - (IBAction) addAllAudioTracksToPopUp: (id) sender;
316 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound;
317 - (IBAction) audioTrackPopUpChanged: (id) sender;
318 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
319 - (IBAction) audioTrackMixdownChanged: (id) sender;
320 - (void) prepareJob;
321 - (IBAction) browseFile: (id) sender;
322 - (void)     browseFileDone: (NSSavePanel *) sheet
323                  returnCode: (int) returnCode contextInfo: (void *) contextInfo;
324
325 - (IBAction) videoMatrixChanged: (id) sender;
326
327 - (IBAction) qualitySliderChanged: (id) sender;
328 - (void) setupQualitySlider;
329
330 - (IBAction) audioDRCSliderChanged: (id) sender;
331 - (IBAction) browseImportSrtFile: (id) sender;
332 - (void) browseImportSrtFileDone: (NSSavePanel *) sheet
333                      returnCode: (int) returnCode contextInfo: (void *) contextInfo;
334
335 - (IBAction) showPicturePanel: (id) sender;
336 - (void) picturePanelFullScreen;
337 - (void) picturePanelWindowed;
338 - (IBAction) showPreviewWindow: (id) sender;
339 - (void)pictureSettingsDidChange;
340 - (IBAction) calculatePictureSizing: (id) sender;
341 - (IBAction) openMainWindow: (id) sender;
342
343 /* Queue File Stuff */
344 - (void) loadQueueFile;
345 - (NSDictionary *)createQueueFileItem;
346 - (void)saveQueueFileItem;
347 - (void) incrementQueueItemDone:(int) queueItemDoneIndexNum;
348 - (void) performNewQueueScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
349 - (void) processNewQueueEncode;
350 - (void) clearQueueEncodedItems;
351 /* Queue Editing */
352 - (IBAction)applyQueueSettingsToMainWindow:(id)sender;
353 - (IBAction)rescanQueueItemToMainWindow:(NSString *) scanPath scanTitleNum: (int) scanTitleNum selectedQueueItem: (int) selectedQueueItem;
354
355
356 - (void) removeQueueFileItem:(int) queueItemToRemove;
357 - (void) clearQueueAllItems;
358 - (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
359 - (void)getQueueStats;
360 - (void)setQueueEncodingItemsAsPending;
361 - (IBAction) addToQueue: (id) sender;
362 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
363                            returnCode: (int) returnCode contextInfo: (void *) contextInfo;
364 - (void)     doAddToQueue;
365
366 - (IBAction) showQueueWindow:(id)sender;
367
368 - (IBAction)showPreferencesWindow:(id)sender;
369
370 - (IBAction) Rip: (id) sender;
371 - (void)     overWriteAlertDone: (NSWindow *) sheet
372                      returnCode: (int) returnCode contextInfo: (void *) contextInfo;
373 - (void)     doRip;
374
375 - (IBAction) Cancel: (id) sender;
376 - (void)     doCancelCurrentJob;
377 - (void) doCancelCurrentJobAndStop;
378 - (IBAction) Pause: (id) sender;
379
380 - (IBAction) calculateBitrate: (id) sender;
381 - (void) controlTextDidChange: (NSNotification *) notification;
382
383 - (IBAction) openHomepage: (id) sender;
384 - (IBAction) openForums:   (id) sender;
385 - (IBAction) openUserGuide:   (id) sender;
386
387 // Preset Methods Here
388     
389 /* These are required by the NSOutlineView Datasource Delegate */
390 /* We use this to deterimine children of an item */
391 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
392 /* We use this to determine if an item should be expandable */
393 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
394 /* used to specify the number of levels to show for each item */
395 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
396 /* Used to tell the outline view which information is to be displayed per item */
397 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
398 /* Use to customize the font and display characteristics of the title cell */
399 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
400 /* We use this to edit the name field in the outline view */
401 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
402 /* We use this to provide tooltips for the items in the presets outline view */
403 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
404 - (void) checkBuiltInsForUpdates;
405 /* We use this to actually select the preset and act accordingly */
406 - (IBAction)selectPreset:(id)sender;    
407
408 /* Export / Import Presets */
409 - (IBAction) browseExportPresetFile: (id) sender;
410 - (void) browseExportPresetFileDone: (NSSavePanel *) sheet
411              returnCode: (int) returnCode contextInfo: (void *) contextInfo;
412              
413 - (IBAction) browseImportPresetFile: (id) sender;
414 - (void) browseImportPresetDone: (NSSavePanel *) sheet
415                    returnCode: (int) returnCode contextInfo: (void *) contextInfo;
416
417 /* Manage User presets */    
418 - (void) loadPresets;
419 - (IBAction) customSettingUsed: (id) sender;
420 - (IBAction) showAddPresetPanel: (id) sender;
421 - (IBAction) closeAddPresetPanel: (id) sender;
422 - (NSDictionary *)createPreset;
423
424 - (IBAction) revertPictureSizeToMax:(id)sender;
425
426 - (IBAction)setDefaultPreset:(id)sender;
427 - (IBAction)selectDefaultPreset:(id)sender;
428 - (void) savePreset;
429 - (void)sortPresets;
430 - (IBAction)addFactoryPresets:(id)sender;
431 - (IBAction)deleteFactoryPresets:(id)sender;
432 - (IBAction)addUserPreset:(id)sender;
433 - (void)addPreset;
434 - (IBAction)insertPreset:(id)sender;
435 - (IBAction)deletePreset:(id)sender;
436 - (IBAction)getDefaultPresets:(id)sender;
437
438 -(void)sendToMetaX:(NSString *) filePath;
439     // Growl methods
440 - (NSDictionary *) registrationDictionaryForGrowl;
441 -(void)showGrowlDoneNotification:(NSString *) filePath;
442 - (IBAction)showDebugOutputPanel:(id)sender;
443 - (void)setupToolbar;
444
445 - (void) prepareJobForPreview;
446 - (void) remindUserOfSleepOrShutdown;
447
448 - (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
449
450 - (int) hbInstances;
451
452
453
454
455 @end
456