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. */
8 #include <Cocoa/Cocoa.h>
15 #define HB_QUEUE_DRAGGING 0 // <--- NOT COMPLETELY FUNCTIONAL YET
16 #define HB_OUTLINE_METRIC_CONTROLS 0 // for tweaking the outline cell spacings
18 // hb_job_t contains a sequence_id field. The high word is a unique job group id.
19 // The low word contains the "sequence id" which is a value starting at 0 and
20 // incremented for each pass in the job group. Use the function below to create and
21 // interpret a sequence_id field.
22 int MakeJobID(int jobGroupID, int sequenceNum);
23 bool IsFirstPass(int jobID);
25 typedef enum _HBQueueJobGroupStatus
30 HBStatusCompleted = 3,
32 } HBQueueJobGroupStatus;
34 // Notification sent whenever the status of a HBJobGroup changes (via setStatus). The
35 // user info contains one object, @"HBOldJobGroupStatus", which is an NSNumber
36 // containing the previous status of the job group.
37 extern NSString * HBJobGroupStatusNotification;
39 //------------------------------------------------------------------------------------
40 // As usual, we need to subclass NSOutlineView to handle a few special cases:
42 // (1) variable row heights during live resizes
43 // HBQueueOutlineView exists solely to get around a bug in variable row height outline
44 // views in which row heights get messed up during live resizes. See this discussion:
45 // http://lists.apple.com/archives/cocoa-dev/2005/Oct/msg00871.html
46 // However, the recommeneded fix (override drawRect:) does not work. Instead, this
47 // subclass implements viewDidEndLiveResize in order to recalculate all row heights.
49 // (2) prevent expanding of items during drags
50 // During dragging operations, we don't want outline items to expand, since a queue
51 // doesn't really have children items.
53 // (3) generate a drag image that incorporates more than just the first column
54 // By default, NSTableView only drags an image of the first column. Change this to
55 // drag an image of the queue's icon and desc columns.
57 @interface HBQueueOutlineView : NSOutlineView
68 //------------------------------------------------------------------------------------
69 // HBJob is the UI's equivalent to libhb's hb_job_t struct. It is used mainly for
70 // drawing the job's description. HBJob are referred to in the UI as 'passes'.
71 //------------------------------------------------------------------------------------
73 @interface HBJob : NSObject
75 HBJobGroup *jobGroup; // The group this job belongs to
77 // The following fields match up with similar fields found in hb_job_t and it's
78 // various substructures.
81 int sequence_id; // This is how we xref to the jobs inside libhb
88 int width; // source dimensions
90 int output_width; // output dimensions
92 int anamorphic_width; // anamorphic dimensions
93 int anamorphic_height;
97 int pixel_aspect_width;
98 int pixel_aspect_height;
108 /* Used to concatenate audio list values into a string for display */
109 NSString *audioinfo_codecs;
110 NSString *audioinfo_summary;
112 int audio_mixdowns[8];
127 // from hb_subtitle_s
128 NSString *subtitleLang;
131 + (HBJob*) jobWithLibhbJob: (hb_job_t *) job;
132 - (id) initWithLibhbJob: (hb_job_t *) job;
133 - (HBJobGroup *) jobGroup;
134 - (void) setJobGroup: (HBJobGroup *)aJobGroup;
135 - (NSMutableAttributedString *) attributedDescriptionWithIcon: (BOOL)withIcon
136 withTitle: (BOOL)withTitle
137 withPassName: (BOOL)withPassName
138 withFormatInfo: (BOOL)withFormatInfo
139 withDestination: (BOOL)withDestination
140 withPictureInfo: (BOOL)withPictureInfo
141 withVideoInfo: (BOOL)withVideoInfo
142 withx264Info: (BOOL)withx264Info
143 withAudioInfo: (BOOL)withAudioInfo
144 withSubtitleInfo: (BOOL)withSubtitleInfo;
146 // Attributes used by attributedDescriptionWithIcon:::::::::
147 + (NSMutableParagraphStyle *) descriptionParagraphStyle;
148 + (NSDictionary *) descriptionDetailAttribute;
149 + (NSDictionary *) descriptionDetailBoldAttribute;
150 + (NSDictionary *) descriptionTitleAttribute;
151 + (NSDictionary *) descriptionShortHeightAttribute;
155 //------------------------------------------------------------------------------------
156 // HBJobGroup is what's referred to in the UI as an 'encode'. A job group contains
157 // multiple HBJobs, one for each 'pass' of the encode. Whereas libhb keeps a simple
158 // list of jobs in it's queue, the queue controller presents them to the user as a
159 // series of encodes and passes (HBJObGroups and HBJobs).
160 //------------------------------------------------------------------------------------
162 @interface HBJobGroup : NSObject
164 NSMutableArray *fJobs; // array of HBJob
165 NSMutableAttributedString *fDescription;
166 BOOL fNeedsDescription;
167 CGFloat fLastDescriptionHeight;
168 CGFloat fLastDescriptionWidth;
169 HBQueueJobGroupStatus fStatus;
170 NSString *fPresetName;
173 // Creating a job group
174 + (HBJobGroup *) jobGroup;
177 - (void) addJob: (HBJob *)aJob;
179 // Querying a job group
180 - (unsigned int) count;
181 - (HBJob *) jobAtIndex: (unsigned)index;
182 - (unsigned int) indexOfJob: (HBJob *)aJob;
183 - (NSEnumerator *) jobEnumerator;
184 - (void) setStatus: (HBQueueJobGroupStatus)status;
185 - (HBQueueJobGroupStatus) status;
186 - (void) setPresetName: (NSString *)name;
187 - (NSString *) presetName;
188 - (NSString *) destinationPath;
191 // Creating a description
192 - (void) setNeedsDescription: (BOOL)flag;
193 - (NSMutableAttributedString *) attributedDescription;
194 - (CGFloat) heightOfDescriptionForWidth:(CGFloat)width;
195 - (CGFloat) lastDescriptionHeight;
199 //------------------------------------------------------------------------------------
201 @interface HBQueueController : NSWindowController
203 hb_handle_t *fHandle; // reference to libhb
204 HBController *fHBController; // reference to HBController
205 NSMutableArray *fJobGroups; // libhb's job list organized in a hierarchy of HBJobGroup and HBJob
206 HBJobGroup *fCurrentJobGroup; // the HJobGroup currently being processed by libhb
207 HBJob *fCurrentJob; // the HJob (pass) currently being processed by libhb
208 int fCurrentJobID; // this is how we track when hbib has started processing a different job. This is the job's sequence_id.
210 unsigned int fPendingCount; // Number of various kinds of job groups in fJobGroups.
211 unsigned int fCompletedCount; // Don't access these directly as they may not always be up-to-date.
212 unsigned int fCanceledCount; // Use the accessor functions instead.
213 unsigned int fWorkingCount;
214 BOOL fJobGroupCountsNeedUpdating;
216 BOOL fCurrentJobPaneShown; // NO when fCurrentJobPane has been shifted out of view (see showCurrentJobPane)
217 NSMutableIndexSet *fSavedExpandedItems; // used by save/restoreOutlineViewState to preserve which items are expanded
218 NSMutableIndexSet *fSavedSelectedItems; // used by save/restoreOutlineViewState to preserve which items are selected
219 #if HB_QUEUE_DRAGGING
220 NSArray *fDraggedNodes;
222 NSTimer *fAnimationTimer; // animates the icon of the current job in the queue outline view
223 int fAnimationIndex; // used to generate name of image used to animate the current job in the queue outline view
225 // +------------------window-------------------+
226 // |+-------------fCurrentJobPane-------------+|
230 // |+-----------------------------------------+|
231 // |+---------------fQueuePane----------------+|
239 // |+-----------------------------------------+|
240 // +-------------------------------------------+
242 // fCurrentJobPane - visible only when processing a job
243 IBOutlet NSView *fCurrentJobPane;
244 IBOutlet NSImageView *fJobIconView;
245 IBOutlet NSTextField *fJobDescTextField;
246 IBOutlet NSProgressIndicator *fProgressBar;
247 IBOutlet NSTextField *fProgressTextField;
249 // fQueuePane - always visible; fills entire window when fCurrentJobPane is hidden
250 IBOutlet NSView *fQueuePane;
251 IBOutlet HBQueueOutlineView *fOutlineView;
252 IBOutlet NSTextField *fQueueCountField;
253 #if HB_OUTLINE_METRIC_CONTROLS
254 IBOutlet NSSlider *fIndentation; // debug
255 IBOutlet NSSlider *fSpacing; // debug
260 - (void)setHandle: (hb_handle_t *)handle;
261 - (void)setHBController: (HBController *)controller;
262 - (void)libhbStateChanged: (hb_state_t &)state;
263 - (void)libhbWillStop;
265 // Adding items to the queue
266 - (void) addJobGroup: (HBJobGroup *) aJobGroup;
268 // Getting the currently processing job group
269 - (HBJobGroup *) currentJobGroup;
270 - (HBJob *) currentJob;
272 // Getting job groups
273 - (HBJobGroup *) pendingJobGroupWithDestinationPath: (NSString *)path;
275 // Getting queue statistics
276 - (unsigned int) pendingCount;
277 - (unsigned int) completedCount;
278 - (unsigned int) canceledCount;
279 - (unsigned int) workingCount;
281 - (IBAction)showQueueWindow: (id)sender;
282 - (IBAction)removeSelectedJobGroups: (id)sender;
283 - (IBAction)revealSelectedJobGroups: (id)sender;
284 - (IBAction)cancelCurrentJob: (id)sender;
285 - (IBAction)toggleStartCancel: (id)sender;
286 - (IBAction)togglePauseResume: (id)sender;
288 #if HB_OUTLINE_METRIC_CONTROLS
289 - (IBAction)imageSpacingChanged: (id)sender;
290 - (IBAction)indentChanged: (id)sender;