OSDN Git Service

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