vlc | branch: master | Marvin Scholz <[email protected]> | Tue Jun 13 12:51:01 2017 +0200| [5286f0c9192a5db7745e66803efc8847bb9353c0] | committer: Marvin Scholz
macOS: Add VLCHUDOutlineView > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5286f0c9192a5db7745e66803efc8847bb9353c0 --- .../package/macosx/VLC.xcodeproj/project.pbxproj | 18 +++ modules/gui/macosx/Makefile.am | 3 + modules/gui/macosx/VLCHUDOutlineView.h | 50 +++++++ modules/gui/macosx/VLCHUDOutlineView.m | 117 +++++++++++++++++ modules/gui/macosx/VLCHUDTableCornerView.h | 42 ++++++ modules/gui/macosx/VLCHUDTableCornerView.m | 59 +++++++++ modules/gui/macosx/VLCHUDTableHeaderCell.h | 45 +++++++ modules/gui/macosx/VLCHUDTableHeaderCell.m | 146 +++++++++++++++++++++ 8 files changed, 480 insertions(+) diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj index b649216205..f902ca7019 100644 --- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj +++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj @@ -80,6 +80,9 @@ 6B81662B1EBFC35D00C26F1B /* VLCVoutWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = E0C2583F161B593D00185AAD /* VLCVoutWindowController.m */; }; 6B81662C1EBFC38100C26F1B /* VLCUIWidgets.m in Sources */ = {isa = PBXBuildFile; fileRef = 5CCED71514C0D4A90057F8D1 /* VLCUIWidgets.m */; }; 6B9FD0391EEB5D8A0085151F /* VLCHUDScroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B9FD0381EEB5D8A0085151F /* VLCHUDScroller.m */; }; + 6BBB05DA1EEFEA29003A1019 /* VLCHUDOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BBB05D91EEFEA29003A1019 /* VLCHUDOutlineView.m */; }; + 6BBB05DD1EEFEADF003A1019 /* VLCHUDTableHeaderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BBB05DC1EEFEADF003A1019 /* VLCHUDTableHeaderCell.m */; }; + 6BBB05E01EEFF165003A1019 /* VLCHUDTableCornerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BBB05DF1EEFF165003A1019 /* VLCHUDTableCornerView.m */; }; 6BF093F91EE0182B0049D8B0 /* VLCTimeField.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF093F81EE0182B0049D8B0 /* VLCTimeField.m */; }; /* End PBXBuildFile section */ @@ -681,6 +684,12 @@ 6B846FEA1CF5DBFF00112E54 /* VLCHUDTextFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCHUDTextFieldCell.m; sourceTree = "<group>"; }; 6B9FD0371EEB5D8A0085151F /* VLCHUDScroller.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCHUDScroller.h; sourceTree = "<group>"; }; 6B9FD0381EEB5D8A0085151F /* VLCHUDScroller.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCHUDScroller.m; sourceTree = "<group>"; }; + 6BBB05D81EEFEA29003A1019 /* VLCHUDOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCHUDOutlineView.h; sourceTree = "<group>"; }; + 6BBB05D91EEFEA29003A1019 /* VLCHUDOutlineView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCHUDOutlineView.m; sourceTree = "<group>"; }; + 6BBB05DB1EEFEADF003A1019 /* VLCHUDTableHeaderCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCHUDTableHeaderCell.h; sourceTree = "<group>"; }; + 6BBB05DC1EEFEADF003A1019 /* VLCHUDTableHeaderCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCHUDTableHeaderCell.m; sourceTree = "<group>"; }; + 6BBB05DE1EEFF165003A1019 /* VLCHUDTableCornerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCHUDTableCornerView.h; sourceTree = "<group>"; }; + 6BBB05DF1EEFF165003A1019 /* VLCHUDTableCornerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCHUDTableCornerView.m; sourceTree = "<group>"; }; 6BBBB8A71D108A17001BD9BA /* VLCRendererDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCRendererDialog.h; sourceTree = "<group>"; }; 6BBBB8A81D108A17001BD9BA /* VLCRendererDialog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCRendererDialog.m; sourceTree = "<group>"; }; 6BBBB8B01D10A994001BD9BA /* VLCRendererItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCRendererItem.h; sourceTree = "<group>"; }; @@ -1596,6 +1605,12 @@ 6B846FE31CF5D88C00112E54 /* VLCHUDSliderCell.m */, 6B9FD0371EEB5D8A0085151F /* VLCHUDScroller.h */, 6B9FD0381EEB5D8A0085151F /* VLCHUDScroller.m */, + 6BBB05D81EEFEA29003A1019 /* VLCHUDOutlineView.h */, + 6BBB05D91EEFEA29003A1019 /* VLCHUDOutlineView.m */, + 6BBB05DE1EEFF165003A1019 /* VLCHUDTableCornerView.h */, + 6BBB05DF1EEFF165003A1019 /* VLCHUDTableCornerView.m */, + 6BBB05DB1EEFEADF003A1019 /* VLCHUDTableHeaderCell.h */, + 6BBB05DC1EEFEADF003A1019 /* VLCHUDTableHeaderCell.m */, ); name = "HUD UI Classes"; sourceTree = "<group>"; @@ -1841,6 +1856,7 @@ 6B8166291EBFC34300C26F1B /* VLCDefaultValueSlider.m in Sources */, 6B81662A1EBFC34300C26F1B /* VLCDefaultValueSliderCell.m in Sources */, 1C69FDF61EAB30C7007724ED /* Windows.m in Sources */, + 6BBB05DD1EEFEADF003A1019 /* VLCHUDTableHeaderCell.m in Sources */, 6B3BE42C1E6217CB008D098A /* VLCImageButton.m in Sources */, 6B4D50901E79781F004479B5 /* VLCHotkeyChangeWindow.m in Sources */, 1C3114031E508C8800D4DD76 /* AppleRemote.m in Sources */, @@ -1867,6 +1883,7 @@ 1C3113961E508C6900D4DD76 /* applescript.m in Sources */, 1C3113981E508C6900D4DD76 /* VLCAudioEffectsWindowController.m in Sources */, 1C31139A1E508C6900D4DD76 /* VLCBookmarksWindowController.m in Sources */, + 6BBB05E01EEFF165003A1019 /* VLCHUDTableCornerView.m in Sources */, 1C31139D1E508C6900D4DD76 /* VLCControlsBarCommon.m in Sources */, 1C31139F1E508C6900D4DD76 /* VLCMainWindowControlsBar.m in Sources */, 1C3113A11E508C6900D4DD76 /* VLCConvertAndSaveWindowController.m in Sources */, @@ -1891,6 +1908,7 @@ 1C3113C51E508C6900D4DD76 /* misc.m in Sources */, 1C3113C71E508C6900D4DD76 /* VLCOpenWindowController.m in Sources */, 1C3113C91E508C6900D4DD76 /* VLCOutput.m in Sources */, + 6BBB05DA1EEFEA29003A1019 /* VLCHUDOutlineView.m in Sources */, 1C3113CB1E508C6900D4DD76 /* VLCPLItem.m in Sources */, 1C3113CD1E508C6900D4DD76 /* VLCPLModel.m in Sources */, 1C3113CF1E508C6900D4DD76 /* prefs_widgets.m in Sources */, diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am index ca2ccdec51..59a73a8219 100644 --- a/modules/gui/macosx/Makefile.am +++ b/modules/gui/macosx/Makefile.am @@ -78,6 +78,9 @@ libmacosx_plugin_la_SOURCES = \ gui/macosx/VLCHUDRadiobuttonCell.h gui/macosx/VLCHUDRadiobuttonCell.m \ gui/macosx/VLCHUDTextFieldCell.h gui/macosx/VLCHUDTextFieldCell.m \ gui/macosx/VLCHUDScroller.h gui/macosx/VLCHUDScroller.m \ + gui/macosx/VLCHUDOutlineView.h gui/macosx/VLCHUDOutlineView.m \ + gui/macosx/VLCHUDTableCornerView.h gui/macosx/VLCHUDTableCornerView.m \ + gui/macosx/VLCHUDTableHeaderCell.h gui/macosx/VLCHUDTableHeaderCell.m \ gui/macosx/VLCInputManager.h gui/macosx/VLCInputManager.m \ gui/macosx/VLCMainWindow.h gui/macosx/VLCMainWindow.m \ gui/macosx/VLCRendererDiscovery.h gui/macosx/VLCRendererDiscovery.m \ diff --git a/modules/gui/macosx/VLCHUDOutlineView.h b/modules/gui/macosx/VLCHUDOutlineView.h new file mode 100644 index 0000000000..8e268f002d --- /dev/null +++ b/modules/gui/macosx/VLCHUDOutlineView.h @@ -0,0 +1,50 @@ +// +// VLCHUDOutlineView.h +// BGHUDAppKit +// +// Created by BinaryGod on 6/17/08. +// +// Copyright (c) 2008, Tim Davis (BinaryMethod.com, [email protected]) +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation and/or +// other materials provided with the distribution. +// +// Neither the name of the BinaryMethod.com nor the names of its contributors +// may be used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#import <Cocoa/Cocoa.h> + +@interface VLCHUDOutlineView : NSOutlineView + +@property (strong) NSColor *tableBackgroundColor; +@property (strong) NSArray *cellAlternatingRowColors; +@property (strong) NSColor *cellHighlightColor; +@property (strong) NSColor *cellEditingFillColor; +@property (strong) NSColor *cellTextColor; +@property (strong) NSColor *cellSelectedTextColor; +@property (strong) NSColor *strokeColor; + +@property (strong) NSGradient *highlightGradient; +@property (strong) NSGradient *normalGradient; + +@end diff --git a/modules/gui/macosx/VLCHUDOutlineView.m b/modules/gui/macosx/VLCHUDOutlineView.m new file mode 100644 index 0000000000..447b67eca2 --- /dev/null +++ b/modules/gui/macosx/VLCHUDOutlineView.m @@ -0,0 +1,117 @@ +// +// VLCHUDOutlineView.m +// BGHUDAppKit +// +// Created by BinaryGod on 6/17/08. +// +// Copyright (c) 2008, Tim Davis (BinaryMethod.com, [email protected]) +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation and/or +// other materials provided with the distribution. +// +// Neither the name of the BinaryMethod.com nor the names of its contributors +// may be used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#import "VLCHUDOutlineView.h" +#import "VLCHUDTableHeaderCell.h" +#import "VLCHUDTableCornerView.h" + +@interface NSOutlineView (private) +- (void)_sendDelegateWillDisplayCell:(id)cell forColumn:(id)column row:(NSInteger)row; +@end + +@implementation VLCHUDOutlineView + +#pragma mark Drawing Functions + +- (instancetype)initWithCoder:(NSCoder *)decoder +{ + + self = [super initWithCoder: decoder]; + + if (self) { + _tableBackgroundColor = [NSColor colorWithCalibratedRed:0 green:0 blue:0 alpha:0]; + _cellHighlightColor = [NSColor colorWithDeviceRed:0.549f green:0.561f blue:0.588f alpha:1]; + _cellEditingFillColor = [NSColor colorWithDeviceRed:0.141f green:0.141f blue:0.141f alpha:0.5f]; + _cellAlternatingRowColors = @[[NSColor colorWithCalibratedWhite:0.16f alpha:0.86f], + [NSColor colorWithCalibratedWhite:0.15f alpha:0.8f]]; + _cellTextColor = [NSColor whiteColor]; + _cellSelectedTextColor = [NSColor blackColor]; + _strokeColor = [NSColor colorWithDeviceRed:0.749f green:0.761f blue:0.788f alpha:1.0f]; + _highlightGradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.451f green:0.451f blue:0.455f alpha:0.5f] + endingColor:[NSColor colorWithDeviceRed:0.318f green:0.318f blue:0.318f alpha:0.5f]]; + _normalGradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.251f green:0.251f blue:0.255f alpha:0.5f] + endingColor:[NSColor colorWithDeviceRed:0.118f green:0.118f blue:0.118f alpha:0.5f]]; + + + [self setBackgroundColor:_tableBackgroundColor]; + [self setFocusRingType:NSFocusRingTypeNone]; + + // Setup Header Cells + for (NSTableColumn* aColumn in [self tableColumns]) { + + // Create new cell and set it's props to that of old cell + VLCHUDTableHeaderCell *newHeader = [[VLCHUDTableHeaderCell alloc] init]; + [newHeader setStringValue: [[aColumn headerCell] stringValue]]; + [newHeader setFont: [[aColumn headerCell] font]]; + + [aColumn setHeaderCell: newHeader]; + } + } + + return self; +} + +- (id)_alternatingRowBackgroundColors { + return _cellAlternatingRowColors; +} + +- (id)_highlightColorForCell:(id)cell { + return _cellHighlightColor; +} + +- (void)_sendDelegateWillDisplayCell:(id)cell forColumn:(id)column row:(NSInteger)row { + + [super _sendDelegateWillDisplayCell:cell forColumn:column row:row]; + + [[self currentEditor] setBackgroundColor:_cellEditingFillColor]; + [[self currentEditor] setTextColor:_cellTextColor]; + + if([[self selectedRowIndexes] containsIndex: row]) { + + if([cell respondsToSelector: @selector(setTextColor:)]) { + [cell setTextColor:_cellSelectedTextColor]; + } + } else { + + if ([cell respondsToSelector:@selector(setTextColor:)]) { + [cell setTextColor:_cellTextColor]; + } + } +} + +- (void)awakeFromNib { + [self setCornerView: [[VLCHUDTableCornerView alloc] init]]; +} + +@end diff --git a/modules/gui/macosx/VLCHUDTableCornerView.h b/modules/gui/macosx/VLCHUDTableCornerView.h new file mode 100644 index 0000000000..6f911abdc9 --- /dev/null +++ b/modules/gui/macosx/VLCHUDTableCornerView.h @@ -0,0 +1,42 @@ +// +// VLCHUDTableCornerView.h +// BGHUDAppKit +// +// Created by BinaryGod on 6/17/08. +// +// Copyright (c) 2008, Tim Davis (BinaryMethod.com, [email protected]) +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation and/or +// other materials provided with the distribution. +// +// Neither the name of the BinaryMethod.com nor the names of its contributors +// may be used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#import <Cocoa/Cocoa.h> + +@interface VLCHUDTableCornerView : NSView + +@property (strong) NSColor *tableHeaderCellBorderColor; +@property (strong) NSGradient *tableHeaderCellNormalFill; + +@end diff --git a/modules/gui/macosx/VLCHUDTableCornerView.m b/modules/gui/macosx/VLCHUDTableCornerView.m new file mode 100644 index 0000000000..37b79778f7 --- /dev/null +++ b/modules/gui/macosx/VLCHUDTableCornerView.m @@ -0,0 +1,59 @@ +// +// VLCHUDTableCornerView.m +// BGHUDAppKit +// +// Created by BinaryGod on 6/17/08. +// +// Copyright (c) 2008, Tim Davis (BinaryMethod.com, [email protected]) +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation and/or +// other materials provided with the distribution. +// +// Neither the name of the BinaryMethod.com nor the names of its contributors +// may be used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +#import "VLCHUDTableCornerView.h" + +@implementation VLCHUDTableCornerView + +- (instancetype)init +{ + self = [super init]; + + if (self) { + _tableHeaderCellBorderColor = [NSColor colorWithDeviceRed:0.349f green:0.361f blue:0.388f alpha:1.0f]; + _tableHeaderCellNormalFill = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.251f green:0.251f blue:0.255f alpha:1.0f] + endingColor:[NSColor colorWithDeviceRed:0.118f green:0.118f blue:0.118f alpha:1.0f]]; + } + return self; +} + +- (void)drawRect:(NSRect)dirtyRect { + + // Draw base layer + [_tableHeaderCellBorderColor set]; + NSRectFill([self bounds]); + + [_tableHeaderCellNormalFill drawInRect:NSInsetRect([self bounds], 1, 1) angle:270]; +} + +@end diff --git a/modules/gui/macosx/VLCHUDTableHeaderCell.h b/modules/gui/macosx/VLCHUDTableHeaderCell.h new file mode 100644 index 0000000000..36a2165736 --- /dev/null +++ b/modules/gui/macosx/VLCHUDTableHeaderCell.h @@ -0,0 +1,45 @@ +// +// VLCHUDTableHeaderCell.h +// BGHUDAppKit +// +// Created by BinaryGod on 6/17/08. +// +// Copyright (c) 2008, Tim Davis (BinaryMethod.com, [email protected]) +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation and/or +// other materials provided with the distribution. +// +// Neither the name of the BinaryMethod.com nor the names of its contributors +// may be used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#import <Cocoa/Cocoa.h> + +@interface VLCHUDTableHeaderCell : NSTableHeaderCell + +@property (strong) NSColor *cellTextColor; +@property (strong) NSColor *disabledCellTextColor; +@property (strong) NSColor *tableHeaderCellBorderColor; +@property (strong) NSGradient *tableHeaderCellNormalFill; +@property (strong) NSGradient *tableHeaderCellSelectedFill; + +@end diff --git a/modules/gui/macosx/VLCHUDTableHeaderCell.m b/modules/gui/macosx/VLCHUDTableHeaderCell.m new file mode 100644 index 0000000000..1161ef575e --- /dev/null +++ b/modules/gui/macosx/VLCHUDTableHeaderCell.m @@ -0,0 +1,146 @@ +// +// VLCHUDTableHeaderCell.m +// BGHUDAppKit +// +// Created by BinaryGod on 6/17/08. +// +// Copyright (c) 2008, Tim Davis (BinaryMethod.com, [email protected]) +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation and/or +// other materials provided with the distribution. +// +// Neither the name of the BinaryMethod.com nor the names of its contributors +// may be used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#import "VLCHUDTableHeaderCell.h" + +@interface NSTableHeaderCell (AppKitPrivate) +- (void)_drawSortIndicatorIfNecessaryWithFrame:(NSRect)arg1 inView:(id)arg2; +@end + +@implementation VLCHUDTableHeaderCell + +#pragma mark Drawing Functions + +- (instancetype)initWithCoder:(NSCoder *)coder +{ + self = [super initWithCoder:coder]; + if (self) { + _cellTextColor = [NSColor whiteColor]; + _disabledCellTextColor = [NSColor colorWithDeviceRed:1 green:1 blue:1 alpha:0.2f]; + _tableHeaderCellBorderColor = [NSColor colorWithDeviceRed:0.349f green:0.361f blue:0.388f alpha:1.0f]; + _tableHeaderCellNormalFill = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.251f green:0.251f blue:0.255f alpha:1.0f] + endingColor:[NSColor colorWithDeviceRed:0.118f green:0.118f blue:0.118f alpha:1.0f]]; + _tableHeaderCellSelectedFill = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.651f green:0.651f blue:0.655f alpha:1.0f] + endingColor:[NSColor colorWithDeviceRed:0.518f green:0.518f blue:0.518f alpha:1.0f]]; + } + return self; +} + +- (id)textColor { + + return _textColor; +} + +- (void)_drawThemeContents:(NSRect)frame highlighted:(BOOL)flag inView:(id)view { + + // Draw base layer + [_tableHeaderCellBorderColor set]; + NSRectFill(frame); + + // Adjust fill layer + // frame.origin.x += 1; - Removed to fix Issue #31 + frame.size.width -= 1; + frame.origin.y +=1; + frame.size.height -= 2; + + if(flag) { + [_tableHeaderCellSelectedFill drawInRect: frame angle: 90]; + } else { + [_tableHeaderCellNormalFill drawInRect: frame angle: 90]; + } + + // Adjust so text aligns correctly + frame.origin.x -= 1; + frame.size.width += 1; + frame.origin.y -= 1; + frame.size.height += 2; + + // REMOVED - Enabling this line draws two sort arrows, frame alignment issue here. + // Not needed since the Apple drawing routines seem to be updating sort + // arrows fine. + /*if ([self respondsToSelector:@selector(_drawSortIndicatorIfNecessaryWithFrame:inView:)]) + [super _drawSortIndicatorIfNecessaryWithFrame: frame inView: view];*/ + + frame.origin.y += (NSMidY(frame) - ([[self font] pointSize] /2)) - 2; + frame.origin.x += 3; + + + + [super drawInteriorWithFrame: frame inView: view]; +} + +- (void)drawSortIndicatorWithFrame:(NSRect) frame inView:(id) controlView ascending:(BOOL) ascFlag priority:(NSInteger) priInt { + + frame.origin.y -=1; + frame.size.height += 2; + + if (priInt == 0) { + + NSRect arrowRect = [self sortIndicatorRectForBounds: frame]; + + // Adjust Arrow rect + arrowRect.size.width -= 2; + arrowRect.size.height -= 1; + + NSBezierPath *arrow = [[NSBezierPath alloc] init]; + NSPoint points[3]; + + if (ascFlag == NO) { + // Re-center arrow + arrowRect.origin.y -= 2; + points[0] = NSMakePoint(NSMinX(arrowRect), NSMinY(arrowRect) +2); + points[1] = NSMakePoint(NSMaxX(arrowRect), NSMinY(arrowRect) +2); + points[2] = NSMakePoint(NSMidX(arrowRect), NSMaxY(arrowRect)); + } else { + points[0] = NSMakePoint(NSMinX(arrowRect), NSMaxY(arrowRect) -2); + points[1] = NSMakePoint(NSMaxX(arrowRect), NSMaxY(arrowRect) -2); + points[2] = NSMakePoint(NSMidX(arrowRect), NSMinY(arrowRect)); + } + + [arrow appendBezierPathWithPoints: points count: 3]; + + if ([self isEnabled]) { + [_cellTextColor set]; + } else { + [_disabledCellTextColor set]; + } + + [arrow fill]; + } + + frame.origin.y += 1; + frame.size.height -= 2; +} + +@end _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
