]> git.sesse.net Git - vlc/commitdiff
* Added sound volume management and changed a bit the menus
authorOlivier Teulière <ipkiss@videolan.org>
Wed, 8 Jan 2003 02:16:09 +0000 (02:16 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Wed, 8 Jan 2003 02:16:09 +0000 (02:16 +0000)
 * Added audio channels selection, but it's currently disabled since
   it's quite buggy :)

modules/gui/win32/mainframe.cpp
modules/gui/win32/mainframe.dfm
modules/gui/win32/mainframe.h
modules/gui/win32/menu.cpp
modules/gui/win32/menu.h
modules/gui/win32/win32.cpp
modules/gui/win32/win32_common.h

index a9afecc1bf1be924890a3a71045d0ef2c1b48e3e..22980a8212b08714346518abdb38e363b554f3ba 100644 (file)
@@ -319,6 +319,44 @@ void __fastcall TMainFrameDlg::EjectActionExecute( TObject *Sender )
     }\r
 }\r
 //--------------------------------------------------------------------------\r
+void __fastcall TMainFrameDlg::VolumeUpActionExecute( TObject *Sender )\r
+{\r
+    aout_instance_t *p_aout;\r
+    p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,\r
+                                                 FIND_ANYWHERE );\r
+    if ( p_aout != NULL )\r
+    {\r
+        aout_VolumeUp( p_aout, 1, NULL );\r
+        vlc_object_release( (vlc_object_t *)p_aout );\r
+    }\r
+}\r
+//---------------------------------------------------------------------------\r
+void __fastcall TMainFrameDlg::VolumeDownActionExecute( TObject *Sender )\r
+{\r
+    aout_instance_t *p_aout;\r
+    p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,\r
+                                                 FIND_ANYWHERE );\r
+    if ( p_aout != NULL )\r
+    {\r
+        aout_VolumeDown( p_aout, 1, NULL );\r
+        vlc_object_release( (vlc_object_t *)p_aout );\r
+    }\r
+}\r
+//---------------------------------------------------------------------------\r
+void __fastcall TMainFrameDlg::MuteActionExecute( TObject *Sender )\r
+{\r
+    aout_instance_t *p_aout;\r
+    p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,\r
+                                                 FIND_ANYWHERE );\r
+    if ( p_aout != NULL )\r
+    {\r
+        aout_VolumeMute( p_aout, NULL );\r
+        vlc_object_release( (vlc_object_t *)p_aout );\r
+\r
+//        MenuMute->Checked = ! MenuMute->Checked;\r
+    }\r
+}\r
+//---------------------------------------------------------------------------\r
 \r
 \r
 /*****************************************************************************\r
@@ -375,7 +413,7 @@ void __fastcall TMainFrameDlg::PopupCloseClick( TObject *Sender )
 //---------------------------------------------------------------------------\r
 void __fastcall TMainFrameDlg::PopupJumpClick( TObject *Sender )\r
 {\r
-    // TODO\r
+    /* TODO */\r
 }\r
 //---------------------------------------------------------------------------\r
 \r
@@ -590,10 +628,10 @@ void __fastcall TMainFrameDlg::ModeManage()
         MenuProgram->Enabled = false;\r
         MenuTitle->Enabled = false;\r
         MenuChapter->Enabled = false;\r
-        MenuAudio->Enabled = false;\r
+        MenuLanguage->Enabled = false;\r
         MenuSubtitles->Enabled = false;\r
         PopupNavigation->Enabled = false;\r
-        PopupAudio->Enabled = false;\r
+        PopupLanguage->Enabled = false;\r
         PopupSubtitles->Enabled = false;\r
     }\r
 \r
index 356353b4bb9a8ef0671742011387d1a633fa26e5..54743e7f0f4fda7a1731aa8e0e395c828d095db6 100644 (file)
@@ -256,7 +256,7 @@ object MainFrameDlg: TMainFrameDlg
   end\r
   object StatusBar: TStatusBar\r
     Left = 0\r
-    Top = 238\r
+    Top = 241\r
     Width = 533\r
     Height = 19\r
     Panels = <>\r
@@ -464,14 +464,6 @@ object MainFrameDlg: TMainFrameDlg
         Caption = '-'\r
         Visible = False\r
       end\r
-      object MenuEjectDisc: TMenuItem\r
-        Tag = 3\r
-        Action = EjectAction\r
-        Caption = '&Eject disc'\r
-      end\r
-      object N1: TMenuItem\r
-        Caption = '-'\r
-      end\r
       object MenuExit: TMenuItem\r
         Tag = 3\r
         Action = ExitAction\r
@@ -486,16 +478,66 @@ object MainFrameDlg: TMainFrameDlg
         Hint = 'Hide the main interface window'\r
         OnClick = MenuHideinterfaceClick\r
       end\r
+      object N3: TMenuItem\r
+        Caption = '-'\r
+      end\r
+      object MenuPlaylist: TMenuItem\r
+        Tag = 3\r
+        Action = PlaylistAction\r
+        Caption = '&Playlist...'\r
+      end\r
+      object MenuMessages: TMenuItem\r
+        Tag = 3\r
+        Action = MessagesAction\r
+      end\r
+      object MenuPreferences: TMenuItem\r
+        Tag = 3\r
+        Action = PreferencesAction\r
+      end\r
+    end\r
+    object MenuControls: TMenuItem\r
+      Tag = 3\r
+      Caption = '&Controls'\r
+      object MenuADevice: TMenuItem\r
+        Tag = 3\r
+        Caption = 'Audio device'\r
+        Enabled = False\r
+      end\r
+      object MenuVolumeUp: TMenuItem\r
+        Tag = 3\r
+        Action = VolumeUpAction\r
+      end\r
+      object MenuVolumeDown: TMenuItem\r
+        Tag = 3\r
+        Action = VolumeDownAction\r
+      end\r
+      object MenuMute: TMenuItem\r
+        Action = MuteAction\r
+      end\r
+      object MenuChannel: TMenuItem\r
+        Tag = 3\r
+        Caption = 'C&hannels'\r
+        Enabled = False\r
+        Hint = 'Select audio channel'\r
+      end\r
+      object N2: TMenuItem\r
+        Caption = '-'\r
+      end\r
+      object MenuVDevice: TMenuItem\r
+        Tag = 3\r
+        Caption = 'Sc&reen'\r
+        Enabled = False\r
+      end\r
       object MenuFullscreen: TMenuItem\r
         Tag = 3\r
         Action = FullscreenAction\r
       end\r
