]> granicus.if.org Git - handbrake/commitdiff
MacGui: moved the HBQueueOutlineView class to its own file.
authorritsuka <damiog@gmail.com>
Sun, 23 Nov 2014 12:56:03 +0000 (12:56 +0000)
committerritsuka <damiog@gmail.com>
Sun, 23 Nov 2014 12:56:03 +0000 (12:56 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6539 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBQueueController.h
macosx/HBQueueController.mm
macosx/HandBrake.xcodeproj/project.pbxproj

index 19266ed40e3af1f817ba04ffca2d18d581a92846..4a366224feebee384d860aaf9537fb5e54ec8684 100644 (file)
 
 @class HBController;
 
-//------------------------------------------------------------------------------------
-// As usual, we need to subclass NSOutlineView to handle a few special cases:
-//
-// (1) variable row heights during live resizes
-// HBQueueOutlineView exists solely to get around a bug in variable row height outline
-// views in which row heights get messed up during live resizes. See this discussion:
-// http://lists.apple.com/archives/cocoa-dev/2005/Oct/msg00871.html
-// However, the recommeneded fix (override drawRect:) does not work. Instead, this
-// subclass implements viewDidEndLiveResize in order to recalculate all row heights.
-//
-// (2) prevent expanding of items during drags
-// During dragging operations, we don't want outline items to expand, since a queue
-// doesn't really have children items.
-//
-// (3) generate a drag image that incorporates more than just the first column
-// By default, NSTableView only drags an image of the first column. Change this to
-// drag an image of the queue's icon and desc columns.
-
-@interface HBQueueOutlineView : NSOutlineView
-
-@property (nonatomic, readonly) BOOL isDragging;
-
-@end
-
 @interface HBQueueController : NSWindowController <NSToolbarDelegate, NSWindowDelegate>
 
 - (void)setPidNum: (int)myPidnum;
@@ -50,9 +26,4 @@
 
 - (IBAction)showQueueWindow: (id)sender;
 
-/* control encodes in the window */
-- (IBAction)removeSelectedQueueItem: (id)sender;
-- (IBAction)revealSelectedQueueItem: (id)sender;
-- (IBAction)editSelectedQueueItem: (id)sender;
-
 @end
index 19fc8a37ac492c78c87aacd18a1b388d23e084d1..d818707935f9197324756930a6736c53bffa525c 100644 (file)
@@ -6,6 +6,8 @@
 
 #import "HBQueueController.h"
 #import "Controller.h"
+
+#import "HBQueueOutlineView.h"
 #import "HBImageAndTextCell.h"
 #import "HBUtilities.h"
 
 }
 @end
 
-
-@implementation HBQueueOutlineView
-
-- (void)viewDidEndLiveResize
-{
-    // Since we disabled calculating row heights during a live resize, force them to
-    // recalculate now.
-    [self noteHeightOfRowsWithIndexesChanged:
-            [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [self numberOfRows])]];
-    [super viewDidEndLiveResize];
-}
-
-/* This should be for dragging, we take this info from the presets right now */
-- (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows
-                            tableColumns:(NSArray *)tableColumns
-                                   event:(NSEvent *)dragEvent
-                                  offset:(NSPointPointer)dragImageOffset
-{
-    _isDragging = YES;
-
-    // By default, NSTableView only drags an image of the first column. Change this to
-    // drag an image of the queue's icon and desc and action columns.
-    NSArray * cols = @[[self tableColumnWithIdentifier:@"desc"], [self tableColumnWithIdentifier:@"icon"],[self tableColumnWithIdentifier:@"action"]];
-    return [super dragImageForRowsWithIndexes:dragRows tableColumns:cols event:dragEvent offset:dragImageOffset];
-}
-
-- (void)mouseDown:(NSEvent *)theEvent
-{
-    [super mouseDown:theEvent];
-       _isDragging = NO;
-}
-
-- (void)keyDown:(NSEvent *)event
-{
-    id delegate = [self delegate];
-
-    unichar key = [[event charactersIgnoringModifiers] characterAtIndex:0];
-    if ((key == NSDeleteCharacter || key == NSDeleteFunctionKey) &&
-               [delegate respondsToSelector:@selector(removeSelectedQueueItem:)])
-    {
-        if ([self selectedRow] == -1)
-        {
-            NSBeep();
-        }
-        else
-        {
-            [delegate removeSelectedQueueItem:self];
-        }
-        return;
-    }
-    else
-    {
-        [super keyDown:event];
-    }
-}
-
-/**
- *  An index set containing the indexes of the targeted rows.
- *  If the selected row indexes contain the clicked row index, it returns every selected row,
- *  otherwise it returns only the clicked row index.
- */
-- (NSIndexSet *)targetedRowIndexes
-{
-    NSMutableIndexSet *rowIndexes = [NSMutableIndexSet indexSet];
-    NSIndexSet *selectedRowIndexes = [self selectedRowIndexes];
-    NSInteger clickedRow = [self clickedRow];
-
-    if (clickedRow != -1)
-    {
-        [rowIndexes addIndex:clickedRow];
-
-        // If we clicked on a selected row, then we want to consider all rows in the selection. Otherwise, we only consider the clicked on row.
-        if ([selectedRowIndexes containsIndex:clickedRow])
-        {
-            [rowIndexes addIndexes:selectedRowIndexes];
-        }
-    }
-    else
-    {
-        [rowIndexes addIndexes:selectedRowIndexes];
-    }
-
-    return [[rowIndexes copy] autorelease];
-}
-
-@end
-
 #pragma mark -
 
-@interface HBQueueController ()
+@interface HBQueueController () <HBQueueOutlineViewDelegate>
 {
     hb_handle_t                  *fQueueEncodeLibhb;              // reference to libhb
     HBController                 *fHBController;        // reference to HBController
     NSDictionary            *shortHeightAttr;
 }
 
+/* control encodes in the window */
+- (IBAction)removeSelectedQueueItem: (id)sender;
+- (IBAction)revealSelectedQueueItem: (id)sender;
+- (IBAction)editSelectedQueueItem: (id)sender;
+
 @end
 
 @implementation HBQueueController
 
 
 #pragma mark Queue Item Controls
+
+- (void)HB_deleteSelectionFromTableView:(NSTableView *)tableView
+{
+    [self removeSelectedQueueItem:tableView];
+}
+
 //------------------------------------------------------------------------------------
 // Delete encodes from the queue window and accompanying array
 // Also handling first cancelling the encode if in fact its currently encoding.
index b8094601fc473bd64efd03778c0da5371492b9b9..fc05ebfd5b6fcd89ce9091da90edc060b9afca45 100644 (file)
                A9E1468316BC2AD800C307BC /* prev-p.pdf in Resources */ = {isa = PBXBuildFile; fileRef = A9E1467F16BC2AD800C307BC /* prev-p.pdf */; };
                A9E2FD271A21BC4A000E8D3F /* HBAddPresetController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9E2FD251A21BC4A000E8D3F /* HBAddPresetController.m */; };
                A9E2FD2B1A21BC6F000E8D3F /* AddPreset.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9E2FD291A21BC6F000E8D3F /* AddPreset.xib */; };
