OSDN Git Service

c660166c2462d29826b2013dcd6db99186cc5169
[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.m0k.org/>.
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     IBOutlet NSTextField         * fAudLang1Field;
144     IBOutlet NSPopUpButton       * fAudLang1PopUp;
145     IBOutlet NSTextField         * fAudLang2Field;
146     IBOutlet NSPopUpButton       * fAudLang2PopUp;
147         /* New Audio Mix PopUps */
148         /* Track info */
149     IBOutlet NSTextField         * fAudTrack1MixLabel;
150         IBOutlet NSPopUpButton       * fAudTrack1MixPopUp;
151     IBOutlet NSTextField         * fAudTrack2MixLabel;
152         IBOutlet NSPopUpButton       * fAudTrack2MixPopUp;
153         
154     /* Quality info */
155         IBOutlet NSTextField         * fAudRateField;
156     IBOutlet NSPopUpButton       * fAudRatePopUp;
157     IBOutlet NSTextField         * fAudBitrateField;
158     IBOutlet NSPopUpButton       * fAudBitratePopUp;
159     /*Dynamic Range Compression */
160     IBOutlet NSSlider            * fAudDrcSlider;
161     IBOutlet NSTextField         * fAudDrcField;
162     IBOutlet NSTextField         * fAudDrcLabel;
163     IBOutlet NSTextField         * fAudDrcDescLabel1;
164     IBOutlet NSTextField         * fAudDrcDescLabel2;
165     IBOutlet NSTextField         * fAudDrcDescLabel3;
166     IBOutlet NSTextField         * fAudDrcDescLabel4;
167     
168     /* Chapters box */
169     IBOutlet NSButton            * fCreateChapterMarkers;
170     IBOutlet NSTableView         * fChapterTable;
171         ChapterTitles                * fChapterTitlesDelegate;
172         
173     /* Bottom */
174     IBOutlet NSButton            * fPictureButton;
175     IBOutlet NSTextField         * fStatusField;
176     IBOutlet NSProgressIndicator * fRipIndicator;
177         BOOL                           fRipIndicatorShown;
178     
179         /* User Preset variables here */
180         HBPresets                    * fPresetsBuiltin;
181         IBOutlet NSDrawer            * fPresetDrawer;
182         IBOutlet NSTextField         * fPresetNewName;
183         IBOutlet NSTextField         * fPresetNewDesc;
184         IBOutlet NSPopUpButton       * fPresetNewPicSettingsPopUp;
185     IBOutlet NSButton            * fPresetNewPicFiltersCheck;
186         IBOutlet NSTextField         * fPresetSelectedDisplay;
187         
188         NSString                     * AppSupportDirectory;
189         NSString                     * UserPresetsFile;
190         NSMutableArray               * UserPresets;
191         NSMutableArray               * UserPresetssortedArray;
192         NSMutableDictionary          * chosenPreset;
193     int                            curUserPresetChosenNum;
194          
195         int                            presetHbDefault; // this is 1 in "Default" preset key
196         int                            presetUserDefault;// this is 2 in "Default" preset key
197     int                        presetCurrentBuiltInCount; // keeps track of the current number of built in presets
198     IBOutlet NSPanel             * fAddPresetPanel;
199         /* new NSOutline View for the presets */
200     NSArray                      *fDraggedNodes;
201     IBOutlet HBPresetsOutlineView * fPresetsOutlineView;
202     IBOutlet NSButton            * fPresetsAdd;
203         IBOutlet NSButton            * fPresetsDelete;
204     IBOutlet MVMenuButton        * fPresetsActionButton;
205     IBOutlet NSMenu              * fPresetsActionMenu;
206         
207     hb_handle_t                  * fHandle;
208         hb_title_t                   * fTitle;
209     /* integer to set to determine the previous state
210                 of encode 0==idle, 1==encoding, 2==cancelled*/
211     int                            fEncodeState;
212         int                            currentScanCount;
213         int                            currentSuccessfulScanCount;
214     BOOL                           SuccessfulScan;
215         NSString                      * currentSource;
216     NSString                     * browsedSourceDisplayName;
217 }
218 - (void) writeToActivityLog:(char *) format, ...;
219 - (IBAction) browseSources: (id) sender;
220 - (void) browseSourcesDone: (NSOpenPanel *) sheet
221                 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
222 - (IBAction) showSourceTitleScanPanel: (id) sender;
223 - (IBAction) closeSourceTitleScanPanel: (id) sender;  
224 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
225 - (IBAction) showNewScan: (id) sender;
226
227 - (void)     TranslateStrings;
228
229 - (void)     updateUI: (NSTimer *) timer;
230 - (void)     enableUI: (bool) enable;
231
232 - (IBAction) titlePopUpChanged: (id) sender;
233 - (IBAction) chapterPopUpChanged: (id) sender;
234
235 - (IBAction) formatPopUpChanged: (id) sender;
236 - (IBAction) codecsPopUpChanged: (id) sender;
237 - (IBAction) encoderPopUpChanged: (id) sender;
238 - (IBAction) autoSetM4vExtension: (id) sender;
239 - (IBAction) twoPassCheckboxChanged: (id) sender;
240 - (IBAction) videoFrameRateChanged: (id) sender;
241 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender;
242 - (IBAction) addAllAudioTracksToPopUp: (id) sender;
243 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound;
244 - (IBAction) audioTrackPopUpChanged: (id) sender;
245 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
246 - (IBAction) audioTrackMixdownChanged: (id) sender;
247 - (IBAction) subtitleSelectionChanged: (id) sender;
248
249 - (IBAction) browseFile: (id) sender;
250 - (void)     browseFileDone: (NSSavePanel *) sheet
251                  returnCode: (int) returnCode contextInfo: (void *) contextInfo;
252
253 - (IBAction) videoMatrixChanged: (id) sender;
254 - (IBAction) qualitySliderChanged: (id) sender;
255 - (IBAction) audioDRCSliderChanged: (id) sender;
256
257 - (IBAction) showPicturePanel: (id) sender;
258 - (IBAction) calculatePictureSizing: (id) sender;
259 - (IBAction) openMainWindow: (id) sender;
260
261 - (IBAction) addToQueue: (id) sender;
262 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
263                            returnCode: (int) returnCode contextInfo: (void *) contextInfo;
264 - (void)     doAddToQueue;
265
266 - (IBAction) showQueueWindow:(id)sender;
267
268 - (IBAction)showPreferencesWindow:(id)sender;
269
270 - (IBAction) Rip: (id) sender;
271 - (void)     overWriteAlertDone: (NSWindow *) sheet
272                      returnCode: (int) returnCode contextInfo: (void *) contextInfo;
273 - (void)     doRip;
274
275 - (IBAction) Cancel: (id) sender;
276 - (void)     doCancelCurrentJob;
277
278 - (IBAction) Pause: (id) sender;
279
280 - (IBAction) calculateBitrate: (id) sender;
281 - (void) controlTextDidChange: (NSNotification *) notification;
282
283 - (IBAction) openHomepage: (id) sender;
284 - (IBAction) openForums:   (id) sender;
285 - (IBAction) openUserGuide:   (id) sender;
286
287 // Preset Methods Here
288     
289 /* These are required by the NSOutlineView Datasource Delegate */
290 /* We use this to deterimine children of an item */
291 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
292 /* We use this to determine if an item should be expandable */
293 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
294 /* used to specify the number of levels to show for each item */
295 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
296 /* Used to tell the outline view which information is to be displayed per item */
297 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
298 /* Use to customize the font and display characteristics of the title cell */
299 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
300 /* We use this to edit the name field in the outline view */
301 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
302 /* We use this to provide tooltips for the items in the presets outline view */
303 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
304
305 /* We use this to actually select the preset and act accordingly */
306 - (IBAction)selectPreset:(id)sender;    
307
308 /* Manage User presets */    
309 - (void) loadPresets;
310 - (IBAction) customSettingUsed: (id) sender;
311 - (IBAction) showAddPresetPanel: (id) sender;
312 - (IBAction) closeAddPresetPanel: (id) sender;
313 - (NSDictionary *)createPreset;
314
315 - (IBAction) revertPictureSizeToMax:(id)sender;
316
317 - (IBAction)setDefaultPreset:(id)sender;
318 - (IBAction)selectDefaultPreset:(id)sender;
319 - (void) savePreset;
320 - (void)sortPresets;
321 - (IBAction)addFactoryPresets:(id)sender;
322 - (IBAction)deleteFactoryPresets:(id)sender;
323 - (IBAction)addUserPreset:(id)sender;
324 - (void)addPreset;
325 - (IBAction)insertPreset:(id)sender;
326 - (IBAction)deletePreset:(id)sender;
327 - (IBAction)getDefaultPresets:(id)sender;
328
329
330     // Growl methods
331 - (NSDictionary *) registrationDictionaryForGrowl;
332 -(IBAction)showGrowlDoneNotification:(id)sender;
333 - (IBAction)showDebugOutputPanel:(id)sender;
334 - (void)setupToolbar;
335
336 - (void) remindUserOfSleepOrShutdown;
337
338 - (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(unsigned)insertIndex;
339 @end
340