OSDN Git Service

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