OSDN Git Service

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