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 @@
[o_play_btn setImage: o_play_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 setNeedsDisplay:YES];
[o_time_fld setRemainingIdentifier:@"DisplayTimeAsTimeRemaining"];
// prepare time slider fance gradient view
if (!b_dark_interface) {
......
......@@ -472,6 +472,7 @@
s_rc.origin.y = 64;
s_rc.size.width = 65;
addTextfield(VLCTimeField, o_streamLength_txt, NSRightTextAlignment, systemFontOfSize, whiteColor);
[o_streamLength_txt setRemainingIdentifier: @"DisplayFullscreenTimeAsTimeRemaining"];
o_background_img = [[NSImage imageNamed:@"fs_background"] retain];
o_vol_sld_img = [[NSImage imageNamed:@"fs_volume_slider_bar"] retain];
......
......@@ -150,10 +150,17 @@
@interface VLCTimeField : NSTextField
{
NSShadow * o_string_shadow;
NSDictionary * o_string_attributes_dict;
NSTextAlignment textAlignment;
NSString *o_remaining_identifier;
BOOL b_time_remaining;
}
@property (readonly) BOOL timeRemaining;
-(id)initWithFrame:(NSRect)frameRect;
- (void)setRemainingIdentifier:(NSString *)o_string;
@end
/*****************************************************************************
......
......@@ -603,21 +603,28 @@ void _drawFrameInRect(NSRect frameRect)
@implementation VLCTimeField
+ (void)initialize{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:@"NO" forKey:@"DisplayTimeAsTimeRemaining"];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
@"NO", @"DisplayTimeAsTimeRemaining",
@"YES", @"DisplayFullscreenTimeAsTimeRemaining",
nil];
[defaults registerDefaults:appDefaults];
}
- (void)awakeFromNib
- (id)initWithFrame:(NSRect)frameRect
{
NSColor *o_string_color;
if (!config_GetInt( 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];
if (self = [super initWithFrame:frameRect]) {
textAlignment = NSCenterTextAlignment;
o_remaining_identifier = @"";
}
return self;
}
textAlignment = NSCenterTextAlignment;
o_string_attributes_dict = [[NSDictionary dictionaryWithObjectsAndKeys: o_string_color, NSForegroundColorAttributeName, [NSFont titleBarFontOfSize:10.0], NSFontAttributeName, nil] retain];
- (void)setRemainingIdentifier:(NSString *)o_string
{
o_remaining_identifier = o_string;
b_time_remaining = [[NSUserDefaults standardUserDefaults] boolForKey:o_remaining_identifier];
}
- (void)setAlignment:(NSTextAlignment)alignment
......@@ -629,7 +636,6 @@ void _drawFrameInRect(NSRect frameRect)
- (void)dealloc
{
[o_string_shadow release];
[o_string_attributes_dict release];
[super dealloc];
}
......@@ -642,7 +648,7 @@ void _drawFrameInRect(NSRect frameRect)
[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];
[o_attributed_string addAttribute: NSShadowAttributeName value: o_string_shadow range: NSMakeRange(0, i_stringLength)];
......@@ -657,17 +663,29 @@ void _drawFrameInRect(NSRect frameRect)
[[[VLCMain sharedInstance] controls] goToSpecificTime: nil];
else
{
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayTimeAsTimeRemaining"])
[[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"DisplayTimeAsTimeRemaining"];
else
[[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"DisplayTimeAsTimeRemaining"];
if (![o_remaining_identifier isEqualToString: @""]) {
if ([[NSUserDefaults standardUserDefaults] boolForKey:o_remaining_identifier]) {
[[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:o_remaining_identifier];
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
{
return [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayTimeAsTimeRemaining"];
if (![o_remaining_identifier isEqualToString: @""])
return [[NSUserDefaults standardUserDefaults] boolForKey:o_remaining_identifier];
else
return b_time_remaining;
}
@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