]> git.sesse.net Git - vlc/commitdiff
* modules/gui/wxwidgets: fixes and improvements to the main interface code.
authorGildas Bazin <gbazin@videolan.org>
Thu, 1 Dec 2005 19:03:28 +0000 (19:03 +0000)
committerGildas Bazin <gbazin@videolan.org>
Thu, 1 Dec 2005 19:03:28 +0000 (19:03 +0000)
modules/gui/wxwidgets/input_manager.cpp
modules/gui/wxwidgets/input_manager.hpp
modules/gui/wxwidgets/interface.cpp
modules/gui/wxwidgets/video.cpp

index 5cc094c5ae5896d61e93555c8db1cbaab51f2ff8..1ba210481763c86501e332a09ed0d7478044134b 100644 (file)
@@ -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();
index 3206d23119e55c870a79e3fa4680b3e7f0a5fdd8..42727ef8e68009eedf097954290c2d1980fba94d 100644 (file)
@@ -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
     };
 };
 
index db8bf469f1616d767d947475b5a4b0c4f4eab75c..5542b68832bd14a9bbf7ba41e4256ed5030cbb3d 100644 (file)
@@ -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 );
 }
index e94356b3f0b7d0728c83eceafe530b50d88d4dcd..1b8c8b06cf24f659b0e466736b134be2e2c7fa33 100644 (file)
@@ -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;