OSDN Git Service

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