]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/interface.cpp
* modules/gui/wxwindows/interface.cpp: fixed special hotkeys with modifiers on win32.
[vlc] / modules / gui / wxwindows / interface.cpp
index f2d7f180aa1d35af6e86265f02b8aa7405b0e4f2..a3d028543b9d9715d91131fb9599ae0a63335d5c 100644 (file)
@@ -120,6 +120,7 @@ enum
     OpenFileSimple_Event,
     OpenAdv_Event,
     OpenFile_Event,
+    OpenDir_Event,
     OpenDisc_Event,
     OpenNet_Event,
     OpenCapture_Event,
@@ -185,6 +186,7 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
     EVT_MENU(OpenFileSimple_Event, Interface::OnShowDialog)
     EVT_MENU(OpenAdv_Event, Interface::OnShowDialog)
     EVT_MENU(OpenFile_Event, Interface::OnShowDialog)
+    EVT_MENU(OpenDir_Event, Interface::OnShowDialog)
     EVT_MENU(OpenDisc_Event, Interface::OnShowDialog)
     EVT_MENU(OpenNet_Event, Interface::OnShowDialog)
     EVT_MENU(OpenCapture_Event, Interface::OnShowDialog)
@@ -209,6 +211,8 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
     EVT_COMMAND(0, wxEVT_INTF, Interface::OnControlEvent)
     EVT_COMMAND(1, wxEVT_INTF, Interface::OnControlEvent)
 
+    EVT_TIMER(ID_CONTROLS_TIMER, Interface::OnControlsTimer)
+    EVT_TIMER(ID_SLIDER_TIMER, Interface::OnSliderTimer)
 END_EVENT_TABLE()
 
 /*****************************************************************************
@@ -224,6 +228,7 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
     b_extra = VLC_FALSE;
 //    b_undock = VLC_FALSE;
 
+
     extra_window = NULL;
 
     /* Give our interface a nice little icon */
