Commit cd8f993a authored by David Fuhrmann's avatar David Fuhrmann

macosx: adapt VLCTimeField and add additional option for remaining state of fs field

parent 021b9f25
...@@ -108,8 +108,16 @@ ...@@ -108,8 +108,16 @@
[o_play_btn setImage: o_play_img]; [o_play_btn setImage: o_play_img];
[o_play_btn setAlternateImage: o_play_pressed_img]; [o_play_btn setAlternateImage: o_play_pressed_img];
NSColor *o_string_color;
if (!var_InheritBool(VLCIntf, "macosx-interfacestyle"))
o_string_color = [NSColor colorWithCalibratedRed:0.229 green:0.229 blue:0.229 alpha:100.0];
else
o_string_color = [NSColor colorWithCalibratedRed:0.64 green:0.64 blue:0.64 alpha:100.0];
[o_time_fld setTextColor: o_string_color];
[o_time_fld setFont:[NSFont titleBarFontOfSize:10.0]];
[o_time_fld setAlignment: NSCenterTextAlignment]; [o_time_fld setAlignment: NSCenterTextAlignment];
[o_time_fld setNeedsDisplay:YES]; [o_time_fld setNeedsDisplay:YES];
[o_time_fld setRemainingIdentifier:@"DisplayTimeAsTimeRemaining"];
// prepare time slider fance gradient view // prepare time slider fance gradient view
if (!b_dark_interface) { if (!b_dark_interface) {
......
...@@ -472,6 +472,7 @@ ...@@ -472,6 +472,7 @@
s_rc.origin.y = 64; s_rc.origin.y = 64;
s_rc.size.width = 65; s_rc.size.width = 65;
addTextfield(VLCTimeField, o_streamLength_txt, NSRightTextAlignment, systemFontOfSize, whiteColor); addTextfield(VLCTimeField, o_streamLength_txt, NSRightTextAlignment, systemFontOfSize, whiteColor);
[o_streamLength_txt setRemainingIdentifier: @"DisplayFullscreenTimeAsTimeRemaining"];
o_background_img = [[NSImage imageNamed:@"fs_background"] retain]; o_background_img = [[NSImage imageNamed:@"fs_background"] retain];
o_vol_sld_img = [[NSImage imageNamed:@"fs_volume_slider_bar"] retain]; o_vol_sld_img = [[NSImage imageNamed:@"fs_volume_slider_bar"] retain];
......
...@@ -150,10 +150,17 @@ ...@@ -150,10 +150,17 @@
@interface VLCTimeField : NSTextField @interface VLCTimeField : NSTextField
{ {
NSShadow * o_string_shadow; NSShadow * o_string_shadow;
NSDictionary * o_string_attributes_dict;
NSTextAlignment textAlignment; NSTextAlignment textAlignment;
NSString *o_remaining_identifier;
BOOL b_time_remaining;
} }
@property (readonly) BOOL timeRemaining; @property (readonly) BOOL timeRemaining;
-(id)initWithFrame:(NSRect)frameRect;
- (void)setRemainingIdentifier:(NSString *)o_string;
@end @end
/***************************************************************************** /*****************************************************************************
......
...@@ -603,21 +603,28 @@ void _drawFrameInRect(NSRect frameRect) ...@@ -603,21 +603,28 @@ void _drawFrameInRect(NSRect frameRect)
@implementation VLCTimeField @implementation VLCTimeField
+ (void)initialize{ + (void)initialize{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:@"NO" forKey:@"DisplayTimeAsTimeRemaining"]; NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
@"NO", @"DisplayTimeAsTimeRemaining",
@"YES", @"DisplayFullscreenTimeAsTimeRemaining",
nil];
[defaults registerDefaults:appDefaults]; [defaults registerDefaults:appDefaults];
} }
- (void)awakeFromNib - (id)initWithFrame:(NSRect)frameRect
{ {
NSColor *o_string_color; if (self = [super initWithFrame:frameRect]) {
if (!config_GetInt( VLCIntf, "macosx-interfacestyle")) textAlignment = NSCenterTextAlignment;
o_string_color = [NSColor colorWithCalibratedRed:0.229 green:0.229 blue:0.229 alpha:100.0]; o_remaining_identifier = @"";
else }
o_string_color = [NSColor colorWithCalibratedRed:0.64 green:0.64 blue:0.64 alpha:100.0];
return self;
}
textAlignment = NSCenterTextAlignment; - (void)setRemainingIdentifier:(NSString *)o_string
o_string_attributes_dict = [[NSDictionary dictionaryWithObjectsAndKeys: o_string_color, NSForegroundColorAttributeName, [NSFont titleBarFontOfSize:10.0], NSFontAttributeName, nil] retain]; {
o_remaining_identifier = o_string;
b_time_remaining = [[NSUserDefaults standardUserDefaults] boolForKey:o_remaining_identifier];
} }
- (void)setAlignment:(NSTextAlignment)alignment - (void)setAlignment:(NSTextAlignment)alignment
...@@ -629,7 +636,6 @@ void _drawFrameInRect(NSRect frameRect) ...@@ -629,7 +636,6 @@ void _drawFrameInRect(NSRect frameRect)
- (void)dealloc - (void)dealloc
{ {
[o_string_shadow release]; [o_string_shadow release];
[o_string_attributes_dict release];
[super dealloc]; [super dealloc];
} }
...@@ -642,7 +648,7 @@ void _drawFrameInRect(NSRect frameRect) ...@@ -642,7 +648,7 @@ void _drawFrameInRect(NSRect frameRect)
[o_string_shadow setShadowBlurRadius:0.0]; [o_string_shadow setShadowBlurRadius:0.0];
} }
NSMutableAttributedString *o_attributed_string = [[NSMutableAttributedString alloc] initWithString:string attributes: o_string_attributes_dict]; NSMutableAttributedString *o_attributed_string = [[NSMutableAttributedString alloc] initWithString:string attributes: nil];
NSUInteger i_stringLength = [string length]; NSUInteger i_stringLength = [string length];
[o_attributed_string addAttribute: NSShadowAttributeName value: o_string_shadow range: NSMakeRange(0, i_stringLength)]; [o_attributed_string addAttribute: NSShadowAttributeName value: o_string_shadow range: NSMakeRange(0, i_stringLength)];
...@@ -657,17 +663,29 @@ void _drawFrameInRect(NSRect frameRect) ...@@ -657,17 +663,29 @@ void _drawFrameInRect(NSRect frameRect)
[[[VLCMain sharedInstance] controls] goToSpecificTime: nil]; [[[VLCMain sharedInstance] controls] goToSpecificTime: nil];
else else
{ {
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayTimeAsTimeRemaining"]) if (![o_remaining_identifier isEqualToString: @""]) {
[[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"DisplayTimeAsTimeRemaining"]; if ([[NSUserDefaults standardUserDefaults] boolForKey:o_remaining_identifier]) {
else [[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:o_remaining_identifier];
[[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"DisplayTimeAsTimeRemaining"]; b_time_remaining = NO;
} else {
[[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:o_remaining_identifier];
b_time_remaining = YES;
}
} else {
b_time_remaining = !b_time_remaining;
[[NSUserDefaults standardUserDefaults] setObject:(b_time_remaining ? @"YES" : @"NO") forKey:o_remaining_identifier];
}
} }
} }
- (BOOL)timeRemaining - (BOOL)timeRemaining
{ {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayTimeAsTimeRemaining"]; if (![o_remaining_identifier isEqualToString: @""])
return [[NSUserDefaults standardUserDefaults] boolForKey:o_remaining_identifier];
else
return b_time_remaining;
} }
@end @end
/***************************************************************************** /*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment