Commit ce80081c authored by Yoann Peronneau's avatar Yoann Peronneau

* wxwidgets: try to implement a go-where-you-click slider

  but I don't have a real video/audio file to test it...
parent a17edf64
...@@ -75,6 +75,10 @@ InputManager::InputManager( intf_thread_t *_p_intf, Interface *_p_main_intf, ...@@ -75,6 +75,10 @@ InputManager::InputManager( intf_thread_t *_p_intf, Interface *_p_main_intf,
/* Create slider */ /* Create slider */
slider = new wxSlider( this, SliderScroll_Event, 0, 0, SLIDER_MAX_POS ); slider = new wxSlider( this, SliderScroll_Event, 0, 0, SLIDER_MAX_POS );
/* Add mouse click on slider */
slider->Connect( wxEVT_LEFT_DOWN,
wxMouseEventHandler( InputManager::OnSliderClick ),
NULL, this );
/* Create disc buttons */ /* Create disc buttons */
disc_frame = new wxPanel( this ); disc_frame = new wxPanel( this );
...@@ -427,6 +431,22 @@ void InputManager::OnSliderUpdate( wxScrollEvent& event ) ...@@ -427,6 +431,22 @@ void InputManager::OnSliderUpdate( wxScrollEvent& event )
vlc_mutex_unlock( &p_intf->change_lock ); vlc_mutex_unlock( &p_intf->change_lock );
} }
void InputManager::OnSliderClick( wxMouseEvent& event )
{
wxSlider* slider = wxStaticCast( event.GetEventObject(), wxSlider );
int min = slider->GetMin();
int max = slider->GetMax();
int pos = event.GetPosition().x;
int dim = slider->GetClientSize().x;
if( pos < 0 || pos >= dim ) return;
int val = ( pos * ( max - min + 1 ) ) / dim;
slider->SetValue( min + val );
event.Skip();
}
void InputManager::ShowSlider( bool show ) void InputManager::ShowSlider( bool show )
{ {
if( !!show == !!slider->IsShown() ) return; if( !!show == !!slider->IsShown() ) return;
......
...@@ -54,6 +54,7 @@ namespace wxvlc ...@@ -54,6 +54,7 @@ namespace wxvlc
void ShowSlider( bool show = true ); void ShowSlider( bool show = true );
void OnSliderUpdate( wxScrollEvent& event ); void OnSliderUpdate( wxScrollEvent& event );
void OnSliderClick( wxMouseEvent& event );
void OnDiscMenu( wxCommandEvent& event ); void OnDiscMenu( wxCommandEvent& event );
void OnDiscPrev( wxCommandEvent& event ); void OnDiscPrev( wxCommandEvent& event );
......
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