@@ -244,7 +249,7 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
     p_systray = NULL;
     if ( config_GetInt( p_intf, "wxwin-systray" ) )
     {
-        p_systray = new Systray(this);
+        p_systray = new Systray(this, p_intf);
         p_systray->SetIcon( wxIcon( vlc16x16_xpm ), wxT("VLC media player") );
         if ( (! p_systray->IsOk()) || (! p_systray->IsIconInstalled()) )
         {
@@ -273,10 +278,11 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
     statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );
 
     /* Video window */
+    video_window = 0;
     if( config_GetInt( p_intf, "wxwin-embed" ) )
     {
-        CreateVideoWindow( p_intf, this );
-        frame_sizer->Add( p_intf->p_sys->p_video_sizer, 1, wxEXPAND , 0 );
+        video_window = CreateVideoWindow( p_intf, this );
+        frame_sizer->Add( p_intf->p_sys->p_video_sizer, 1, wxEXPAND, 0 );
     }
 
     /* Creation of the slider sub-window */
@@ -298,23 +304,39 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
 
     SetupHotkeys();
 
+    m_controls_timer.SetOwner(this, ID_CONTROLS_TIMER);
+    m_slider_timer.SetOwner(this, ID_SLIDER_TIMER);
+
     /* Start timer */
     timer = new Timer( p_intf, this );
+
+    /* */
+    WindowSettings *ws = p_intf->p_sys->p_window_settings;
+    wxPoint p;
+    wxSize  s;
+    bool    b_shown;
+
+    ws->SetScreen( wxSystemSettings::GetMetric( wxSYS_SCREEN_X ),
+                   wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) );
+
+    if( ws->GetSettings( WindowSettings::ID_MAIN, b_shown, p, s ) )
+        Move( p );
 }
 
 Interface::~Interface()
 {
+    WindowSettings *ws = p_intf->p_sys->p_window_settings;
+
+    ws->SetSettings( WindowSettings::ID_MAIN, true,
+                     GetPosition(), GetSize() );
+
+    if( video_window ) delete video_window;
+
 #ifdef wxHAS_TASK_BAR_ICON
-    if( p_systray )
-    {
-        delete p_systray;
-    }
+    if( p_systray ) delete p_systray;
 #endif
 
-    if( p_intf->p_sys->p_wxwindow )
-    {
-        delete p_intf->p_sys->p_wxwindow;
-    }
+    if( p_intf->p_sys->p_wxwindow ) delete p_intf->p_sys->p_wxwindow;
 
     /* Clean up */
     delete timer;
@@ -337,8 +359,13 @@ void Interface::OnControlEvent( wxCommandEvent& event )
     switch( event.GetId() )
     {
     case 0:
+        {
+          if( p_intf->p_sys->b_video_autosize )
+          {
         frame_sizer->Layout();
         frame_sizer->Fit(this);
+          }
+        }
         break;
 
     case 1:
@@ -355,13 +382,19 @@ void Interface::OnControlEvent( wxCommandEvent& event )
  *****************************************************************************/
 void Interface::CreateOurMenuBar()
 {
+    int minimal = config_GetInt( p_intf, "wxwin-minimal" );
+
     /* Create the "File" menu */
     wxMenu *file_menu = new wxMenu;
+
+    if (!minimal)
+    {
     file_menu->Append( OpenFileSimple_Event,
                        wxU(_("Quick &Open File...\tCtrl-O")) );
 
     file_menu->AppendSeparator();
     file_menu->Append( OpenFile_Event, wxU(_("Open &File...\tCtrl-F")) );
+    file_menu->Append( OpenDir_Event, wxU(_("Open D&irectory...\tCtrl-I")) );
     file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...\tCtrl-D")) );
     file_menu->Append( OpenNet_Event,
                        wxU(_("Open &Network Stream...\tCtrl-N")) );
@@ -371,11 +404,15 @@ void Interface::CreateOurMenuBar()
     file_menu->AppendSeparator();
     file_menu->Append( Wizard_Event, wxU(_("&Wizard...\tCtrl-W")) );
     file_menu->AppendSeparator();
+    }
     file_menu->Append( Exit_Event, wxU(_("E&xit\tCtrl-X")) );
 
     /* Create the "View" menu */
     wxMenu *view_menu = new wxMenu;
+    if (!minimal)
+    {
     view_menu->Append( Playlist_Event, wxU(_("&Playlist...\tCtrl-P")) );
+    }
     view_menu->Append( Logs_Event, wxU(_("&Messages...\tCtrl-M")) );
     view_menu->Append( FileInfo_Event,
                        wxU(_("Stream and Media &info...\tCtrl-I")) );
@@ -443,6 +480,8 @@ void Interface::CreateOurToolBar()
 #define HELP_SLOW N_("Play slower")
 #define HELP_FAST N_("Play faster")
 
+    int minimal = config_GetInt( p_intf, "wxwin-minimal" );
+
     wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
                          * version because we don't include wx.rc */
 
@@ -451,17 +490,23 @@ void Interface::CreateOurToolBar()
 
     toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
 
+    if (!minimal)
+    {
     toolbar->AddTool( OpenFile_Event, wxT(""),
                       wxBitmap( eject_xpm ), wxU(_(HELP_OPEN)) );
     toolbar->AddSeparator();
+    }
 
     wxToolBarToolBase *p_tool = toolbar->AddTool( PlayStream_Event, wxT(""),
                       wxBitmap( play_xpm ), wxU(_(HELP_PLAY)) );
     p_tool->SetClientData( p_tool );
 
+    if (!minimal)
+    {
     toolbar->AddTool( StopStream_Event, wxT(""), wxBitmap( stop_xpm ),
                       wxU(_(HELP_STOP)) );
     toolbar->AddSeparator();
+
     toolbar->AddTool( PrevStream_Event, wxT(""),
                       wxBitmap( prev_xpm ), wxU(_(HELP_PLP)) );
     toolbar->AddTool( SlowStream_Event, wxT(""),
@@ -473,6 +518,7 @@ void Interface::CreateOurToolBar()
     toolbar->AddSeparator();
     toolbar->AddTool( Playlist_Event, wxT(""), wxBitmap( playlist_xpm ),
                       wxU(_(HELP_PLO)) );
+    }
 
     wxControl *p_dummy_ctrl =
         new wxControl( toolbar, -1, wxDefaultPosition,
@@ -607,7 +653,8 @@ void Interface::SetupHotkeys()
         int i_key = ConvertHotkey( p_hotkeys[i].i_key );
 
 #ifdef WIN32
-        if( i_mod ) i_key = toupper(i_key);
+        if( !(p_hotkeys[i].i_key & KEY_SPECIAL) && i_mod )
+            i_key = toupper(i_key);
 #endif
 
         p_entries[i].Set( i_mod, i_key,
@@ -628,11 +675,108 @@ void Interface::SetupHotkeys()
     delete [] p_entries;
 }
 
+void Interface::HideSlider( bool layout )
+{
+    ShowSlider( false, layout );
+}
+
+void Interface::ShowSlider( bool show, bool layout )
+{
+    if( show )
+    {
+        //prevent the hide timers from hiding it now
+        m_slider_timer.Stop();
+        m_controls_timer.Stop();
+
+        //prevent continuous layout
+        if( slider_frame->IsShown() ) return;
+
+        slider_frame->Show();
+        frame_sizer->Show( slider_frame );
+    }
+    else
+    {
+        //prevent continuous layout
+        if( !slider_frame->IsShown() ) return;
+
+        slider_frame->Hide();
+        frame_sizer->Hide( slider_frame );
+    }
+
+    if( layout )
+    {
+        frame_sizer->Layout();
+        if( p_intf->p_sys->b_video_autosize )
+        {
+            UpdateVideoWindow( p_intf, video_window );
+            frame_sizer->Fit( this );
+        }
+    }
+}
+
+void Interface::HideDiscFrame( bool layout )
+{
+    ShowDiscFrame( false, layout );
+}
+
+void Interface::ShowDiscFrame( bool show, bool layout )
+{
+    if( show )
+    {
+        //prevent the hide timer from hiding it now
+        m_controls_timer.Stop();
+
+        //prevent continuous layout
+        if( disc_frame->IsShown() ) return;
+
+        disc_frame->Show();
+        slider_sizer->Show( disc_frame );
+    }
+    else
+    {
+        //prevent continuous layout
+        if( !disc_frame->IsShown() ) return;
+
+        disc_frame->Hide();
+        slider_sizer->Hide( disc_frame );
+    }
+
+    if( layout )
+    {
+        slider_sizer->Layout();
+        if( p_intf->p_sys->b_video_autosize )
+        {
+            UpdateVideoWindow( p_intf, video_window );
+            slider_sizer->Fit( slider_frame );
+        }
+    }
+}
+
 /*****************************************************************************
  * Event Handlers.
  *****************************************************************************/
+void Interface::OnControlsTimer( wxTimerEvent& WXUNUSED(event) )
+{
+    /* Hide slider and Disc Buttons */
+    //postpone layout, we'll do it ourselves
+    HideDiscFrame( false );
+    HideSlider( false );
+
+    slider_sizer->Layout();
+    if( p_intf->p_sys->b_video_autosize )
+    {
+        slider_sizer->Fit( slider_frame );
+        UpdateVideoWindow( p_intf, video_window );
+        frame_sizer->Fit( this );
+    }
+}
 
-void Interface::OnMenuOpen(wxMenuEvent& event)
+void Interface::OnSliderTimer( wxTimerEvent& WXUNUSED(event) )
+{
+    HideSlider();
+}
+
+void Interface::OnMenuOpen( wxMenuEvent& event )
 {
 #if defined( __WXMSW__ )
 #   define GetEventObject GetMenu
@@ -731,6 +875,9 @@ void Interface::OnShowDialog( wxCommandEvent& event )
         case OpenFile_Event:
             i_id = INTF_DIALOG_FILE;
             break;
+        case OpenDir_Event:
+            i_id = INTF_DIALOG_DIRECTORY;
+            break;
         case OpenDisc_Event:
             i_id = INTF_DIALOG_DISC;
             break;
@@ -813,7 +960,11 @@ void Interface::OnExtended(wxCommandEvent& event)
                 fprintf(stderr,"Creating window\n");
             extra_frame->Hide();
             frame_sizer->Hide( extra_frame );
+#if (wxCHECK_VERSION(2,5,0))
             frame_sizer->Detach( extra_frame );
+#else
+            frame_sizer->Remove( extra_frame );
+#endif
             frame_sizer->Layout();
             frame_sizer->Fit(this);
             extra_window = new ExtraWindow( p_intf, this, extra_frame );
@@ -857,7 +1008,11 @@ void Interface::OnUndock(wxCommandEvent& event)
                 fprintf(stderr,"Creating window\n");
             extra_frame->Hide();
             frame_sizer->Hide( extra_frame );
+#if (wxCHECK_VERSION(2,5,0))
             frame_sizer->Detach( extra_frame );
+#else
+            frame_sizer->Remove( extra_frame );
+#endif
             frame_sizer->Layout();
             frame_sizer->Fit(this);
             extra_window = new ExtraWindow( p_intf, this, extra_frame );
@@ -1311,7 +1466,7 @@ BEGIN_EVENT_TABLE(Systray, wxTaskBarIcon)
     EVT_TASKBAR_LEFT_DOWN(Systray::OnLeftClick)
 #endif
     /* Menu events */
-    EVT_MENU(Iconize_Event, Systray::OnLeftClick)
+    EVT_MENU(Iconize_Event, Systray::OnMenuIconize)
     EVT_MENU(Exit_Event, Systray::OnExit)
     EVT_MENU(PlayStream_Event, Systray::OnPlayStream)
     EVT_MENU(NextStream_Event, Systray::OnNextStream)
@@ -1319,18 +1474,25 @@ BEGIN_EVENT_TABLE(Systray, wxTaskBarIcon)
     EVT_MENU(StopStream_Event, Systray::OnStopStream)
 END_EVENT_TABLE()
 
-Systray::Systray( Interface *_p_main_interface )
+Systray::Systray( Interface *_p_main_interface, intf_thread_t *_p_intf )
 {
     p_main_interface = _p_main_interface;
+    p_intf = _p_intf;
 }
 
 /* Event handlers */
-void Systray::OnLeftClick( wxTaskBarIconEvent& event )
+void Systray::OnMenuIconize( wxCommandEvent& event )
 {
     p_main_interface->Show( ! p_main_interface->IsShown() );
     if ( p_main_interface->IsShown() ) p_main_interface->Raise();
 }
 
+void Systray::OnLeftClick( wxTaskBarIconEvent& event )
+{
+    wxCommandEvent cevent;
+    OnMenuIconize(cevent);
+}
+
 void Systray::OnExit( wxCommandEvent& event )
 {
     p_main_interface->Close(TRUE);
@@ -1359,13 +1521,19 @@ void Systray::OnStopStream( wxCommandEvent& event )
 /* Systray popup menu */
 wxMenu* Systray::CreatePopupMenu()
 {
+    int minimal = config_GetInt( p_intf, "wxwin-minimal" );
+
     wxMenu* systray_menu = new wxMenu;
     systray_menu->Append( Exit_Event, wxU(_("Quit VLC")) );
     systray_menu->AppendSeparator();
     systray_menu->Append( PlayStream_Event, wxU(_("Play/Pause")) );
+
+    if (!minimal)
+    {
     systray_menu->Append( PrevStream_Event, wxU(_("Previous")) );
     systray_menu->Append( NextStream_Event, wxU(_("Next")) );
     systray_menu->Append( StopStream_Event, wxU(_("Stop")) );
+    }
     systray_menu->AppendSeparator();
     systray_menu->Append( Iconize_Event, wxU(_("Show/Hide interface")) );
     return systray_menu;