From a55eb27d5f918b63310947ee559a762f92213e7a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9rome=20Decoodt?= Date: Sun, 13 Mar 2005 23:19:12 +0000 Subject: [PATCH] Added setScrollField: and resetScrollField to manage the scroll field. --- modules/gui/macosx/controls.m | 14 +++++++++-- modules/gui/macosx/intf.h | 3 +++ modules/gui/macosx/intf.m | 45 +++++++++++++++++++++++++++++++---- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/modules/gui/macosx/controls.m b/modules/gui/macosx/controls.m index 9e0b6ce18f..6f738d571d 100644 --- a/modules/gui/macosx/controls.m +++ b/modules/gui/macosx/controls.m @@ -247,17 +247,27 @@ { intf_thread_t * p_intf = VLCIntf; audio_volume_t i_volume = (audio_volume_t)[sender intValue]; - aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_STEP ); + [self updateVolumeSlider]; } - (void)updateVolumeSlider { + NSString * o_text; + char * psz_text; intf_thread_t * p_intf = VLCIntf; audio_volume_t i_volume; aout_VolumeGet( p_intf, &i_volume ); - + psz_text = malloc( 32 * sizeof( char ) ); +/*FIXME: do we really need to work with a char * before NSString ? */ + if( psz_text ) + { + sprintf( psz_text, "Volume: %d", i_volume * 200 / AOUT_VOLUME_MAX ); + o_text = [[NSString alloc] initWithCString:psz_text]; + [o_main setScrollField:o_text stopAfter:1000000]; + free( psz_text ); + } [o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)]; } diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h index d1f552a417..d43771cc04 100644 --- a/modules/gui/macosx/intf.h +++ b/modules/gui/macosx/intf.h @@ -237,6 +237,7 @@ struct intf_sys_t bool b_small_window; + mtime_t i_end_scroll; } + (VLCMain *)sharedInstance; @@ -258,6 +259,8 @@ struct intf_sys_t - (void)manage; - (void)manageIntf:(NSTimer *)o_timer; - (void)setupMenus; +- (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout; +- (void)resetScrollField; - (void)updateMessageArray; - (void)playStatusUpdated:(int) i_status; diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index f4defeced0..d227969a95 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -417,7 +417,7 @@ static VLCMain *_o_sharedMainInstance = nil; - (void)initStrings { [o_window setTitle: _NS("VLC - Controller")]; - [o_scrollfield setStringValue: _NS("VLC media player")]; + [self setScrollField:_NS("VLC media player") stopAfter:-1]; /* button controls */ [o_btn_prev setToolTip: _NS("Previous")]; @@ -755,7 +755,6 @@ static VLCMain *_o_sharedMainInstance = nil; { NSDate * o_sleep_date; playlist_t * p_playlist; - vlc_value_t val; /* new thread requires a new pool */ NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; @@ -797,7 +796,7 @@ static VLCMain *_o_sharedMainInstance = nil; /* input stopped */ p_intf->p_sys->b_intf_update = VLC_TRUE; p_intf->p_sys->i_play_status = END_S; - [o_scrollfield setStringValue: _NS("VLC media player") ]; + [self setScrollField: _NS("VLC media player") stopAfter:-1]; vlc_object_release( p_input ); p_input = NULL; } @@ -909,7 +908,7 @@ static VLCMain *_o_sharedMainInstance = nil; if( o_temp == NULL ) o_temp = [NSString stringWithCString: p_playlist->status.p_item->input.psz_name]; - [o_scrollfield setStringValue: o_temp ]; + [self setScrollField: o_temp stopAfter:-1]; p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE ); @@ -978,6 +977,9 @@ static VLCMain *_o_sharedMainInstance = nil; [self updateMessageArray]; + if( (i_end_scroll != -1) && (mdate() > i_end_scroll) ) + [self resetScrollField]; + [NSTimer scheduledTimerWithTimeInterval: 0.3 target: self selector: @selector(manageIntf:) userInfo: nil repeats: FALSE]; @@ -1052,6 +1054,41 @@ static VLCMain *_o_sharedMainInstance = nil; #undef p_input } +- (void)setScrollField:(NSString *)o_string stopAfter:(int)timeout +{ + if( timeout != -1 ) + i_end_scroll = mdate() + timeout; + else + i_end_scroll = -1; + [o_scrollfield setStringValue: o_string]; +} + +- (void)resetScrollField +{ + i_end_scroll = -1; +#define p_input p_intf->p_sys->p_input + if( p_input && !p_input->b_die ) + { + NSString *o_temp; + playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, + FIND_ANYWHERE ); + if( p_playlist == NULL ) + { + return; + } + o_temp = [NSString stringWithUTF8String: + p_playlist->status.p_item->input.psz_name]; + if( o_temp == NULL ) + o_temp = [NSString stringWithCString: + p_playlist->status.p_item->input.psz_name]; + [self setScrollField: o_temp stopAfter:-1]; + vlc_object_release( p_playlist ); + return; + } +#undef p_input + [self setScrollField: _NS("VLC media player") stopAfter:-1]; +} + - (void)updateMessageArray { int i_start, i_stop; -- 2.39.5