Commit 8d3e7704 authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wxwidgets: fixes and improvements to the main interface code.

parent 507fe5c1
......@@ -71,6 +71,7 @@ InputManager::InputManager( intf_thread_t *_p_intf, Interface *_p_main_intf,
i_old_playing_status = STATUS_STOP;
i_old_rate = INPUT_RATE_DEFAULT;
b_slider_free = VLC_TRUE;
i_input_hide_delay = 0;
/* Create slider */
slider = new wxSlider( this, SliderScroll_Event, 0, 0, SLIDER_MAX_POS );
......@@ -280,10 +281,15 @@ void InputManager::Update()
{
slider->SetValue( 0 );
}
else
else if( !i_input_hide_delay )
{
i_input_hide_delay = mdate() + 200000;
}
else if( i_input_hide_delay < mdate() )
{
if( disc_frame->IsShown() ) HideDiscFrame();
if( slider->IsShown() ) HideSlider();
i_input_hide_delay = 0;
}
}
else if( p_input->b_dead )
......@@ -292,6 +298,10 @@ void InputManager::Update()
vlc_object_release( p_input );
p_input = NULL;
}
else
{
i_input_hide_delay = 0;
}
if( p_input && !p_input->b_die )
{
......@@ -416,8 +426,7 @@ void InputManager::ShowSlider( bool show )
{
if( !!show == !!slider->IsShown() ) return;
if( p_intf->p_sys->b_video_autosize )
UpdateVideoWindow( p_intf, p_main_intf->video_window );
UpdateVideoWindow( p_intf, p_main_intf->video_window );
sizer->Show( slider, show );
sizer->Layout();
......@@ -430,8 +439,7 @@ void InputManager::ShowDiscFrame( bool show )
{
if( !!show == !!disc_frame->IsShown() ) return;
if( p_intf->p_sys->b_video_autosize )
UpdateVideoWindow( p_intf, p_main_intf->video_window );
UpdateVideoWindow( p_intf, p_main_intf->video_window );
sizer->Show( disc_frame, show );
sizer->Layout();
......
......@@ -84,6 +84,7 @@ namespace wxvlc
int i_old_playing_status; ///< Previous playing status
int i_old_rate; ///< Previous playing rate
mtime_t i_input_hide_delay; ///< Allows delaying slider hidding
};
};
......
......@@ -222,7 +222,8 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
/* Create a main panel that will fill in the interface window */
main_sizer = new wxBoxSizer( wxVERTICAL );
SetSizer( main_sizer );
main_panel = new wxPanel( this );
main_panel = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize,
wxCLIP_CHILDREN );
main_sizer->Add( main_panel, 1, wxEXPAND );
main_panel->SetFocus();
......@@ -260,6 +261,11 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
statusbar->SetStatusWidths( 3, i_status_width );
statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );
/* Get minimum window size to prevent user from glitching it */
panel_sizer->Layout(); panel_sizer->Fit( main_panel );
main_sizer->Layout(); main_sizer->Fit( this );
main_min_size = GetSize();
/* Video window */
video_window = 0;
if( config_GetInt( p_intf, "wx-embed" ) )
......@@ -273,10 +279,8 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
panel_sizer->Add( input_manager, 0, wxEXPAND , 0 );
/* Layout everything */
panel_sizer->Layout();
panel_sizer->Fit( main_panel );
main_sizer->Layout();
main_sizer->Fit( this );
panel_sizer->Layout(); panel_sizer->Fit( main_panel );
main_sizer->Layout(); main_sizer->Fit( this );
#if wxUSE_DRAG_AND_DROP
/* Associate drop targets with the main interface */
......@@ -299,12 +303,6 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
if( ws->GetSettings( WindowSettings::ID_MAIN, b_shown, p, s ) ) Move( p );
/* Get minimum window size to prevent user from glitching it */
s = GetSize();
if( video_window && video_window->IsShown() )
s.SetHeight( s.GetHeight() - video_window->GetSize().GetHeight() );
main_min_size = s;
/* Show extended GUI if requested */
wxCommandEvent dummy;
if( config_GetInt( p_intf, "wx-extended" ) ) OnExtended( dummy );
......@@ -353,11 +351,8 @@ void Interface::OnControlEvent( wxCommandEvent& event )
switch( event.GetId() )
{
case 0:
if( p_intf->p_sys->b_video_autosize )
{
main_sizer->Layout();
main_sizer->Fit(this);
}
main_sizer->Layout();
main_sizer->Fit( this );
break;
case 1:
......@@ -659,11 +654,7 @@ void Interface::SetIntfMinSize()
ms.SetWidth( ext_min_size.GetWidth() );
}
#if ( wxCHECK_VERSION( 2,5,4 ) )
SetMinSize( ms );
#else
main_sizer->SetMinSize( ms );
#endif
SetSizeHints( ms );
}
/*****************************************************************************
......@@ -824,6 +815,8 @@ void Interface::OnShowDialog( wxCommandEvent& event )
void Interface::OnExtended( wxCommandEvent& WXUNUSED(event) )
{
UpdateVideoWindow( p_intf, video_window );
if( !extra_frame )
{
/* Create the extra panel */
......@@ -833,7 +826,6 @@ void Interface::OnExtended( wxCommandEvent& WXUNUSED(event) )
}
b_extra = !b_extra;
panel_sizer->Show( extra_frame, b_extra );
SetIntfMinSize();
......@@ -999,6 +991,14 @@ void Interface::TogglePlayButton( int i_playing_status )
}
GetToolBar()->Realize();
#if defined( __WXMSW__ )
/* Needed to work around a bug in wxToolBar::Realize() */
GetToolBar()->SetSize( GetSize().GetWidth(),
GetToolBar()->GetSize().GetHeight() );
GetToolBar()->Update();
#endif
GetToolBar()->ToggleTool( PlayStream_Event, true );
GetToolBar()->ToggleTool( PlayStream_Event, false );
}
......
......@@ -70,7 +70,9 @@ wxWindow *CreateVideoWindow( intf_thread_t *p_intf, wxWindow *p_parent )
void UpdateVideoWindow( intf_thread_t *p_intf, wxWindow *p_window )
{
#if (wxCHECK_VERSION(2,5,0))
#if (wxCHECK_VERSION(2,5,3))
if( !p_intf->p_sys->b_video_autosize ) return;
if( p_window && mdate() - ((VideoWindow *)p_window)->i_creation_date < 2000000 )
return; /* Hack to prevent saving coordinates if window is not yet
* properly created. Yuck :( */
......@@ -84,15 +86,16 @@ void UpdateVideoWindow( intf_thread_t *p_intf, wxWindow *p_window )
* Constructor.
*****************************************************************************/
VideoWindow::VideoWindow( intf_thread_t *_p_intf, wxWindow *_p_parent ):
wxWindow( _p_parent, -1 )
wxWindow( _p_parent, -1, wxDefaultPosition, wxDefaultSize, wxCLIP_CHILDREN )
{
/* Initializations */
p_intf = _p_intf;
p_parent = _p_parent;
p_child_window = 0;
vlc_mutex_init( p_intf, &lock );
b_auto_size = config_GetInt( p_intf, "wx-autosize" );
b_auto_size = p_intf->p_sys->b_video_autosize;
p_vout = NULL;
i_creation_date = 0;
......@@ -118,15 +121,18 @@ VideoWindow::VideoWindow( intf_thread_t *_p_intf, wxWindow *_p_parent ):
SetSize( child_size );
}
p_child_window = new wxWindow( this, -1, wxDefaultPosition, child_size );
#ifdef __WXGTK__
p_child_window = new wxWindow( this, -1, wxDefaultPosition, child_size,
wxCLIP_CHILDREN );
#endif
if( !b_auto_size )
{
SetBackgroundColour( *wxBLACK );
p_child_window->SetBackgroundColour( *wxBLACK );
if( p_child_window ) p_child_window->SetBackgroundColour( *wxBLACK );
}
p_child_window->Show();
if( p_child_window ) p_child_window->Show();
Show();
b_shown = VLC_TRUE;
......@@ -333,8 +339,8 @@ int VideoWindow::ControlWindow( void *p_window, int i_query, va_list args )
unsigned int *pi_width = va_arg( args, unsigned int * );
unsigned int *pi_height = va_arg( args, unsigned int * );
*pi_width = GetSize().GetWidth();
*pi_height = GetSize().GetHeight();
*pi_width = GetSize().GetWidth();
*pi_height = GetSize().GetHeight();
i_ret = VLC_SUCCESS;
}
break;
......
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