OSDN Git Service

Change the fifo size from being statically tuned for a Mac Pro with 4 CPUs to dynamic...
[handbrake-jp/handbrake-jp-git.git] / macosx / HBQueueController.h
1 /* HBQueueController
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
8 #include <Cocoa/Cocoa.h>
9 #include "hb.h"
10
11 @class HBController;
12
13 #define HB_QUEUE_DRAGGING 0             // <--- NOT COMPLETELY FUNCTIONAL YET
14 #define HB_OUTLINE_METRIC_CONTROLS 1    // for tweaking the outline cell spacings
15
16 typedef enum _HBQueueJobGroupStatus
17 {
18     HBStatusNone          = 0,
19     HBStatusPending       = 1,
20     HBStatusWorking       = 2,
21     HBStatusComplete      = 3,
22     HBStatusCanceled      = 4
23 } HBQueueJobGroupStatus;
24
25 //------------------------------------------------------------------------------------
26 // As usual, we need to subclass NSOutlineView to handle a few special cases:
27 //
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.
34 //
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.
38 //
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.
42
43 @interface HBQueueOutlineView : NSOutlineView
44 {
45 #if HB_QUEUE_DRAGGING
46 BOOL                        fIsDragging;
47 #endif
48 }
49 #if HB_QUEUE_DRAGGING
50 - (BOOL) isDragging;
51 #endif
52 @end
53
54 //------------------------------------------------------------------------------------
55
56 @interface HBJob : NSObject
57 {
58     hb_job_t                     *hbJob;
59 }
60
61 + (HBJob*)             jobWithJob: (hb_job_t *) job;
62 - (id)                 initWithJob: (hb_job_t *) job;
63 - (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;
75
76 @end
77
78 //------------------------------------------------------------------------------------
79
80 @interface HBJobGroup : NSObject
81 {
82     NSMutableArray               *fJobs;   // array of HBJob
83     NSMutableAttributedString    *fDescription;
84     BOOL                         fNeedsDescription;
85     float                        fLastDescriptionHeight;
86     float                        fLastDescriptionWidth;
87     HBQueueJobGroupStatus        fStatus;
88     NSString                     *fPath;
89 }
90
91 // Creating a job group
92 + (HBJobGroup *)       jobGroup;
93
94 // Adding jobs
95 - (void)               addJob: (HBJob *)aJob;
96
97 // Removing jobs
98 - (void)               removeAllJobs;
99
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;
108 - (NSString *)         path;
109
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;
115
116 @end
117
118 //------------------------------------------------------------------------------------
119
120 @interface HBQueueController : NSObject
121 {
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;
132 #endif
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
136     
137     //  +---------------fQueueWindow----------------+
138     //  |+-------------fCurrentJobPane-------------+|
139     //  ||                                         ||
140     //  ||                                         ||
141     //  ||                                         ||
142     //  |+-----------------------------------------+|
143     //  |+---------------fQueuePane----------------+|
144     //  ||                                         ||
145     //  ||                                         ||
146     //  ||                                         ||
147     //  ||                                         ||
148     //  ||                                         ||
149     //  ||                                         ||
150     //  ||                                         ||
151     //  |+-----------------------------------------+|
152     //  +-------------------------------------------+
153     
154     IBOutlet NSWindow            *fQueueWindow;
155
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;
162     
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
170 #endif
171     
172 }
173
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;
179
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;
186
187 #if HB_OUTLINE_METRIC_CONTROLS
188 - (IBAction)imageSpacingChanged: (id)sender;
189 - (IBAction)indentChanged: (id)sender;
190 #endif
191
192 @end
193