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.m0k.org/>.
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 "PictureController.h"
14 #import "HBQueueController.h"
15 #import "MVMenuButton.h"
16 #import "HBAdvancedController.h"
17 #import "HBPreferencesController.h"
19 @class HBOutputPanelController;
21 @interface HBController : NSObject <GrowlApplicationBridgeDelegate>
24 IBOutlet NSWindow * fWindow;
27 /* Main Menu Outlets */
28 NSMenuItem * fOpenSourceTitleMMenu;
30 /* Source Title Scan Outlets */
31 IBOutlet NSPanel * fScanSrcTitlePanel;
32 IBOutlet NSTextField * fScanSrcTitlePathField;
33 IBOutlet NSTextField * fSrcDsplyNameTitleScan;
34 IBOutlet NSTextField * fScanSrcTitleNumField;
35 IBOutlet NSButton * fScanSrcTitleCancelButton;
36 IBOutlet NSButton * fScanSrcTitleOpenButton;
39 PictureController * fPictureController;
41 /* Advanced options tab */
42 HBAdvancedController * fAdvancedOptions;
43 IBOutlet NSBox * fAdvancedView;
45 HBPreferencesController * fPreferencesController;
48 HBQueueController * fQueueController;
49 IBOutlet NSTextField * fQueueStatus;
52 HBOutputPanelController *outputPanel;
55 IBOutlet NSProgressIndicator * fScanIndicator;
56 NSString * sourceDisplayName;
57 IBOutlet NSTextField * fSrcDVD2Field;
58 IBOutlet NSTextField * fSrcTitleField;
59 IBOutlet NSPopUpButton * fSrcTitlePopUp;
60 IBOutlet NSTextField * fSrcChapterField;
61 IBOutlet NSPopUpButton * fSrcChapterStartPopUp;
62 IBOutlet NSTextField * fSrcChapterToField;
63 IBOutlet NSPopUpButton * fSrcChapterEndPopUp;
64 IBOutlet NSTextField * fSrcDuration1Field;
65 IBOutlet NSTextField * fSrcDuration2Field;
68 IBOutlet NSTextField * fDstFormatField;
69 IBOutlet NSPopUpButton * fDstFormatPopUp;
70 IBOutlet NSTextField * fDstCodecsField;
71 IBOutlet NSPopUpButton * fDstCodecsPopUp;
72 IBOutlet NSTextField * fDstFile1Field;
73 IBOutlet NSTextField * fDstFile2Field;
74 IBOutlet NSButton * fDstBrowseButton;
76 // Creates 64 bit mp4's that allow file sizes over 4gb
77 IBOutlet NSButton * fDstMp4LargeFileCheck;
78 // Optimizes mp4's for http
79 IBOutlet NSButton * fDstMp4HttpOptFileCheck;
82 IBOutlet NSTextField * fVidRateField;
83 IBOutlet NSPopUpButton * fVidRatePopUp;
84 IBOutlet NSTextField * fVidEncoderField;
85 IBOutlet NSPopUpButton * fVidEncoderPopUp;
86 IBOutlet NSTextField * fVidQualityField;
87 IBOutlet NSMatrix * fVidQualityMatrix;
88 IBOutlet NSButtonCell * fVidTargetCell;
89 IBOutlet NSTextField * fVidTargetSizeField;
90 IBOutlet NSButtonCell * fVidBitrateCell;
91 IBOutlet NSTextField * fVidBitrateField;
92 IBOutlet NSButtonCell * fVidConstantCell;
93 IBOutlet NSSlider * fVidQualitySlider;
94 IBOutlet NSButton * fVidGrayscaleCheck;
95 IBOutlet NSButton * fVidTwoPassCheck;
96 IBOutlet NSButton * fVidTurboPassCheck;
98 /* Picture Settings box */
99 IBOutlet NSTextField * fPicLabelSettings;
100 IBOutlet NSTextField * fPicLabelSrc;
101 IBOutlet NSTextField * fPicLabelOutp;
102 IBOutlet NSTextField * fPicLabelAr;
103 IBOutlet NSTextField * fPicLabelSrcX;
104 IBOutlet NSTextField * fPicLabelOutputX;
105 IBOutlet NSTextField * fPicLabelAutoCrop;
106 IBOutlet NSTextField * fPicLabelDetelecine;
107 IBOutlet NSTextField * fPicLabelDeinterlace;
108 IBOutlet NSTextField * fPicLabelDenoise;
109 IBOutlet NSTextField * fPicLabelDeblock;
111 IBOutlet NSTextField * fPicSrcWidth;
112 IBOutlet NSTextField * fPicSrcHeight;
113 IBOutlet NSTextField * fPicSettingWidth;
114 IBOutlet NSTextField * fPicSettingHeight;
115 IBOutlet NSTextField * fPicSettingDeinterlace;
116 IBOutlet NSTextField * fPicSettingARkeep;
117 IBOutlet NSTextField * fPicSettingPAR;
118 IBOutlet NSTextField * fPicSettingAutoCrop;
119 IBOutlet NSTextField * fPicSettingDetelecine;
120 IBOutlet NSTextField * fPicSettingDenoise;
121 IBOutlet NSTextField * fPicSettingDeblock;
123 IBOutlet NSTextField * fPicLabelAnamorphic;
124 IBOutlet NSTextField * fPicLabelPAROutputX;
125 IBOutlet NSTextField * fPicSettingPARWidth;
126 IBOutlet NSTextField * fPicSettingPARHeight;
127 /* Picture variables */
128 int PicOrigOutputWidth;
129 int PicOrigOutputHeight;
135 IBOutlet NSTextField * fSubField;
136 IBOutlet NSPopUpButton * fSubPopUp;
137 IBOutlet NSButton * fSubForcedCheck;
140 IBOutlet NSTextField * fAudLang1Field;
141 IBOutlet NSPopUpButton * fAudLang1PopUp;
142 IBOutlet NSTextField * fAudLang2Field;
143 IBOutlet NSPopUpButton * fAudLang2PopUp;
144 /* New Audio Mix PopUps */
146 IBOutlet NSTextField * fAudTrack1MixLabel;
147 IBOutlet NSPopUpButton * fAudTrack1MixPopUp;
148 IBOutlet NSTextField * fAudTrack2MixLabel;
149 IBOutlet NSPopUpButton * fAudTrack2MixPopUp;
152 IBOutlet NSTextField * fAudRateField;
153 IBOutlet NSPopUpButton * fAudRatePopUp;
154 IBOutlet NSTextField * fAudBitrateField;
155 IBOutlet NSPopUpButton * fAudBitratePopUp;
156 /*Dynamic Range Compression */
157 IBOutlet NSSlider * fAudDrcSlider;
158 IBOutlet NSTextField * fAudDrcField;
159 IBOutlet NSTextField * fAudDrcLabel;
162 IBOutlet NSButton * fCreateChapterMarkers;
163 IBOutlet NSTableView * fChapterTable;
164 ChapterTitles * fChapterTitlesDelegate;
167 IBOutlet NSButton * fPictureButton;
168 IBOutlet NSTextField * fStatusField;
169 IBOutlet NSProgressIndicator * fRipIndicator;
170 BOOL fRipIndicatorShown;
172 /* User Preset variables here */
173 HBPresets * fPresetsBuiltin;
174 IBOutlet NSDrawer * fPresetDrawer;
175 IBOutlet NSTextField * fPresetNewName;
176 IBOutlet NSTextField * fPresetNewDesc;
177 IBOutlet NSPopUpButton * fPresetNewPicSettingsPopUp;
178 IBOutlet NSButton * fPresetNewPicFiltersCheck;
179 IBOutlet NSTextField * fPresetSelectedDisplay;
181 NSString * AppSupportDirectory;
182 NSString * UserPresetsFile;
183 NSMutableArray * UserPresets;
184 NSMutableArray * UserPresetssortedArray;
185 NSMutableDictionary * chosenPreset;
186 int curUserPresetChosenNum;
188 int presetHbDefault; // this is 1 in "Default" preset key
189 int presetUserDefault;// this is 2 in "Default" preset key
190 IBOutlet NSPanel * fAddPresetPanel;
191 /* new NSOutline View for the presets */
192 NSArray *fDraggedNodes;
193 IBOutlet NSOutlineView * fPresetsOutlineView;
194 IBOutlet NSButton * fPresetsAdd;
195 IBOutlet NSButton * fPresetsDelete;
196 IBOutlet MVMenuButton * fPresetsActionButton;
197 IBOutlet NSMenu * fPresetsActionMenu;
199 hb_handle_t * fHandle;
201 /* integer to set to determine the previous state
202 of encode 0==idle, 1==encoding, 2==cancelled*/
204 int currentScanCount;
205 int currentSuccessfulScanCount;
207 NSString * currentSource;
210 - (IBAction) browseSources: (id) sender;
211 - (void) browseSourcesDone: (NSOpenPanel *) sheet
212 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
213 - (IBAction) showSourceTitleScanPanel: (id) sender;
214 - (IBAction) closeSourceTitleScanPanel: (id) sender;
215 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
216 - (IBAction) showNewScan: (id) sender;
218 - (void) TranslateStrings;
220 - (void) updateUI: (NSTimer *) timer;
221 - (void) enableUI: (bool) enable;
223 - (IBAction) titlePopUpChanged: (id) sender;
224 - (IBAction) chapterPopUpChanged: (id) sender;
226 - (IBAction) formatPopUpChanged: (id) sender;
227 - (IBAction) codecsPopUpChanged: (id) sender;
228 - (IBAction) encoderPopUpChanged: (id) sender;
229 - (IBAction) twoPassCheckboxChanged: (id) sender;
230 - (IBAction) videoFrameRateChanged: (id) sender;
231 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender;
232 - (IBAction) addAllAudioTracksToPopUp: (id) sender;
233 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound;
234 - (IBAction) audioTrackPopUpChanged: (id) sender;
235 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
236 - (IBAction) audioTrackMixdownChanged: (id) sender;
237 - (IBAction) subtitleSelectionChanged: (id) sender;
239 - (IBAction) browseFile: (id) sender;
240 - (void) browseFileDone: (NSSavePanel *) sheet
241 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
243 - (IBAction) videoMatrixChanged: (id) sender;
244 - (IBAction) qualitySliderChanged: (id) sender;
245 - (IBAction) audioDRCSliderChanged: (id) sender;
247 - (IBAction) showPicturePanel: (id) sender;
248 - (IBAction) calculatePictureSizing: (id) sender;
249 - (IBAction) openMainWindow: (id) sender;
251 - (IBAction) addToQueue: (id) sender;
252 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
253 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
254 - (void) doAddToQueue;
256 - (IBAction) showQueueWindow:(id)sender;
258 - (IBAction)showPreferencesWindow:(id)sender;
260 - (IBAction) Rip: (id) sender;
261 - (void) overWriteAlertDone: (NSWindow *) sheet
262 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
263 - (void) updateAlertDone: (NSWindow *) sheet
264 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
267 - (IBAction) Cancel: (id) sender;
268 - (void) doCancelCurrentJob;
270 - (IBAction) Pause: (id) sender;
272 - (IBAction) calculateBitrate: (id) sender;
273 - (void) controlTextDidChange: (NSNotification *) notification;
275 - (IBAction) openHomepage: (id) sender;
276 - (IBAction) openForums: (id) sender;
277 - (IBAction) openUserGuide: (id) sender;
279 // Preset Methods Here
281 /* These are required by the NSOutlineView Datasource Delegate */
282 /* We use this to deterimine children of an item */
283 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
284 /* We use this to determine if an item should be expandable */
285 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
286 /* used to specify the number of levels to show for each item */
287 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
288 /* Used to tell the outline view which information is to be displayed per item */
289 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
290 /* Use to customize the font and display characteristics of the title cell */
291 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
292 /* We use this to edit the name field in the outline view */
293 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
294 /* We use this to provide tooltips for the items in the presets outline view */
295 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
297 /* We use this to actually select the preset and act accordingly */
298 - (IBAction)selectPreset:(id)sender;
300 /* Manage User presets */
301 - (void) loadPresets;
302 - (IBAction) customSettingUsed: (id) sender;
303 - (IBAction) showAddPresetPanel: (id) sender;
304 - (IBAction) closeAddPresetPanel: (id) sender;
305 - (NSDictionary *)createPreset;
307 - (IBAction) revertPictureSizeToMax:(id)sender;
309 - (IBAction)setDefaultPreset:(id)sender;
310 - (IBAction)selectDefaultPreset:(id)sender;
312 - (IBAction)addFactoryPresets:(id)sender;
313 - (IBAction)deleteFactoryPresets:(id)sender;
314 - (IBAction)addUserPreset:(id)sender;
316 - (IBAction)insertPreset:(id)sender;
317 - (IBAction)deletePreset:(id)sender;
318 - (IBAction)getDefaultPresets:(id)sender;
322 - (NSDictionary *) registrationDictionaryForGrowl;
323 -(IBAction)showGrowlDoneNotification:(id)sender;
324 - (IBAction)showDebugOutputPanel:(id)sender;
325 - (void)setupToolbar;
327 - (void) remindUserOfSleepOrShutdown;