OSDN Git Service

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