+               A9EA43681A2210C400785E95 /* HBQueueOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9EA43671A2210C400785E95 /* HBQueueOutlineView.m */; };
                A9F2EB6F196F12C800066546 /* Audio.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9F2EB6D196F12C800066546 /* Audio.xib */; };
                A9F472891976B7F30009EC65 /* HBSubtitlesDefaultsController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9F472871976B7F30009EC65 /* HBSubtitlesDefaultsController.m */; };
                A9F4728D1976BAA70009EC65 /* HBSubtitlesDefaults.m in Sources */ = {isa = PBXBuildFile; fileRef = A9F4728C1976BAA70009EC65 /* HBSubtitlesDefaults.m */; };
                A9E2FD241A21BC4A000E8D3F /* HBAddPresetController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBAddPresetController.h; sourceTree = "<group>"; };
                A9E2FD251A21BC4A000E8D3F /* HBAddPresetController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBAddPresetController.m; sourceTree = "<group>"; };
                A9E2FD2A1A21BC6F000E8D3F /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = AddPreset.xib; sourceTree = "<group>"; };
+               A9EA43661A2210C400785E95 /* HBQueueOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBQueueOutlineView.h; sourceTree = "<group>"; };
+               A9EA43671A2210C400785E95 /* HBQueueOutlineView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBQueueOutlineView.m; sourceTree = "<group>"; };
                A9F2EB6E196F12C800066546 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Audio.xib; sourceTree = "<group>"; };
                A9F472861976B7F30009EC65 /* HBSubtitlesDefaultsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBSubtitlesDefaultsController.h; sourceTree = "<group>"; };
                A9F472871976B7F30009EC65 /* HBSubtitlesDefaultsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBSubtitlesDefaultsController.m; sourceTree = "<group>"; };
                A9B34D711976844500871B7D /* UI Views */ = {
                        isa = PBXGroup;
                        children = (
+                               A9EA43661A2210C400785E95 /* HBQueueOutlineView.h */,
+                               A9EA43671A2210C400785E95 /* HBQueueOutlineView.m */,
                                46AB433315F98A2B009C0961 /* DockTextField.h */,
                                46AB433415F98A2B009C0961 /* DockTextField.m */,
                                A9F7102419A475EC00F61301 /* HBDockTile.h */,
                                273F20BA14ADBE670021BE6D /* PictureController.m in Sources */,
                                A9CF25F71990D6820023F727 /* HBPresetsViewController.m in Sources */,
                                273F20BE14ADC09F0021BE6D /* main.mm in Sources */,
+                               A9EA43681A2210C400785E95 /* HBQueueOutlineView.m in Sources */,
                                A91726E7197291BC00D1AFEF /* HBChapterTitlesController.m in Sources */,
                                A9C9F88919A733FE00DC8923 /* HBHUDView.m in Sources */,
                                A932E26F198833920047D13E /* HBAudioDefaultsController.m in Sources */,