OSDN Git Service

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