-      object N2: TMenuItem\r
+      object N11: TMenuItem\r
         Caption = '-'\r
       end\r
       object MenuProgram: TMenuItem\r
         Tag = 3\r
-        Caption = 'Progr&am'\r
+        Caption = '&Program'\r
         Enabled = False\r
         Hint = 'Select program'\r
       end\r
@@ -513,29 +555,13 @@ object MainFrameDlg: TMainFrameDlg
       end\r
       object MenuAngle: TMenuItem\r
         Tag = 3\r
-        Caption = 'An&gle'\r
+        Caption = '&Angle'\r
         Enabled = False\r
         Hint = 'Select angle'\r
       end\r
-      object N3: TMenuItem\r
-        Caption = '-'\r
-      end\r
-      object MenuPlaylist: TMenuItem\r
+      object MenuLanguage: TMenuItem\r
         Tag = 3\r
-        Action = PlaylistAction\r
-        Caption = '&Playlist...'\r
-      end\r
-      object MenuMessages: TMenuItem\r
-        Tag = 3\r
-        Action = MessagesAction\r
-      end\r
-    end\r
-    object MenuSettings: TMenuItem\r
-      Tag = 3\r
-      Caption = '&Settings'\r
-      object MenuAudio: TMenuItem\r
-        Tag = 3\r
-        Caption = '&Audio'\r
+        Caption = '&Language'\r
         Enabled = False\r
         Hint = 'Select audio language'\r
       end\r
@@ -545,13 +571,6 @@ object MainFrameDlg: TMainFrameDlg
         Enabled = False\r
         Hint = 'Select subtitles language'\r
       end\r
-      object N4: TMenuItem\r
-        Caption = '-'\r
-      end\r
-      object MenuPreferences: TMenuItem\r
-        Tag = 3\r
-        Action = PreferencesAction\r
-      end\r
     end\r
     object MenuHelp: TMenuItem\r
       Tag = 3\r
@@ -2299,16 +2318,17 @@ object MainFrameDlg: TMainFrameDlg
   end\r
   object PopupMenuMain: TPopupMenu\r
     AutoPopup = False\r
+    TrackButton = tbLeftButton\r
     Left = 72\r
     Top = 208\r
     object PopupClose: TMenuItem\r
       Tag = 3\r
-      Caption = '&Close this popup'\r
+      Caption = 'Close this popup'\r
       OnClick = PopupCloseClick\r
     end\r
     object PopupToggleInterface: TMenuItem\r
       Tag = 3\r
-      Caption = '&Toggle interface'\r
+      Caption = 'Show interface'\r
       OnClick = PopupToggleInterfaceClick\r
     end\r
     object N9: TMenuItem\r
@@ -2363,9 +2383,38 @@ object MainFrameDlg: TMainFrameDlg
       object PopupFullscreen: TMenuItem\r
         Tag = 3\r
         Action = FullscreenAction\r
-        ShortCut = 70\r
       end\r
     end\r
+    object PopupAudioSettings: TMenuItem\r
+      Tag = 3\r
+      Caption = 'Audio settings'\r
+      object PopupADevice: TMenuItem\r
+        Tag = 3\r
+        Caption = 'Device'\r
+      end\r
+      object VolumeUp1: TMenuItem\r
+        Tag = 3\r
+        Action = VolumeUpAction\r
+      end\r
+      object VolumeDown1: TMenuItem\r
+        Tag = 3\r
+        Action = VolumeDownAction\r
+      end\r
+      object Mute1: TMenuItem\r
+        Tag = 3\r
+        Action = MuteAction\r
+      end\r
+      object PopupChannel: TMenuItem\r
+        Tag = 3\r
+        Caption = 'Channels'\r
+      end\r
+    end\r
+    object PopupVDevice: TMenuItem\r
+      Caption = 'Screen'\r
+    end\r
+    object N1: TMenuItem\r
+      Caption = '-'\r
+    end\r
     object PopupNavigation: TMenuItem\r
       Tag = 3\r
       Caption = 'Navigation'\r
@@ -2374,9 +2423,9 @@ object MainFrameDlg: TMainFrameDlg
       Tag = 3\r
       Caption = 'Program'\r
     end\r
-    object PopupAudio: TMenuItem\r
+    object PopupLanguage: TMenuItem\r
       Tag = 3\r
-      Caption = 'Audio'\r
+      Caption = 'Language'\r
     end\r
     object PopupSubtitles: TMenuItem\r
       Tag = 3\r
@@ -2553,8 +2602,9 @@ object MainFrameDlg: TMainFrameDlg
     object FullscreenAction: TAction\r
       Tag = 3\r
       Category = 'Control'\r
-      Caption = 'Fullscreen'\r
+      Caption = '&Fullscreen'\r
       Hint = 'Toggle fullscreen'\r
+      ShortCut = 70\r
       OnExecute = FullscreenActionExecute\r
     end\r
     object PreferencesAction: TAction\r
