1 /* $Id: Controller.h,v 1.35 2005/08/01 14:29:50 titer Exp $
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. */
7 #import <Cocoa/Cocoa.h>
8 #import <Growl/Growl.h>
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"
21 @class HBOutputPanelController;
23 /* We subclass NSView so that our drags show both the icon as well as PresetName columns */
24 @interface HBPresetsOutlineView : NSOutlineView
32 @interface HBController : NSObject <GrowlApplicationBridgeDelegate>
34 NSImage * fApplicationIcon;
35 IBOutlet NSWindow * fWindow;
37 /* Main Menu Outlets */
38 NSMenuItem * fOpenSourceTitleMMenu;
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;
49 /* Picture Settings */
50 PictureController * fPictureController;
53 PreviewController * fPreviewController;
55 /* Advanced options tab */
56 HBAdvancedController * fAdvancedOptions;
57 IBOutlet NSBox * fAdvancedView;
59 HBPreferencesController * fPreferencesController;
62 HBQueueController * fQueueController;
63 IBOutlet NSTextField * fQueueStatus;
66 HBOutputPanelController *outputPanel;
69 IBOutlet NSProgressIndicator * fScanIndicator;
70 NSString * sourceDisplayName;
71 IBOutlet NSTextField * fSrcDVD2Field;
72 IBOutlet NSTextField * fSrcTitleField;
73 IBOutlet NSPopUpButton * fSrcTitlePopUp;
76 /* lib dvd nav specific */
77 IBOutlet NSTextField * fSrcAngleLabel;
78 IBOutlet NSPopUpButton * fSrcAnglePopUp;
80 /* Source start and end points */
81 IBOutlet NSPopUpButton * fEncodeStartStopPopUp;
82 /* pts based start / stop */
83 IBOutlet NSTextField * fSrcTimeStartEncodingField;
84 IBOutlet NSTextField * fSrcTimeEndEncodingField;
85 /* frame based based start / stop */
86 IBOutlet NSTextField * fSrcFrameStartEncodingField;
87 IBOutlet NSTextField * fSrcFrameEndEncodingField;
89 IBOutlet NSTextField * fSrcChapterField;
90 IBOutlet NSPopUpButton * fSrcChapterStartPopUp;
91 IBOutlet NSTextField * fSrcChapterToField;
92 IBOutlet NSPopUpButton * fSrcChapterEndPopUp;
94 /* Source duration information */
95 IBOutlet NSTextField * fSrcDuration1Field;
96 IBOutlet NSTextField * fSrcDuration2Field;
99 IBOutlet NSTextField * fDstFormatField;
100 IBOutlet NSPopUpButton * fDstFormatPopUp;
102 IBOutlet NSTextField * fDstFile1Field;
103 IBOutlet NSTextField * fDstFile2Field;
104 IBOutlet NSButton * fDstBrowseButton;
106 // Creates 64 bit mp4's that allow file sizes over 4gb
107 IBOutlet NSButton * fDstMp4LargeFileCheck;
108 // Optimizes mp4's for http
109 IBOutlet NSButton * fDstMp4HttpOptFileCheck;
110 // Creates iPod compatible mp4's (add ipod uuid atom)
111 IBOutlet NSButton * fDstMp4iPodFileCheck;
114 IBOutlet NSTextField * fVidRateField;
115 IBOutlet NSPopUpButton * fVidRatePopUp;
116 IBOutlet NSTextField * fVidEncoderField;
117 IBOutlet NSPopUpButton * fVidEncoderPopUp;
118 IBOutlet NSTextField * fVidQualityField;
119 IBOutlet NSTextField * fVidQualityRFLabel;
120 IBOutlet NSTextField * fVidQualityRFField;
121 IBOutlet NSMatrix * fVidQualityMatrix;
122 IBOutlet NSButtonCell * fVidTargetCell;
123 IBOutlet NSTextField * fVidTargetSizeField;
124 IBOutlet NSButtonCell * fVidBitrateCell;
125 IBOutlet NSTextField * fVidBitrateField;
126 IBOutlet NSButtonCell * fVidConstantCell;
127 IBOutlet NSSlider * fVidQualitySlider;
128 IBOutlet NSButton * fVidTwoPassCheck;
129 IBOutlet NSButton * fVidTurboPassCheck;
131 /* Status read out fileds for picture sizing */
132 IBOutlet NSTextField * fPictureSizeField;
133 IBOutlet NSTextField * fPictureCroppingField;
135 /* Status read out fileds for video filters */
136 IBOutlet NSTextField * fVideoFiltersField;
138 /* Picture variables */
139 int PicOrigOutputWidth;
140 int PicOrigOutputHeight;
146 IBOutlet NSTextField * fSubField;
147 IBOutlet NSPopUpButton * fSubPopUp;
148 IBOutlet NSButton * fSubForcedCheck;
151 IBOutlet NSTableView * fSubtitlesTable;
152 HBSubtitles * fSubtitlesDelegate;
153 IBOutlet NSButton * fBrowseSrtFileButton;
158 IBOutlet NSTextField * fAudSourceLabel;
159 IBOutlet NSTextField * fAudCodecLabel;
160 IBOutlet NSTextField * fAudMixdownLabel;
161 IBOutlet NSTextField * fAudSamplerateLabel;
162 IBOutlet NSTextField * fAudBitrateLabel;
163 IBOutlet NSTextField * fAudDrcLabel;
165 IBOutlet NSTextField * fAudTrack1Label;
166 IBOutlet NSTextField * fAudTrack2Label;
167 IBOutlet NSTextField * fAudTrack3Label;
168 IBOutlet NSTextField * fAudTrack4Label;
170 /* Source Audio PopUps */
171 IBOutlet NSPopUpButton * fAudLang1PopUp;
172 IBOutlet NSPopUpButton * fAudLang2PopUp;
173 IBOutlet NSPopUpButton * fAudLang3PopUp;
174 IBOutlet NSPopUpButton * fAudLang4PopUp;
177 IBOutlet NSPopUpButton * fAudTrack1CodecPopUp;
178 IBOutlet NSPopUpButton * fAudTrack2CodecPopUp;
179 IBOutlet NSPopUpButton * fAudTrack3CodecPopUp;
180 IBOutlet NSPopUpButton * fAudTrack4CodecPopUp;
183 IBOutlet NSPopUpButton * fAudTrack1MixPopUp;
184 IBOutlet NSPopUpButton * fAudTrack2MixPopUp;
185 IBOutlet NSPopUpButton * fAudTrack3MixPopUp;
186 IBOutlet NSPopUpButton * fAudTrack4MixPopUp;
188 /* Samplerate PopUps */
189 IBOutlet NSPopUpButton * fAudTrack1RatePopUp;
190 IBOutlet NSPopUpButton * fAudTrack2RatePopUp;
191 IBOutlet NSPopUpButton * fAudTrack3RatePopUp;
192 IBOutlet NSPopUpButton * fAudTrack4RatePopUp;
195 IBOutlet NSPopUpButton * fAudTrack1BitratePopUp;
196 IBOutlet NSPopUpButton * fAudTrack2BitratePopUp;
197 IBOutlet NSPopUpButton * fAudTrack3BitratePopUp;
198 IBOutlet NSPopUpButton * fAudTrack4BitratePopUp;
200 /* Dynamic Range Compression */
201 IBOutlet NSSlider * fAudTrack1DrcSlider;
202 IBOutlet NSTextField * fAudTrack1DrcField;
203 IBOutlet NSSlider * fAudTrack2DrcSlider;
204 IBOutlet NSTextField * fAudTrack2DrcField;
205 IBOutlet NSSlider * fAudTrack3DrcSlider;
206 IBOutlet NSTextField * fAudTrack3DrcField;
207 IBOutlet NSSlider * fAudTrack4DrcSlider;
208 IBOutlet NSTextField * fAudTrack4DrcField;
211 IBOutlet NSButton * fCreateChapterMarkers;
212 IBOutlet NSTableView * fChapterTable;
213 ChapterTitles * fChapterTitlesDelegate;
216 IBOutlet NSTextField * fStatusField;
217 IBOutlet NSProgressIndicator * fRipIndicator;
218 BOOL fRipIndicatorShown;
220 /* Queue File variables */
221 NSString * QueueFile;
222 NSMutableArray * QueueFileArray;
223 int currentQueueEncodeIndex; // Used to track the currently encoding queueu item
225 /* User Preset variables here */
226 HBPresets * fPresetsBuiltin;
227 IBOutlet NSDrawer * fPresetDrawer;
228 IBOutlet NSTextField * fPresetNewName;
229 IBOutlet NSTextField * fPresetNewDesc;
230 IBOutlet NSPopUpButton * fPresetNewPicSettingsPopUp;
231 IBOutlet NSButton * fPresetNewPicFiltersCheck;
232 IBOutlet NSButton * fPresetNewFolderCheck;
233 IBOutlet NSTextField * fPresetSelectedDisplay;
235 NSString * AppSupportDirectory;
236 NSString * UserPresetsFile;
237 NSMutableArray * UserPresets;
238 NSMutableArray * UserPresetssortedArray;
239 NSMutableDictionary * chosenPreset;
240 int curUserPresetChosenNum;
242 NSMutableDictionary *presetHbDefault; // this is 1 in "Default" preset key
243 NSMutableDictionary *presetUserDefault;// this is 2 in "Default" preset key
244 NSMutableDictionary *presetUserDefaultParent;
245 NSMutableDictionary *presetUserDefaultParentParent;
246 int presetCurrentBuiltInCount; // keeps track of the current number of built in presets
247 IBOutlet NSPanel * fAddPresetPanel;
249 /* NSOutline View for the presets */
250 NSArray *fDraggedNodes;
251 IBOutlet HBPresetsOutlineView * fPresetsOutlineView;
252 IBOutlet NSButton * fPresetsAdd;
253 IBOutlet NSButton * fPresetsDelete;
254 IBOutlet NSPopUpButton * fPresetsActionButton;
256 hb_handle_t * fHandle;
258 /* Queue variables */
259 hb_handle_t * fQueueEncodeLibhb; // libhb for HB Encoding
261 hb_title_t * fQueueEncodeTitle;
262 int fEncodingQueueItem; // corresponds to the index of fJobGroups encoding item
263 int fPendingCount; // Number of various kinds of job groups in fJobGroups.
268 int fqueueEditRescanItemNum; // queue array item to be reloaded into the main window
271 /* integer to set to determine the previous state
272 of encode 0==idle, 1==encoding, 2==cancelled*/
274 int currentScanCount;
275 int currentSuccessfulScanCount;
277 BOOL applyQueueToScan;
278 NSString * currentSource;
279 NSString * browsedSourceDisplayName;
281 double dockIconProgress;
284 - (IBAction) showAboutPanel:(id)sender;
286 - (void) writeToActivityLog:(const char *) format, ...;
287 - (IBAction) browseSources: (id) sender;
288 - (void) browseSourcesDone: (NSOpenPanel *) sheet
289 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
290 - (IBAction) showSourceTitleScanPanel: (id) sender;
291 - (IBAction) closeSourceTitleScanPanel: (id) sender;
292 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
293 - (IBAction) showNewScan: (id) sender;
296 - (IBAction) cancelScanning:(id)sender;
298 - (void) updateUI: (NSTimer *) timer;
299 - (void) enableUI: (bool) enable;
300 - (IBAction) encodeStartStopPopUpChanged: (id) sender;
301 - (IBAction) titlePopUpChanged: (id) sender;
302 - (IBAction) chapterPopUpChanged: (id) sender;
303 - (IBAction) startEndSecValueChanged: (id) sender;
304 - (IBAction) startEndFrameValueChanged: (id) sender;
307 - (IBAction) formatPopUpChanged: (id) sender;
308 - (IBAction) videoEncoderPopUpChanged: (id) sender;
309 - (IBAction) autoSetM4vExtension: (id) sender;
310 - (IBAction) twoPassCheckboxChanged: (id) sender;
311 - (IBAction) videoFrameRateChanged: (id) sender;
312 - (IBAction) audioAddAudioTrackCodecs: (id)sender;
313 - (IBAction) audioCodecsPopUpChanged: (id) sender;
314 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender;
315 - (IBAction) addAllAudioTracksToPopUp: (id) sender;
316 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound;
317 - (IBAction) audioTrackPopUpChanged: (id) sender;
318 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
319 - (IBAction) audioTrackMixdownChanged: (id) sender;
321 - (IBAction) browseFile: (id) sender;
322 - (void) browseFileDone: (NSSavePanel *) sheet
323 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
325 - (IBAction) videoMatrixChanged: (id) sender;
327 - (IBAction) qualitySliderChanged: (id) sender;
328 - (void) setupQualitySlider;
330 - (IBAction) audioDRCSliderChanged: (id) sender;
331 - (IBAction) browseImportSrtFile: (id) sender;
332 - (void) browseImportSrtFileDone: (NSSavePanel *) sheet
333 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
335 - (IBAction) showPicturePanel: (id) sender;
336 - (void) picturePanelFullScreen;
337 - (void) picturePanelWindowed;
338 - (IBAction) showPreviewWindow: (id) sender;
339 - (void)pictureSettingsDidChange;
340 - (IBAction) calculatePictureSizing: (id) sender;
341 - (IBAction) openMainWindow: (id) sender;
343 /* Queue File Stuff */
344 - (void) loadQueueFile;
345 - (NSDictionary *)createQueueFileItem;
346 - (void)saveQueueFileItem;
347 - (void) incrementQueueItemDone:(int) queueItemDoneIndexNum;
348 - (void) performNewQueueScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
349 - (void) processNewQueueEncode;
350 - (void) clearQueueEncodedItems;
352 - (IBAction)applyQueueSettingsToMainWindow:(id)sender;
353 - (IBAction)rescanQueueItemToMainWindow:(NSString *) scanPath scanTitleNum: (int) scanTitleNum selectedQueueItem: (int) selectedQueueItem;
356 - (void) removeQueueFileItem:(int) queueItemToRemove;
357 - (void) clearQueueAllItems;
358 - (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
359 - (void)getQueueStats;
360 - (void)setQueueEncodingItemsAsPending;
361 - (IBAction) addToQueue: (id) sender;
362 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
363 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
364 - (void) doAddToQueue;
366 - (IBAction) showQueueWindow:(id)sender;
368 - (IBAction)showPreferencesWindow:(id)sender;
370 - (IBAction) Rip: (id) sender;
371 - (void) overWriteAlertDone: (NSWindow *) sheet
372 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
375 - (IBAction) Cancel: (id) sender;
376 - (void) doCancelCurrentJob;
377 - (void) doCancelCurrentJobAndStop;
378 - (IBAction) Pause: (id) sender;
380 - (IBAction) calculateBitrate: (id) sender;
381 - (void) controlTextDidChange: (NSNotification *) notification;
383 - (IBAction) openHomepage: (id) sender;
384 - (IBAction) openForums: (id) sender;
385 - (IBAction) openUserGuide: (id) sender;
387 // Preset Methods Here
389 /* These are required by the NSOutlineView Datasource Delegate */
390 /* We use this to deterimine children of an item */
391 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
392 /* We use this to determine if an item should be expandable */
393 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
394 /* used to specify the number of levels to show for each item */
395 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
396 /* Used to tell the outline view which information is to be displayed per item */
397 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
398 /* Use to customize the font and display characteristics of the title cell */
399 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
400 /* We use this to edit the name field in the outline view */
401 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
402 /* We use this to provide tooltips for the items in the presets outline view */
403 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
404 - (void) checkBuiltInsForUpdates;
405 /* We use this to actually select the preset and act accordingly */
406 - (IBAction)selectPreset:(id)sender;
408 /* Export / Import Presets */
409 - (IBAction) browseExportPresetFile: (id) sender;
410 - (void) browseExportPresetFileDone: (NSSavePanel *) sheet
411 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
413 - (IBAction) browseImportPresetFile: (id) sender;
414 - (void) browseImportPresetDone: (NSSavePanel *) sheet
415 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
417 /* Manage User presets */
418 - (void) loadPresets;
419 - (IBAction) customSettingUsed: (id) sender;
420 - (IBAction) showAddPresetPanel: (id) sender;
421 - (IBAction) closeAddPresetPanel: (id) sender;
422 - (NSDictionary *)createPreset;
424 - (IBAction) revertPictureSizeToMax:(id)sender;
426 - (IBAction)setDefaultPreset:(id)sender;
427 - (IBAction)selectDefaultPreset:(id)sender;
430 - (IBAction)addFactoryPresets:(id)sender;
431 - (IBAction)deleteFactoryPresets:(id)sender;
432 - (IBAction)addUserPreset:(id)sender;
434 - (IBAction)insertPreset:(id)sender;
435 - (IBAction)deletePreset:(id)sender;
436 - (IBAction)getDefaultPresets:(id)sender;
438 -(void)sendToMetaX:(NSString *) filePath;
440 - (NSDictionary *) registrationDictionaryForGrowl;
441 -(void)showGrowlDoneNotification:(NSString *) filePath;
442 - (IBAction)showDebugOutputPanel:(id)sender;
443 - (void)setupToolbar;
445 - (void) prepareJobForPreview;
446 - (void) remindUserOfSleepOrShutdown;
448 - (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;