[vlc-devel] [PATCH] macosx: Add dark UI Elements for use on HUD Panels

epirat07 at gmail.com epirat07 at gmail.com
Tue Feb 9 16:35:12 CET 2016


From: Marvin Scholz <epirat07 at gmail.com>

This adds a dark Button, Checkbox, Radiobutton and Slider Cell
for use on dark HUD Panels (like the Audio and Video effects panels)
---
 .../package/macosx/vlc.xcodeproj/project.pbxproj   |  32 +++++
 modules/gui/macosx/Makefile.am                     |   6 +-
 modules/gui/macosx/VLCHUDButtonCell.h              |  37 +++++
 modules/gui/macosx/VLCHUDButtonCell.m              |  69 ++++++++++
 modules/gui/macosx/VLCHUDCheckboxCell.h            |  37 +++++
 modules/gui/macosx/VLCHUDCheckboxCell.m            | 103 ++++++++++++++
 modules/gui/macosx/VLCHUDRadiobuttonCell.h         |  33 +++++
 modules/gui/macosx/VLCHUDRadiobuttonCell.m         |  95 +++++++++++++
 modules/gui/macosx/VLCHUDSliderCell.h              |  43 ++++++
 modules/gui/macosx/VLCHUDSliderCell.m              | 152 +++++++++++++++++++++
 10 files changed, 606 insertions(+), 1 deletion(-)
 create mode 100644 modules/gui/macosx/VLCHUDButtonCell.h
 create mode 100644 modules/gui/macosx/VLCHUDButtonCell.m
 create mode 100644 modules/gui/macosx/VLCHUDCheckboxCell.h
 create mode 100644 modules/gui/macosx/VLCHUDCheckboxCell.m
 create mode 100644 modules/gui/macosx/VLCHUDRadiobuttonCell.h
 create mode 100644 modules/gui/macosx/VLCHUDRadiobuttonCell.m
 create mode 100644 modules/gui/macosx/VLCHUDSliderCell.h
 create mode 100644 modules/gui/macosx/VLCHUDSliderCell.m

diff --git a/extras/package/macosx/vlc.xcodeproj/project.pbxproj b/extras/package/macosx/vlc.xcodeproj/project.pbxproj
index 3f1122e..d4178ea 100644
--- a/extras/package/macosx/vlc.xcodeproj/project.pbxproj
+++ b/extras/package/macosx/vlc.xcodeproj/project.pbxproj
@@ -461,6 +461,10 @@
 		1CE5ED2619DD6AB700FCEFD3 /* lion-window-fullscreen at 2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1CE5ED2019DD6AB700FCEFD3 /* lion-window-fullscreen at 2x.png */; };
 		633121D01B5112C300E636DA /* ResumeDialog.xib in Resources */ = {isa = PBXBuildFile; fileRef = 633121CE1B5112C300E636DA /* ResumeDialog.xib */; };
 		6B13E2A81BC67678001AD24A /* VLCScrollingClipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B13E2A71BC67678001AD24A /* VLCScrollingClipView.m */; };
+		6B676C491C6A3E0200EF8093 /* VLCHUDButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B676C421C6A3E0200EF8093 /* VLCHUDButtonCell.m */; };
+		6B676C4A1C6A3E0200EF8093 /* VLCHUDCheckboxCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B676C441C6A3E0200EF8093 /* VLCHUDCheckboxCell.m */; };
+		6B676C4B1C6A3E0200EF8093 /* VLCHUDRadiobuttonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B676C461C6A3E0200EF8093 /* VLCHUDRadiobuttonCell.m */; };
+		6B676C4C1C6A3E0200EF8093 /* VLCHUDSliderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B676C481C6A3E0200EF8093 /* VLCHUDSliderCell.m */; };
 		7D3F6525188051F2005776C4 /* BWQuincyMain.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D3F6523188051F2005776C4 /* BWQuincyMain.xib */; };
 		7D8BB0B71830311300FAE9B7 /* DebugMessageVisualizer.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D8BB0B51830311300FAE9B7 /* DebugMessageVisualizer.xib */; };
 		7D8BB0BA1830367200FAE9B7 /* PlaylistMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D8BB0B81830367200FAE9B7 /* PlaylistMenu.xib */; };
