[vlc-commits] [Git][videolan/vlc][master] macosx: Add hover effect on star rating view

Marvin Scholz (@ePirat) gitlab at videolan.org
Fri Jul 11 18:40:48 UTC 2025



Marvin Scholz pushed to branch master at VideoLAN / VLC


Commits:
4ed95f35 by Bob Moriasi at 2025-07-11T18:15:20+00:00
macosx: Add hover effect on star rating view

- - - - -


5 changed files:

- extras/package/macosx/VLC.xcodeproj/project.pbxproj
- modules/gui/macosx/Makefile.am
- modules/gui/macosx/UI/VLCLibraryCollectionViewMediaItemSupplementaryDetailView.xib
- + modules/gui/macosx/views/VLCLibraryRatingIndicator.h
- + modules/gui/macosx/views/VLCLibraryRatingIndicator.m


Changes:

=====================================
extras/package/macosx/VLC.xcodeproj/project.pbxproj
=====================================
@@ -73,6 +73,7 @@
 		1CCC89052078A3D500E5626F /* TextfieldPanel.xib in Sources */ = {isa = PBXBuildFile; fileRef = 6B8224151E4D2A9000833BE1 /* TextfieldPanel.xib */; };
 		1CCC89062078A3D500E5626F /* TimeSelectionPanel.xib in Sources */ = {isa = PBXBuildFile; fileRef = 6B8224161E4D2A9000833BE1 /* TimeSelectionPanel.xib */; };
 		1CFE8D591EA0D42A00E94451 /* VLCErrorWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CFE8D581EA0D42A00E94451 /* VLCErrorWindowController.m */; };
+		3D46D70D2E1C023F00741E96 /* VLCLibraryRatingIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D46D70C2E1C023F00741E96 /* VLCLibraryRatingIndicator.m */; };
 		530771F42AEBBD5B00656D3D /* VLCLibraryRepresentedItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 530771F32AEBBD5B00656D3D /* VLCLibraryRepresentedItem.m */; };
 		5307A6F52967859F001E0C6A /* NSImage+VLCAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 5307A6F42967859F001E0C6A /* NSImage+VLCAdditions.m */; };
 		5307A6F82969904D001E0C6A /* VLCLibraryMediaSourceViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5307A6F72969904D001E0C6A /* VLCLibraryMediaSourceViewController.m */; };