@@ -2607,5 +2657,28 @@ object MainFrameDlg: TMainFrameDlg
       Hint = 'Jump to next chapter'\r
       OnExecute = NextChapterActionExecute\r
     end\r
+    object VolumeUpAction: TAction\r
+      Tag = 3\r
+      Category = 'Control'\r
+      Caption = 'Volume &Up'\r
+      Hint = 'Increase the volume'\r
+      ShortCut = 16469\r
+      OnExecute = VolumeUpActionExecute\r
+    end\r
+    object VolumeDownAction: TAction\r
+      Tag = 3\r
+      Category = 'Control'\r
+      Caption = 'Volume &Down'\r
+      Hint = 'Decrease the volume'\r
+      ShortCut = 16452\r
+      OnExecute = VolumeDownActionExecute\r
+    end\r
+    object MuteAction: TAction\r
+      Tag = 3\r
+      Category = 'Control'\r
+      Caption = '&Mute'\r
+      Hint = 'Toggle mute'\r
+      OnExecute = MuteActionExecute\r
+    end\r
   end\r
 end\r
index a657e2d4b115ac563cbd3dfd7ff07244d9d37f07..6ebf018792c22fd15f2d567c3aab0eb17db8d03f 100644 (file)
@@ -70,22 +70,19 @@ __published:        // IDE-managed Components
     TMenuItem *MenuOpenFile;\r
     TMenuItem *MenuOpenDisc;\r
     TMenuItem *MenuNetworkStream;\r
-    TMenuItem *N1;\r
     TMenuItem *MenuExit;\r
     TMenuItem *MenuView;\r
     TMenuItem *MenuHideinterface;\r
     TMenuItem *MenuFullscreen;\r
-    TMenuItem *N2;\r
     TMenuItem *MenuTitle;\r
     TMenuItem *MenuChapter;\r
     TMenuItem *MenuAngle;\r
     TMenuItem *N3;\r
     TMenuItem *MenuPlaylist;\r
     TMenuItem *MenuMessages;\r
-    TMenuItem *MenuSettings;\r
-    TMenuItem *MenuAudio;\r
+    TMenuItem *MenuControls;\r
+    TMenuItem *MenuLanguage;\r
     TMenuItem *MenuSubtitles;\r
-    TMenuItem *N4;\r
     TMenuItem *MenuPreferences;\r
     TMenuItem *MenuHelp;\r
     TMenuItem *MenuAbout;\r
@@ -105,7 +102,7 @@ __published:        // IDE-managed Components
     TMenuItem *PopupJump;\r
     TMenuItem *PopupNavigation;\r
     TMenuItem *PopupProgram;\r
-    TMenuItem *PopupAudio;\r
+    TMenuItem *PopupLanguage;\r
     TMenuItem *PopupSubtitles;\r
     TMenuItem *PopupFile;\r
     TMenuItem *PopupPlaylist;\r
@@ -120,7 +117,6 @@ __published:        // IDE-managed Components
     TLabel *LabelServer;\r
     TGroupBox *GroupBoxDisc;\r
     TMenuItem *N8;\r
-    TMenuItem *MenuEjectDisc;\r
     TMenuItem *MenuProgram;\r
     TLabel *LabelDisc;\r
     TLabel *LabelTitle;\r
@@ -169,6 +165,25 @@ __published:       // IDE-managed Components
     TAction *NextTitleAction;\r
     TAction *PrevChapterAction;\r
     TAction *NextChapterAction;\r
+    TMenuItem *N11;\r
+    TMenuItem *MenuChannel;\r
+    TMenuItem *PopupChannel;\r
+    TMenuItem *MenuVolumeUp;\r
+    TMenuItem *MenuVolumeDown;\r
+    TMenuItem *MenuMute;\r
+    TAction *VolumeUpAction;\r
+    TAction *VolumeDownAction;\r
+    TAction *MuteAction;\r
+    TMenuItem *MenuADevice;\r
+    TMenuItem *PopupAudioSettings;\r
+    TMenuItem *PopupADevice;\r
+    TMenuItem *VolumeDown1;\r
+    TMenuItem *VolumeUp1;\r
+    TMenuItem *Mute1;\r
+    TMenuItem *MenuVDevice;\r
+    TMenuItem *N2;\r
+    TMenuItem *N1;\r
+    TMenuItem *PopupVDevice;\r
     void __fastcall TimerManageTimer( TObject *Sender );\r
     void __fastcall TrackBarChange( TObject *Sender );\r
     void __fastcall FormClose( TObject *Sender, TCloseAction &Action );\r
@@ -180,21 +195,24 @@ __published:      // IDE-managed Components
     void __fastcall OpenFileActionExecute( TObject *Sender );\r
     void __fastcall OpenDiscActionExecute( TObject *Sender );\r
     void __fastcall NetworkStreamActionExecute( TObject *Sender );\r
+    void __fastcall ExitActionExecute( TObject *Sender );\r
+    void __fastcall PlaylistActionExecute( TObject *Sender );\r
+    void __fastcall MessagesActionExecute( TObject *Sender );\r
+    void __fastcall AboutActionExecute( TObject *Sender );\r
     void __fastcall BackActionExecute( TObject *Sender );\r
     void __fastcall PlayActionExecute( TObject *Sender );\r
     void __fastcall PauseActionExecute( TObject *Sender );\r
     void __fastcall StopActionExecute( TObject *Sender );\r
     void __fastcall SlowActionExecute( TObject *Sender );\r
     void __fastcall FastActionExecute( TObject *Sender );\r
-    void __fastcall EjectActionExecute( TObject *Sender );\r
-    void __fastcall PlaylistActionExecute( TObject *Sender );\r
     void __fastcall PreviousActionExecute( TObject *Sender );\r
     void __fastcall NextActionExecute( TObject *Sender );\r
