OSDN Git Service

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