]> git.sesse.net Git - vlc/commitdiff
* modules/gui/wince: better volume slider behaviour.
authorGildas Bazin <gbazin@videolan.org>
Wed, 16 Mar 2005 23:38:51 +0000 (23:38 +0000)
committerGildas Bazin <gbazin@videolan.org>
Wed, 16 Mar 2005 23:38:51 +0000 (23:38 +0000)
modules/gui/wince/interface.cpp
modules/gui/wince/timer.cpp
modules/gui/wince/wince.h

index b4bcdc7cd9d446ca2149fe140e79ff4ed0f2a22c..634655ff5c45937efb02065d5e5b9ab410c37961 100644 (file)
@@ -108,7 +108,7 @@ Interface::Interface()
   : hwndMain(0), hwndCB(0), hwndTB(0), hwndSlider(0), hwndLabel(0),
     hwndVol(0), hwndSB(0),
     fileinfo(0), messages(0), preferences(0), playlist(0),
-    timer(0), open(0), video(0)
+    timer(0), open(0), video(0), b_volume_hold(0)
 {
 }
 
@@ -915,17 +915,34 @@ void Interface::OnChange( int wp )
 
     if( LOWORD(wp) == SB_THUMBPOSITION || LOWORD(wp) == SB_ENDSCROLL )
     {
-        Change( 200 - (int)dwPos );
+        VolumeChange( 200 - (int)dwPos );
+        b_volume_hold = VLC_FALSE;
+    }
+    else
+    {
+        b_volume_hold = VLC_TRUE;
     }
 }
 
-void Interface::Change( int i_volume )
+void Interface::VolumeChange( int i_volume )
 {
     aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
-#if 0
-    SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
-                i_volume ) );
-#endif
+}
+
+void Interface::VolumeUpdate()
+{
+    audio_volume_t i_volume;
+
+    if( b_volume_hold ) return;
+
+    aout_VolumeGet( p_intf, &i_volume );
+
+    int i_volume_ctrl = 200 - i_volume * 200 * 2 / AOUT_VOLUME_MAX;
+
+    DWORD dwPos = SendMessage( hwndVol, TBM_GETPOS, 0, 0 );
+    if( i_volume_ctrl == (int)dwPos ) return;
+
+    SendMessage( hwndVol, TBM_SETPOS, 1, i_volume_ctrl );
 }
 
 void Interface::OnStopStream( void )
@@ -982,3 +999,9 @@ void Interface::OnFastStream( void )
     var_Set( p_input, "rate-faster", val );
     vlc_object_release( p_input );
 }
+
+void Interface::Update()
+{
+    /* Misc updates */
+    VolumeUpdate();
+}
index f2f354818e73348c7164e61ba50702d673a4fb0f..d7bd859a8aafe1aa637149c2cb92828edbf7442f 100644 (file)
@@ -118,12 +118,6 @@ void Timer::Notify( void )
 
             p_main_interface->TogglePlayButton( PLAYING_S );
             i_old_playing_status = PLAYING_S;
-
-            /* Take care of the volume */
-            audio_volume_t i_volume;
-            aout_VolumeGet( p_intf, &i_volume );                        
-            SendMessage( p_main_interface->hwndVol, TBM_SETPOS, 1,
-                         200 - (i_volume * 200 * 2 / AOUT_VOLUME_MAX ) );
         }
     }
     else if( p_intf->p_sys->p_input->b_dead )
@@ -183,6 +177,9 @@ void Timer::Notify( void )
                 }
             }
 
+            /* Take care of the volume, etc... */
+            p_main_interface->Update();
+
             /* Manage Playing status */
             var_Get( p_input, "state", &val );
             if( i_old_playing_status != val.i_int )
index 098e7be0ed1d0588be7143f9d792488d3621d2bf..31c6afff4d2b994f8a5f6f4b8de68f31d0fe664b 100644 (file)
@@ -141,6 +141,7 @@ public:
 
     HWND CreateMenuBar( HWND, HINSTANCE );
     void TogglePlayButton( int i_playing_status );
+    void Update();
 
     HWND hwndMain;      // Handle to the main window.
 
@@ -171,7 +172,8 @@ protected:
 
     void OnSliderUpdate( int wp );
     void OnChange( int wp );
-    void Change( int i_volume );
+    void VolumeChange( int i_volume );
+    void VolumeUpdate( void );
     void OnStopStream( void );
     void OnPrevStream( void );
     void OnNextStream( void );
@@ -185,6 +187,8 @@ private:
     HMENU menu_video;
     HMENU menu_audio;
     HMENU menu_navigation;
+
+    vlc_bool_t b_volume_hold;
 };
 
 /* File Info */