From 58a23fb880f43cc05994e32d7b029b78827ca3b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20Paul=20K=C3=BChne?= Date: Wed, 27 Jul 2011 11:43:30 +0200 Subject: [PATCH] macosx: store counting mode of the time field (default is to count up) Fixes #3078 --- modules/gui/macosx/MainWindow.h | 2 -- modules/gui/macosx/MainWindow.m | 12 ++++-------- modules/gui/macosx/misc.h | 1 + modules/gui/macosx/misc.m | 19 ++++++++++++++++++- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/modules/gui/macosx/MainWindow.h b/modules/gui/macosx/MainWindow.h index 7295c08e87..6545081aaf 100644 --- a/modules/gui/macosx/MainWindow.h +++ b/modules/gui/macosx/MainWindow.h @@ -59,7 +59,6 @@ BOOL b_dark_interface; BOOL b_video_playback_enabled; - BOOL b_time_remaining; int i_lastShownVolume; BOOL b_mute; input_state_e cachedInputState; @@ -94,7 +93,6 @@ - (IBAction)repeat:(id)sender; - (IBAction)shuffle:(id)sender; - (IBAction)timeSliderAction:(id)sender; -- (IBAction)timeFieldWasClicked:(id)sender; - (IBAction)volumeAction:(id)sender; - (IBAction)effects:(id)sender; - (IBAction)fullscreen:(id)sender; diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m index 92f38fc270..dca06f70c9 100644 --- a/modules/gui/macosx/MainWindow.m +++ b/modules/gui/macosx/MainWindow.m @@ -29,6 +29,7 @@ #import "CoreInteraction.h" #import "AudioEffects.h" #import "MainMenu.h" +#import "misc.h" #import "controls.h" // TODO: remove me #import #import @@ -415,7 +416,7 @@ static VLCMainWindow *_o_sharedInstance = nil; var_Get( p_input, "time", &time ); mtime_t dur = input_item_GetDuration( input_GetItem( p_input ) ); - if( b_time_remaining && dur != -1 ) + if( [o_time_fld timeRemaining] && dur != -1 ) { o_time = [NSString stringWithFormat: @"-%s", secstotimestr( psz_time, ((dur - time.i_time) / 1000000) )]; } @@ -429,12 +430,6 @@ static VLCMainWindow *_o_sharedInstance = nil; [self drawFancyGradientEffectForTimeSlider]; } -- (IBAction)timeFieldWasClicked:(id)sender -{ - b_time_remaining = !b_time_remaining; - NSLog( @"b_time_remaining %i", b_time_remaining ); -} - - (IBAction)volumeAction:(id)sender { if (sender == o_volume_sld) @@ -477,7 +472,7 @@ static VLCMainWindow *_o_sharedInstance = nil; var_Get( p_input, "time", &time ); mtime_t dur = input_item_GetDuration( input_GetItem( p_input ) ); - if( b_time_remaining && dur != -1 ) + if( [o_time_fld timeRemaining] && dur != -1 ) { o_time = [NSString stringWithFormat: @"-%s", secstotimestr( psz_time, ((dur - time.i_time) / 1000000))]; } @@ -485,6 +480,7 @@ static VLCMainWindow *_o_sharedInstance = nil; o_time = [NSString stringWithUTF8String: secstotimestr( psz_time, (time.i_time / 1000000) )]; [o_time_fld setStringValue: o_time]; + [o_time_fld setNeedsDisplay:YES]; // [[[[VLCMain sharedInstance] controls] fspanel] setStreamPos: f_updated andTime: o_time]; } else diff --git a/modules/gui/macosx/misc.h b/modules/gui/macosx/misc.h index a6defe57ca..b391840357 100644 --- a/modules/gui/macosx/misc.h +++ b/modules/gui/macosx/misc.h @@ -146,4 +146,5 @@ @interface VLCTimeField : NSTextField { } +- (BOOL)timeRemaining; @end diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m index 38caa1ef10..1df47a23d1 100644 --- a/modules/gui/macosx/misc.m +++ b/modules/gui/macosx/misc.m @@ -658,11 +658,28 @@ void _drawFrameInRect(NSRect frameRect) *****************************************************************************/ @implementation VLCTimeField ++ (void)initialize{ + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:@"NO" forKey:@"DisplayTimeAsTimeRemaining"]; + + [defaults registerDefaults:appDefaults]; +} + - (void)mouseDown: (NSEvent *)ourEvent { if( [ourEvent clickCount] > 1 ) [[[VLCMain sharedInstance] controls] goToSpecificTime: nil]; else - [[VLCMainWindow sharedInstance] timeFieldWasClicked: self]; + { + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayTimeAsTimeRemaining"]) + [[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"DisplayTimeAsTimeRemaining"]; + else + [[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"DisplayTimeAsTimeRemaining"]; + } +} + +- (BOOL)timeRemaining +{ + return [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayTimeAsTimeRemaining"]; } @end -- 2.39.5