[vlc-commits] macosx: adapt VLCTimeField and add additional option for remaining state of fs field
David Fuhrmann
git at videolan.org
Sun Feb 24 18:08:43 CET 2013
vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Sun Feb 24 18:06:02 2013 +0100| [cd8f993a5498d82246e96b50f00528b1fcf88ac3] | committer: David Fuhrmann
macosx: adapt VLCTimeField and add additional option for remaining state of fs field
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cd8f993a5498d82246e96b50f00528b1fcf88ac3
---
modules/gui/macosx/ControlsBar.m | 8 ++++++
modules/gui/macosx/fspanel.m | 1 +
modules/gui/macosx/misc.h | 9 ++++++-
modules/gui/macosx/misc.m | 52 +++++++++++++++++++++++++-------------
4 files changed, 52 insertions(+), 18 deletions(-)
diff --git a/modules/gui/macosx/ControlsBar.m b/modules/gui/macosx/ControlsBar.m
index 411ba83..15a5a97 100644
--- a/modules/gui/macosx/ControlsBar.m
+++ b/modules/gui/macosx/ControlsBar.m
@@ -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) {
diff --git a/modules/gui/macosx/fspanel.m b/modules/gui/macosx/fspanel.m
index 1849cbb..0d73ff2 100644
--- a/modules/gui/macosx/fspanel.m
+++ b/modules/gui/macosx/fspanel.m
@@ -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];
diff --git a/modules/gui/macosx/misc.h b/modules/gui/macosx/misc.h
index a523c9e..6855c05 100644
--- a/modules/gui/macosx/misc.h
+++ b/modules/gui/macosx/misc.h
@@ -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
/*****************************************************************************
diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m
index 502bfd9..60955a5 100644
--- a/modules/gui/macosx/misc.m
+++ b/modules/gui/macosx/misc.m
@@ -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
/*****************************************************************************
More information about the vlc-commits
mailing list