Commit 7d3c9e87 authored by Olivier Teulière's avatar Olivier Teulière

* modules/gui/win32/mainframe.cpp: simplifications using the new

   aout_Volume* API
parent df8f6747
/***************************************************************************** /*****************************************************************************
* mainframe.cpp: Win32 interface plugin for vlc * mainframe.cpp: Win32 interface plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* *
* Authors: Olivier Teulire <ipkiss@via.ecp.fr> * Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
#include <vcl.h> #include <vcl.h>
#pragma hdrstop #pragma hdrstop
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/intf.h> #include <vlc/intf.h>
#include <vlc/vout.h> #include <vlc/vout.h>
#include "dragdrop.h" #include "dragdrop.h"
#include "mainframe.h" #include "mainframe.h"
#include "menu.h" #include "menu.h"
#include "disc.h" #include "disc.h"
#include "network.h" #include "network.h"
#include "about.h" #include "about.h"
#include "preferences.h" #include "preferences.h"
#include "messages.h" #include "messages.h"
#include "playlist.h" #include "playlist.h"
#include "sout.h" #include "sout.h"
#include "subtitles.h" #include "subtitles.h"
#include "misc.h" #include "misc.h"
#include "win32_common.h" #include "win32_common.h"
#include "netutils.h" #include "netutils.h"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#pragma link "CSPIN" #pragma link "CSPIN"
#pragma resource "*.dfm" #pragma resource "*.dfm"
extern int Win32Manage( intf_thread_t *p_intf ); extern int Win32Manage( intf_thread_t *p_intf );
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
__fastcall TMainFrameDlg::TMainFrameDlg( __fastcall TMainFrameDlg::TMainFrameDlg(
TComponent* Owner, intf_thread_t *_p_intf ) : TForm( Owner ) TComponent* Owner, intf_thread_t *_p_intf ) : TForm( Owner )
{ {
p_intf = _p_intf; p_intf = _p_intf;
Application->ShowHint = true; Application->ShowHint = true;
Application->OnHint = DisplayHint; Application->OnHint = DisplayHint;
TimerManage->Interval = INTF_IDLE_SLEEP / 1000; TimerManage->Interval = INTF_IDLE_SLEEP / 1000;
TrackBar->Max = SLIDER_MAX_VALUE; TrackBar->Max = SLIDER_MAX_VALUE;
/* default height and caption */ /* default height and caption */
ClientHeight = 37 + ToolBar->Height; ClientHeight = 37 + ToolBar->Height;
Caption = VOUT_TITLE " (Win32 interface)"; Caption = VOUT_TITLE " (Win32 interface)";
StringListPref = new TStringList(); StringListPref = new TStringList();
Translate( this ); Translate( this );
/* drag and drop stuff */ /* drag and drop stuff */
/* initialize the OLE library */ /* initialize the OLE library */
OleInitialize( NULL ); OleInitialize( NULL );
/* TDropTarget will send the WM_OLEDROP message to the form */ /* TDropTarget will send the WM_OLEDROP message to the form */
lpDropTarget = (LPDROPTARGET)new TDropTarget( this->Handle ); lpDropTarget = (LPDROPTARGET)new TDropTarget( this->Handle );
CoLockObjectExternal( lpDropTarget, true, true ); CoLockObjectExternal( lpDropTarget, true, true );
/* register the form as a drop target */ /* register the form as a drop target */
RegisterDragDrop( this->Handle, lpDropTarget ); RegisterDragDrop( this->Handle, lpDropTarget );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
__fastcall TMainFrameDlg::~TMainFrameDlg() __fastcall TMainFrameDlg::~TMainFrameDlg()
{ {
delete StringListPref; delete StringListPref;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
/***************************************************************************** /*****************************************************************************
* Event handlers * Event handlers
****************************************************************************/ ****************************************************************************/
void __fastcall TMainFrameDlg::TimerManageTimer( TObject *Sender ) void __fastcall TMainFrameDlg::TimerManageTimer( TObject *Sender )
{ {
Win32Manage( p_intf ); Win32Manage( p_intf );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::DisplayHint( TObject *Sender ) void __fastcall TMainFrameDlg::DisplayHint( TObject *Sender )
{ {
StatusBar->SimpleText = GetLongHint( Application->Hint ); StatusBar->SimpleText = GetLongHint( Application->Hint );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::TrackBarChange( TObject *Sender ) void __fastcall TMainFrameDlg::TrackBarChange( TObject *Sender )
{ {
/* This function displays the current date related to the position in /* This function displays the current date related to the position in
* the stream. It is called whenever the slider changes its value. * the stream. It is called whenever the slider changes its value.
* The lock has to be taken before the function is called */ * The lock has to be taken before the function is called */
if( p_intf->p_sys->p_input != NULL ) if( p_intf->p_sys->p_input != NULL )
{ {
#define p_area p_intf->p_sys->p_input->stream.p_selected_area #define p_area p_intf->p_sys->p_input->stream.p_selected_area
char psz_time[ OFFSETTOTIME_MAX_SIZE ]; char psz_time[ OFFSETTOTIME_MAX_SIZE ];
off_t Value = TrackBar->Position; off_t Value = TrackBar->Position;
GroupBoxSlider->Caption = GroupBoxSlider->Caption =
input_OffsetToTime( p_intf->p_sys->p_input, psz_time, input_OffsetToTime( p_intf->p_sys->p_input, psz_time,
( p_area->i_size * Value ) / (off_t)SLIDER_MAX_VALUE ); ( p_area->i_size * Value ) / (off_t)SLIDER_MAX_VALUE );
#undef p_area #undef p_area
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::FormClose( TObject *Sender, void __fastcall TMainFrameDlg::FormClose( TObject *Sender,
TCloseAction &Action ) TCloseAction &Action )
{ {
vlc_mutex_lock( &p_intf->change_lock ); vlc_mutex_lock( &p_intf->change_lock );
p_intf->p_vlc->b_die = VLC_TRUE; p_intf->p_vlc->b_die = VLC_TRUE;
vlc_mutex_unlock( &p_intf->change_lock ); vlc_mutex_unlock( &p_intf->change_lock );
/* remove the form from the list of drop targets */ /* remove the form from the list of drop targets */
RevokeDragDrop( this->Handle ); RevokeDragDrop( this->Handle );
lpDropTarget->Release(); lpDropTarget->Release();
CoLockObjectExternal( lpDropTarget, false, true ); CoLockObjectExternal( lpDropTarget, false, true );
/* uninitialize the OLE library */ /* uninitialize the OLE library */
OleUninitialize(); OleUninitialize();
/* we don't destroy the form immediatly */ /* we don't destroy the form immediatly */
Action = caHide; Action = caHide;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
/***************************************************************************** /*****************************************************************************
* Main callbacks * Main callbacks
****************************************************************************/ ****************************************************************************/
void __fastcall TMainFrameDlg::OpenFileActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::OpenFileActionExecute( TObject *Sender )
{ {
if( OpenDialog1->Execute() ) if( OpenDialog1->Execute() )
{ {
/* add the new file to the interface playlist */ /* add the new file to the interface playlist */
for( int i = 0; i < OpenDialog1->Files->Count; i++ ) for( int i = 0; i < OpenDialog1->Files->Count; i++ )
p_intf->p_sys->p_playwin->Add( OpenDialog1->Files->Strings[i], p_intf->p_sys->p_playwin->Add( OpenDialog1->Files->Strings[i],
PLAYLIST_APPEND PLAYLIST_APPEND
| ( p_intf->p_sys->b_play_when_adding ? PLAYLIST_GO : 0 ), | ( p_intf->p_sys->b_play_when_adding ? PLAYLIST_GO : 0 ),
PLAYLIST_END ); PLAYLIST_END );
}; };
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::OpenDiscActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::OpenDiscActionExecute( TObject *Sender )
{ {
TDiscDlg *p_disc = p_intf->p_sys->p_disc; TDiscDlg *p_disc = p_intf->p_sys->p_disc;
if( p_disc == NULL ) if( p_disc == NULL )
{ {
p_disc = new TDiscDlg( this, p_intf ); p_disc = new TDiscDlg( this, p_intf );
p_intf->p_sys->p_disc = p_disc; p_intf->p_sys->p_disc = p_disc;
} }
p_disc->Show(); p_disc->Show();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::NetworkStreamActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::NetworkStreamActionExecute( TObject *Sender )
{ {
TNetworkDlg *p_network = p_intf->p_sys->p_network; TNetworkDlg *p_network = p_intf->p_sys->p_network;
if( p_network == NULL ) if( p_network == NULL )
{ {
p_network = new TNetworkDlg( this, p_intf ); p_network = new TNetworkDlg( this, p_intf );
p_intf->p_sys->p_network = p_network; p_intf->p_sys->p_network = p_network;
} }
p_network->Show(); p_network->Show();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::AddSubtitlesActionsExecute( TObject *Sender ) void __fastcall TMainFrameDlg::AddSubtitlesActionsExecute( TObject *Sender )
{ {
TSubtitlesDlg *p_subtitles = new TSubtitlesDlg( this, p_intf ); TSubtitlesDlg *p_subtitles = new TSubtitlesDlg( this, p_intf );
p_subtitles->ShowModal(); p_subtitles->ShowModal();
delete p_subtitles; delete p_subtitles;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::StreamOutputActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::StreamOutputActionExecute( TObject *Sender )
{ {
TSoutDlg *p_sout = new TSoutDlg( this, p_intf ); TSoutDlg *p_sout = new TSoutDlg( this, p_intf );
p_sout->ShowModal(); p_sout->ShowModal();
delete p_sout; delete p_sout;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::ExitActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::ExitActionExecute( TObject *Sender )
{ {
Close(); Close();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::FullscreenActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::FullscreenActionExecute( TObject *Sender )
{ {
vout_thread_t *p_vout; vout_thread_t *p_vout;
p_vout = (vout_thread_t *)vlc_object_find( p_intf->p_sys->p_input, p_vout = (vout_thread_t *)vlc_object_find( p_intf->p_sys->p_input,
VLC_OBJECT_VOUT, FIND_CHILD ); VLC_OBJECT_VOUT, FIND_CHILD );
if( p_vout == NULL ) if( p_vout == NULL )
{ {
return; return;
} }
p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
vlc_object_release( p_vout ); vlc_object_release( p_vout );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::OnTopActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::OnTopActionExecute( TObject *Sender )
{ {
vlc_object_t *p_vout; vlc_object_t *p_vout;
p_vout = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, p_vout = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE ); FIND_ANYWHERE );
if( p_vout != NULL ) if( p_vout != NULL )
{ {
vlc_value_t val; vlc_value_t val;
if( var_Get( p_vout, "directx-on-top", &val ) >= 0 ) if( var_Get( p_vout, "directx-on-top", &val ) >= 0 )
...@@ -228,517 +228,495 @@ void __fastcall TMainFrameDlg::OnTopActionExecute( TObject *Sender ) ...@@ -228,517 +228,495 @@ void __fastcall TMainFrameDlg::OnTopActionExecute( TObject *Sender )
MenuOnTop->Checked = val.b_bool; MenuOnTop->Checked = val.b_bool;
PopupOnTop->Checked = val.b_bool; PopupOnTop->Checked = val.b_bool;
} }
vlc_object_release( p_vout ); vlc_object_release( p_vout );
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::PlaylistActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::PlaylistActionExecute( TObject *Sender )
{ {
TPlaylistDlg *p_playwin = p_intf->p_sys->p_playwin; TPlaylistDlg *p_playwin = p_intf->p_sys->p_playwin;
if( p_playwin->Visible ) if( p_playwin->Visible )
{ {
p_playwin->Hide(); p_playwin->Hide();
} }
else else
{ {
p_playwin->UpdateGrid(); p_playwin->UpdateGrid();
p_playwin->Show(); p_playwin->Show();
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::MessagesActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::MessagesActionExecute( TObject *Sender )
{ {
p_intf->p_sys->p_messages->Show(); p_intf->p_sys->p_messages->Show();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::PreferencesActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::PreferencesActionExecute( TObject *Sender )
{ {
CreatePreferences( "main" ); CreatePreferences( "main" );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::AboutActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::AboutActionExecute( TObject *Sender )
{ {
TAboutDlg *AboutDlg = new TAboutDlg( this, p_intf ); TAboutDlg *AboutDlg = new TAboutDlg( this, p_intf );
AboutDlg->ShowModal(); AboutDlg->ShowModal();
delete AboutDlg; delete AboutDlg;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::BackActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::BackActionExecute( TObject *Sender )
{ {
/* TODO */ /* TODO */
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::PlayActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::PlayActionExecute( TObject *Sender )
{ {
p_intf->p_sys->p_playwin->Play(); p_intf->p_sys->p_playwin->Play();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::PauseActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::PauseActionExecute( TObject *Sender )
{ {
p_intf->p_sys->p_playwin->Pause(); p_intf->p_sys->p_playwin->Pause();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::StopActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::StopActionExecute( TObject *Sender )
{ {
p_intf->p_sys->p_playwin->Stop(); p_intf->p_sys->p_playwin->Stop();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::SlowActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::SlowActionExecute( TObject *Sender )
{ {
p_intf->p_sys->p_playwin->Slow(); p_intf->p_sys->p_playwin->Slow();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::FastActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::FastActionExecute( TObject *Sender )
{ {
p_intf->p_sys->p_playwin->Fast(); p_intf->p_sys->p_playwin->Fast();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::PreviousActionExecute(TObject *Sender) void __fastcall TMainFrameDlg::PreviousActionExecute(TObject *Sender)
{ {
p_intf->p_sys->p_playwin->Previous(); p_intf->p_sys->p_playwin->Previous();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::NextActionExecute(TObject *Sender) void __fastcall TMainFrameDlg::NextActionExecute(TObject *Sender)
{ {
p_intf->p_sys->p_playwin->Next(); p_intf->p_sys->p_playwin->Next();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::EjectActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::EjectActionExecute( TObject *Sender )
{ {
AnsiString Device = ""; AnsiString Device = "";
char * psz_current; char * psz_current;
playlist_t * p_playlist; playlist_t * p_playlist;
p_playlist = (playlist_t *)vlc_object_find( p_intf, p_playlist = (playlist_t *)vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist == NULL ) if( p_playlist == NULL )
{ {
return; return;
} }
/* /*
* Get the active input * Get the active input
* Determine whether we can eject a media, ie it's a VCD or DVD * Determine whether we can eject a media, ie it's a VCD or DVD
* If it's neither a VCD nor a DVD, then return * If it's neither a VCD nor a DVD, then return
*/ */
vlc_mutex_lock( &p_playlist->object_lock ); vlc_mutex_lock( &p_playlist->object_lock );
psz_current = p_playlist->pp_items[ p_playlist->i_index ]->psz_name; psz_current = p_playlist->pp_items[ p_playlist->i_index ]->psz_name;
if( psz_current != NULL ) if( psz_current != NULL )
{ {
if( strncmp( psz_current, "dvd", 3 ) if( strncmp( psz_current, "dvd", 3 )
|| strncmp( psz_current, "vcd", 3 ) ) || strncmp( psz_current, "vcd", 3 ) )
{ {
/* Determine the device name by omitting the first 4 characters /* Determine the device name by omitting the first 4 characters
* and keeping 3 characters */ * and keeping 3 characters */
Device = strdup( ( psz_current + 4 ) ); Device = strdup( ( psz_current + 4 ) );
Device = Device.SubString( 1, 2 ); Device = Device.SubString( 1, 2 );
} }
} }
vlc_mutex_unlock( &p_playlist->object_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
if( Device == "" ) if( Device == "" )
{ {
return; return;
} }
/* If there's a stream playing, we aren't allowed to eject ! */ /* If there's a stream playing, we aren't allowed to eject ! */
if( p_intf->p_sys->p_input == NULL ) if( p_intf->p_sys->p_input == NULL )
{ {
msg_Dbg( p_intf, "ejecting %s", Device.c_str() ); msg_Dbg( p_intf, "ejecting %s", Device.c_str() );
intf_Eject( p_intf, Device.c_str() ); intf_Eject( p_intf, Device.c_str() );
} }
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
void __fastcall TMainFrameDlg::VolumeUpActionExecute( TObject *Sender ) void __fastcall TMainFrameDlg::VolumeUpActionExecute( TObject *Sender )
{ {
aout_instance_t *p_aout; aout_VolumeUp( p_intf, 1, NULL );
p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT, }
FIND_ANYWHERE ); //---------------------------------------------------------------------------
if ( p_aout != NULL ) void __fastcall TMainFrameDlg::VolumeDownActionExecute( TObject *Sender )
{ {
aout_VolumeUp( p_aout, 1, NULL ); aout_VolumeDown( p_intf, 1, NULL );
vlc_object_release( (vlc_object_t *)p_aout ); }
} //---------------------------------------------------------------------------
} void __fastcall TMainFrameDlg::MuteActionExecute( TObject *Sender )
//--------------------------------------------------------------------------- {
void __fastcall TMainFrameDlg::VolumeDownActionExecute( TObject *Sender ) aout_VolumeMute( p_intf, NULL );
{ // MenuMute->Checked = ! MenuMute->Checked;
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 ); * External drop handling
vlc_object_release( (vlc_object_t *)p_aout ); *****************************************************************************/
} void __fastcall TMainFrameDlg::OnDrop( TMessage &Msg )
} {
//--------------------------------------------------------------------------- /* find the number of files dropped */
void __fastcall TMainFrameDlg::MuteActionExecute( TObject *Sender ) int num_files = DragQueryFile( (HDROP)Msg.WParam, 0xFFFFFFFF,
{ (LPSTR)NULL, NULL );
aout_instance_t *p_aout;
p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT, /* append each file to the playlist */
FIND_ANYWHERE ); for( int i = 0; i < num_files; i++ )
if ( p_aout != NULL ) {
{ /* find the length of the filename */
aout_VolumeMute( p_aout, NULL ); int name_length = DragQueryFile( (HDROP)Msg.WParam, i, NULL, NULL ) + 1;
vlc_object_release( (vlc_object_t *)p_aout );
/* get the filename */
// MenuMute->Checked = ! MenuMute->Checked; char *FileName = new char[name_length];
} DragQueryFile( (HDROP)Msg.WParam, i, FileName, name_length );
}
//--------------------------------------------------------------------------- /* add the new file to the playlist */
if( config_GetInt( p_intf, "enqueue" ) )
{
/***************************************************************************** p_intf->p_sys->p_playwin->Add( FileName,
* External drop handling PLAYLIST_APPEND, PLAYLIST_END );
*****************************************************************************/ }
void __fastcall TMainFrameDlg::OnDrop( TMessage &Msg ) else
{ {
/* find the number of files dropped */ p_intf->p_sys->p_playwin->Add( FileName,
int num_files = DragQueryFile( (HDROP)Msg.WParam, 0xFFFFFFFF, PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
(LPSTR)NULL, NULL ); }
/* append each file to the playlist */ delete[] FileName;
for( int i = 0; i < num_files; i++ ) }
{
/* find the length of the filename */ DragFinish( (HDROP)Msg.WParam );
int name_length = DragQueryFile( (HDROP)Msg.WParam, i, NULL, NULL ) + 1; Msg.Result = 0;
}
/* get the filename */ //--------------------------------------------------------------------------
char *FileName = new char[name_length];
DragQueryFile( (HDROP)Msg.WParam, i, FileName, name_length );
/*****************************************************************************
/* add the new file to the playlist */ * Menu and popup callbacks
if( config_GetInt( p_intf, "enqueue" ) ) *****************************************************************************/
{ void __fastcall TMainFrameDlg::MenuHideinterfaceClick( TObject *Sender )
p_intf->p_sys->p_playwin->Add( FileName, {
PLAYLIST_APPEND, PLAYLIST_END ); this->SendToBack();
} }
else //---------------------------------------------------------------------------
{ void __fastcall TMainFrameDlg::PopupToggleInterfaceClick( TObject *Sender )
p_intf->p_sys->p_playwin->Add( FileName, {
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END ); this->BringToFront();
} }
//---------------------------------------------------------------------------
delete[] FileName; void __fastcall TMainFrameDlg::PopupCloseClick( TObject *Sender )
} {
/* We do nothing, we just need a click on a menu item
DragFinish( (HDROP)Msg.WParam ); * to close the popup. Don't ask me why... */
Msg.Result = 0; return;
} }
//-------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::PopupJumpClick( TObject *Sender )
{
/***************************************************************************** /* TODO */
* Menu and popup callbacks }
*****************************************************************************/ //---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::MenuHideinterfaceClick( TObject *Sender )
{
this->SendToBack(); /*****************************************************************************
} * Callbacks for DVD/VCD navigation
//--------------------------------------------------------------------------- ****************************************************************************/
void __fastcall TMainFrameDlg::PopupToggleInterfaceClick( TObject *Sender ) void __fastcall TMainFrameDlg::PrevTitleActionExecute( TObject *Sender )
{ {
this->BringToFront(); input_area_t * p_area;
} int i_id;
//---------------------------------------------------------------------------
void __fastcall TMainFrameDlg::PopupCloseClick( TObject *Sender ) vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
{ i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id - 1;
/* We do nothing, we just need a click on a menu item
* to close the popup. Don't ask me why... */ /* Disallow area 0 since it is used for video_ts.vob */
return; if( i_id > 0 )
} {
//--------------------------------------------------------------------------- p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id];
void __fastcall TMainFrameDlg::PopupJumpClick( TObject *Sender ) vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
{
/* TODO */ input_ChangeArea( p_intf->p_sys->p_input, p_area );
} input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
//---------------------------------------------------------------------------
p_intf->p_sys->b_title_update = VLC_TRUE;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
/***************************************************************************** p_intf->p_sys->p_menus->SetupMenus();
* Callbacks for DVD/VCD navigation }
****************************************************************************/
void __fastcall TMainFrameDlg::PrevTitleActionExecute( TObject *Sender ) vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
{ }
input_area_t * p_area; //---------------------------------------------------------------------------
int i_id; void __fastcall TMainFrameDlg::NextTitleActionExecute( TObject *Sender )
{
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); input_area_t * p_area;
i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id - 1; unsigned int i_id;
/* Disallow area 0 since it is used for video_ts.vob */ vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
if( i_id > 0 ) i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id + 1;
{
p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id]; if( i_id < p_intf->p_sys->p_input->stream.i_area_nb )
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); {
p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id];
input_ChangeArea( p_intf->p_sys->p_input, p_area ); vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
input_ChangeArea( p_intf->p_sys->p_input, p_area );
p_intf->p_sys->b_title_update = VLC_TRUE; input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
p_intf->p_sys->p_menus->SetupMenus(); p_intf->p_sys->b_title_update = VLC_TRUE;
} vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
p_intf->p_sys->p_menus->SetupMenus();
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); }
}
//--------------------------------------------------------------------------- vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
void __fastcall TMainFrameDlg::NextTitleActionExecute( TObject *Sender ) }
{ //---------------------------------------------------------------------------
input_area_t * p_area; void __fastcall TMainFrameDlg::PrevChapterActionExecute( TObject *Sender )
unsigned int i_id; {
input_area_t * p_area;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id + 1; vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
p_area = p_intf->p_sys->p_input->stream.p_selected_area;
if( i_id < p_intf->p_sys->p_input->stream.i_area_nb )
{ if( p_area->i_part - 1 > 0 )
p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id]; {
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); p_area->i_part--;
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
input_ChangeArea( p_intf->p_sys->p_input, p_area );
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); input_ChangeArea( p_intf->p_sys->p_input, p_area );
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
p_intf->p_sys->b_title_update = VLC_TRUE;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); p_intf->p_sys->b_chapter_update = VLC_TRUE;
p_intf->p_sys->p_menus->SetupMenus(); vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
} p_intf->p_sys->p_menus->SetupMenus();
}
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
} vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
//--------------------------------------------------------------------------- }
void __fastcall TMainFrameDlg::PrevChapterActionExecute( TObject *Sender ) //---------------------------------------------------------------------------
{ void __fastcall TMainFrameDlg::NextChapterActionExecute( TObject *Sender )
input_area_t * p_area; {
input_area_t * p_area;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
p_area = p_intf->p_sys->p_input->stream.p_selected_area; vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
p_area = p_intf->p_sys->p_input->stream.p_selected_area;
if( p_area->i_part - 1 > 0 )
{ if( p_area->i_part + 1 < p_area->i_part_nb )
p_area->i_part--; {
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); p_area->i_part++;
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
input_ChangeArea( p_intf->p_sys->p_input, p_area );
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); input_ChangeArea( p_intf->p_sys->p_input, p_area );
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
p_intf->p_sys->b_chapter_update = VLC_TRUE;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); p_intf->p_sys->b_chapter_update = VLC_TRUE;
p_intf->p_sys->p_menus->SetupMenus(); vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
} p_intf->p_sys->p_menus->SetupMenus();
}
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
} vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
//--------------------------------------------------------------------------- }
void __fastcall TMainFrameDlg::NextChapterActionExecute( TObject *Sender ) //---------------------------------------------------------------------------
{
input_area_t * p_area;
/*****************************************************************************
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); * Callback for the 'go!' button
p_area = p_intf->p_sys->p_input->stream.p_selected_area; ****************************************************************************/
void __fastcall TMainFrameDlg::ButtonGoClick( TObject *Sender )
if( p_area->i_part + 1 < p_area->i_part_nb ) {
{ int i_channel;
p_area->i_part++;
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); i_channel = SpinEditChannel->Value;
msg_Dbg( p_intf, "joining channel %d", i_channel );
input_ChangeArea( p_intf->p_sys->p_input, p_area );
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); vlc_mutex_lock( &p_intf->change_lock );
network_ChannelJoin( p_intf, i_channel );
p_intf->p_sys->b_chapter_update = VLC_TRUE; vlc_mutex_unlock( &p_intf->change_lock );
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
p_intf->p_sys->p_menus->SetupMenus(); // input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
} }
//---------------------------------------------------------------------------
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
}
//--------------------------------------------------------------------------- /*****************************************************************************
* ModeManage: actualise the aspect of the interface whenever the input
* changes.
/***************************************************************************** *****************************************************************************
* Callback for the 'go!' button * The lock has to be taken before you call the function.
****************************************************************************/ *****************************************************************************/
void __fastcall TMainFrameDlg::ButtonGoClick( TObject *Sender ) void __fastcall TMainFrameDlg::ModeManage()
{ {
int i_channel; TGroupBox * ActiveGB;
int i_Height;
i_channel = SpinEditChannel->Value; bool b_control;
msg_Dbg( p_intf, "joining channel %d", i_channel );
/* hide all boxes */
vlc_mutex_lock( &p_intf->change_lock ); GroupBoxFile->Visible = false;
network_ChannelJoin( p_intf, i_channel ); GroupBoxNetwork->Visible = false;
vlc_mutex_unlock( &p_intf->change_lock ); GroupBoxDisc->Visible = false;
// input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); /* hide slider */
} GroupBoxSlider->Hide();
//---------------------------------------------------------------------------
/* controls unavailable */
b_control = 0;
/*****************************************************************************
* ModeManage: actualise the aspect of the interface whenever the input /* show the box related to current input mode */
* changes. if( p_intf->p_sys->p_input != NULL )
***************************************************************************** {
* The lock has to be taken before you call the function. switch( p_intf->p_sys->p_input->stream.i_method & 0xf0 )
*****************************************************************************/ {
void __fastcall TMainFrameDlg::ModeManage() case INPUT_METHOD_FILE:
{ GroupBoxFile->Visible = true;
TGroupBox * ActiveGB; ActiveGB = GroupBoxFile;
int i_Height; LabelFileName->Caption = p_intf->p_sys->p_input->psz_source;
bool b_control; break;
case INPUT_METHOD_DISC:
/* hide all boxes */ GroupBoxDisc->Visible = true;
GroupBoxFile->Visible = false; ActiveGB = GroupBoxDisc;
GroupBoxNetwork->Visible = false; break;
GroupBoxDisc->Visible = false; case INPUT_METHOD_NETWORK:
GroupBoxNetwork->Visible = true;
/* hide slider */ ActiveGB = GroupBoxNetwork;
GroupBoxSlider->Hide(); LabelServer->Caption = p_intf->p_sys->p_input->psz_source;
if( config_GetInt( p_intf, "network-channel" ) )
/* controls unavailable */ {
b_control = 0; LabelChannel->Visible = true;
}
/* show the box related to current input mode */ else
if( p_intf->p_sys->p_input != NULL ) {
{ LabelChannel->Visible = false;
switch( p_intf->p_sys->p_input->stream.i_method & 0xf0 ) }
{ break;
case INPUT_METHOD_FILE: default:
GroupBoxFile->Visible = true; msg_Warn( p_intf, "cannot determine input method" );
ActiveGB = GroupBoxFile; GroupBoxFile->Visible = true;
LabelFileName->Caption = p_intf->p_sys->p_input->psz_source; ActiveGB = GroupBoxFile;
break; LabelFileName->Caption = p_intf->p_sys->p_input->psz_source;
case INPUT_METHOD_DISC: break;
GroupBoxDisc->Visible = true; }
ActiveGB = GroupBoxDisc;
break; i_Height = StatusBar->Height + ActiveGB->Height + ToolBar->Height + 54;
case INPUT_METHOD_NETWORK:
GroupBoxNetwork->Visible = true; /* initialize and show slider for seekable streams */
ActiveGB = GroupBoxNetwork; if( p_intf->p_sys->p_input->stream.b_seekable )
LabelServer->Caption = p_intf->p_sys->p_input->psz_source; {
if( config_GetInt( p_intf, "network-channel" ) ) TrackBar->Position = p_intf->p_sys->OldValue = 0;
{ GroupBoxSlider->Show();
LabelChannel->Visible = true; i_Height += GroupBoxSlider->Height;
} }
else
{ /* control buttons for free pace streams */
LabelChannel->Visible = false; b_control = p_intf->p_sys->p_input->stream.b_pace_control;
}
break; /* get ready for menu regeneration */
default: p_intf->p_sys->b_program_update = 1;
msg_Warn( p_intf, "cannot determine input method" ); p_intf->p_sys->b_title_update = 1;
GroupBoxFile->Visible = true; p_intf->p_sys->b_chapter_update = 1;
ActiveGB = GroupBoxFile; p_intf->p_sys->b_audio_update = 1;
LabelFileName->Caption = p_intf->p_sys->p_input->psz_source; p_intf->p_sys->b_spu_update = 1;
break; p_intf->p_sys->i_part = 0;
}
p_intf->p_sys->p_input->stream.b_changed = 0;
i_Height = StatusBar->Height + ActiveGB->Height + ToolBar->Height + 54; msg_Dbg( p_intf, "stream has changed, refreshing interface" );
}
/* initialize and show slider for seekable streams */ else
if( p_intf->p_sys->p_input->stream.b_seekable ) {
{ i_Height = StatusBar->Height + ToolBar->Height + 47;
TrackBar->Position = p_intf->p_sys->OldValue = 0;
GroupBoxSlider->Show(); if( config_GetInt( p_intf, "network-channel" ) )
i_Height += GroupBoxSlider->Height; {
} GroupBoxNetwork->Visible = true;
LabelChannel->Visible = true;
/* control buttons for free pace streams */ i_Height += GroupBoxNetwork->Height + 7;
b_control = p_intf->p_sys->p_input->stream.b_pace_control; }
else
/* get ready for menu regeneration */ {
p_intf->p_sys->b_program_update = 1; /* add space between tolbar and statusbar when
p_intf->p_sys->b_title_update = 1; * nothing is displayed; isn't it nicer ? :) */
p_intf->p_sys->b_chapter_update = 1; i_Height += 17;
p_intf->p_sys->b_audio_update = 1; }
p_intf->p_sys->b_spu_update = 1;
p_intf->p_sys->i_part = 0; /* unsensitize menus */
MenuProgram->Enabled = false;
p_intf->p_sys->p_input->stream.b_changed = 0; MenuTitle->Enabled = false;
msg_Dbg( p_intf, "stream has changed, refreshing interface" ); MenuChapter->Enabled = false;
} MenuLanguage->Enabled = false;
else MenuSubtitles->Enabled = false;
{ PopupNavigation->Enabled = false;
i_Height = StatusBar->Height + ToolBar->Height + 47; PopupLanguage->Enabled = false;
PopupSubtitles->Enabled = false;
if( config_GetInt( p_intf, "network-channel" ) ) }
{
GroupBoxNetwork->Visible = true; /* resize main window */
LabelChannel->Visible = true; this->Height = i_Height;
i_Height += GroupBoxNetwork->Height + 7;
} /* set control items */
else ToolButtonBack->Enabled = false;
{ ToolButtonEject->Enabled = !b_control;
/* add space between tolbar and statusbar when StopAction->Enabled = true;
* nothing is displayed; isn't it nicer ? :) */ PauseAction->Enabled = b_control;
i_Height += 17; SlowAction->Enabled = b_control;
} FastAction->Enabled = b_control;
PopupBack->Enabled = false;
/* unsensitize menus */ }
MenuProgram->Enabled = false; //---------------------------------------------------------------------------
MenuTitle->Enabled = false;
MenuChapter->Enabled = false;
MenuLanguage->Enabled = false; /*****************************************************************************
MenuSubtitles->Enabled = false; * CreateConfig: create a configuration dialog and save it for further use
PopupNavigation->Enabled = false; *****************************************************************************
PopupLanguage->Enabled = false; * Check if the dialog box is already opened, if so this will save us
PopupSubtitles->Enabled = false; * quite a bit of work. (the interface will be destroyed when you actually
} * close the main window, but remember that it is only hidden if you
* clicked on the action buttons). This trick also allows us not to
/* resize main window */ * duplicate identical dialog windows.
this->Height = i_Height; *****************************************************************************/
void __fastcall TMainFrameDlg::CreatePreferences( AnsiString Name )
/* set control items */ {
ToolButtonBack->Enabled = false; TPreferencesDlg *Preferences;
ToolButtonEject->Enabled = !b_control; int i_index, i_pos;
StopAction->Enabled = true;
PauseAction->Enabled = b_control; i_index = StringListPref->IndexOf( Name );
SlowAction->Enabled = b_control; if( i_index != -1 )
FastAction->Enabled = b_control; {
PopupBack->Enabled = false; /* config dialog already exists */
} Preferences = (TPreferencesDlg *)StringListPref->Objects[i_index];
//--------------------------------------------------------------------------- }
else
{
/***************************************************************************** /* create the config dialog */
* CreateConfig: create a configuration dialog and save it for further use Preferences = new TPreferencesDlg( this, p_intf );
***************************************************************************** Preferences->CreateConfigDialog( Name.c_str() );
* Check if the dialog box is already opened, if so this will save us
* quite a bit of work. (the interface will be destroyed when you actually /* save it */
* close the main window, but remember that it is only hidden if you i_pos = StringListPref->Add( Name );
* clicked on the action buttons). This trick also allows us not to StringListPref->Objects[i_pos] = Preferences;
* duplicate identical dialog windows. }
*****************************************************************************/
void __fastcall TMainFrameDlg::CreatePreferences( AnsiString Name ) /* display the dialog */
{ Preferences->Show();
TPreferencesDlg *Preferences; }
int i_index, i_pos; //---------------------------------------------------------------------------
i_index = StringListPref->IndexOf( Name );
if( i_index != -1 )
{
/* config dialog already exists */
Preferences = (TPreferencesDlg *)StringListPref->Objects[i_index];
}
else
{
/* create the config dialog */
Preferences = new TPreferencesDlg( this, p_intf );
Preferences->CreateConfigDialog( Name.c_str() );
/* save it */
i_pos = StringListPref->Add( Name );
StringListPref->Objects[i_pos] = Preferences;
}
/* display the dialog */
Preferences->Show();
}
//---------------------------------------------------------------------------
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