OSDN Git Service

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