@@ -1253,6 +1257,14 @@
 		633121CF1B5112C300E636DA /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/ResumeDialog.xib; sourceTree = "<group>"; };
 		6B13E2A61BC67678001AD24A /* VLCScrollingClipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCScrollingClipView.h; path = ../../../modules/gui/macosx/VLCScrollingClipView.h; sourceTree = "<group>"; };
 		6B13E2A71BC67678001AD24A /* VLCScrollingClipView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCScrollingClipView.m; path = ../../../modules/gui/macosx/VLCScrollingClipView.m; sourceTree = "<group>"; };
+		6B676C411C6A3E0200EF8093 /* VLCHUDButtonCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCHUDButtonCell.h; path = ../../../modules/gui/macosx/VLCHUDButtonCell.h; sourceTree = "<group>"; };
+		6B676C421C6A3E0200EF8093 /* VLCHUDButtonCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCHUDButtonCell.m; path = ../../../modules/gui/macosx/VLCHUDButtonCell.m; sourceTree = "<group>"; };
+		6B676C431C6A3E0200EF8093 /* VLCHUDCheckboxCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCHUDCheckboxCell.h; path = ../../../modules/gui/macosx/VLCHUDCheckboxCell.h; sourceTree = "<group>"; };
+		6B676C441C6A3E0200EF8093 /* VLCHUDCheckboxCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCHUDCheckboxCell.m; path = ../../../modules/gui/macosx/VLCHUDCheckboxCell.m; sourceTree = "<group>"; };
+		6B676C451C6A3E0200EF8093 /* VLCHUDRadiobuttonCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCHUDRadiobuttonCell.h; path = ../../../modules/gui/macosx/VLCHUDRadiobuttonCell.h; sourceTree = "<group>"; };
+		6B676C461C6A3E0200EF8093 /* VLCHUDRadiobuttonCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCHUDRadiobuttonCell.m; path = ../../../modules/gui/macosx/VLCHUDRadiobuttonCell.m; sourceTree = "<group>"; };
+		6B676C471C6A3E0200EF8093 /* VLCHUDSliderCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCHUDSliderCell.h; path = ../../../modules/gui/macosx/VLCHUDSliderCell.h; sourceTree = "<group>"; };
+		6B676C481C6A3E0200EF8093 /* VLCHUDSliderCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCHUDSliderCell.m; path = ../../../modules/gui/macosx/VLCHUDSliderCell.m; sourceTree = "<group>"; };
 		7D3F6524188051F2005776C4 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/BWQuincyMain.xib; sourceTree = "<group>"; };
 		7D3F652618805297005776C4 /* BWQuincyManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = BWQuincyManager.h; path = ../../../modules/gui/macosx/BWQuincyManager.h; sourceTree = SOURCE_ROOT; };
 		7D3F652718805297005776C4 /* BWQuincyManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = BWQuincyManager.m; path = ../../../modules/gui/macosx/BWQuincyManager.m; sourceTree = SOURCE_ROOT; };
@@ -1931,6 +1943,7 @@
 				E0C2583F161B593D00185AAD /* VLCVoutWindowController.m */,
 				E06CF7F416020F6200C698B7 /* Windows.h */,
 				E06CF7F516020F6200C698B7 /* Windows.m */,
+				6B676C4D1C6A3E0A00EF8093 /* Custom UI Classes */,
 				CC0CD0E513DE0FC600B0D90D /* Imported Code */,
 			);
 			name = Classes;
@@ -2353,6 +2366,21 @@
 			path = "Resources/fspanel-yosemite";
 			sourceTree = "<group>";
 		};
