OSDN Git Service

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