+    void __fastcall EjectActionExecute( TObject *Sender );\r
+    void __fastcall VolumeUpActionExecute( TObject *Sender );\r
+    void __fastcall VolumeDownActionExecute( TObject *Sender );\r
+    void __fastcall MuteActionExecute( TObject *Sender );\r
     void __fastcall FullscreenActionExecute( TObject *Sender );\r
     void __fastcall PreferencesActionExecute( TObject *Sender );\r
-    void __fastcall MessagesActionExecute( TObject *Sender );\r
-    void __fastcall AboutActionExecute( TObject *Sender );\r
-    void __fastcall ExitActionExecute( TObject *Sender );\r
     void __fastcall PrevTitleActionExecute( TObject *Sender );\r
     void __fastcall NextTitleActionExecute( TObject *Sender );\r
     void __fastcall PrevChapterActionExecute( TObject *Sender );\r
index c1fdebb249ee4f9052c0605ce50f1f6a555a591d..148ec41c440aa64b77fc7e7866ca5bfe134a49d9 100644 (file)
@@ -2,7 +2,7 @@
  * menu.cpp: functions to handle menu items
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: menu.cpp,v 1.2 2002/12/13 03:52:58 videolan Exp $
+ * $Id: menu.cpp,v 1.3 2003/01/08 02:16:09 ipkiss Exp $
  *
  * Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
  *
 
 /*****************************************************************************
  * TMenusGen::*Click: callbacks for the menuitems
- ****************************************************************************
- * These functions need to be in a class, or we won't be able to pass them
- * as arguments (since TNotifyEvent uses __closure)
  ****************************************************************************/
 
- /*
+/*
+ * Variables
+ */
+
+/* variables of the audio output */
+void __fastcall TMenusGen::AoutVarClick( TObject *Sender )
+{
+    TMenuItem * Item = (TMenuItem *)Sender;
+
+    vlc_object_t * p_aout;
+    p_aout = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
+                                              FIND_ANYWHERE );
+    if( p_aout == NULL )
+    {
+        msg_Warn( p_intf, "cannot set variable (%s)", Item->Caption.c_str() );
+        return;
+    }
+
+    if( Item->Parent == MenuADevice || Item->Parent == PopupADevice )
+    {
+        VarChange( p_aout, "audio-device", MenuADevice, PopupADevice, Item );
+    }
+    else if( Item->Parent == MenuChannel || Item->Parent == PopupChannel )
+    {
+        VarChange( p_aout, "audio-channels", MenuChannel, PopupChannel, Item );
+    }
+
+    vlc_object_release( p_aout );
+}
+
+/* variables of the video output */
+void __fastcall TMenusGen::VoutVarClick( TObject *Sender )
+{
+    TMenuItem * Item = (TMenuItem *)Sender;
+
+    vlc_object_t * p_vout;
+    p_vout = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
+                                              FIND_ANYWHERE );
+    if( p_vout == NULL )
+    {
+        msg_Warn( p_intf, "cannot set variable (%s)", Item->Caption.c_str() );
+        return;
+    }
+
+    if( Item->Parent == MenuVDevice || Item->Parent == PopupVDevice )
+    {
+        VarChange( p_vout, "video-device", MenuVDevice, PopupVDevice, Item );
+    }
+
+    vlc_object_release( p_vout );
+}
+
+/*
  * Audio
  */
 
-void __fastcall TMenusGen::MenuAudioClick( TObject *Sender )
+void __fastcall TMenusGen::MenuLanguageClick( TObject *Sender )
 {
-    LangChange( MenuAudio, (TMenuItem *)Sender, PopupAudio, AUDIO_ES );
+    LangChange( MenuLanguage, (TMenuItem *)Sender, PopupLanguage, AUDIO_ES );
 }
 
