[vlc-commits] [Git][videolan/vlc][master] macosx: Fix supplementary view arrow tip position and shape
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sun Sep 4 04:34:57 UTC 2022
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
2c76c045 by Claudio Cambra at 2022-09-04T04:10:04+00:00
macosx: Fix supplementary view arrow tip position and shape
Signed-off-by: Claudio Cambra <claudio.cambra at gmail.com>
- - - - -
3 changed files:
- modules/gui/macosx/library/VLCLibraryAudioDataSource.m
- modules/gui/macosx/library/VLCLibraryCollectionViewSupplementaryDetailView.h
- modules/gui/macosx/library/VLCLibraryCollectionViewSupplementaryDetailView.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryAudioDataSource.m
=====================================
@@ -396,7 +396,7 @@ viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
VLCMediaLibraryAlbum *album = _displayedCollection[indexPath.item];
albumSupplementaryDetailView.representedAlbum = album;
- albumSupplementaryDetailView.selectedItemFrame = [collectionView frameForItemAtIndex:indexPath.item];
+ albumSupplementaryDetailView.selectedItem = [collectionView itemAtIndex:indexPath.item];
return albumSupplementaryDetailView;
@@ -406,7 +406,7 @@ viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
id<VLCMediaLibraryAudioGroupProtocol> audioGroup = _displayedCollection[indexPath.item];
audioGroupSupplementaryDetailView.representedAudioGroup = audioGroup;
- audioGroupSupplementaryDetailView.selectedItemFrame = [collectionView frameForItemAtIndex:indexPath.item];
+ audioGroupSupplementaryDetailView.selectedItem = [collectionView itemAtIndex:indexPath.item];
return audioGroupSupplementaryDetailView;
}
=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewSupplementaryDetailView.h
=====================================
@@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface VLCLibraryCollectionViewSupplementaryDetailView : NSView <NSCollectionViewElement>
- at property (readwrite, assign) NSRect selectedItemFrame;
+ at property (readwrite, assign) NSCollectionViewItem *selectedItem;
@end
=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewSupplementaryDetailView.m
=====================================
@@ -40,25 +40,24 @@ static const CGFloat kBackgroundCornerRadius = 10.;
_arrowSize = NSMakeSize(kArrowWidth, kArrowHeight);
}
- NSPoint itemCenterPoint = NSMakePoint(NSMinX(_selectedItemFrame) + NSWidth(_selectedItemFrame) / 2,
- NSMinY(_selectedItemFrame) + NSHeight(_selectedItemFrame) / 2);
- NSRect backgroundRect = NSMakeRect(NSMinX(self.bounds),
- NSMinY(self.bounds), NSWidth(self.bounds) + 2,
- NSHeight(self.bounds) - _arrowSize.height);
- CGFloat backgroundTop = NSMaxY(backgroundRect);
- CGFloat backgroundLeft = NSMinX(backgroundRect);
-
- NSPoint arrowLeftPoint = NSMakePoint(itemCenterPoint.x - _arrowSize.width / 2, backgroundTop);
- NSPoint arrowTopPoint = NSMakePoint(itemCenterPoint.x, backgroundTop - 1);
- NSPoint arrowRightPoint = NSMakePoint(itemCenterPoint.x + _arrowSize.width / 2, backgroundTop);
-
- NSPoint topLeftCorner = NSMakePoint(backgroundLeft, backgroundTop);
- NSPoint topLeftCornerAfterCurve = NSMakePoint(backgroundLeft + kBackgroundCornerRadius, backgroundTop);
-
- NSBezierPath *backgroundPath = [NSBezierPath bezierPathWithRoundedRect:backgroundRect xRadius:kBackgroundCornerRadius yRadius:kBackgroundCornerRadius];
- backgroundPath.flatness = 1.0;
- backgroundPath.lineJoinStyle = NSLineJoinStyleRound;
- backgroundPath.lineWidth = 0.5;
+ const NSRect selectedItemFrame = _selectedItem.view.frame;
+
+ const NSPoint itemCenterPoint = NSMakePoint(NSMinX(selectedItemFrame) + NSWidth(selectedItemFrame) / 2,
+ NSMinY(selectedItemFrame) + NSHeight(selectedItemFrame) / 2);
+ const NSRect backgroundRect = NSMakeRect(NSMinX(self.bounds),
+ NSMinY(self.bounds), NSWidth(self.bounds) + 2,
+ NSHeight(self.bounds) - _arrowSize.height);
+ const CGFloat backgroundTop = NSMaxY(backgroundRect);
+ const CGFloat backgroundLeft = NSMinX(backgroundRect);
+
+ const NSPoint arrowLeftPoint = NSMakePoint(itemCenterPoint.x - _arrowSize.width / 2, backgroundTop);
+ const NSPoint arrowTopPoint = NSMakePoint(itemCenterPoint.x, backgroundTop + kArrowHeight - 1);
+ const NSPoint arrowRightPoint = NSMakePoint(itemCenterPoint.x + _arrowSize.width / 2, backgroundTop);
+
+ const NSPoint topLeftCorner = NSMakePoint(backgroundLeft, backgroundTop);
+ const NSPoint topLeftCornerAfterCurve = NSMakePoint(backgroundLeft + kBackgroundCornerRadius, backgroundTop);
+
+ const NSBezierPath *backgroundPath = [NSBezierPath bezierPathWithRoundedRect:backgroundRect xRadius:kBackgroundCornerRadius yRadius:kBackgroundCornerRadius];
[backgroundPath moveToPoint:topLeftCornerAfterCurve];
[backgroundPath lineToPoint:arrowLeftPoint];
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/2c76c045d9423f3fc9d5160460e6668c594d3960
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/2c76c045d9423f3fc9d5160460e6668c594d3960
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list