[vlc-commits] [Git][videolan/vlc][master] 11 commits: macosx: Modernise VLCSlider and VLCSliderCell code
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Sun Jun 23 08:42:32 UTC 2024
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
913fa08b by Claudio Cambra at 2024-06-23T08:01:16+00:00
macosx: Modernise VLCSlider and VLCSliderCell code
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1bfb7fd6 by Claudio Cambra at 2024-06-23T08:01:16+00:00
macosx: Constify things in VLCSliderCell
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
14b87f51 by Claudio Cambra at 2024-06-23T08:01:16+00:00
macosx: Reorder VLCSliderCell to match other classes with C-style callbacks into libvlc (e.g. VLCLibraryModel)
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
cb5040d3 by Claudio Cambra at 2024-06-23T08:01:16+00:00
macosx: Expose AB loop times and positions in player controller when ab loop state changes
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
8ac92701 by Claudio Cambra at 2024-06-23T08:01:16+00:00
macosx: Correctly initialise ab loop properties in player controller
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
84e240fc by Claudio Cambra at 2024-06-23T08:01:16+00:00
macosx: Add method to draw a tick mark at a given position on VLCSlider
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
f79b8908 by Claudio Cambra at 2024-06-23T08:01:16+00:00
macosx: Draw a and b position marks when A to B loop set
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
040d3337 by Claudio Cambra at 2024-06-23T08:01:16+00:00
macosx: Rename VLCSlider to VLCPlaybackProgressSlider
Since it is only used for this purpose, rename more accurately
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
4c9417e7 by Claudio Cambra at 2024-06-23T08:01:16+00:00
macosx: Remove unused custom colouring attributes and procedures in playback progress slider
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
a09effb3 by Claudio Cambra at 2024-06-23T08:01:16+00:00
macosx: React to ab loop change notifications rather than querying player controller every draw iteration in VLCPlaybackProgressSliderCell
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
56f36896 by Claudio Cambra at 2024-06-23T08:01:16+00:00
macosx: Clearly define slider tick thickness in VLCLibraryUIUnits, don't use magic numbers
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
17 changed files:
- extras/package/macosx/VLC.xcodeproj/project.pbxproj
- modules/gui/macosx/Makefile.am
- modules/gui/macosx/UI/VLCDetachedAudioWindow.xib
- modules/gui/macosx/UI/VLCLibraryWindow.xib
- modules/gui/macosx/UI/VLCMainVideoView.xib
- modules/gui/macosx/library/VLCLibraryUIUnits.h
- modules/gui/macosx/library/VLCLibraryUIUnits.m
- modules/gui/macosx/playlist/VLCPlayerController.h
- modules/gui/macosx/playlist/VLCPlayerController.m
- modules/gui/macosx/views/VLCDefaultValueSliderCell.m
- modules/gui/macosx/views/VLCSlider.h → modules/gui/macosx/views/VLCPlaybackProgressSlider.h
- modules/gui/macosx/views/VLCSlider.m → modules/gui/macosx/views/VLCPlaybackProgressSlider.m
- modules/gui/macosx/views/VLCSliderCell.h → modules/gui/macosx/views/VLCPlaybackProgressSliderCell.h
- modules/gui/macosx/views/VLCSliderCell.m → modules/gui/macosx/views/VLCPlaybackProgressSliderCell.m
- modules/gui/macosx/windows/controlsbar/VLCControlsBarCommon.h
- modules/gui/macosx/windows/controlsbar/VLCControlsBarCommon.m
- po/POTFILES.in
Changes:
=====================================
extras/package/macosx/VLC.xcodeproj/project.pbxproj
=====================================
@@ -142,8 +142,8 @@
53F0E930299B17DF00491D49 /* VLCInputNodePathControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 53F0E92F299B17DF00491D49 /* VLCInputNodePathControl.m */; };
53F399802AC6D6B400B86241 /* VLCLibraryHomeViewVideoCarouselContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 53F3997F2AC6D6B400B86241 /* VLCLibraryHomeViewVideoCarouselContainerView.m */; };
6B0292E61F43256300A50082 /* VLCBottomBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B0292E51F43256300A50082 /* VLCBottomBarView.m */; };
- 6B0AB0F01F1AC8B3003A1B4E /* VLCSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B0AB0ED1F1AC8B3003A1B4E /* VLCSlider.m */; };
- 6B0AB0F11F1AC8B3003A1B4E /* VLCSliderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B0AB0EF1F1AC8B3003A1B4E /* VLCSliderCell.m */; };
+ 6B0AB0F01F1AC8B3003A1B4E /* VLCPlaybackProgressSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B0AB0ED1F1AC8B3003A1B4E /* VLCPlaybackProgressSlider.m */; };
+ 6B0AB0F11F1AC8B3003A1B4E /* VLCPlaybackProgressSliderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B0AB0EF1F1AC8B3003A1B4E /* VLCPlaybackProgressSliderCell.m */; };
6B196852265E974400870512 /* window_macosx.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B19684F265E928A00870512 /* window_macosx.m */; };
6B2EFC601F2819F700F3C0EA /* VLCVolumeSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B2EFC5F1F2819F700F3C0EA /* VLCVolumeSlider.m */; };
6B2EFC631F281A0900F3C0EA /* VLCVolumeSliderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B2EFC621F281A0900F3C0EA /* VLCVolumeSliderCell.m */; };
@@ -432,10 +432,10 @@
633121CB1B51122700E636DA /* VLCResumeDialogController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCResumeDialogController.m; sourceTree = "<group>"; };
6B0292E41F43256300A50082 /* VLCBottomBarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCBottomBarView.h; sourceTree = "<group>"; };
6B0292E51F43256300A50082 /* VLCBottomBarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCBottomBarView.m; sourceTree = "<group>"; };
- 6B0AB0EC1F1AC8B3003A1B4E /* VLCSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCSlider.h; sourceTree = "<group>"; };
- 6B0AB0ED1F1AC8B3003A1B4E /* VLCSlider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCSlider.m; sourceTree = "<group>"; };
- 6B0AB0EE1F1AC8B3003A1B4E /* VLCSliderCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCSliderCell.h; sourceTree = "<group>"; };
- 6B0AB0EF1F1AC8B3003A1B4E /* VLCSliderCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCSliderCell.m; sourceTree = "<group>"; };
+ 6B0AB0EC1F1AC8B3003A1B4E /* VLCPlaybackProgressSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCPlaybackProgressSlider.h; sourceTree = "<group>"; };
+ 6B0AB0ED1F1AC8B3003A1B4E /* VLCPlaybackProgressSlider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCPlaybackProgressSlider.m; sourceTree = "<group>"; };
+ 6B0AB0EE1F1AC8B3003A1B4E /* VLCPlaybackProgressSliderCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCPlaybackProgressSliderCell.h; sourceTree = "<group>"; };
+ 6B0AB0EF1F1AC8B3003A1B4E /* VLCPlaybackProgressSliderCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCPlaybackProgressSliderCell.m; sourceTree = "<group>"; };
6B13E2A61BC67678001AD24A /* VLCScrollingClipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCScrollingClipView.h; sourceTree = "<group>"; };
6B13E2A71BC67678001AD24A /* VLCScrollingClipView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCScrollingClipView.m; sourceTree = "<group>"; };
6B19684F265E928A00870512 /* window_macosx.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = window_macosx.m; path = ../../../modules/video_output/window_macosx.m; sourceTree = "<group>"; };
@@ -1079,16 +1079,16 @@
535053ED2B610C3400D7EAF2 /* VLCLoadingOverlayView.m */,
53CBE3092C159A4D006BF2E3 /* VLCNoResultsLabel.h */,
53CBE30A2C159A4D006BF2E3 /* VLCNoResultsLabel.m */,
+ 6B0AB0EC1F1AC8B3003A1B4E /* VLCPlaybackProgressSlider.h */,
+ 6B0AB0ED1F1AC8B3003A1B4E /* VLCPlaybackProgressSlider.m */,
+ 6B0AB0EE1F1AC8B3003A1B4E /* VLCPlaybackProgressSliderCell.h */,
+ 6B0AB0EF1F1AC8B3003A1B4E /* VLCPlaybackProgressSliderCell.m */,
7D1BF28822A153E20027C50F /* VLCRoundedCornerTextField.h */,
7D1BF28922A153E20027C50F /* VLCRoundedCornerTextField.m */,
6B13E2A61BC67678001AD24A /* VLCScrollingClipView.h */,
6B13E2A71BC67678001AD24A /* VLCScrollingClipView.m */,
537976B92A4319330036827E /* VLCSettingTextField.h */,
537976B82A4319330036827E /* VLCSettingTextField.m */,
- 6B0AB0EC1F1AC8B3003A1B4E /* VLCSlider.h */,
- 6B0AB0ED1F1AC8B3003A1B4E /* VLCSlider.m */,
- 6B0AB0EE1F1AC8B3003A1B4E /* VLCSliderCell.h */,
- 6B0AB0EF1F1AC8B3003A1B4E /* VLCSliderCell.m */,
53628401291147C500640C15 /* VLCSubScrollView.h */,
53628400291147C500640C15 /* VLCSubScrollView.m */,
6BF093F71EE0182B0049D8B0 /* VLCTimeField.h */,
@@ -2119,7 +2119,7 @@
5307A6F82969904D001E0C6A /* VLCLibraryMediaSourceViewController.m in Sources */,
6B81662C1EBFC38100C26F1B /* VLCUIWidgets.m in Sources */,
53ED472329C74D1F00795DB1 /* VLCLibraryAudioTableViewDelegate.m in Sources */,
- 6B0AB0F11F1AC8B3003A1B4E /* VLCSliderCell.m in Sources */,
+ 6B0AB0F11F1AC8B3003A1B4E /* VLCPlaybackProgressSliderCell.m in Sources */,
6B8166291EBFC34300C26F1B /* VLCDefaultValueSlider.m in Sources */,
6B81662A1EBFC34300C26F1B /* VLCDefaultValueSliderCell.m in Sources */,
6B3BE42C1E6217CB008D098A /* VLCImageButton.m in Sources */,
@@ -2158,7 +2158,7 @@
7D445D8E2203375100263D34 /* VLCPlaylistMenuController.m in Sources */,
53903D3A29576ED500D0B308 /* VLCLibraryAudioGroupDataSource.m in Sources */,
1C31139A1E508C6900D4DD76 /* VLCBookmarksWindowController.m in Sources */,
- 6B0AB0F01F1AC8B3003A1B4E /* VLCSlider.m in Sources */,
+ 6B0AB0F01F1AC8B3003A1B4E /* VLCPlaybackProgressSlider.m in Sources */,
7D28E6362275B4820098D30E /* NSColor+VLCAdditions.m in Sources */,
6BF5C5041EFE66EF008A9C12 /* VLCHUDTableView.m in Sources */,
535F1BBA2B47ACCE00C78D98 /* VLCLibraryHomeViewVideoContainerViewDataSource.m in Sources */,
=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -348,16 +348,16 @@ libmacosx_plugin_la_SOURCES = \
gui/macosx/views/VLCLoadingOverlayView.m \
gui/macosx/views/VLCNoResultsLabel.h \
gui/macosx/views/VLCNoResultsLabel.m \
+ gui/macosx/views/VLCPlaybackProgressSlider.h \
+ gui/macosx/views/VLCPlaybackProgressSlider.m \
+ gui/macosx/views/VLCPlaybackProgressSliderCell.h \
+ gui/macosx/views/VLCPlaybackProgressSliderCell.m \
gui/macosx/views/VLCRoundedCornerTextField.h \
gui/macosx/views/VLCRoundedCornerTextField.m \
gui/macosx/views/VLCScrollingClipView.h \
gui/macosx/views/VLCScrollingClipView.m \
gui/macosx/views/VLCSettingTextField.h \
gui/macosx/views/VLCSettingTextField.m \
- gui/macosx/views/VLCSlider.h \
- gui/macosx/views/VLCSlider.m \
- gui/macosx/views/VLCSliderCell.h \
- gui/macosx/views/VLCSliderCell.m \
gui/macosx/views/VLCSubScrollView.h \
gui/macosx/views/VLCSubScrollView.m \
gui/macosx/views/VLCTimeField.h \
=====================================
modules/gui/macosx/UI/VLCDetachedAudioWindow.xib
=====================================
@@ -94,12 +94,12 @@
<constraint firstAttribute="bottom" secondItem="10" secondAttribute="bottom" id="yGM-Jx-9fD"/>
</constraints>
</customView>
- <slider hidden="YES" horizontalHuggingPriority="200" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="20" customClass="VLCSlider">
+ <slider hidden="YES" horizontalHuggingPriority="200" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="20" customClass="VLCPlaybackProgressSlider">
<rect key="frame" x="8" y="50" width="176" height="18"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="MYp-CS-yPe"/>
</constraints>
- <sliderCell key="cell" controlSize="small" continuous="YES" state="on" alignment="left" maxValue="1" doubleValue="0.32600000000000001" tickMarkPosition="above" sliderType="linear" id="23" customClass="VLCSliderCell">
+ <sliderCell key="cell" controlSize="small" continuous="YES" state="on" alignment="left" maxValue="1" doubleValue="0.32600000000000001" tickMarkPosition="above" sliderType="linear" id="23" customClass="VLCPlaybackProgressSliderCell">
<font key="font" size="12" name="Helvetica"/>
</sliderCell>
<connections>
=====================================
modules/gui/macosx/UI/VLCLibraryWindow.xib
=====================================
@@ -190,9 +190,9 @@
<constraint firstItem="5o7-Z0-dqS" firstAttribute="leading" secondItem="SM6-nx-NKD" secondAttribute="leading" id="vGw-cB-VLb"/>
</constraints>
</customView>
- <slider hidden="YES" horizontalHuggingPriority="200" verticalHuggingPriority="750" verticalCompressionResistancePriority="751" mirrorLayoutDirectionWhenInternationalizing="never" translatesAutoresizingMaskIntoConstraints="NO" id="9Hg-t2-K5z" customClass="VLCSlider">
+ <slider hidden="YES" horizontalHuggingPriority="200" verticalHuggingPriority="750" verticalCompressionResistancePriority="751" mirrorLayoutDirectionWhenInternationalizing="never" translatesAutoresizingMaskIntoConstraints="NO" id="9Hg-t2-K5z" customClass="VLCPlaybackProgressSlider">
<rect key="frame" x="86" y="-2" width="480" height="20"/>
- <sliderCell key="cell" controlSize="mini" continuous="YES" state="on" alignment="left" maxValue="1" doubleValue="0.32600000000000001" tickMarkPosition="above" sliderType="linear" id="YMg-uo-8nX" customClass="VLCSliderCell"/>
+ <sliderCell key="cell" controlSize="mini" continuous="YES" state="on" alignment="left" maxValue="1" doubleValue="0.32600000000000001" tickMarkPosition="above" sliderType="linear" id="YMg-uo-8nX" customClass="VLCPlaybackProgressSliderCell"/>
<connections>
<action selector="timeSliderAction:" target="Uzf-Tf-H8x" id="eDh-39-Ej1"/>
</connections>
=====================================
modules/gui/macosx/UI/VLCMainVideoView.xib
=====================================
@@ -134,12 +134,12 @@
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
- <slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="qNZ-Fh-W8i" customClass="VLCSlider">
+ <slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="qNZ-Fh-W8i" customClass="VLCPlaybackProgressSlider">
<rect key="frame" x="18" y="37" width="684" height="19"/>
<constraints>
<constraint firstAttribute="height" constant="15" id="xm6-li-LpC"/>
</constraints>
- <sliderCell key="cell" controlSize="small" continuous="YES" state="on" alignment="left" maxValue="1" tickMarkPosition="above" sliderType="linear" id="dZM-dm-qvL" customClass="VLCSliderCell"/>
+ <sliderCell key="cell" controlSize="small" continuous="YES" state="on" alignment="left" maxValue="1" tickMarkPosition="above" sliderType="linear" id="dZM-dm-qvL" customClass="VLCPlaybackProgressSliderCell"/>
<connections>
<action selector="timeSliderAction:" target="3" id="W32-wA-rN9"/>
</connections>
=====================================
modules/gui/macosx/library/VLCLibraryUIUnits.h
=====================================
@@ -71,6 +71,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (class, readonly) const CGFloat libraryWindowNavSidebarMaxWidth;
@property (class, readonly) const CGFloat libraryWindowPlaylistSidebarMaxWidth;
+ at property (class, readonly) const CGFloat sliderTickThickness;
+
+ (const NSSize)adjustedCollectionViewItemSizeForCollectionView:(NSCollectionView *)collectionView
withLayout:(VLCLibraryCollectionViewFlowLayout *)collectionViewLayout
withItemsAspectRatio:(VLCLibraryCollectionViewItemAspectRatio)itemsAspectRatio;
=====================================
modules/gui/macosx/library/VLCLibraryUIUnits.m
=====================================
@@ -231,4 +231,9 @@
return 400.;
}
++ (const CGFloat)sliderTickThickness
+{
+ return 1.;
+}
+
@end
=====================================
modules/gui/macosx/playlist/VLCPlayerController.h
=====================================
@@ -283,6 +283,10 @@ extern const CGFloat VLCVolumeDefault;
* @note listen to VLCPlayerABLoopStateChanged for changes to this property
*/
@property (readonly) enum vlc_player_abloop abLoopState;
+ at property (readonly) vlc_tick_t aLoopTime;
+ at property (readonly) vlc_tick_t bLoopTime;
+ at property (readonly) float aLoopPosition;
+ at property (readonly) float bLoopPosition;
/**
* set the A→B loop
=====================================
modules/gui/macosx/playlist/VLCPlayerController.m
=====================================
@@ -599,6 +599,11 @@ static int BossCallback(vlc_object_t *p_this,
_volume = VLCVolumeDefault;
+ _aLoopTime = -1;
+ _bLoopTime = -1;
+ _aLoopPosition = -1;
+ _bLoopPosition = -1;
+
libvlc_int_t *libvlc = vlc_object_instance(getIntf());
var_AddCallback(libvlc, "intf-boss", BossCallback, (__bridge void *)self);
}
@@ -1523,6 +1528,21 @@ static int BossCallback(vlc_object_t *p_this,
- (void)ABLoopStateChanged:(enum vlc_player_abloop)abLoopState
{
_abLoopState = abLoopState;
+
+ vlc_tick_t a_time = -1;
+ vlc_tick_t b_time = -1;
+ float a_pos = -1;
+ float b_pos = -1;
+
+ vlc_player_Lock(_p_player);
+ const enum vlc_player_abloop state = vlc_player_GetAtoBLoop(_p_player, &a_time, &a_pos, &b_time, &b_pos);
+ vlc_player_Unlock(_p_player);
+
+ _aLoopTime = a_time;
+ _bLoopTime = b_time;
+ _aLoopPosition = a_pos;
+ _bLoopPosition = b_pos;
+
[_defaultNotificationCenter postNotificationName:VLCPlayerABLoopStateChanged
object:self];
}
=====================================
modules/gui/macosx/views/VLCDefaultValueSliderCell.m
=====================================
@@ -30,6 +30,7 @@
#import "VLCDefaultValueSliderCell.h"
+#import "library/VLCLibraryUIUnits.h"
#import "main/CompatibilityFixes.h"
@interface VLCDefaultValueSliderCell (){
@@ -160,7 +161,7 @@
if (_drawTickMarkForDefault && _defaultValue != DBL_MAX) {
// Calculate rect for default tick mark
- CGFloat tickThickness = 1.0;
+ const CGFloat tickThickness = VLCLibraryUIUnits.sliderTickThickness;
NSRect tickFrame = [self knobRectFlipped:_isFlipped
forValue:_defaultValue];
=====================================
modules/gui/macosx/views/VLCSlider.h → modules/gui/macosx/views/VLCPlaybackProgressSlider.h
=====================================
@@ -1,5 +1,5 @@
/*****************************************************************************
- * VLCSlider.h
+ * VLCPlaybackProgressSlider.h
*****************************************************************************
* Copyright (C) 2017 VLC authors and VideoLAN
*
@@ -22,12 +22,12 @@
#import <Cocoa/Cocoa.h>
- at interface VLCSlider : NSSlider
+ at interface VLCPlaybackProgressSlider : NSSlider
- at property (nonatomic, getter=getIndefinite,setter=setIndefinite:) BOOL indefinite;
- at property (nonatomic, getter=getKnobHidden,setter=setKnobHidden:) BOOL isKnobHidden;
+ at property (readwrite, nonatomic) BOOL indefinite;
+ at property (readwrite, nonatomic) BOOL knobHidden;
/* Indicates if the slider is scrollable with the mouse or trackpad scrollwheel. */
- at property (readwrite) BOOL isScrollable;
+ at property (readwrite) BOOL scrollable;
@end
=====================================
modules/gui/macosx/views/VLCSlider.m → modules/gui/macosx/views/VLCPlaybackProgressSlider.m
=====================================
@@ -1,5 +1,5 @@
/*****************************************************************************
- * VLCSlider.m
+ * VLCPlaybackProgressSlider.m
*****************************************************************************
* Copyright (C) 2017 VLC authors and VideoLAN
*
@@ -20,40 +20,42 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#import "VLCSlider.h"
+#import "VLCPlaybackProgressSlider.h"
#import "extensions/NSView+VLCAdditions.h"
-#import "views/VLCSliderCell.h"
+#import "views/VLCPlaybackProgressSliderCell.h"
- at implementation VLCSlider
+ at implementation VLCPlaybackProgressSlider
+
++ (Class)cellClass
+{
+ return VLCPlaybackProgressSliderCell.class;
+}
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
- NSAssert([self.cell isKindOfClass:[VLCSliderCell class]],
- @"VLCSlider cell is not VLCSliderCell");
- _isScrollable = YES;
+ NSAssert([self.cell isKindOfClass:[VLCPlaybackProgressSlider cellClass]],
+ @"VLCPlaybackProgressSlider cell is not a VLCPlaybackProgressSliderCell");
+ self.scrollable = YES;
if (@available(macOS 10.14, *)) {
[self viewDidChangeEffectiveAppearance];
} else {
- [(VLCSliderCell*)self.cell setSliderStyleLight];
+ [(VLCPlaybackProgressSliderCell*)self.cell setSliderStyleLight];
}
}
return self;
}
-+ (Class)cellClass
-{
- return [VLCSliderCell class];
-}
-
- (void)scrollWheel:(NSEvent *)event
{
- if (!_isScrollable)
+ if (!self.scrollable) {
return [super scrollWheel:event];
+ }
+
double increment;
CGFloat deltaY = [event scrollingDeltaY];
double range = [self maxValue] - [self minValue];
@@ -62,43 +64,46 @@
if (event.hasPreciseScrollingDeltas) {
increment = (range * 0.002) * deltaY;
} else {
- if (deltaY == 0.0)
+ if (deltaY == 0.0) {
return;
+ }
increment = (range * 0.01 * deltaY);
}
// If scrolling is inversed, increment in other direction
- if (!event.isDirectionInvertedFromDevice)
+ if (!event.isDirectionInvertedFromDevice) {
increment = -increment;
+ }
- [self setDoubleValue:self.doubleValue - increment];
+ self.doubleValue = self.doubleValue - increment;
[self sendAction:self.action to:self.target];
}
// Workaround for 10.7
// http://stackoverflow.com/questions/3985816/custom-nsslidercell
-- (void)setNeedsDisplayInRect:(NSRect)invalidRect {
- [super setNeedsDisplayInRect:[self bounds]];
+- (void)setNeedsDisplayInRect:(NSRect)invalidRect
+{
+ [super setNeedsDisplayInRect:self.bounds];
}
-- (BOOL)getIndefinite
+- (BOOL)indefinite
{
- return [(VLCSliderCell*)[self cell] indefinite];
+ return [(VLCPlaybackProgressSliderCell*)self.cell indefinite];
}
- (void)setIndefinite:(BOOL)indefinite
{
- [(VLCSliderCell*)[self cell] setIndefinite:indefinite];
+ [(VLCPlaybackProgressSliderCell*)self.cell setIndefinite:indefinite];
}
-- (BOOL)getKnobHidden
+- (BOOL)knobHidden
{
- return [(VLCSliderCell*)[self cell] isKnobHidden];
+ return [(VLCPlaybackProgressSliderCell*)self.cell knobHidden];
}
-- (void)setKnobHidden:(BOOL)isKnobHidden
+- (void)setKnobHidden:(BOOL)knobHidden
{
- [(VLCSliderCell*)[self cell] setKnobHidden:isKnobHidden];
+ [(VLCPlaybackProgressSliderCell*)self.cell setKnobHidden:knobHidden];
}
- (BOOL)isFlipped
@@ -109,9 +114,9 @@
- (void)viewDidChangeEffectiveAppearance
{
if (self.shouldShowDarkAppearance) {
- [(VLCSliderCell*)self.cell setSliderStyleDark];
+ [(VLCPlaybackProgressSliderCell*)self.cell setSliderStyleDark];
} else {
- [(VLCSliderCell*)self.cell setSliderStyleLight];
+ [(VLCPlaybackProgressSliderCell*)self.cell setSliderStyleLight];
}
}
=====================================
modules/gui/macosx/views/VLCSliderCell.h → modules/gui/macosx/views/VLCPlaybackProgressSliderCell.h
=====================================
@@ -1,5 +1,5 @@
/*****************************************************************************
- * VLCSliderCell.h
+ * VLCPlaybackProgressSliderCell.h
*****************************************************************************
* Copyright (C) 2017 VLC authors and VideoLAN
*
@@ -22,24 +22,10 @@
#import <Cocoa/Cocoa.h>
- at interface VLCSliderCell : NSSliderCell
+ at interface VLCPlaybackProgressSliderCell : NSSliderCell
-// Colors
- at property NSColor *gradientColor;
- at property NSColor *gradientColor2;
- at property NSColor *trackStrokeColor;
- at property NSColor *filledTrackColor;
- at property NSColor *shadowColor;
- at property NSColor *highlightBackground;
-
-// Gradients
- at property NSGradient *trackGradient;
- at property NSGradient *highlightGradient;
-
- at property NSInteger animationWidth;
-
- at property (nonatomic, setter=setIndefinite:) BOOL indefinite;
- at property (nonatomic, setter=setKnobHidden:) BOOL isKnobHidden;
+ at property (readwrite, nonatomic) BOOL indefinite;
+ at property (readwrite, nonatomic) BOOL knobHidden;
- (void)setSliderStyleLight;
- (void)setSliderStyleDark;
=====================================
modules/gui/macosx/views/VLCSliderCell.m → modules/gui/macosx/views/VLCPlaybackProgressSliderCell.m
=====================================
@@ -1,5 +1,5 @@
/*****************************************************************************
- * VLCSliderCell.m
+ * VLCPlaybackProgressSliderCell.m
*****************************************************************************
* Copyright (C) 2017 VLC authors and VideoLAN
*
@@ -20,38 +20,91 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#import "VLCSliderCell.h"
+#import "VLCPlaybackProgressSliderCell.h"
#import <CoreVideo/CoreVideo.h>
#import "extensions/NSGradient+VLCAdditions.h"
#import "extensions/NSColor+VLCAdditions.h"
+
+#import "library/VLCLibraryUIUnits.h"
+
#import "main/CompatibilityFixes.h"
+#import "main/VLCMain.h"
+
+#import "playlist/VLCPlayerController.h"
+#import "playlist/VLCPlaylistController.h"
- at interface VLCSliderCell () {
+ at interface VLCPlaybackProgressSliderCell ()
+{
+ NSInteger _animationWidth;
NSInteger _animationPosition;
double _lastTime;
double _deltaToLastFrame;
CVDisplayLinkRef _displayLink;
NSColor *_emptySliderBackgroundColor;
+
+ enum vlc_player_abloop _abLoopState;
+ CGFloat _aToBLoopAMarkPosition; // Position of the A loop mark as a fraction of slider width
+ CGFloat _aToBLoopBMarkPosition; // Position of the B loop mark as a fraction of slider width
}
+
+- (void)displayLink:(CVDisplayLinkRef)displayLink tickWithTime:(const CVTimeStamp *)inNow;
+
@end
- at implementation VLCSliderCell
+static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink,
+ const CVTimeStamp *inNow,
+ const CVTimeStamp *inOutputTime,
+ CVOptionFlags flagsIn,
+ CVOptionFlags *flagsOut,
+ void *displayLinkContext)
+{
+ const CVTimeStamp inNowCopy = *inNow;
+ dispatch_async(dispatch_get_main_queue(), ^{
+ VLCPlaybackProgressSliderCell * const sliderCell = (__bridge VLCPlaybackProgressSliderCell*)displayLinkContext;
+ [sliderCell displayLink:displayLink tickWithTime:&inNowCopy];
+ });
+ return kCVReturnSuccess;
+}
+
+ at implementation VLCPlaybackProgressSliderCell
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
- [self setSliderStyleLight];
- _animationWidth = [[self controlView] bounds].size.width;
+ _animationWidth = self.controlView.bounds.size.width;
+ [self setSliderStyleLight];
+ [self updateAtoBLoopState];
[self initDisplayLink];
+
+ NSNotificationCenter * const notificationCenter = NSNotificationCenter.defaultCenter;
+ [notificationCenter addObserver:self
+ selector:@selector(abLoopStateChanged:)
+ name:VLCPlayerABLoopStateChanged
+ object:nil];
}
return self;
}
+- (void)dealloc
+{
+ CVDisplayLinkRelease(_displayLink);
+}
+
+- (void)initDisplayLink
+{
+ const CVReturn ret = CVDisplayLinkCreateWithActiveCGDisplays(&_displayLink);
+ if (ret != kCVReturnSuccess) {
+ // TODO: Handle error
+ return;
+ }
+ CVDisplayLinkSetOutputCallback(_displayLink, DisplayLinkCallback, (__bridge void*) self);
+}
+
- (void)setSliderStyleLight
{
_emptySliderBackgroundColor = NSColor.VLCSliderLightBackgroundColor;
@@ -62,22 +115,22 @@
_emptySliderBackgroundColor = NSColor.VLCSliderDarkBackgroundColor;
}
-- (void)dealloc
+- (void)abLoopStateChanged:(NSNotification *)notification
{
- CVDisplayLinkRelease(_displayLink);
+ [self updateAtoBLoopState];
}
-static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *inNow, const CVTimeStamp *inOutputTime, CVOptionFlags flagsIn, CVOptionFlags *flagsOut, void *displayLinkContext)
+- (void)updateAtoBLoopState
{
- CVTimeStamp inNowCopy = *inNow;
- dispatch_async(dispatch_get_main_queue(), ^{
- VLCSliderCell *sliderCell = (__bridge VLCSliderCell*)displayLinkContext;
- [sliderCell displayLink:displayLink tickWithTime:&inNowCopy];
- });
- return kCVReturnSuccess;
+ VLCPlayerController * const playerController =
+ VLCMain.sharedInstance.playlistController.playerController;
+
+ _abLoopState = playerController.abLoopState;
+ _aToBLoopAMarkPosition = playerController.aLoopPosition;
+ _aToBLoopBMarkPosition = playerController.bLoopPosition;
}
-- (void)displayLink:(CVDisplayLinkRef)displayLink tickWithTime:(const CVTimeStamp*)inNow
+- (void)displayLink:(CVDisplayLinkRef)displayLink tickWithTime:(const CVTimeStamp *)inNow
{
if (_lastTime == 0) {
_deltaToLastFrame = 0;
@@ -86,17 +139,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
}
_lastTime = inNow->videoTime;
- [self.controlView setNeedsDisplay:YES];
-}
-
-- (void)initDisplayLink
-{
- CVReturn ret = CVDisplayLinkCreateWithActiveCGDisplays(&_displayLink);
- if (ret != kCVReturnSuccess) {
- // TODO: Handle error
- return;
- }
- CVDisplayLinkSetOutputCallback(_displayLink, DisplayLinkCallback, (__bridge void*) self);
+ self.controlView.needsDisplay = YES;
}
#pragma mark -
@@ -104,7 +147,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
- (void)drawKnob:(NSRect)knobRect
{
- if (_isKnobHidden) {
+ if (self.knobHidden) {
return;
}
@@ -113,28 +156,30 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
- (void)drawBarInside:(NSRect)rect flipped:(BOOL)flipped
{
- const CGFloat trackBorderRadius = 1;
+ static const CGFloat trackBorderRadius = 1;
// Empty Track Drawing
- NSBezierPath* emptyTrackPath = [NSBezierPath bezierPathWithRoundedRect:rect
- xRadius:trackBorderRadius
- yRadius:trackBorderRadius];
+ NSBezierPath * const emptyTrackPath =
+ [NSBezierPath bezierPathWithRoundedRect:rect
+ xRadius:trackBorderRadius
+ yRadius:trackBorderRadius];
[_emptySliderBackgroundColor setFill];
[emptyTrackPath fill];
- if (_isKnobHidden) {
+ if (self.knobHidden) {
return;
}
// Calculate filled track
NSRect filledTrackRect = rect;
- NSRect knobRect = [self knobRectFlipped:NO];
+ const NSRect knobRect = [self knobRectFlipped:NO];
filledTrackRect.size.width = knobRect.origin.x + (knobRect.size.width / 2);
// Filled Track Drawing
- NSBezierPath* filledTrackPath = [NSBezierPath bezierPathWithRoundedRect:filledTrackRect
- xRadius:trackBorderRadius
- yRadius:trackBorderRadius];
+ NSBezierPath * const filledTrackPath =
+ [NSBezierPath bezierPathWithRoundedRect:filledTrackRect
+ xRadius:trackBorderRadius
+ yRadius:trackBorderRadius];
[NSColor.VLCAccentColor setFill];
[filledTrackPath fill];
@@ -143,28 +188,12 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
#pragma mark -
#pragma mark Indefinite slider drawing
-
-- (void)drawHighlightInRect:(NSRect)rect
-{
- [_highlightGradient drawInRect:rect angle:0];
-}
-
-
-- (void)drawHighlightBackgroundInRect:(NSRect)rect
-{
- rect = NSInsetRect(rect, 1.0, 1.0);
- NSBezierPath *fullPath = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:2.0 yRadius:2.0];
- [_highlightBackground setFill];
- [fullPath fill];
-}
-
- (void)drawAnimationInRect:(NSRect)rect
{
- [self drawHighlightBackgroundInRect:rect];
-
[NSGraphicsContext saveGraphicsState];
rect = NSInsetRect(rect, 1.0, 1.0);
- NSBezierPath *fullPath = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:2.0 yRadius:2.0];
+ NSBezierPath * const fullPath =
+ [NSBezierPath bezierPathWithRoundedRect:rect xRadius:2.0 yRadius:2.0];
[fullPath setClip];
// Use previously calculated position
@@ -179,20 +208,60 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
rect.size.width = _animationWidth;
-
- [self drawHighlightInRect:rect];
[NSGraphicsContext restoreGraphicsState];
_deltaToLastFrame = 0;
}
+- (void)drawCustomTickMarkAtPosition:(const CGFloat)position
+ inCellFrame:(const NSRect)cellFrame
+ withColor:(NSColor * const)color
+{
+ const CGFloat tickThickness = VLCLibraryUIUnits.sliderTickThickness;
+ const CGSize cellSize = cellFrame.size;
+ NSRect tickFrame;
+
+ if (self.isVertical) {
+ const CGFloat tickY = cellSize.height * position;
+ tickFrame = NSMakeRect(cellFrame.origin.x, tickY, cellSize.width, tickThickness);
+ } else {
+ const CGFloat tickX = cellSize.width * position;
+ tickFrame = NSMakeRect(tickX, cellFrame.origin.y, tickThickness, cellSize.height);
+ }
+
+ const NSAlignmentOptions alignOpts =
+ NSAlignMinXOutward | NSAlignMinYOutward | NSAlignWidthOutward | NSAlignMaxYOutward;
+ const NSRect finalTickRect =
+ [self.controlView backingAlignedRect:tickFrame options:alignOpts];
+
+ [color setFill];
+ NSRectFill(finalTickRect);
+}
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
- if (_indefinite)
+ if (self.indefinite) {
return [self drawAnimationInRect:cellFrame];
+ } else {
+ [super drawWithFrame:cellFrame inView:controlView];
+ }
- [super drawWithFrame:cellFrame inView:controlView];
+ if (_abLoopState == VLC_PLAYER_ABLOOP_NONE) {
+ return;
+ }
+ if (_aToBLoopAMarkPosition >= 0) {
+ [self drawCustomTickMarkAtPosition:_aToBLoopAMarkPosition
+ inCellFrame:cellFrame
+ withColor:_emptySliderBackgroundColor];
+ }
+ if (_aToBLoopBMarkPosition >= 0) {
+ [self drawCustomTickMarkAtPosition:_aToBLoopBMarkPosition
+ inCellFrame:cellFrame
+ withColor:_emptySliderBackgroundColor];
+ }
+
+ // Redraw knob
+ [super drawKnob];
}
#pragma mark -
@@ -200,37 +269,40 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
- (void)beginAnimating
{
- CVReturn err = CVDisplayLinkStart(_displayLink);
+ const CVReturn err = CVDisplayLinkStart(_displayLink);
if (err != kCVReturnSuccess) {
// TODO: Handle error
}
_animationPosition = -(_animationWidth);
- [self setEnabled:NO];
+ self.enabled = NO;
}
- (void)endAnimating
{
CVDisplayLinkStop(_displayLink);
- [self setEnabled:YES];
+ self.enabled = YES;
}
- (void)setIndefinite:(BOOL)indefinite
{
- if (_indefinite == indefinite)
+ if (self.indefinite == indefinite) {
return;
+ }
- if (indefinite)
+ _indefinite = indefinite;
+
+ if (indefinite) {
[self beginAnimating];
- else
+ } else {
[self endAnimating];
- _indefinite = indefinite;
+ }
}
-- (void)setKnobHidden:(BOOL)isKnobHidden
+- (void)setKnobHidden:(BOOL)knobHidden
{
- _isKnobHidden = isKnobHidden;
- [self.controlView setNeedsDisplay:YES];
+ _knobHidden = knobHidden;
+ self.controlView.needsDisplay = YES;
}
=====================================
modules/gui/macosx/windows/controlsbar/VLCControlsBarCommon.h
=====================================
@@ -24,7 +24,7 @@
#import <Cocoa/Cocoa.h>
@class VLCDragDropView;
- at class VLCSlider;
+ at class VLCPlaybackProgressSlider;
@class VLCVolumeSlider;
@class VLCTimeField;
@class VLCImageView;
@@ -46,7 +46,7 @@
@property (readwrite, strong) IBOutlet NSButton *backwardButton;
@property (readwrite, strong) IBOutlet NSButton *forwardButton;
- at property (readwrite, strong) IBOutlet VLCSlider *timeSlider;
+ at property (readwrite, strong) IBOutlet VLCPlaybackProgressSlider *timeSlider;
@property (readwrite, strong) IBOutlet VLCVolumeSlider *volumeSlider;
@property (readwrite, strong) IBOutlet NSButton *muteVolumeButton;
=====================================
modules/gui/macosx/windows/controlsbar/VLCControlsBarCommon.m
=====================================
@@ -34,8 +34,8 @@
#import "views/VLCBottomBarView.h"
#import "views/VLCDragDropView.h"
#import "views/VLCImageView.h"
+#import "views/VLCPlaybackProgressSlider.h"
#import "views/VLCTimeField.h"
-#import "views/VLCSlider.h"
#import "views/VLCVolumeSlider.h"
#import "views/VLCWrappableTextField.h"
=====================================
po/POTFILES.in
=====================================
@@ -597,14 +597,14 @@ modules/gui/macosx/views/VLCImageView.h
modules/gui/macosx/views/VLCImageView.m
modules/gui/macosx/views/VLCLinearProgressIndicator.h
modules/gui/macosx/views/VLCLinearProgressIndicator.m
+modules/gui/macosx/views/VLCPlaybackProgressSlider.h
+modules/gui/macosx/views/VLCPlaybackProgressSlider.m
+modules/gui/macosx/views/VLCPlaybackProgressSliderCell.h
+modules/gui/macosx/views/VLCPlaybackProgressSliderCell.m
modules/gui/macosx/views/VLCRoundedCornerTextField.h
modules/gui/macosx/views/VLCRoundedCornerTextField.m
modules/gui/macosx/views/VLCScrollingClipView.h
modules/gui/macosx/views/VLCScrollingClipView.m
-modules/gui/macosx/views/VLCSlider.h
-modules/gui/macosx/views/VLCSlider.m
-modules/gui/macosx/views/VLCSliderCell.h
-modules/gui/macosx/views/VLCSliderCell.m
modules/gui/macosx/views/VLCTimeField.h
modules/gui/macosx/views/VLCTimeField.m
modules/gui/macosx/views/VLCTrackingView.h
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5bd5a7ed2d58018376fe07f515daf4d89934f755...56f36896a12e37a27d1ca75eebab468cd415a325
--
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5bd5a7ed2d58018376fe07f515daf4d89934f755...56f36896a12e37a27d1ca75eebab468cd415a325
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