-void __fastcall TMenusGen::PopupAudioClick( TObject *Sender )
+void __fastcall TMenusGen::PopupLanguageClick( TObject *Sender )
 {
-    LangChange( PopupAudio, (TMenuItem *)Sender, MenuAudio, AUDIO_ES );
+    LangChange( PopupLanguage, (TMenuItem *)Sender, MenuLanguage, AUDIO_ES );
 }
 
 /*
@@ -56,14 +105,12 @@ void __fastcall TMenusGen::PopupAudioClick( TObject *Sender )
 
 void __fastcall TMenusGen::MenuSubtitleClick( TObject *Sender )
 {
-    LangChange( MenuSubtitles, (TMenuItem *)Sender,
-        PopupSubtitles, SPU_ES );
+    LangChange( MenuSubtitles, (TMenuItem *)Sender, PopupSubtitles, SPU_ES );
 }
 
 void __fastcall TMenusGen::PopupSubtitleClick( TObject *Sender )
 {
-    LangChange( PopupSubtitles, (TMenuItem *)Sender,
-        MenuSubtitles, SPU_ES );
+    LangChange( PopupSubtitles, (TMenuItem *)Sender, MenuSubtitles, SPU_ES );
 }
 
 /*
@@ -170,12 +217,18 @@ __fastcall TMenusGen::TMenusGen( intf_thread_t *_p_intf ) : TObject()
     TMainFrameDlg * p_window = p_intf->p_sys->p_window;
     if( p_window == NULL )
     {
-        msg_Err( p_intf, "Main window wasn't created, expect problems..." );
+        msg_Warn( p_intf, "Main window wasn't created, expect problems..." );
         return;
     }
 
-    MenuAudio = p_window->MenuAudio;
-    PopupAudio = p_window->PopupAudio;
+    MenuChannel = p_window->MenuChannel;
+    PopupChannel = p_window->PopupChannel;
+    MenuADevice = p_window->MenuADevice;
+    PopupADevice = p_window->PopupADevice;
+    MenuVDevice = p_window->MenuVDevice;
+    PopupVDevice = p_window->PopupVDevice;
+    MenuLanguage = p_window->MenuLanguage;
+    PopupLanguage = p_window->PopupLanguage;
     MenuSubtitles = p_window->MenuSubtitles;
     PopupSubtitles = p_window->PopupSubtitles;
     MenuProgram = p_window->MenuProgram;
@@ -185,18 +238,19 @@ __fastcall TMenusGen::TMenusGen( intf_thread_t *_p_intf ) : TObject()
     PopupNavigation = p_window->PopupNavigation;
 }
 
+
 void __fastcall TMenusGen::SetupMenus()
 {
-    TMainFrameDlg * p_window = p_intf->p_sys->p_window;
-    input_thread_t *p_input = p_intf->p_sys->p_input;
+    TMainFrameDlg  * p_window = p_intf->p_sys->p_window;
+    input_thread_t * p_input  = p_intf->p_sys->p_input;
     es_descriptor_t   * p_audio_es;
     es_descriptor_t   * p_spu_es;
 
     p_intf->p_sys->b_chapter_update |= p_intf->p_sys->b_title_update;
-    p_intf->p_sys->b_audio_update |= p_intf->p_sys->b_program_update;
-//  p_intf->p_sys->b_audio_update |= p_intf->p_sys->b_title_update;
-    p_intf->p_sys->b_spu_update |= p_intf->p_sys->b_program_update;
-//  p_intf->p_sys->b_spu_update |= p_intf->p_sys->b_title_update;
+    p_intf->p_sys->b_audio_update |= p_intf->p_sys->b_program_update |
+                                     p_intf->p_sys->b_title_update;
+    p_intf->p_sys->b_spu_update |= p_intf->p_sys->b_program_update |
+                                   p_intf->p_sys->b_title_update;
 
     if( p_intf->p_sys->b_program_update )
     {
@@ -211,8 +265,8 @@ void __fastcall TMenusGen::SetupMenus()
             p_pgrm = p_input->stream.p_selected_program;
         }
 
-        ProgramMenu( p_window->MenuProgram, p_pgrm, MenuProgramClick );
-        ProgramMenu( p_window->PopupProgram, p_pgrm, PopupProgramClick );
+        ProgramMenu( MenuProgram, p_pgrm, MenuProgramClick );
+        ProgramMenu( PopupProgram, p_pgrm, PopupProgramClick );
 
         p_intf->p_sys->b_program_update = 0;
     }
@@ -220,7 +274,7 @@ void __fastcall TMenusGen::SetupMenus()
     if( p_intf->p_sys->b_title_update )
     {
 // why "-1" ?
-        RadioMenu( p_window->MenuTitle, "Title",
+        RadioMenu( MenuTitle, "Title",
                    p_input->stream.i_area_nb - 1,
                    p_input->stream.p_selected_area->i_id,
                    MenuTitleClick );
@@ -234,13 +288,12 @@ void __fastcall TMenusGen::SetupMenus()
 
     if( p_intf->p_sys->b_chapter_update )
     {
-        RadioMenu( p_window->MenuChapter, "Chapter",
+        RadioMenu( MenuChapter, "Chapter",
                    p_input->stream.p_selected_area->i_part_nb,
                    p_input->stream.p_selected_area->i_part,
                    MenuChapterClick );
 
-        NavigationMenu( p_window->PopupNavigation,
-                        PopupNavigationClick );
+        NavigationMenu( PopupNavigation, PopupNavigationClick );
 
         AnsiString CurrentChapter;
         CurrentChapter.sprintf( "%d", p_input->stream.p_selected_area->i_part );
@@ -275,10 +328,8 @@ void __fastcall TMenusGen::SetupMenus()
     /* audio menus */
     if( p_intf->p_sys->b_audio_update )
     {
-        LanguageMenu( p_window->MenuAudio, p_audio_es, AUDIO_ES,
-                      MenuAudioClick );
-        LanguageMenu( p_window->PopupAudio, p_audio_es, AUDIO_ES,
-                      PopupAudioClick );
+        LanguageMenu( MenuLanguage, p_audio_es, AUDIO_ES, MenuLanguageClick );
+        LanguageMenu( PopupLanguage, p_audio_es, AUDIO_ES, PopupLanguageClick );
 
         p_intf->p_sys->b_audio_update = 0;
     }
@@ -286,14 +337,65 @@ void __fastcall TMenusGen::SetupMenus()
     /* sub picture menus */
     if( p_intf->p_sys->b_spu_update )
     {
-        LanguageMenu( p_window->PopupSubtitles, p_spu_es, SPU_ES,
-                      PopupSubtitleClick );
-        LanguageMenu( p_window->MenuSubtitles, p_spu_es, SPU_ES,
-                      MenuSubtitleClick );
+        LanguageMenu( PopupSubtitles, p_spu_es, SPU_ES, PopupSubtitleClick );
+        LanguageMenu( MenuSubtitles, p_spu_es, SPU_ES, MenuSubtitleClick );
 
         p_intf->p_sys->b_spu_update = 0;
     }
 
