[vlc-commits] macOS: Correct colors of VLCHUDCheckboxCell
Marvin Scholz
git at videolan.org
Wed Jun 21 00:35:39 CEST 2017
vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Wed Jun 21 00:18:12 2017 +0200| [388780a1c90cb261503eab0ddb58ec111380e986] | committer: Marvin Scholz
macOS: Correct colors of VLCHUDCheckboxCell
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=388780a1c90cb261503eab0ddb58ec111380e986
---
modules/gui/macosx/VLCHUDCheckboxCell.h | 6 ++++++
modules/gui/macosx/VLCHUDCheckboxCell.m | 32 ++++++++++++++++++++++++++++----
2 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/modules/gui/macosx/VLCHUDCheckboxCell.h b/modules/gui/macosx/VLCHUDCheckboxCell.h
index cc734c4311..77c3e67699 100644
--- a/modules/gui/macosx/VLCHUDCheckboxCell.h
+++ b/modules/gui/macosx/VLCHUDCheckboxCell.h
@@ -45,4 +45,10 @@
@property NSGradient *highlightGradient;
@property NSGradient *pushedGradient;
+ at property NSColor *cellTextColor;
+ at property NSColor *disabledCellTextColor;
+
+ at property NSColor *strokeColor;
+ at property NSColor *disabledStrokeColor;
+
@end
diff --git a/modules/gui/macosx/VLCHUDCheckboxCell.m b/modules/gui/macosx/VLCHUDCheckboxCell.m
index c9b7496e25..7ac23cc0cf 100644
--- a/modules/gui/macosx/VLCHUDCheckboxCell.m
+++ b/modules/gui/macosx/VLCHUDCheckboxCell.m
@@ -40,6 +40,13 @@
{
self = [super initWithCoder:coder];
if (self) {
+ /* Colors */
+ _cellTextColor = [NSColor whiteColor];
+ _disabledCellTextColor = [NSColor colorWithCalibratedWhite:1.0f alpha:0.5f];
+ _strokeColor = [NSColor whiteColor];
+ _disabledStrokeColor = [NSColor colorWithCalibratedWhite:1.0f alpha:0.5f];
+
+ /* Gradients */
_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]
@@ -80,9 +87,9 @@
} else {
[_normalGradient drawInBezierPath:backgroundPath angle:90.0];
}
- [[NSColor whiteColor] setStroke];
+ [_strokeColor setStroke];
} else {
- [[NSColor colorWithCalibratedWhite:0.25 alpha:1.0] setStroke];
+ [_disabledStrokeColor setStroke];
}
[backgroundPath setLineWidth:1.0];
@@ -97,12 +104,29 @@
[bezierPath setLineWidth: 1.5];
if([self isEnabled]) {
- [[NSColor whiteColor] setStroke];
+ [_strokeColor setStroke];
} else {
- [[NSColor colorWithCalibratedWhite:0.25 alpha:1.0] setStroke];
+ [_disabledStrokeColor setStroke];
}
[bezierPath stroke];
}
}
+- (NSRect)drawTitle:(NSAttributedString *)title withFrame:(NSRect)frame inView:(NSView *)controlView
+{
+ NSMutableAttributedString *newTitle = [title mutableCopy];
+
+ if([self isEnabled]) {
+ [newTitle addAttribute:NSForegroundColorAttributeName
+ value:_cellTextColor
+ range:NSMakeRange(0, [newTitle length])];
+ } else {
+ [newTitle addAttribute:NSForegroundColorAttributeName
+ value:_disabledCellTextColor
+ range:NSMakeRange(0, [newTitle length])];
+ }
+
+ return [super drawTitle: newTitle withFrame: frame inView: controlView];
+}
+
@end
More information about the vlc-commits
mailing list