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. */
8 #include <Cocoa/Cocoa.h>
13 #define HB_QUEUE_DRAGGING 0 // <--- NOT COMPLETELY FUNCTIONAL YET
14 #define HB_OUTLINE_METRIC_CONTROLS 1 // for tweaking the outline cell spacings
16 typedef enum _HBQueueJobGroupStatus
23 } HBQueueJobGroupStatus;
25 //------------------------------------------------------------------------------------
26 // As usual, we need to subclass NSOutlineView to handle a few special cases:
28 // (1) variable row heights during live resizes
29 // HBQueueOutlineView exists solely to get around a bug in variable row height outline
30 // views in which row heights get messed up during live resizes. See this discussion:
31 // http://lists.apple.com/archives/cocoa-dev/2005/Oct/msg00871.html
32 // However, the recommeneded fix (override drawRect:) does not work. Instead, this
33 // subclass implements viewDidEndLiveResize in order to recalculate all row heights.
35 // (2) prevent expanding of items during drags
36 // During dragging operations, we don't want outline items to expand, since a queue
37 // doesn't really have children items.
39 // (3) generate a drag image that incorporates more than just the first column
40 // By default, NSTableView only drags an image of the first column. Change this to
41 // drag an image of the queue's icon and desc columns.
43 @interface HBQueueOutlineView : NSOutlineView
54 //------------------------------------------------------------------------------------
56 @interface HBJob : NSObject
61 + (HBJob*) jobWithJob: (hb_job_t *) job;
62 - (id) initWithJob: (hb_job_t *) job;
64 - (NSMutableAttributedString *) attributedDescriptionWithHBHandle: (hb_handle_t *)handle
65 withIcon: (BOOL)withIcon
66 withTitle: (BOOL)withTitle
67 withPassName: (BOOL)withPassName
68 withFormatInfo: (BOOL)withFormatInfo
69 withDestination: (BOOL)withDestination
70 withPictureInfo: (BOOL)withPictureInfo
71 withVideoInfo: (BOOL)withVideoInfo
72 withx264Info: (BOOL)withx264Info
73 withAudioInfo: (BOOL)withAudioInfo
74 withSubtitleInfo: (BOOL)withSubtitleInfo;
78 //------------------------------------------------------------------------------------
80 @interface HBJobGroup : NSObject
82 NSMutableArray *fJobs; // array of HBJob
83 NSMutableAttributedString *fDescription;
84 BOOL fNeedsDescription;
85 float fLastDescriptionHeight;
86 float fLastDescriptionWidth;
87 HBQueueJobGroupStatus fStatus;
91 // Creating a job group
92 + (HBJobGroup *) jobGroup;
95 - (void) addJob: (HBJob *)aJob;
98 - (void) removeAllJobs;
100 // Querying a job group
101 - (unsigned int) count;
102 - (HBJob *) jobAtIndex: (unsigned)index;
103 - (unsigned) indexOfJob: (HBJob *)aJob;
104 - (NSEnumerator *) jobEnumerator;
105 - (void) setStatus: (HBQueueJobGroupStatus)status;
106 - (HBQueueJobGroupStatus) status;
107 - (void) setPath: (NSString *)path;
110 // Creating a description
111 - (void) setNeedsDescription: (BOOL)flag;
112 - (NSMutableAttributedString *) attributedDescriptionWithHBHandle: (hb_handle_t *)handle;
113 - (float) heightOfDescriptionForWidth:(float)width withHBHandle: (hb_handle_t *)handle;
114 - (float) lastDescriptionHeight;
118 //------------------------------------------------------------------------------------
120 @interface HBQueueController : NSObject
122 hb_handle_t *fHandle; // reference to hblib
123 HBController *fHBController; // reference to HBController
124 NSMutableArray *fJobGroups; // hblib's job list organized in a hierarchy of HBJobGroup and HBJob
125 HBJobGroup *fCurrentJobGroup; // the HJobGroup current being processed by hblib
126 BOOL fCurrentJobPaneShown; // NO when fCurrentJobPane has been shifted out of view (see showCurrentJobPane)
127 hb_job_t *fLastKnownCurrentJob; // this is how we track when hbib has started processing a different job
128 NSMutableIndexSet *fSavedExpandedItems; // used by save/restoreOutlineViewState to preserve which items are expanded
129 NSMutableIndexSet *fSavedSelectedItems; // used by save/restoreOutlineViewState to preserve which items are selected
130 #if HB_QUEUE_DRAGGING
131 NSArray *fDraggedNodes;
133 NSMutableArray *fCompleted; // HBJobGroups that have been completed. These also appear in fJobGroups.
134 NSTimer *fAnimationTimer; // animates the icon of the current job in the queue outline view
135 int fAnimationIndex; // used to generate name of image used to animate the current job in the queue outline view
137 // +---------------fQueueWindow----------------+
138 // |+-------------fCurrentJobPane-------------+|
142 // |+-----------------------------------------+|
143 // |+---------------fQueuePane----------------+|
151 // |+-----------------------------------------+|
152 // +-------------------------------------------+
154 IBOutlet NSWindow *fQueueWindow;
156 // fCurrentJobPane - visible only when processing a job
157 IBOutlet NSView *fCurrentJobPane;
158 IBOutlet NSImageView *fJobIconView;
159 IBOutlet NSTextField *fJobDescTextField;
160 IBOutlet NSProgressIndicator *fProgressBar;
161 IBOutlet NSTextField *fProgressTextField;
163 // fQueuePane - always visible; fills entire window when fCurrentJobPane is hidden
164 IBOutlet NSView *fQueuePane;
165 IBOutlet HBQueueOutlineView *fOutlineView;
166 IBOutlet NSTextField *fQueueCountField;
167 #if HB_OUTLINE_METRIC_CONTROLS
168 IBOutlet NSSlider *fIndentation; // debug
169 IBOutlet NSSlider *fSpacing; // debug
174 - (void)setHandle: (hb_handle_t *)handle;
175 - (void)setHBController: (HBController *)controller;
176 - (void)hblibJobListChanged;
177 - (void)hblibStateChanged: (hb_state_t &)state;
178 - (void)hblibWillStop;
180 - (IBAction)showQueueWindow: (id)sender;
181 - (IBAction)removeSelectedJobGroups: (id)sender;
182 - (IBAction)revealSelectedJobGroups: (id)sender;
183 - (IBAction)cancelCurrentJob: (id)sender;
184 - (IBAction)toggleStartCancel: (id)sender;
185 - (IBAction)togglePauseResume: (id)sender;
187 #if HB_OUTLINE_METRIC_CONTROLS
188 - (IBAction)imageSpacingChanged: (id)sender;
189 - (IBAction)indentChanged: (id)sender;