@@ -299,6 +300,8 @@
 		1CFE8D561EA0D3D300E94451 /* ErrorPanel.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ErrorPanel.xib; sourceTree = "<group>"; };
 		1CFE8D571EA0D42A00E94451 /* VLCErrorWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCErrorWindowController.h; sourceTree = "<group>"; };
 		1CFE8D581EA0D42A00E94451 /* VLCErrorWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCErrorWindowController.m; sourceTree = "<group>"; };
+		3D46D70B2E1C023F00741E96 /* VLCLibraryRatingIndicator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryRatingIndicator.h; sourceTree = "<group>"; };
+		3D46D70C2E1C023F00741E96 /* VLCLibraryRatingIndicator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryRatingIndicator.m; sourceTree = "<group>"; };
 		530429942DD1ED66004BB598 /* VLCPlaybackEndView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = VLCPlaybackEndView.xib; sourceTree = "<group>"; };
 		530771F22AEBB80C00656D3D /* VLCLibraryRepresentedItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCLibraryRepresentedItem.h; sourceTree = "<group>"; };
 		530771F32AEBBD5B00656D3D /* VLCLibraryRepresentedItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryRepresentedItem.m; sourceTree = "<group>"; };
@@ -1143,6 +1146,8 @@
 		1C1ED5062204AB7C00811EC0 /* views */ = {
 			isa = PBXGroup;
 			children = (
+				3D46D70B2E1C023F00741E96 /* VLCLibraryRatingIndicator.h */,
+				3D46D70C2E1C023F00741E96 /* VLCLibraryRatingIndicator.m */,
 				5310AFB22B53EC4E00E75F9A /* iCarousel */,
 				536283FE291147C500640C15 /* VLCBasicView.h */,
 				536283FF291147C500640C15 /* VLCBasicView.m */,
@@ -2297,6 +2302,7 @@
 				1CCC89022078A3D500E5626F /* ResumeDialog.xib in Sources */,
 				531062162CE259290087F863 /* VLCLibraryHomeViewActionButtonCell.m in Sources */,
 				532572032C3D79D80068DEC3 /* VLCLibrarySegmentBookmarkedLocation.m in Sources */,
+				3D46D70D2E1C023F00741E96 /* VLCLibraryRatingIndicator.m in Sources */,
 				537040DF2DD848440030ABF5 /* VLCPlaybackEndViewController.m in Sources */,
 				7DE7232E22A51F8D00D72616 /* VLCPositionFormatter.m in Sources */,
 				534E8E3A29A06325009503F8 /* VLCMainVideoViewController.m in Sources */,


=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -427,6 +427,8 @@ libmacosx_plugin_la_SOURCES = \
 	gui/macosx/views/VLCImageButton.m \
 	gui/macosx/views/VLCImageView.h \
 	gui/macosx/views/VLCImageView.m \
+	gui/macosx/views/VLCLibraryRatingIndicator.h \
+	gui/macosx/views/VLCLibraryRatingIndicator.m \
 	gui/macosx/views/VLCLinearProgressIndicator.h \
 	gui/macosx/views/VLCLinearProgressIndicator.m \
 	gui/macosx/views/VLCLoadingOverlayView.h \


=====================================
modules/gui/macosx/UI/VLCLibraryCollectionViewMediaItemSupplementaryDetailView.xib
=====================================
@@ -278,7 +278,7 @@
                                         <stackView distribution="fill" orientation="vertical" alignment="leading" spacing="5" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="B2d-Zo-xAO">
                                             <rect key="frame" x="84" y="3" width="173" height="184"/>
                                             <subviews>
-                                                <levelIndicator verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="lYc-WP-hlc">
+                                                <levelIndicator verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="lYc-WP-hlc" customClass="VLCLibraryRatingIndicator">
                                                     <rect key="frame" x="0.0" y="168" width="60" height="16"/>
                                                     <levelIndicatorCell key="cell" editable="YES" alignment="left" doubleValue="5" maxValue="5" levelIndicatorStyle="rating" id="bi9-yf-v6w"/>
                                                     <color key="fillColor" name="systemYellowColor" catalog="System" colorSpace="catalog"/>


=====================================
modules/gui/macosx/views/VLCLibraryRatingIndicator.h
=====================================
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * VLCLibraryRatingIndicator.h
+ *****************************************************************************
+ * Copyright (C) 2025 VLC authors and VideoLAN
+ *
+ * Authors: Bob Moriasi <official.bobmoriasi at gmail.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>
+
+NS_ASSUME_NONNULL_BEGIN
+
+ at interface VLCLibraryRatingIndicator : NSLevelIndicator
+
+ at property (nonatomic) BOOL            isHovering;
+ at property (nonatomic) CGFloat         originalValue;
+ at property (nonatomic) NSTrackingArea *trackingArea;
+
+ at end
+
+NS_ASSUME_NONNULL_END


=====================================
modules/gui/macosx/views/VLCLibraryRatingIndicator.m
=====================================
@@ -0,0 +1,103 @@
+/*****************************************************************************
+ * VLCLibraryRatingIndicator.m
+ *****************************************************************************
+ * Copyright (C) 2025 VLC authors and VideoLAN
+ *
+ * Authors: Bob Moriasi <official.bobmoriasi at gmail.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 "VLCLibraryRatingIndicator.h"
+
+#import "vlc_common.h"
+
+ at implementation VLCLibraryRatingIndicator
+
+- (void)awakeFromNib
+{
+    [super awakeFromNib];
+    [self updateTrackingAreas];
+
+    self.originalValue = self.doubleValue;
+}
+
+- (void)mouseEntered:(NSEvent *)event
+{
+    [super mouseEntered:event];
+
+    self.isHovering = YES;
+    self.originalValue = self.doubleValue;
+}
+
+- (void)mouseExited:(NSEvent *)event
+{
+    [super mouseExited:event];
+
+    self.isHovering = NO;
+    self.doubleValue = self.originalValue;
+}
+
+- (void)mouseMoved:(NSEvent *)event
+{
+    [super mouseMoved:event];
+
+    if (self.isHovering) {
+        NSPoint locationInView = [self convertPoint:event.locationInWindow
+                                           fromView:nil];
+
+        CGFloat hoverValue =
+            (locationInView.x / self.bounds.size.width) * self.maxValue;
+        hoverValue = ceil(hoverValue);
+        hoverValue = VLC_CLIP(hoverValue, 0, self.maxValue);
+
+        self.doubleValue = hoverValue;
+    }
+}
+
+- (void)mouseUp:(NSEvent *)event
+{
+    [super mouseUp:event];
+
+    if (self.isHovering) {
+        self.originalValue = self.doubleValue;
+    }
+}
+
+- (void)setDoubleValue:(double)doubleValue
+{
+    [super setDoubleValue:doubleValue];
+
+    if (!self.isHovering) {
+        self.originalValue = self.doubleValue;
+    }
+}
+
+- (void)updateTrackingAreas
+{
+    if (self.trackingArea) {
+        [self removeTrackingArea:self.trackingArea];
+    }
+
+    self.trackingArea = [[NSTrackingArea alloc]
+        initWithRect:self.bounds
+             options:NSTrackingActiveInKeyWindow |
+                     NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved
+               owner:self
+            userInfo:nil];
+    [self addTrackingArea:self.trackingArea];
+}
+
+ at end



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/4ed95f35fd360d62260d86c20dc4fc68f48e259e

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/4ed95f35fd360d62260d86c20dc4fc68f48e259e
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