Commit d9aff9ce authored by Olivier Teulière's avatar Olivier Teulière

* Added sound volume management and changed a bit the menus

 * Added audio channels selection, but it's currently disabled since
   it's quite buggy :)
parent 2d8e1a61
......@@ -319,6 +319,44 @@ void __fastcall TMainFrameDlg::EjectActionExecute( TObject *Sender )
}
}
//--------------------------------------------------------------------------
void __fastcall TMainFrameDlg::VolumeUpActionExecute( TObject *Sender )
{
aout_instance_t *p_aout;
p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if ( p_aout != NULL )
{
aout_VolumeUp( p_aout, 1, NULL );
vlc_object_release( (vlc_object_t *)p_aout );
}
}
//---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::VolumeDownActionExecute( TObject *Sender )
{
aout_instance_t *p_aout;
p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if ( p_aout != NULL )
{
aout_VolumeDown( p_aout, 1, NULL );
vlc_object_release( (vlc_object_t *)p_aout );
}
}
//---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::MuteActionExecute( TObject *Sender )
{
aout_instance_t *p_aout;
p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if ( p_aout != NULL )
{
aout_VolumeMute( p_aout, NULL );
vlc_object_release( (vlc_object_t *)p_aout );
// MenuMute->Checked = ! MenuMute->Checked;
}
}
//---------------------------------------------------------------------------
/*****************************************************************************
......@@ -375,7 +413,7 @@ void __fastcall TMainFrameDlg::PopupCloseClick( TObject *Sender )
//---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::PopupJumpClick( TObject *Sender )
{
// TODO
/* TODO */
}
//---------------------------------------------------------------------------
......@@ -590,10 +628,10 @@ void __fastcall TMainFrameDlg::ModeManage()
MenuProgram->Enabled = false;
MenuTitle->Enabled = false;
MenuChapter->Enabled = false;
MenuAudio->Enabled = false;
MenuLanguage->Enabled = false;
MenuSubtitles->Enabled = false;
PopupNavigation->Enabled = false;
PopupAudio->Enabled = false;
PopupLanguage->Enabled = false;
PopupSubtitles->Enabled = false;
}
......
......@@ -256,7 +256,7 @@ object MainFrameDlg: TMainFrameDlg
end
object StatusBar: TStatusBar
Left = 0
Top = 238
Top = 241
Width = 533
Height = 19
Panels = <>
......@@ -464,14 +464,6 @@ object MainFrameDlg: TMainFrameDlg
Caption = '-'
Visible = False
end
object MenuEjectDisc: TMenuItem
Tag = 3
Action = EjectAction
Caption = '&Eject disc'
end
object N1: TMenuItem
Caption = '-'
end
object MenuExit: TMenuItem
Tag = 3
Action = ExitAction
......@@ -486,16 +478,66 @@ object MainFrameDlg: TMainFrameDlg
Hint = 'Hide the main interface window'
OnClick = MenuHideinterfaceClick
end
object N3: TMenuItem
Caption = '-'
end
object MenuPlaylist: TMenuItem
Tag = 3
Action = PlaylistAction
Caption = '&Playlist...'
end
object MenuMessages: TMenuItem
Tag = 3
Action = MessagesAction
end
object MenuPreferences: TMenuItem
Tag = 3
Action = PreferencesAction
end
end
object MenuControls: TMenuItem
Tag = 3
Caption = '&Controls'
object MenuADevice: TMenuItem
Tag = 3
Caption = 'Audio device'
Enabled = False
end
object MenuVolumeUp: TMenuItem
Tag = 3
Action = VolumeUpAction
end
object MenuVolumeDown: TMenuItem
Tag = 3
Action = VolumeDownAction
end
object MenuMute: TMenuItem
Action = MuteAction
end
object MenuChannel: TMenuItem
Tag = 3
Caption = 'C&hannels'
Enabled = False
Hint = 'Select audio channel'
end
object N2: TMenuItem
Caption = '-'
end
object MenuVDevice: TMenuItem
Tag = 3
Caption = 'Sc&reen'
Enabled = False
end
object MenuFullscreen: TMenuItem
Tag = 3
Action = FullscreenAction
end
object N2: TMenuItem
object N11: TMenuItem
Caption = '-'
end
object MenuProgram: TMenuItem
Tag = 3
Caption = 'Progr&am'
Caption = '&Program'
Enabled = False
Hint = 'Select program'
end
......@@ -513,29 +555,13 @@ object MainFrameDlg: TMainFrameDlg
end
object MenuAngle: TMenuItem
Tag = 3
Caption = 'An&gle'
Caption = '&Angle'
Enabled = False
Hint = 'Select angle'
end
object N3: TMenuItem
Caption = '-'
end
object MenuPlaylist: TMenuItem
Tag = 3
Action = PlaylistAction
Caption = '&Playlist...'
end
object MenuMessages: TMenuItem
Tag = 3
Action = MessagesAction
end
end
object MenuSettings: TMenuItem
Tag = 3
Caption = '&Settings'
object MenuAudio: TMenuItem
object MenuLanguage: TMenuItem
Tag = 3
Caption = '&Audio'
Caption = '&Language'
Enabled = False
Hint = 'Select audio language'
end
......@@ -545,13 +571,6 @@ object MainFrameDlg: TMainFrameDlg
Enabled = False
Hint = 'Select subtitles language'
end
object N4: TMenuItem
Caption = '-'
end
object MenuPreferences: TMenuItem
Tag = 3
Action = PreferencesAction
end
end
object MenuHelp: TMenuItem
Tag = 3
......@@ -2299,16 +2318,17 @@ object MainFrameDlg: TMainFrameDlg
end
object PopupMenuMain: TPopupMenu
AutoPopup = False
TrackButton = tbLeftButton
Left = 72
Top = 208
object PopupClose: TMenuItem
Tag = 3
Caption = '&Close this popup'
Caption = 'Close this popup'
OnClick = PopupCloseClick
end
object PopupToggleInterface: TMenuItem
Tag = 3
Caption = '&Toggle interface'
Caption = 'Show interface'
OnClick = PopupToggleInterfaceClick
end
object N9: TMenuItem
......@@ -2363,9 +2383,38 @@ object MainFrameDlg: TMainFrameDlg
object PopupFullscreen: TMenuItem
Tag = 3
Action = FullscreenAction
ShortCut = 70
end
end
object PopupAudioSettings: TMenuItem
Tag = 3
Caption = 'Audio settings'
object PopupADevice: TMenuItem
Tag = 3
Caption = 'Device'
end
object VolumeUp1: TMenuItem
Tag = 3
Action = VolumeUpAction
end
object VolumeDown1: TMenuItem
Tag = 3
Action = VolumeDownAction
end
object Mute1: TMenuItem
Tag = 3
Action = MuteAction
end
object PopupChannel: TMenuItem
Tag = 3
Caption = 'Channels'
end
end
object PopupVDevice: TMenuItem
Caption = 'Screen'
end
object N1: TMenuItem
Caption = '-'
end
object PopupNavigation: TMenuItem
Tag = 3
Caption = 'Navigation'
......@@ -2374,9 +2423,9 @@ object MainFrameDlg: TMainFrameDlg
Tag = 3
Caption = 'Program'
end
object PopupAudio: TMenuItem
object PopupLanguage: TMenuItem
Tag = 3
Caption = 'Audio'
Caption = 'Language'
end
object PopupSubtitles: TMenuItem
Tag = 3
......@@ -2553,8 +2602,9 @@ object MainFrameDlg: TMainFrameDlg
object FullscreenAction: TAction
Tag = 3
Category = 'Control'
Caption = 'Fullscreen'
Caption = '&Fullscreen'
Hint = 'Toggle fullscreen'
ShortCut = 70
OnExecute = FullscreenActionExecute
end
object PreferencesAction: TAction
......@@ -2607,5 +2657,28 @@ object MainFrameDlg: TMainFrameDlg
Hint = 'Jump to next chapter'
OnExecute = NextChapterActionExecute
end
object VolumeUpAction: TAction
Tag = 3
Category = 'Control'
Caption = 'Volume &Up'
Hint = 'Increase the volume'
ShortCut = 16469
OnExecute = VolumeUpActionExecute
end
object VolumeDownAction: TAction
Tag = 3
Category = 'Control'
Caption = 'Volume &Down'
Hint = 'Decrease the volume'
ShortCut = 16452
OnExecute = VolumeDownActionExecute
end
object MuteAction: TAction
Tag = 3
Category = 'Control'
Caption = '&Mute'
Hint = 'Toggle mute'
OnExecute = MuteActionExecute
end
end
end
......@@ -70,22 +70,19 @@ __published: // IDE-managed Components
TMenuItem *MenuOpenFile;
TMenuItem *MenuOpenDisc;
TMenuItem *MenuNetworkStream;
TMenuItem *N1;
TMenuItem *MenuExit;
TMenuItem *MenuView;
TMenuItem *MenuHideinterface;
TMenuItem *MenuFullscreen;
TMenuItem *N2;
TMenuItem *MenuTitle;
TMenuItem *MenuChapter;
TMenuItem *MenuAngle;
TMenuItem *N3;
TMenuItem *MenuPlaylist;
TMenuItem *MenuMessages;
TMenuItem *MenuSettings;
TMenuItem *MenuAudio;
TMenuItem *MenuControls;
TMenuItem *MenuLanguage;
TMenuItem *MenuSubtitles;
TMenuItem *N4;
TMenuItem *MenuPreferences;
TMenuItem *MenuHelp;
TMenuItem *MenuAbout;
......@@ -105,7 +102,7 @@ __published: // IDE-managed Components
TMenuItem *PopupJump;
TMenuItem *PopupNavigation;
TMenuItem *PopupProgram;
TMenuItem *PopupAudio;
TMenuItem *PopupLanguage;
TMenuItem *PopupSubtitles;
TMenuItem *PopupFile;
TMenuItem *PopupPlaylist;
......@@ -120,7 +117,6 @@ __published: // IDE-managed Components
TLabel *LabelServer;
TGroupBox *GroupBoxDisc;
TMenuItem *N8;
TMenuItem *MenuEjectDisc;
TMenuItem *MenuProgram;
TLabel *LabelDisc;
TLabel *LabelTitle;
......@@ -169,6 +165,25 @@ __published: // IDE-managed Components
TAction *NextTitleAction;
TAction *PrevChapterAction;
TAction *NextChapterAction;
TMenuItem *N11;
TMenuItem *MenuChannel;
TMenuItem *PopupChannel;
TMenuItem *MenuVolumeUp;
TMenuItem *MenuVolumeDown;
TMenuItem *MenuMute;
TAction *VolumeUpAction;
TAction *VolumeDownAction;
TAction *MuteAction;
TMenuItem *MenuADevice;
TMenuItem *PopupAudioSettings;
TMenuItem *PopupADevice;
TMenuItem *VolumeDown1;
TMenuItem *VolumeUp1;
TMenuItem *Mute1;
TMenuItem *MenuVDevice;
TMenuItem *N2;
TMenuItem *N1;
TMenuItem *PopupVDevice;
void __fastcall TimerManageTimer( TObject *Sender );
void __fastcall TrackBarChange( TObject *Sender );
void __fastcall FormClose( TObject *Sender, TCloseAction &Action );
......@@ -180,21 +195,24 @@ __published: // IDE-managed Components
void __fastcall OpenFileActionExecute( TObject *Sender );
void __fastcall OpenDiscActionExecute( TObject *Sender );
void __fastcall NetworkStreamActionExecute( TObject *Sender );
void __fastcall ExitActionExecute( TObject *Sender );
void __fastcall PlaylistActionExecute( TObject *Sender );
void __fastcall MessagesActionExecute( TObject *Sender );
void __fastcall AboutActionExecute( TObject *Sender );
void __fastcall BackActionExecute( TObject *Sender );
void __fastcall PlayActionExecute( TObject *Sender );
void __fastcall PauseActionExecute( TObject *Sender );
void __fastcall StopActionExecute( TObject *Sender );
void __fastcall SlowActionExecute( TObject *Sender );
void __fastcall FastActionExecute( TObject *Sender );
void __fastcall EjectActionExecute( TObject *Sender );
void __fastcall PlaylistActionExecute( TObject *Sender );
void __fastcall PreviousActionExecute( TObject *Sender );
void __fastcall NextActionExecute( TObject *Sender );
void __fastcall EjectActionExecute( TObject *Sender );
void __fastcall VolumeUpActionExecute( TObject *Sender );
void __fastcall VolumeDownActionExecute( TObject *Sender );
void __fastcall MuteActionExecute( TObject *Sender );
void __fastcall FullscreenActionExecute( TObject *Sender );
void __fastcall PreferencesActionExecute( TObject *Sender );
void __fastcall MessagesActionExecute( TObject *Sender );
void __fastcall AboutActionExecute( TObject *Sender );
void __fastcall ExitActionExecute( TObject *Sender );
void __fastcall PrevTitleActionExecute( TObject *Sender );
void __fastcall NextTitleActionExecute( TObject *Sender );
void __fastcall PrevChapterActionExecute( TObject *Sender );
......
......@@ -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>
*
......@@ -31,23 +31,72 @@
/*****************************************************************************
* 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;
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;
}
......
......@@ -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 );
......
......@@ -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 Teulire <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 );
......
......@@ -20,7 +20,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include "about.h"
#include "disc.h"
#include "mainframe.h"
#include "menu.h"
......@@ -47,6 +46,10 @@ struct intf_sys_t
vlc_bool_t b_slider_free; /* slider status */
/* menus handlers */
vlc_bool_t b_aout_update; /* do we need to update menus
related with audio output */
vlc_bool_t b_vout_update; /* do we need to update menus
related with video output */
vlc_bool_t b_program_update; /* do we need to update programs
menu */
vlc_bool_t b_title_update; /* do we need to update title menus */
......
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