+		6B676C4D1C6A3E0A00EF8093 /* Custom UI Classes */ = {
+			isa = PBXGroup;
+			children = (
+				6B676C411C6A3E0200EF8093 /* VLCHUDButtonCell.h */,
+				6B676C421C6A3E0200EF8093 /* VLCHUDButtonCell.m */,
+				6B676C431C6A3E0200EF8093 /* VLCHUDCheckboxCell.h */,
+				6B676C441C6A3E0200EF8093 /* VLCHUDCheckboxCell.m */,
+				6B676C451C6A3E0200EF8093 /* VLCHUDRadiobuttonCell.h */,
+				6B676C461C6A3E0200EF8093 /* VLCHUDRadiobuttonCell.m */,
+				6B676C471C6A3E0200EF8093 /* VLCHUDSliderCell.h */,
+				6B676C481C6A3E0200EF8093 /* VLCHUDSliderCell.m */,
+			);
+			name = "Custom UI Classes";
+			sourceTree = "<group>";
+		};
 		7D3F652A1880529C005776C4 /* QuincyKit */ = {
 			isa = PBXGroup;
 			children = (
@@ -3894,6 +3922,7 @@
 				1CCB5F521A62A724004C3E90 /* about.m in Sources */,
 				1CCB5F531A62A724004C3E90 /* AddonListDataSource.h in Sources */,
 				1CCB5F541A62A724004C3E90 /* AddonListDataSource.m in Sources */,
+				6B676C491C6A3E0200EF8093 /* VLCHUDButtonCell.m in Sources */,
 				1CCB5F551A62A724004C3E90 /* AddonsWindowController.h in Sources */,
 				1CCB5F561A62A724004C3E90 /* AddonsWindowController.m in Sources */,
 				1CCB5F571A62A724004C3E90 /* applescript.h in Sources */,
@@ -3905,6 +3934,7 @@
 				1CCB5F5C1A62A724004C3E90 /* bookmarks.m in Sources */,
 				1CCB5F5D1A62A724004C3E90 /* CompatibilityFixes.h in Sources */,
 				1CCB5F601A62A724004C3E90 /* ControlsBar.h in Sources */,
+				6B676C4C1C6A3E0200EF8093 /* VLCHUDSliderCell.m in Sources */,
 				1CCB5F611A62A724004C3E90 /* ControlsBar.m in Sources */,
 				1CCB5F621A62A724004C3E90 /* ConvertAndSave.h in Sources */,
 				1CCB5F631A62A724004C3E90 /* ConvertAndSave.m in Sources */,
@@ -3947,6 +3977,7 @@
 				1CCB5F851A62A724004C3E90 /* SharedDialogs.h in Sources */,
 				1CCB5F861A62A724004C3E90 /* SharedDialogs.m in Sources */,
 				1CCB5F871A62A724004C3E90 /* simple_prefs.h in Sources */,
+				6B676C4A1C6A3E0200EF8093 /* VLCHUDCheckboxCell.m in Sources */,
 				1CCB5F881A62A724004C3E90 /* simple_prefs.m in Sources */,
 				1CCB5F891A62A724004C3E90 /* StringUtility.h in Sources */,
 				1CCB5F8A1A62A724004C3E90 /* StringUtility.m in Sources */,
@@ -3968,6 +3999,7 @@
 				1CCB5F9C1A62A724004C3E90 /* MainWindowTitle.m in Sources */,
 				1CCB5F9D1A62A724004C3E90 /* BWQuincyManager.h in Sources */,
 				1CCB5F9E1A62A724004C3E90 /* BWQuincyManager.m in Sources */,
+				6B676C4B1C6A3E0200EF8093 /* VLCHUDRadiobuttonCell.m in Sources */,
 				1CCB5F9F1A62A724004C3E90 /* BWQuincyUI.h in Sources */,
 				1CCB5FA01A62A724004C3E90 /* BWQuincyUI.m in Sources */,
 				1CCB5FA11A62A724004C3E90 /* AppleRemote.h in Sources */,
diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
index 2c5d48a..ed5e76a 100644
--- a/modules/gui/macosx/Makefile.am
+++ b/modules/gui/macosx/Makefile.am
@@ -76,4 +76,8 @@ libmacosx_plugin_la_SOURCES = \
 	VLCScrollingClipView.h VLCScrollingClipView.m \
 	VLCStatusBarIcon.h VLCStatusBarIcon.m \
 	VLCVoutWindowController.h VLCVoutWindowController.m \
-	Windows.h Windows.m
+	Windows.h Windows.m \
+	VLCHUDSliderCell.h VLCHUDSliderCell.m \
+	VLCHUDButtonCell.h VLCHUDButtonCell.m \
+	VLCHUDCheckboxCell.h VLCHUDCheckboxCell.m \
+	VLCHUDRadiobuttonCell.h VLCHUDRadiobuttonCell.m
diff --git a/modules/gui/macosx/VLCHUDButtonCell.h b/modules/gui/macosx/VLCHUDButtonCell.h
new file mode 100644
index 0000000..cceded2
--- /dev/null
+++ b/modules/gui/macosx/VLCHUDButtonCell.h
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * VLCHUDButtonCell.h: Custom button cell UI for dark HUD Panels
+ *****************************************************************************
+ * Copyright (C) 2016 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Marvin Scholz <epirat07 -at- gmail -dot- com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+/* Custom subclass that provides a dark NSButtonCell for HUD Panels.
+ *
+ * It does NOT support checkboxes or radio buttons,
+ * use VLCHUDCheckboxCell and VLCHUDRadiobuttonCell instead.
+ */
+ at interface VLCHUDButtonCell : NSButtonCell
+
+ at property NSGradient *normalGradient;
+ at property NSGradient *highlightGradient;
+ at property NSGradient *pushedGradient;
+
+ at end
diff --git a/modules/gui/macosx/VLCHUDButtonCell.m b/modules/gui/macosx/VLCHUDButtonCell.m
new file mode 100644
index 0000000..bf9670d
--- /dev/null
+++ b/modules/gui/macosx/VLCHUDButtonCell.m
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * VLCHUDButtonCell.m: Custom button cell UI for dark HUD Panels
+ *****************************************************************************
+ * Copyright (C) 2016 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Marvin Scholz <epirat07 -at- gmail -dot- com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "VLCHUDButtonCell.h"
+
+ at implementation VLCHUDButtonCell
+
+- (instancetype) initWithCoder:(NSCoder *)coder
+{
+    self = [super initWithCoder:coder];
+    if (self) {
+        _normalGradient    = [[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]];
+        _highlightGradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.451f green:0.451f blue:0.455f alpha:1.0f]
+                                                           endingColor:[NSColor colorWithDeviceRed:0.318f green:0.318f blue:0.318f alpha:1.0f]];
+        _pushedGradient    = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.451f green:0.451f blue:0.455f alpha:1.0f]
+                                                           endingColor:[NSColor colorWithDeviceRed:0.318f green:0.318f blue:0.318f alpha:1.0f]];
+    }
+    return self;
+}
+
+- (void) drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView
+{
+    NSLog(@"Bezel style: %lu", self.bezelStyle);
+    // Set frame to the correct size
+    frame.size.height = self.cellSize.height;
+    // Inset rect to have enough room for the stroke
+    frame = NSInsetRect(frame, 1, 1);
+    if (self.bezelStyle == NSRoundRectBezelStyle) {
+        [self drawRoundRectButtonBezelInRect:frame];
+    } else {
+        [super drawBezelWithFrame:frame inView:controlView];
+    }
+}
+
+- (void) drawRoundRectButtonBezelInRect:(NSRect)rect
+{
+    NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:8.0 yRadius:8.0];
+    if (self.highlighted) {
+        [_normalGradient drawInBezierPath:path angle:90.0f];
+    } else {
+        [_pushedGradient drawInBezierPath:path angle:90.0f];
+    }
+    [[NSColor colorWithCalibratedWhite:1.0 alpha:1.0] setStroke];
+    [path setLineWidth:0.5];
+    [path stroke];
+}
+
+ at end
diff --git a/modules/gui/macosx/VLCHUDCheckboxCell.h b/modules/gui/macosx/VLCHUDCheckboxCell.h
new file mode 100644
index 0000000..59c0e62
--- /dev/null
+++ b/modules/gui/macosx/VLCHUDCheckboxCell.h
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * VLCHUDCheckboxCell.h: Custom checkbox cell UI for dark HUD Panels
+ *****************************************************************************
+ * Copyright (C) 2016 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Marvin Scholz <epirat07 -at- gmail -dot- com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+/* Custom subclass that provides a dark NSButtonCell Checkbox style for HUD Panels.
+ *
+ * It is not possible to get from the coder if we are a checkbox or radio button
+ * that's why this class exists, so that it can be set easily in Interface Builder.
+ */
+ at interface VLCHUDCheckboxCell : NSButtonCell
+
+ at property NSGradient *normalGradient;
+ at property NSGradient *highlightGradient;
+ at property NSGradient *pushedGradient;
+
+ at end
diff --git a/modules/gui/macosx/VLCHUDCheckboxCell.m b/modules/gui/macosx/VLCHUDCheckboxCell.m
new file mode 100644
index 0000000..af1056a
--- /dev/null
+++ b/modules/gui/macosx/VLCHUDCheckboxCell.m
@@ -0,0 +1,103 @@
+/*****************************************************************************
+ * VLCHUDCheckboxCell.m: Custom checkbox cell UI for dark HUD Panels
+ *****************************************************************************
+ * Copyright (C) 2016 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Marvin Scholz <epirat07 -at- gmail -dot- com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "VLCHUDCheckboxCell.h"
+
+ at implementation VLCHUDCheckboxCell
+
+- (instancetype) initWithCoder:(NSCoder *)coder
+{
+    self = [super initWithCoder:coder];
+    if (self) {
+        _normalGradient    = [[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]];
+        _highlightGradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.451f green:0.451f blue:0.455f alpha:1.0f]
+                                                           endingColor:[NSColor colorWithDeviceRed:0.318f green:0.318f blue:0.318f alpha:1.0f]];
+        _pushedGradient    = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.451f green:0.451f blue:0.455f alpha:1.0f]
+                                                           endingColor:[NSColor colorWithDeviceRed:0.318f green:0.318f blue:0.318f alpha:1.0f]];
+    }
+    return self;
+}
+
+- (void) drawImage:(NSImage *)image withFrame:(NSRect)frame inView:(NSView *)controlView
+{
+    // Set frame size correctly
+    NSRect backgroundFrame = frame;
+    if (self.controlSize == NSSmallControlSize) {
+        frame.origin.x += 4;
+        frame.origin.y += 2.5;
+        frame.size.width -= 5;
+        frame.size.height -= 5;
+        backgroundFrame = NSInsetRect(frame, 1.5, 1.5);
+    } else if (self.controlSize == NSMiniControlSize) {
+        frame.origin.x += 2.5;
+        frame.origin.y += 4;
+        frame.size.width -= 5;
+        frame.size.height -= 5;
+        backgroundFrame = NSInsetRect(frame, 2, 2);
+    }
+
+    // Set fill frame
+    NSBezierPath *backgroundPath = [NSBezierPath bezierPathWithRoundedRect:backgroundFrame
+                                                                   xRadius:2
+                                                                   yRadius:2];
+
+    // Draw border and background
+    [NSColor.whiteColor setStroke];
+    [backgroundPath setLineWidth:1];
+    [backgroundPath stroke];
+
+    if([self isEnabled]) {
+        [_normalGradient drawInBezierPath:backgroundPath angle:90.0];
+    } else {
+        [[NSColor lightGrayColor] setFill];
+        NSRectFill(backgroundFrame);
+    }
+
+    // Drawing inner contents
+    //NSRect fillFrame = NSInsetRect(frame, 4, 4);
+    if([self isHighlighted]) {
+
+        //[[NSColor colorWithCalibratedWhite:0.9f alpha:1.0f] setFill];
+    } else {
+        //[[NSColor colorWithCalibratedWhite:0.8f alpha:1.0f] setFill];
+    }
+    //NSRectFill(fillFrame);
+
+    // Now drawing tick
+    if ([self intValue]) {
+        if([self isEnabled]) {
+            NSBezierPath* bezierPath = [NSBezierPath bezierPath];
+            [bezierPath moveToPoint: NSMakePoint(NSMinX(frame) + 3.0, NSMidY(frame) - 2.0)];
+            [bezierPath lineToPoint: NSMakePoint(NSMidX(frame), NSMidY(frame) + 2.0)];
+            [bezierPath lineToPoint: NSMakePoint((NSMinX(frame) + NSWidth(frame) - 1), NSMinY(frame) - 2.0)];
+            [bezierPath setLineWidth: 1.5];
+            [bezierPath stroke];
+        } else {
+            //[[NSColor blackColor] setFill];
+        }
+        //NSRectFill(NSInsetRect(frame, 6, 6));
+    }
+}
+
+ at end
diff --git a/modules/gui/macosx/VLCHUDRadiobuttonCell.h b/modules/gui/macosx/VLCHUDRadiobuttonCell.h
new file mode 100644
index 0000000..4f1d4d0
--- /dev/null
+++ b/modules/gui/macosx/VLCHUDRadiobuttonCell.h
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * VLCHUDRadiobuttonCell.h: Custom radiobutton cell UI for dark HUD Panels
+ *****************************************************************************
+ * Copyright (C) 2016 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Marvin Scholz <epirat07 -at- gmail -dot- com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+ at interface VLCHUDRadiobuttonCell : NSButtonCell
+
+ at property NSGradient *normalGradient;
+ at property NSGradient *highlightGradient;
+ at property NSGradient *pushedGradient;
+ at property NSColor    *textColor;
+
+ at end
diff --git a/modules/gui/macosx/VLCHUDRadiobuttonCell.m b/modules/gui/macosx/VLCHUDRadiobuttonCell.m
new file mode 100644
index 0000000..68290bf
--- /dev/null
+++ b/modules/gui/macosx/VLCHUDRadiobuttonCell.m
@@ -0,0 +1,95 @@
+/*****************************************************************************
+ * VLCHUDRadiobuttonCell.m: Custom radiobutton cell UI for dark HUD Panels
+ *****************************************************************************
+ * Copyright (C) 2016 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Marvin Scholz <epirat07 -at- gmail -dot- com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "VLCHUDRadiobuttonCell.h"
+
+ at implementation VLCHUDRadiobuttonCell
+
+- (instancetype) initWithCoder:(NSCoder *)coder
+{
+    self = [super initWithCoder:coder];
+    if (self) {
+        _normalGradient    = [[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]];
+        _highlightGradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.451f green:0.451f blue:0.455f alpha:1.0f]
+                                                           endingColor:[NSColor colorWithDeviceRed:0.318f green:0.318f blue:0.318f alpha:1.0f]];
+        _pushedGradient    = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.451f green:0.451f blue:0.455f alpha:1.0f]
+                                                           endingColor:[NSColor colorWithDeviceRed:0.318f green:0.318f blue:0.318f alpha:1.0f]];
+        _textColor         = [NSColor whiteColor];
+    }
+    return self;
+}
+
+- (void) drawImage:(NSImage *)image withFrame:(NSRect)frame inView:(NSView *)controlView
+{
+    // Set text color
+    NSMutableAttributedString *colorTitle = [[NSMutableAttributedString alloc] initWithAttributedString:self.attributedTitle];
+    NSRange titleRange = NSMakeRange(0, [colorTitle length]);
+    [colorTitle addAttribute:NSForegroundColorAttributeName value:_textColor range:titleRange];
+    [self setAttributedTitle:colorTitle];
+
+    // Set frame size correctly
+    NSRect backgroundFrame = frame;
+    NSRect innerFrame = frame;
+    if (self.controlSize == NSSmallControlSize) {
+        frame.origin.x += 3.5;
+        frame.origin.y += 4;
+        frame.size.width -= 7;
+        frame.size.height -= 7;
+        innerFrame = NSInsetRect(frame, 2, 2);
+    } else if (self.controlSize == NSMiniControlSize) {
+        frame.origin.x += 2;
+        frame.origin.y += 4;
+        frame.size.width -= 6.5;
+        frame.size.height -= 6.5;
+        innerFrame = NSInsetRect(frame, 4, 4);
+    }
+
+    // Set fill frame
+    NSBezierPath *backgroundPath = [NSBezierPath bezierPathWithOvalInRect:frame];
+
+    // Draw border and background
+    [NSColor.whiteColor setStroke];
+    [backgroundPath setLineWidth:1.5];
+    [backgroundPath stroke];
+
+    if ([self isEnabled]) {
+        if ([self isHighlighted]) {
+            [_normalGradient drawInBezierPath:backgroundPath angle:90.0];
+        } else {
+            [_pushedGradient drawInBezierPath:backgroundPath angle:90.0];
+        }
+    } else {
+        [[NSColor lightGrayColor] setFill];
+        [backgroundPath fill];
+    }
+
+    // Draw dot
+    if ([self integerValue] && [self isEnabled]) {
+        NSBezierPath* bezierPath = [NSBezierPath bezierPathWithOvalInRect:innerFrame];
+        [[NSColor whiteColor] setFill];
+        [bezierPath fill];
+    }
+}
+
+ at end
diff --git a/modules/gui/macosx/VLCHUDSliderCell.h b/modules/gui/macosx/VLCHUDSliderCell.h
new file mode 100644
index 0000000..e0271f3
--- /dev/null
+++ b/modules/gui/macosx/VLCHUDSliderCell.h
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * VLCHUDSliderCell.h: Custom slider cell UI for dark HUD Panels
+ *****************************************************************************
+ * Copyright (C) 2016 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Marvin Scholz <epirat07 -at- gmail -dot- com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+
+/* Custom subclass that provides a dark NSSliderCell for HUD Panels.
+ *
+ * It does NOT support circular sliders, only horizontal and vertical
+ * sliders with and without tickmarks are supported!
+ * The size used should be "Mini" or "Small".
+ */
+ at interface VLCHUDSliderCell : NSSliderCell
+
+ at property NSColor       *sliderColor;
+ at property NSColor       *disabledSliderColor;
+ at property NSColor       *strokeColor;
+ at property NSColor       *disabledStrokeColor;
+
+ at property NSGradient    *knobGradient;
+ at property NSGradient    *disableKnobGradient;
+
+ at end
diff --git a/modules/gui/macosx/VLCHUDSliderCell.m b/modules/gui/macosx/VLCHUDSliderCell.m
new file mode 100644
index 0000000..e48d45c
--- /dev/null
+++ b/modules/gui/macosx/VLCHUDSliderCell.m
@@ -0,0 +1,152 @@
+/*****************************************************************************
+ * VLCHUDSliderCell.m: Custom slider cell UI for dark HUD Panels
+ *****************************************************************************
+ * Copyright (C) 2016 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Marvin Scholz <epirat07 -at- gmail -dot- com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "VLCHUDSliderCell.h"
+
+ at implementation VLCHUDSliderCell
+
+
+- (instancetype)initWithCoder:(NSCoder *)coder
+{
+    self = [super initWithCoder:coder];
+    if (self) {
+        // Custom colors for the slider
+        _sliderColor            = [NSColor colorWithCalibratedRed:0.318 green:0.318 blue:0.318 alpha:0.6];
+        _disabledSliderColor    = [NSColor colorWithCalibratedRed:0.318 green:0.318 blue:0.318 alpha:0.2];
+        _strokeColor            = [NSColor colorWithCalibratedRed:0.749 green:0.761 blue:0.788 alpha:1.0];
+        _disabledStrokeColor    = [NSColor colorWithCalibratedRed:0.749 green:0.761 blue:0.788 alpha:0.2];
+
+
+        // Custom knob gradients
+        _knobGradient           = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.251 green:0.251 blue:0.255 alpha:1.0]
+                                                                endingColor:[NSColor colorWithDeviceRed:0.118 green:0.118 blue:0.118 alpha:1.0]];
+        _disableKnobGradient    = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.251 green:0.251 blue:0.255 alpha:1.0]
+                                                                endingColor:[NSColor colorWithDeviceRed:0.118 green:0.118 blue:0.118 alpha:1.0]];
+    }
+    return self;
+}
+
+NSAffineTransform* RotationTransform(const CGFloat angle, const NSPoint point)
+{
+    NSAffineTransform*	transform = [NSAffineTransform transform];
+    [transform translateXBy:point.x yBy:point.y];
+    [transform rotateByRadians:angle];
+    [transform translateXBy:-(point.x) yBy:-(point.y)];
+    return transform;
+}
+
+- (void) drawKnob:(NSRect)smallRect
+{
+    NSBezierPath *path = [NSBezierPath bezierPath];
+    // Inset rect to have enough room for the stroke
+    smallRect = NSInsetRect(smallRect, 0.5, 0.5);
+
+    // Get min/max/mid coords for shape calculations
+    CGFloat minX = NSMinX(smallRect);
+    CGFloat minY = NSMinY(smallRect);
+    CGFloat maxX = NSMaxX(smallRect);
+    CGFloat maxY = NSMaxY(smallRect);
+    CGFloat midX = NSMidX(smallRect);
+    CGFloat midY = NSMidY(smallRect);
+
+    // Draw the knobs shape
+    if (self.numberOfTickMarks > 0) {
+        // We have tickmarks, draw an arrow-like shape
+        if (self.isVertical) {
+            // For some reason the rect is not alligned correctly at
+            // tickmarks and clipped, so this ugly thing is necessary:
+            maxY = maxY - 2;
+            midY = midY - 1;
+
+            // Right pointing arrow
+            [path moveToPoint:NSMakePoint(minX + 3, minY)];
+            [path lineToPoint:NSMakePoint(midX + 2, minY)];
+            [path lineToPoint:NSMakePoint(maxX, midY)];
+            [path lineToPoint:NSMakePoint(midX + 2, maxY)];
+            [path lineToPoint:NSMakePoint(minX + 3, maxY)];
+            [path appendBezierPathWithArcFromPoint:NSMakePoint(minX, maxY)
+                                           toPoint:NSMakePoint(minX, maxY - 3)
+                                            radius:2.5f];
+            [path lineToPoint:NSMakePoint(minX, maxY - 3)];
+            [path lineToPoint:NSMakePoint(minX, minY + 3)];
+            [path appendBezierPathWithArcFromPoint:NSMakePoint(minX, minY)
+                                           toPoint:NSMakePoint(minX + 3, minY)
+                                            radius:2.5f];
+            [path closePath];
+        } else {
+            // Down pointing arrow
+            [path moveToPoint:NSMakePoint(minX + 3, minY)];
+            [path lineToPoint:NSMakePoint(maxX - 3, minY)];
+            [path appendBezierPathWithArcFromPoint:NSMakePoint(maxX, minY)
+                                           toPoint:NSMakePoint(maxX, minY + 3)
+                                            radius:2.5f];
+            [path lineToPoint:NSMakePoint(maxX, minY + 3)];
+            [path lineToPoint:NSMakePoint(maxX, midY + 2)];
+            [path lineToPoint:NSMakePoint(midX, maxY)];
+            [path lineToPoint:NSMakePoint(minX, midY + 2)];
+            [path lineToPoint:NSMakePoint(minX, minY + 3)];
+            [path appendBezierPathWithArcFromPoint:NSMakePoint(minX, minY)
+                                           toPoint:NSMakePoint(minX + 3, minY)
+                                            radius:2.5f];
+            [path closePath];
+        }
+
+        // Rotate our knob if needed to the correct position
+        if (self.tickMarkPosition == NSTickMarkAbove) {
+            NSAffineTransform *transform = nil;
+            transform = RotationTransform(M_PI, NSMakePoint(midX, midY));
+            [path transformUsingAffineTransform:transform];
+        }
+    } else {
+        // We have no tickmarks, draw a round knob
+        [path appendBezierPathWithOvalInRect:NSInsetRect(smallRect, 0.5, 0.5)];
+    }
+
+    // Draw the knobs background
+    if (self.isEnabled && self.isHighlighted) {
+        [_knobGradient drawInBezierPath:path angle:270.0f];
+    } else if (self.isEnabled) {
+        [_knobGradient drawInBezierPath:path angle:90.0f];
+    } else {
+        [_disableKnobGradient drawInBezierPath:path angle:90.0f];
+    }
+
+    // Draw white stroke around the knob
+    if (self.isEnabled) {
+        [_strokeColor setStroke];
+    } else {
+        [_disabledStrokeColor setStroke];
+    }
+
+    [path setLineWidth:0.5f];
+    [path stroke];
+}
+
+/*
+- (void) drawFocusRingMaskWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
+{
+
+}
+*/
+
+ at end
-- 
2.2.1




More information about the vlc-devel mailing list