+    if( p_intf->p_sys->b_aout_update )
+    {
+        aout_instance_t * p_aout;
+        p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
+                                                     FIND_ANYWHERE );
+
+        if ( p_aout != NULL )
+        {
+            vlc_value_t val;
+            val.b_bool = 0;
+
+            var_Set( (vlc_object_t *)p_aout, "intf-change", val );
+
+            SetupVarMenu( (vlc_object_t *)p_aout, "audio-channels",
+                          MenuChannel, AoutVarClick );
+            SetupVarMenu( (vlc_object_t *)p_aout, "audio-channels",
+                          PopupChannel, AoutVarClick );
+
+            SetupVarMenu( (vlc_object_t *)p_aout, "audio-device",
+                          MenuADevice, AoutVarClick );
+            SetupVarMenu( (vlc_object_t *)p_aout, "audio-device",
+                          PopupADevice, AoutVarClick );
+
+            vlc_object_release( (vlc_object_t *)p_aout );
+        }
+
+        p_intf->p_sys->b_aout_update = 0;
+    }
+
+    if( p_intf->p_sys->b_vout_update )
+    {
+        vout_thread_t * p_vout;
+        p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
+                                                   FIND_ANYWHERE );
+
+        if ( p_vout != NULL )
+        {
+            vlc_value_t val;
+            val.b_bool = 0;
+
+            var_Set( (vlc_object_t *)p_vout, "intf-change", val );
+
+            SetupVarMenu( (vlc_object_t *)p_vout, "video-device",
+                          MenuVDevice, VoutVarClick );
+            SetupVarMenu( (vlc_object_t *)p_vout, "video-device",
+                          PopupVDevice, VoutVarClick );
+
+            vlc_object_release( (vlc_object_t *)p_vout );
+        }
+
+        p_intf->p_sys->b_vout_update = 0;
+    }
+
     vlc_mutex_lock( &p_input->stream.stream_lock );
 }
 
@@ -301,7 +403,8 @@ void __fastcall TMenusGen::SetupMenus()
 /*****************************************************************************
  * Private functions
  *****************************************************************************/
-TMenuItem * TMenusGen::Index2Item( TMenuItem *Root, int i_index, bool SingleColumn )
+TMenuItem * TMenusGen::Index2Item( TMenuItem *Root, int i_index,
+                                   bool SingleColumn )
 {
     if( SingleColumn || ( i_index < 20 ) )
         return Root->Items[i_index];
@@ -332,6 +435,30 @@ int __fastcall TMenusGen::Pos2Data( int title, int chapter )
     return (int) (( title << 16 ) | ( chapter & 0xffff ));
 }
 
