OSDN Git Service

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