macosx: Make darkest gradient colour for main video view overlay view settable

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
This commit is contained in:
Claudio Cambra 2024-05-12 23:17:05 +02:00 committed by Steve Lhomme
parent b78d3018dd
commit 05236fc07b
2 changed files with 15 additions and 10 deletions

View File

@ -29,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface VLCMainVideoViewOverlayView : NSView
@property (readwrite, assign) BOOL drawGradientForTopControls;
@property (readwrite, strong) NSColor *darkestGradientColor;
@end

View File

@ -22,24 +22,28 @@
#import "VLCMainVideoViewOverlayView.h"
@implementation VLCMainVideoViewOverlayView
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
- (void)awakeFromNib
{
self.darkestGradientColor = [NSColor colorWithCalibratedWhite:0 alpha:0.4];
}
// Drawing code here.
NSColor *_darkestGradientColor = [NSColor colorWithWhite:0 alpha:0.4];
- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];
NSGradient *gradient;
if (_drawGradientForTopControls) {
gradient = [[NSGradient alloc] initWithColorsAndLocations:_darkestGradientColor, 0.,
[NSColor clearColor], 0.5,
_darkestGradientColor, 1.,
if (self.drawGradientForTopControls) {
gradient = [[NSGradient alloc] initWithColorsAndLocations:self.darkestGradientColor, 0.,
NSColor.clearColor, 0.5,
self.darkestGradientColor, 1.,
nil];
} else {
gradient = [[NSGradient alloc] initWithColorsAndLocations:_darkestGradientColor, 0,
[NSColor clearColor], 1.,
gradient = [[NSGradient alloc] initWithColorsAndLocations:self.darkestGradientColor, 0.,
NSColor.clearColor, 1.,
nil];
}