[vlc-commits] [Git][videolan/vlc][master] 8 commits: macosx: Remove calls to needsDisplay for timeFields
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Sun Dec 22 12:28:58 UTC 2024
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
04b03b2a by Claudio Cambra at 2024-12-22T12:06:23+00:00
macosx: Remove calls to needsDisplay for timeFields
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
ba57e34c by Claudio Cambra at 2024-12-22T12:06:23+00:00
macosx: Use existing identifier property on VLCTimeField rather than private BOOL
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
3aeea2a5 by Claudio Cambra at 2024-12-22T12:06:23+00:00
macosx: Use modern property access syntax in VLCTimeField
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
aa5e79e4 by Claudio Cambra at 2024-12-22T12:06:23+00:00
macosx: Use modern dictionary literal syntax to set standard appDefaults regarding time field
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
5b6137f5 by Claudio Cambra at 2024-12-22T12:06:23+00:00
macosx: Set bool directory in defaults regarding time field mode
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
905edadb by Claudio Cambra at 2024-12-22T12:06:23+00:00
macosx: Further cleanups for code in VLCTimeField formatting
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
5a743172 by Claudio Cambra at 2024-12-22T12:06:23+00:00
macosx: Constify time field display time setting strings
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
039c1b38 by Claudio Cambra at 2024-12-22T12:06:23+00:00
Replace setRemainingIdentifier with override of standard identifier
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
3 changed files:
- modules/gui/macosx/views/VLCTimeField.h
- modules/gui/macosx/views/VLCTimeField.m
- modules/gui/macosx/windows/controlsbar/VLCControlsBarCommon.m
Changes:
=====================================
modules/gui/macosx/views/VLCTimeField.h
=====================================
@@ -30,14 +30,13 @@
* we need the implementation to catch our click-event in the controller window
*****************************************************************************/
-extern NSString *VLCTimeFieldDisplayTimeAsElapsed;
-extern NSString *VLCTimeFieldDisplayTimeAsRemaining;
+extern NSString * const VLCTimeFieldDisplayTimeAsElapsed;
+extern NSString * const VLCTimeFieldDisplayTimeAsRemaining;
@interface VLCTimeField : NSTextField
@property (readwrite, assign, nonatomic) BOOL isTimeRemaining;
-- (void)setRemainingIdentifier:(NSString *)identifier;
- (void)setTime:(NSString *)time withRemainingTime:(NSString *)remainingTime;
@end
=====================================
modules/gui/macosx/views/VLCTimeField.m
=====================================
@@ -28,12 +28,11 @@
#import "main/VLCMain.h"
#import "menus/VLCMainMenu.h"
-NSString *VLCTimeFieldDisplayTimeAsElapsed = @"DisplayTimeAsTimeElapsed";
-NSString *VLCTimeFieldDisplayTimeAsRemaining = @"DisplayTimeAsTimeRemaining";
+NSString * const VLCTimeFieldDisplayTimeAsElapsed = @"DisplayTimeAsTimeElapsed";
+NSString * const VLCTimeFieldDisplayTimeAsRemaining = @"DisplayTimeAsTimeRemaining";
@interface VLCTimeField ()
{
- NSString *_identifier;
NSString *_cachedTime;
NSString *_remainingTime;
}
@@ -43,42 +42,38 @@ NSString *VLCTimeFieldDisplayTimeAsRemaining = @"DisplayTimeAsTimeRemaining";
+ (void)initialize
{
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
- @"NO", VLCTimeFieldDisplayTimeAsRemaining,
- nil];
-
- [defaults registerDefaults:appDefaults];
+ NSDictionary * const appDefaults = @{VLCTimeFieldDisplayTimeAsRemaining : @NO};
+ [NSUserDefaults.standardUserDefaults registerDefaults:appDefaults];
}
-- (void)setRemainingIdentifier:(NSString *)identifier
+- (void)setIdentifier:(NSUserInterfaceItemIdentifier)identifier
{
- _identifier = identifier;
- _isTimeRemaining = [[NSUserDefaults standardUserDefaults] boolForKey:_identifier];
+ [super setIdentifier:identifier];
+ self.isTimeRemaining = [NSUserDefaults.standardUserDefaults boolForKey:self.identifier];
}
- (void)setIsTimeRemaining:(BOOL)isTimeRemaining
{
_isTimeRemaining = isTimeRemaining;
- if (_identifier) {
- [[NSUserDefaults standardUserDefaults] setObject:(_isTimeRemaining ? @"YES" : @"NO") forKey:_identifier];
+ if (self.identifier) {
+ [NSUserDefaults.standardUserDefaults setBool:_isTimeRemaining forKey:self.identifier];
}
[self updateTimeValue];
}
-- (void)mouseDown: (NSEvent *)ourEvent
+- (void)mouseDown:(NSEvent *)ourEvent
{
- if ( [ourEvent clickCount] > 1 ) {
- [VLCMain.sharedInstance.mainMenu goToSpecificTime: nil];
+ if (ourEvent.clickCount > 1) {
+ [VLCMain.sharedInstance.mainMenu goToSpecificTime:nil];
} else {
self.isTimeRemaining = !self.isTimeRemaining;
}
[self updateTimeValue];
- [[self nextResponder] mouseDown:ourEvent];
+ [self.nextResponder mouseDown:ourEvent];
}
- (void)setTime:(NSString *)time withRemainingTime:(NSString *)remainingTime
@@ -91,13 +86,14 @@ NSString *VLCTimeFieldDisplayTimeAsRemaining = @"DisplayTimeAsTimeRemaining";
- (void)updateTimeValue
{
- if (!_cachedTime || !_remainingTime)
+ if (!_cachedTime || !_remainingTime) {
return;
+ }
- if ([self timeRemaining]) {
- [super setStringValue:_remainingTime];
+ if (self.timeRemaining) {
+ self.stringValue = _remainingTime;
} else {
- [super setStringValue:_cachedTime];
+ self.stringValue = _cachedTime;
}
}
@@ -111,10 +107,11 @@ NSString *VLCTimeFieldDisplayTimeAsRemaining = @"DisplayTimeAsTimeRemaining";
- (BOOL)timeRemaining
{
- if (_identifier)
- return [[NSUserDefaults standardUserDefaults] boolForKey:_identifier];
- else
+ if (self.identifier) {
+ return [NSUserDefaults.standardUserDefaults boolForKey:self.identifier];
+ } else {
return _isTimeRemaining;
+ }
}
@end
=====================================
modules/gui/macosx/windows/controlsbar/VLCControlsBarCommon.m
=====================================
@@ -216,13 +216,13 @@
self.muteVolumeButton.accessibilityLabel = self.muteVolumeButton.toolTip;
self.timeField.needsDisplay = YES;
- [self.timeField setRemainingIdentifier:VLCTimeFieldDisplayTimeAsElapsed];
+ self.timeField.identifier = VLCTimeFieldDisplayTimeAsElapsed;
self.trailingTimeField.isTimeRemaining = NO;
self.timeField.accessibilityLabel = _NS("Playback time");
self.trailingTimeField.isTimeRemaining = !self.timeField.isTimeRemaining;
self.trailingTimeField.needsDisplay = YES;
- [self.trailingTimeField setRemainingIdentifier:VLCTimeFieldDisplayTimeAsRemaining];
+ self.timeField.identifier = VLCTimeFieldDisplayTimeAsRemaining;
self.trailingTimeField.isTimeRemaining = YES;
self.trailingTimeField.accessibilityLabel = _NS("Playback time");
@@ -430,8 +430,6 @@
[self.timeField setTime:timeString withRemainingTime:remainingTime];
[self.trailingTimeField setTime:timeString withRemainingTime:remainingTime];
- self.timeField.needsDisplay = YES;
- self.trailingTimeField.needsDisplay = YES;
}
- (void)updateVolumeSlider:(NSNotification *)aNotification
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4ae6754355eecf72da9b5d5880ca3adc898a3424...039c1b38e7d2f396d79d04f88e6e1185a295663b
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4ae6754355eecf72da9b5d5880ca3adc898a3424...039c1b38e7d2f396d79d04f88e6e1185a295663b
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