+/****************************************************************************
+ * VarChange: change a variable in a vlc_object_t
+ ****************************************************************************
+ * Change the variable and update the menuitems.
+ ****************************************************************************/
+void __fastcall TMenusGen::VarChange( vlc_object_t *p_object,
+        const char *psz_variable, TMenuItem *RootMenu, TMenuItem *RootPopup,
+        TMenuItem *Item )
+{
+    vlc_value_t val;
+    int i_index;
+
+    /* set the new value */
+    val.psz_string = Item->Name.c_str();
+    if( var_Set( p_object, psz_variable, val ) < 0 )
+    {
+        msg_Warn( p_object, "cannot set variable (%s)", val.psz_string );
+    }
+
+    i_index = Item->MenuIndex;
+    RootMenu->Items[i_index]->Checked = true;
+    RootPopup->Items[i_index]->Checked = true;
+}
+
 /****************************************************************************
  * LangChange: change audio or subtitles languages
  ****************************************************************************
@@ -411,6 +538,56 @@ void __fastcall TMenusGen::ProgramChange( TMenuItem *Item,
     input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
 }
 
+/*****************************************************************************
+ * SetupVarMenu: build a menu allowing to change a variable
+ *****************************************************************************/
+void __fastcall TMenusGen::SetupVarMenu( vlc_object_t *p_object,
+        const char *psz_variable, TMenuItem *Root, TNotifyEvent MenuItemClick )
+{
+    TMenuItem * Item;
+    vlc_value_t val;
+    char * psz_value;
+    int i;
+
+    /* remove previous menu */
+    Root->Clear();
+
+    /* get the current value */
+    if ( var_Get( p_object, psz_variable, &val ) < 0 )
+    {
+        return;
+    }
+    psz_value = val.psz_string;
+
+    if ( var_Change( p_object, psz_variable, VLC_VAR_GETLIST, &val ) < 0 )
+    {
+        free( psz_value );
+        return;
+    }
+
+    /* append a menuitem for each option */
+    for ( i = 0; i < val.p_list->i_count; i++ )
+    {
+        Item = new TMenuItem( Root );
+        Item->Caption = val.p_list->p_values[i].psz_string;
+        Item->Hint = val.p_list->p_values[i].psz_string;
+        Item->RadioItem = true;
+        Item->OnClick = MenuItemClick;
+        if( !strcmp( psz_value, val.p_list->p_values[i].psz_string ) )
+            Item->Checked = true;
+
+        /* Add the item to the submenu */
+        Root->Add( Item );
+    }
+
+    /* enable the menu if there is at least 1 item */
+    Root->Enabled = ( val.p_list->i_count > 0 );
+
+    /* clean up everything */
+    var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val );
+    free( psz_value );
+}
+
 /*****************************************************************************
  * ProgramMenu: update the programs menu of the interface
  *****************************************************************************
@@ -418,17 +595,14 @@ void __fastcall TMenusGen::ProgramChange( TMenuItem *Item,
  * by the input. Useful for multi-programs streams such as DVB ones.
  *****************************************************************************/
 void __fastcall TMenusGen::ProgramMenu( TMenuItem *Root,
-    pgrm_descriptor_t *p_pgrm, TNotifyEvent MenuItemClick)
+    pgrm_descriptor_t *p_pgrm, TNotifyEvent MenuItemClick )
 {
     TMenuItem * Item;
-    TMenuItem * ItemActive;
 
     /* remove previous menu */
     Root->Clear();
     Root->Enabled = false;
 
-    ItemActive = NULL;
-
     /* create a set of program buttons and append them to the container */
     for( int i = 0; i < p_intf->p_sys->p_input->stream.i_pgrm_number; i++ )
     {
@@ -446,22 +620,16 @@ void __fastcall TMenusGen::ProgramMenu( TMenuItem *Root,
          * It will be used in the callback. */
         Item->Tag = i + 1;
 
+        /* check the currently selected program */
         if( p_pgrm == p_intf->p_sys->p_input->stream.pp_programs[i] )
         {
-            /* don't lose Item when we append into menu */
-            ItemActive = Item;
+            Item->Checked = true;
         }
 
-        /* Add the item to the submenu */
+        /* add the item to the submenu */
         Root->Add( Item );
     }
 
-    /* check currently selected program */
-    if( ItemActive != NULL )
-    {
-        ItemActive->Checked = true;
-    }
-
     /* be sure that menu is enabled if more than 1 program */
     if( p_intf->p_sys->p_input->stream.i_pgrm_number > 1 )
     {
@@ -481,15 +649,12 @@ void __fastcall TMenusGen::RadioMenu( TMenuItem *Root, AnsiString ItemName,
 {
     TMenuItem  * ItemGroup;
     TMenuItem  * Item;
-    TMenuItem  * ItemActive;
     AnsiString   Name;
 
     /* remove previous menu */
     Root->Enabled = false;
     Root->Clear();
 
-    ItemActive = NULL;
-
     for( int i_item = 0; i_item < i_nb; i_item++ )
     {
         /* we group titles/chapters in packets of ten for small screens */
@@ -523,9 +688,10 @@ void __fastcall TMenusGen::RadioMenu( TMenuItem *Root, AnsiString ItemName,
          * It will be used in the callback. */
         Item->Tag = i_item + 1;
 
+        /* check the currently selected chapter */
         if( i_selected == i_item + 1 )
         {
-            ItemActive = Item;
+            Item->Checked = true;
         }
 
         /* setup signal handling */
@@ -543,12 +709,6 @@ void __fastcall TMenusGen::RadioMenu( TMenuItem *Root, AnsiString ItemName,
         Root->Add( ItemGroup );
     }
 
-    /* check currently selected chapter */
-    if( ItemActive != NULL )
-    {
-        ItemActive->Checked = true;
-    }
-
     /* be sure that menu is enabled, if there are several items */
     if( i_nb > 1 )
     {
@@ -570,7 +730,6 @@ void __fastcall TMenusGen::LanguageMenu( TMenuItem *Root, es_descriptor_t *p_es,
 {
     TMenuItem     * Separator;
     TMenuItem     * Item;
-    TMenuItem     * ItemActive;
     AnsiString      Name;
 
     /* remove previous menu */
@@ -592,7 +751,6 @@ void __fastcall TMenusGen::LanguageMenu( TMenuItem *Root, es_descriptor_t *p_es,
     Separator->Caption = "-";
     Root->Add( Separator );
 
-    ItemActive = NULL;
     int i_item = 0;
 
     vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
@@ -619,10 +777,10 @@ void __fastcall TMenusGen::LanguageMenu( TMenuItem *Root, es_descriptor_t *p_es,
             Item->Caption = Name;
             Item->Tag = i;
 
+            /* check the currently selected item */
             if( p_es == p_intf->p_sys->p_input->stream.pp_es[i] )
             {
-                /* don't lose Item when we append into menu */
-                ItemActive = Item;
+                Item->Checked = true;
             }
 
             /* setup signal hanling */
@@ -634,12 +792,6 @@ void __fastcall TMenusGen::LanguageMenu( TMenuItem *Root, es_descriptor_t *p_es,
 
     vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
 
-    /* check currently selected item */
-    if( ItemActive != NULL )
-    {
-        ItemActive->Checked = true;
-    }
-
     /* be sure that menu is enabled if non empty */
     if( i_item > 0 )
     {
@@ -659,7 +811,6 @@ void __fastcall TMenusGen::NavigationMenu( TMenuItem *Root,
 {
     TMenuItem     * TitleGroup;
     TMenuItem     * TitleItem;
-    TMenuItem     * ItemActive;
     TMenuItem     * ChapterGroup;
     TMenuItem     * ChapterItem;
     AnsiString      Name;
@@ -671,7 +822,6 @@ void __fastcall TMenusGen::NavigationMenu( TMenuItem *Root,
     Root->Enabled = false;
     Root->Clear();
 
-    ItemActive = NULL;
     i_title_nb = p_intf->p_sys->p_input->stream.i_area_nb;
 
     /* loop on titles */
@@ -733,11 +883,12 @@ void __fastcall TMenusGen::NavigationMenu( TMenuItem *Root,
                  ChapterItem->Tag = Pos2Data( i_title, i_chapter + 1 );
 
 #define p_area p_intf->p_sys->p_input->stream.pp_areas[i_title]
+                /* check the currently selected chapter */
                 if( ( p_area ==
                         p_intf->p_sys->p_input->stream.p_selected_area ) &&
                     ( p_area->i_part == i_chapter + 1 ) )
                 {
-                    ItemActive = ChapterItem;
+                    ChapterItem->Checked = true;
                 }
 #undef p_area
 
@@ -774,12 +925,6 @@ void __fastcall TMenusGen::NavigationMenu( TMenuItem *Root,
         Root->Add( TitleGroup );
     }
 
-    /* Default selected chapter */
-    if( ItemActive != NULL )
-    {
-        ItemActive->Checked = true;
-    }
-
     /* be sure that menu is sensitive */
     Root->Enabled = true;
 }
index 10157d928f44cb01f3e7aa1ee9b2f0e320ae63da..f2c1950127b582b116a7c1a3e4eaf01d61afeabe 100644 (file)
@@ -2,7 +2,7 @@
  * menu.h: prototypes for menu functions
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: menu.h,v 1.2 2002/12/13 03:52:58 videolan Exp $
+ * $Id: menu.h,v 1.3 2003/01/08 02:16:09 ipkiss Exp $
  *
  * Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
  *
@@ -30,8 +30,14 @@ private:
     intf_thread_t *p_intf;
 
     /* local pointers to main window menu items */
-    TMenuItem *MenuAudio;
-    TMenuItem *PopupAudio;
+    TMenuItem *MenuChannel;
+    TMenuItem *PopupChannel;
+    TMenuItem *MenuADevice;
+    TMenuItem *PopupADevice;
+    TMenuItem *MenuVDevice;
+    TMenuItem *PopupVDevice;
+    TMenuItem *MenuLanguage;
+    TMenuItem *PopupLanguage;
     TMenuItem *MenuSubtitles;
     TMenuItem *PopupSubtitles;
     TMenuItem *MenuProgram;
@@ -51,8 +57,13 @@ private:
     int __fastcall Data2Chapter( int data );
     int __fastcall Pos2Data( int title, int chapter );
 
+    void __fastcall VarChange( vlc_object_t *, const char *, TMenuItem *,
+                               TMenuItem *, TMenuItem * );
     void __fastcall LangChange( TMenuItem *, TMenuItem *, TMenuItem *, int );
     void __fastcall ProgramChange( TMenuItem *, TMenuItem * );
+
+    void __fastcall SetupVarMenu( vlc_object_t *, const char *, TMenuItem *,
+                                  TNotifyEvent );
     void __fastcall ProgramMenu( TMenuItem *, pgrm_descriptor_t *,
                                  TNotifyEvent );
     void __fastcall RadioMenu( TMenuItem *, AnsiString, int, int,
@@ -67,8 +78,10 @@ public:
     void __fastcall SetupMenus();
 
     /* callbacks for menuitems */
-    void __fastcall MenuAudioClick( TObject *Sender );
-    void __fastcall PopupAudioClick( TObject *Sender );
+    void __fastcall AoutVarClick( TObject *Sender );
+    void __fastcall VoutVarClick( TObject *Sender );
+    void __fastcall MenuLanguageClick( TObject *Sender );
+    void __fastcall PopupLanguageClick( TObject *Sender );
     void __fastcall MenuSubtitleClick( TObject *Sender );
     void __fastcall PopupSubtitleClick( TObject *Sender );
     void __fastcall MenuProgramClick( TObject *Sender );
index ae7d9caadc3882f6584f02364815b3bfec050aa0..c33be59f27bd674f01f6d5abfd3f6c53dd0357e4 100644 (file)
@@ -2,7 +2,7 @@
  * win32.cpp : Win32 interface plugin for vlc
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: win32.cpp,v 1.6 2002/12/13 17:05:12 babal Exp $
+ * $Id: win32.cpp,v 1.7 2003/01/08 02:16:09 ipkiss Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *
@@ -129,6 +129,9 @@ static void Run( intf_thread_t *p_intf )
  *****************************************************************************/
 int Win32Manage( intf_thread_t *p_intf )
 {
+    aout_instance_t * p_aout;
+    vout_thread_t   * p_vout;
+
     vlc_mutex_lock( &p_intf->change_lock );
 
     /* If the "display popup" flag has changed */
@@ -230,6 +233,42 @@ int Win32Manage( intf_thread_t *p_intf )
         p_intf->p_sys->b_playing = 0;
     }
 
+    /* Does the audio output require to update the menus ? */
+    p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
+                                                 FIND_ANYWHERE );
+    if( p_aout != NULL )
+    {
+        vlc_value_t val;
+        if( var_Get( (vlc_object_t *)p_aout, "intf-change", &val ) >= 0
+            && val.b_bool )
+        {
+#if 0
+            p_intf->p_sys->b_aout_update = 1;
+            p_intf->p_sys->p_menus->SetupMenus();
+#endif
+        }
+
+        vlc_object_release( (vlc_object_t *)p_aout );
+    }
+
+    /* Does the video output require to update the menus ? */
+    p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
+                                               FIND_ANYWHERE );
+    if( p_vout != NULL )
+    {
+        vlc_value_t val;
+        if( var_Get( (vlc_object_t *)p_vout, "intf-change", &val ) >= 0
+            && val.b_bool )
+        {
+#if 0
+            p_intf->p_sys->b_vout_update = 1;
+            p_intf->p_sys->p_menus->SetupMenus();
+#endif
+        }
+
+        vlc_object_release( (vlc_object_t *)p_vout );
+    }
+
     if( p_intf->b_die )
     {
         vlc_mutex_unlock( &p_intf->change_lock );
index 04f35e761ec34dba56631c7319f906195701f2bd..9896d18c1905649b917ac28a8e67fc17df6beb98 100644 (file)
@@ -9,7 +9,7 @@
  * it under the terms of the GNU General Public License as published by\r
  * the Free Software Foundation; either version 2 of the License, or\r
  * (at your option) any later version.\r
- * \r
+ *\r
  * This program is distributed in the hope that it will be useful,\r
  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
@@ -20,7 +20,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.\r
  *****************************************************************************/\r
 \r
-#include "about.h"\r
 #include "disc.h"\r
 #include "mainframe.h"\r
 #include "menu.h"\r
@@ -47,7 +46,11 @@ struct intf_sys_t
     vlc_bool_t          b_slider_free;                      /* slider status */\r
 \r
     /* menus handlers */\r
-    vlc_bool_t          b_program_update;   /* do we need to update programs \r
+    vlc_bool_t          b_aout_update;         /* do we need to update menus\r
+                                                   related with audio output */\r
+    vlc_bool_t          b_vout_update;         /* do we need to update menus\r
+                                                   related with video output */\r
+    vlc_bool_t          b_program_update;   /* do we need to update programs\r
                                                                         menu */\r
     vlc_bool_t          b_title_update;  /* do we need to update title menus */\r
     vlc_bool_t          b_chapter_update;    /* do we need to update chapter\r