vlc | branch: master | Felix Paul Kühne <fe...@feepk.net> | Sun Nov  3 18:44:36 
2019 +0100| [bcef1373d83e76e094aa4474a24b918cf1c08fa9] | committer: Felix Paul 
Kühne

macosx/image view: add API to disable rounded corner masking

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bcef1373d83e76e094aa4474a24b918cf1c08fa9
---

 modules/gui/macosx/views/VLCImageView.h |  1 +
 modules/gui/macosx/views/VLCImageView.m | 22 +++++++++++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/modules/gui/macosx/views/VLCImageView.h 
b/modules/gui/macosx/views/VLCImageView.h
index 4008d299da..9bb3094f04 100644
--- a/modules/gui/macosx/views/VLCImageView.h
+++ b/modules/gui/macosx/views/VLCImageView.h
@@ -41,6 +41,7 @@ typedef NS_ENUM(NSInteger, VLCImageViewContentGravity) {
 
 @property (readwrite, retain, nonatomic, nullable) NSImage *image;
 @property (readwrite) VLCImageViewContentGravity contentGravity;
+@property (readwrite) BOOL cropsImagesToRoundedCorners;
 
 - (void)setImageURL:(NSURL * _Nonnull)url placeholderImage:(NSImage * 
_Nullable)image;
 
diff --git a/modules/gui/macosx/views/VLCImageView.m 
b/modules/gui/macosx/views/VLCImageView.m
index bd4184cbfd..53294a0c2e 100644
--- a/modules/gui/macosx/views/VLCImageView.m
+++ b/modules/gui/macosx/views/VLCImageView.m
@@ -49,12 +49,28 @@
     self.layer = [[CALayer alloc] init];
     self.contentGravity = VLCImageViewContentGravityResizeAspectFill;
     self.wantsLayer = YES;
-    self.layer.cornerRadius = 5.;
-    self.layer.masksToBounds = YES;
-    self.layer.borderWidth = 1.;
+    [self setCropsImagesToRoundedCorners:YES];
     [self setupBorderColor];
 }
 
+- (void)setCropsImagesToRoundedCorners:(BOOL)cropsImagesToRoundedCorners
+{
+    if (cropsImagesToRoundedCorners) {
+        self.layer.cornerRadius = 5.;
+        self.layer.masksToBounds = YES;
+        self.layer.borderWidth = 1.;
+    } else {
+        self.layer.cornerRadius = 0.;
+        self.layer.masksToBounds = NO;
+        self.layer.borderWidth = 0.;
+    }
+}
+
+- (BOOL)cropsImagesToRoundedCorners
+{
+    return self.layer.masksToBounds;
+}
+
 - (void)setupBorderColor
 {
     self.layer.borderColor = self.shouldShowDarkAppearance ? [NSColor 
VLClibrarySeparatorDarkColor].CGColor : [NSColor 
VLClibrarySeparatorLightColor].CGColor;

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to