OSDN Git Service

MacGui: Adds a popup menu item for Hadamard-transformed exhaustive motion estimation...
[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         /* Status read out fileds for picture sizing */
113     IBOutlet NSTextField         * fPictureSizeField;
114     IBOutlet NSTextField         * fPictureCroppingField;
115         
116     /* Status read out fileds for video filters */
117     IBOutlet NSTextField         * fVideoFiltersField;
118         
119         /* Picture variables */
120         int                        PicOrigOutputWidth;
121         int                        PicOrigOutputHeight;
122         int                        AutoCropTop;
123         int                        AutoCropBottom;
124         int                        AutoCropLeft;
125         int                        AutoCropRight;
126     /* Subtitles box */
127     IBOutlet NSTextField         * fSubField;
128     IBOutlet NSPopUpButton       * fSubPopUp;
129         IBOutlet NSButton            * fSubForcedCheck;
130         
131     /* Audio box */
132     /* Track Labels */
133     IBOutlet NSTextField         * fAudSourceLabel;
134     IBOutlet NSTextField         * fAudCodecLabel;
135     IBOutlet NSTextField         * fAudMixdownLabel;
136     IBOutlet NSTextField         * fAudSamplerateLabel;
137     IBOutlet NSTextField         * fAudBitrateLabel;
138     IBOutlet NSTextField         * fAudDrcLabel;
139     
140     IBOutlet NSTextField         * fAudTrack1Label;
141     IBOutlet NSTextField         * fAudTrack2Label;
142     IBOutlet NSTextField         * fAudTrack3Label;
143     IBOutlet NSTextField         * fAudTrack4Label;
144     
145     /* Source Audio PopUps */
146     IBOutlet NSPopUpButton       * fAudLang1PopUp;
147     IBOutlet NSPopUpButton       * fAudLang2PopUp;
148     IBOutlet NSPopUpButton       * fAudLang3PopUp;
149     IBOutlet NSPopUpButton       * fAudLang4PopUp;
150     
151     /* Codec Popups */
152     IBOutlet NSPopUpButton       * fAudTrack1CodecPopUp;
153     IBOutlet NSPopUpButton       * fAudTrack2CodecPopUp;
154     IBOutlet NSPopUpButton       * fAudTrack3CodecPopUp;
155     IBOutlet NSPopUpButton       * fAudTrack4CodecPopUp;
156     
157         /* Mixdown PopUps */
158         IBOutlet NSPopUpButton       * fAudTrack1MixPopUp;
159     IBOutlet NSPopUpButton       * fAudTrack2MixPopUp;
160     IBOutlet NSPopUpButton       * fAudTrack3MixPopUp;
161     IBOutlet NSPopUpButton       * fAudTrack4MixPopUp;
162         
163     /* Samplerate PopUps */
164         IBOutlet NSPopUpButton       * fAudTrack1RatePopUp;
165     IBOutlet NSPopUpButton       * fAudTrack2RatePopUp;
166     IBOutlet NSPopUpButton       * fAudTrack3RatePopUp;
167     IBOutlet NSPopUpButton       * fAudTrack4RatePopUp;
168     
169     /* Bitrate PopUps */
170     IBOutlet NSPopUpButton       * fAudTrack1BitratePopUp;
171     IBOutlet NSPopUpButton       * fAudTrack2BitratePopUp;
172     IBOutlet NSPopUpButton       * fAudTrack3BitratePopUp;
173     IBOutlet NSPopUpButton       * fAudTrack4BitratePopUp;
174     
175     /* Dynamic Range Compression */
176     IBOutlet NSSlider            * fAudTrack1DrcSlider;
177     IBOutlet NSTextField         * fAudTrack1DrcField;
178     IBOutlet NSSlider            * fAudTrack2DrcSlider;
179     IBOutlet NSTextField         * fAudTrack2DrcField;
180     IBOutlet NSSlider            * fAudTrack3DrcSlider;
181     IBOutlet NSTextField         * fAudTrack3DrcField;
182     IBOutlet NSSlider            * fAudTrack4DrcSlider;
183     IBOutlet NSTextField         * fAudTrack4DrcField;
184     
185     /* Chapters box */
186     IBOutlet NSButton            * fCreateChapterMarkers;
187     IBOutlet NSTableView         * fChapterTable;
188         ChapterTitles                * fChapterTitlesDelegate;
189         
190     /* Bottom */
191     IBOutlet NSTextField         * fStatusField;
192     IBOutlet NSProgressIndicator * fRipIndicator;
193         BOOL                           fRipIndicatorShown;
194     
195     /* Queue File variables */
196     NSString                     * QueueFile;
197         NSMutableArray               * QueueFileArray;
198     int                            currentQueueEncodeIndex; // Used to track the currently encoding queueu item
199     
200         /* User Preset variables here */
201         HBPresets                    * fPresetsBuiltin;
202         IBOutlet NSDrawer            * fPresetDrawer;
203         IBOutlet NSTextField         * fPresetNewName;
204         IBOutlet NSTextField         * fPresetNewDesc;
205         IBOutlet NSPopUpButton       * fPresetNewPicSettingsPopUp;
206     IBOutlet NSButton            * fPresetNewPicFiltersCheck;
207     IBOutlet NSButton            * fPresetNewFolderCheck;
208         IBOutlet NSTextField         * fPresetSelectedDisplay;
209         
210         NSString                     * AppSupportDirectory;
211         NSString                     * UserPresetsFile;
212         NSMutableArray               * UserPresets;
213         NSMutableArray               * UserPresetssortedArray;
214         NSMutableDictionary          * chosenPreset;
215     int                            curUserPresetChosenNum;
216          
217         NSMutableDictionary          *presetHbDefault; // this is 1 in "Default" preset key
218         NSMutableDictionary          *presetUserDefault;// this is 2 in "Default" preset key
219     NSMutableDictionary          *presetUserDefaultParent;
220     NSMutableDictionary          *presetUserDefaultParentParent;
221     int                        presetCurrentBuiltInCount; // keeps track of the current number of built in presets
222     IBOutlet NSPanel             * fAddPresetPanel;
223         
224     /* NSOutline View for the presets */
225     NSArray                      *fDraggedNodes;
226     IBOutlet HBPresetsOutlineView * fPresetsOutlineView;
227     IBOutlet NSButton            * fPresetsAdd;
228         IBOutlet NSButton            * fPresetsDelete;
229     IBOutlet NSPopUpButton       * fPresetsActionButton;
230
231     hb_handle_t                  * fHandle;
232     
233     /* Queue variables */
234     hb_handle_t              * fQueueEncodeLibhb;           // libhb for HB Encoding
235         hb_title_t                   * fTitle;
236     hb_title_t                   * fQueueEncodeTitle;
237     int                          fEncodingQueueItem;     // corresponds to the index of fJobGroups encoding item
238     int                          fPendingCount;         // Number of various kinds of job groups in fJobGroups.
239     int                          fCompletedCount;
240     int                          fCanceledCount;
241     int                          fWorkingCount;
242     
243     
244     /* integer to set to determine the previous state
245                 of encode 0==idle, 1==encoding, 2==cancelled*/
246     int                            fEncodeState;
247         int                            currentScanCount;
248         int                            currentSuccessfulScanCount;
249     BOOL                           SuccessfulScan;
250     BOOL                           applyQueueToScan;
251         NSString                      * currentSource;
252     NSString                     * browsedSourceDisplayName;
253 }
254
255 - (void) writeToActivityLog:(char *) format, ...;
256 - (IBAction) browseSources: (id) sender;
257 - (void) browseSourcesDone: (NSOpenPanel *) sheet
258                 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
259 - (IBAction) showSourceTitleScanPanel: (id) sender;
260 - (IBAction) closeSourceTitleScanPanel: (id) sender;  
261 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
262 - (IBAction) showNewScan: (id) sender;
263
264 - (void)     updateUI: (NSTimer *) timer;
265 - (void)     enableUI: (bool) enable;
266
267 - (IBAction) titlePopUpChanged: (id) sender;
268 - (IBAction) chapterPopUpChanged: (id) sender;
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 - (IBAction) audioAddAudioTrackCodecs: (id)sender;
276 - (IBAction) audioCodecsPopUpChanged: (id) sender;
277 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender;
278 - (IBAction) addAllAudioTracksToPopUp: (id) sender;
279 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound;
280 - (IBAction) audioTrackPopUpChanged: (id) sender;
281 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
282 - (IBAction) audioTrackMixdownChanged: (id) sender;
283 - (IBAction) subtitleSelectionChanged: (id) sender;
284 - (void) prepareJob;
285 - (IBAction) browseFile: (id) sender;
286 - (void)     browseFileDone: (NSSavePanel *) sheet
287                  returnCode: (int) returnCode contextInfo: (void *) contextInfo;
288
289 - (IBAction) videoMatrixChanged: (id) sender;
290 - (IBAction) qualitySliderChanged: (id) sender;
291 - (IBAction) audioDRCSliderChanged: (id) sender;
292
293 - (IBAction) showPicturePanel: (id) sender;
294 - (void) picturePanelFullScreen;
295 - (void) picturePanelWindowed;
296 - (IBAction) showFiltersPanel: (id) sender;
297 - (IBAction) showPreviewWindow: (id) sender;
298 - (void)pictureSettingsDidChange;
299 - (IBAction) calculatePictureSizing: (id) sender;
300 - (IBAction) openMainWindow: (id) sender;
301
302 /* Queue File Stuff */
303 - (void) loadQueueFile;
304 - (NSDictionary *)createQueueFileItem;
305 - (void)saveQueueFileItem;
306 - (void) incrementQueueItemDone:(int) queueItemDoneIndexNum;
307 - (void) performNewQueueScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
308 - (void) processNewQueueEncode;
309 - (void) clearQueueEncodedItems;
310 - (IBAction)applyQueueSettings:(id)sender;
311 - (void) removeQueueFileItem:(int) queueItemToRemove;
312 - (void) clearQueueAllItems;
313 - (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(unsigned)insertIndex;
314 - (void)getQueueStats;
315 - (void)setQueueEncodingItemsAsPending;
316 - (IBAction) addToQueue: (id) sender;
317 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
318                            returnCode: (int) returnCode contextInfo: (void *) contextInfo;
319 - (void)     doAddToQueue;
320
321 - (IBAction) showQueueWindow:(id)sender;
322
323 - (IBAction)showPreferencesWindow:(id)sender;
324
325 - (IBAction) Rip: (id) sender;
326 - (void)     overWriteAlertDone: (NSWindow *) sheet
327                      returnCode: (int) returnCode contextInfo: (void *) contextInfo;
328 - (void)     doRip;
329
330 - (IBAction) Cancel: (id) sender;
331 - (void)     doCancelCurrentJob;
332 - (void) doCancelCurrentJobAndStop;
333 - (IBAction) Pause: (id) sender;
334
335 - (IBAction) calculateBitrate: (id) sender;
336 - (void) controlTextDidChange: (NSNotification *) notification;
337
338 - (IBAction) openHomepage: (id) sender;
339 - (IBAction) openForums:   (id) sender;
340 - (IBAction) openUserGuide:   (id) sender;
341
342 // Preset Methods Here
343     
344 /* These are required by the NSOutlineView Datasource Delegate */
345 /* We use this to deterimine children of an item */
346 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
347 /* We use this to determine if an item should be expandable */
348 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
349 /* used to specify the number of levels to show for each item */
350 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
351 /* Used to tell the outline view which information is to be displayed per item */
352 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
353 /* Use to customize the font and display characteristics of the title cell */
354 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
355 /* We use this to edit the name field in the outline view */
356 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
357 /* We use this to provide tooltips for the items in the presets outline view */
358 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
359
360 /* We use this to actually select the preset and act accordingly */
361 - (IBAction)selectPreset:(id)sender;    
362
363 /* Manage User presets */    
364 - (void) loadPresets;
365 - (IBAction) customSettingUsed: (id) sender;
366 - (IBAction) showAddPresetPanel: (id) sender;
367 - (IBAction) closeAddPresetPanel: (id) sender;
368 - (NSDictionary *)createPreset;
369
370 - (IBAction) revertPictureSizeToMax:(id)sender;
371
372 - (IBAction)setDefaultPreset:(id)sender;
373 - (IBAction)selectDefaultPreset:(id)sender;
374 - (void) savePreset;
375 - (void)sortPresets;
376 - (IBAction)addFactoryPresets:(id)sender;
377 - (IBAction)deleteFactoryPresets:(id)sender;
378 - (IBAction)addUserPreset:(id)sender;
379 - (void)addPreset;
380 - (IBAction)insertPreset:(id)sender;
381 - (IBAction)deletePreset:(id)sender;
382 - (IBAction)getDefaultPresets:(id)sender;
383
384 -(void)sendToMetaX:(NSString *) filePath;
385     // Growl methods
386 - (NSDictionary *) registrationDictionaryForGrowl;
387 -(void)showGrowlDoneNotification:(NSString *) filePath;
388 - (IBAction)showDebugOutputPanel:(id)sender;
389 - (void)setupToolbar;
390
391 - (void) prepareJobForPreview;
392 - (void) remindUserOfSleepOrShutdown;
393
394 - (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(unsigned)insertIndex;
395 @end
396