📄 interface.cpp
字号:
}}void Interface::OnExtended( wxCommandEvent& WXUNUSED(event) ){ UpdateVideoWindow( p_intf, video_window ); if( !extra_frame ) { /* Create the extra panel */ extra_frame = new ExtraPanel( p_intf, main_panel ); panel_sizer->Add( extra_frame, 0, wxEXPAND , 0 ); ext_min_size = extra_frame->GetBestSize(); } b_extra = !b_extra; panel_sizer->Show( extra_frame, b_extra ); SetIntfMinSize(); main_sizer->Layout(); main_sizer->Fit( this );}void Interface::OnSmallPlaylist( wxCommandEvent& WXUNUSED(event) ){ UpdateVideoWindow( p_intf, video_window ); if( !playlist_manager ) { /* Create the extra panel */ playlist_manager = new PlaylistManager( p_intf, splitter ); } if( !splitter->IsSplit() ) splitter->Split( main_panel, playlist_manager ); else splitter->Unsplit( playlist_manager ); SetIntfMinSize(); main_sizer->Layout(); main_sizer->Fit( this );}void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) ){ PlayStream();}void Interface::PlayStream(){ wxCommandEvent dummy; playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) return; if( p_playlist->i_size && p_playlist->i_enabled ) { vlc_value_t state; input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input == NULL ) { /* No stream was playing, start one */ playlist_Play( p_playlist ); vlc_object_release( p_playlist ); input_manager->Update(); return; } var_Get( p_input, "state", &state ); if( state.i_int != PAUSE_S ) { /* A stream is being played, pause it */ state.i_int = PAUSE_S; } else { /* Stream is paused, resume it */ state.i_int = PLAYING_S; } var_Set( p_input, "state", state ); vlc_object_release( p_input ); vlc_object_release( p_playlist ); input_manager->Update(); } else { /* If the playlist is empty, open a file requester instead */ vlc_object_release( p_playlist ); OnShowDialog( dummy ); GetToolBar()->ToggleTool( PlayStream_Event, false ); }}void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) ){ StopStream();}void Interface::StopStream(){ playlist_t * p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) { return; } playlist_Stop( p_playlist ); vlc_object_release( p_playlist ); input_manager->Update();}void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) ){ PrevStream();}void Interface::PrevStream(){ playlist_t * p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) { return; } playlist_Prev( p_playlist ); vlc_object_release( p_playlist );}void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) ){ NextStream();}void Interface::NextStream(){ playlist_t * p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) { return; } playlist_Next( p_playlist ); vlc_object_release( p_playlist );}void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) ){ input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input ) { vlc_value_t val; val.b_bool = VLC_TRUE; var_Set( p_input, "rate-slower", val ); vlc_object_release( p_input ); }}void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) ){ input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input ) { vlc_value_t val; val.b_bool = VLC_TRUE; var_Set( p_input, "rate-faster", val ); vlc_object_release( p_input ); }}void Interface::TogglePlayButton( int i_playing_status ){ wxToolBarToolBase *p_tool = (wxToolBarToolBase *) GetToolBar()->GetToolClientData( PlayStream_Event ); if( !p_tool ) return; if( i_playing_status == PLAYING_S ) { p_tool->SetNormalBitmap( wxBitmap( pause_xpm ) ); p_tool->SetLabel( wxU(_("Pause")) ); p_tool->SetShortHelp( wxU(_(HELP_PAUSE)) ); } else { p_tool->SetNormalBitmap( wxBitmap( play_xpm ) ); p_tool->SetLabel( wxU(_("Play")) ); p_tool->SetShortHelp( wxU(_(HELP_PLAY)) ); } GetToolBar()->Realize();#if defined( __WXMSW__ ) /* Needed to work around a bug in wxToolBar::Realize() */ GetToolBar()->SetSize( GetSize().GetWidth(), GetToolBar()->GetSize().GetHeight() ); GetToolBar()->Update();#endif GetToolBar()->ToggleTool( PlayStream_Event, true ); GetToolBar()->ToggleTool( PlayStream_Event, false );}void Interface::OnInteraction( wxCommandEvent& event ){ interaction_dialog_t *p_dialog = (interaction_dialog_t *) event.GetClientData(); intf_dialog_args_t *p_arg = new intf_dialog_args_t; p_arg->p_dialog = p_dialog; p_arg->p_intf = p_intf; if( p_dialog->i_type == INTERACT_PROGRESS ) { /// \todo Handle progress in the interface } else { p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_INTERACTION, 0, p_arg ); }}static int InteractCallback( vlc_object_t *p_this, const char *psz_var, vlc_value_t old_val, vlc_value_t new_val, void *param ){ Interface *p_interface = (Interface*)param; /*interaction_dialog_t *p_dialog = (interaction_dialog_t*)(new_val.p_address);*/ wxCommandEvent event( wxEVT_INTERACTION, -1 ); event.SetClientData( new_val.p_address ); p_interface->AddPendingEvent( event ); return VLC_SUCCESS;}#if wxUSE_DRAG_AND_DROP/***************************************************************************** * Definition of DragAndDrop class. *****************************************************************************/DragAndDrop::DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t _b_enqueue ){ p_intf = _p_intf; b_enqueue = _b_enqueue;}bool DragAndDrop::OnDropFiles( wxCoord, wxCoord, const wxArrayString& filenames ){ /* Add dropped files to the playlist */ playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) { return FALSE; } /* If we drag & drop a subtitle file, add it on the fly */ if( filenames.GetCount() == 1 ) { char *psz_utf8 = wxDnDFromLocale( filenames[0] ); input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input ) { if( input_AddSubtitles( p_input, psz_utf8, VLC_TRUE ) ) { vlc_object_release( p_input ); wxDnDLocaleFree( psz_utf8 ); vlc_object_release( p_playlist ); return TRUE; } vlc_object_release( p_input ); } wxDnDLocaleFree( psz_utf8 ); } for( size_t i = 0; i < filenames.GetCount(); i++ ) { char *psz_utf8 = wxDnDFromLocale( filenames[i] ); playlist_Add( p_playlist, psz_utf8, psz_utf8, PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO), PLAYLIST_END ); wxDnDLocaleFree( psz_utf8 ); } vlc_object_release( p_playlist ); return TRUE;}#endif/***************************************************************************** * Definition of VolCtrl class. *****************************************************************************/class wxVolCtrl: public wxGauge{public: /* Constructor */ wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id, wxPoint = wxDefaultPosition, wxSize = wxSize( 20, -1 ) ); virtual ~wxVolCtrl() {}; void UpdateVolume(); int GetVolume(); void OnChange( wxMouseEvent& event );private: intf_thread_t *p_intf; DECLARE_EVENT_TABLE();};BEGIN_EVENT_TABLE(wxVolCtrl, wxWindow) /* Mouse events */ EVT_LEFT_DOWN(wxVolCtrl::OnChange) EVT_MOTION(wxVolCtrl::OnChange)END_EVENT_TABLE()wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id, wxPoint point, wxSize size ) : wxGauge( parent, id, 200, point, size, wxGA_HORIZONTAL | wxGA_SMOOTH ){ p_intf = _p_intf; UpdateVolume();}void wxVolCtrl::OnChange( wxMouseEvent& event ){ if( !event.LeftDown() && !event.LeftIsDown() ) return; int i_volume = event.GetX() * 200 / GetClientSize().GetWidth(); aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 ); UpdateVolume();}void wxVolCtrl::UpdateVolume(){ audio_volume_t i_volume; aout_VolumeGet( p_intf, &i_volume ); int i_gauge_volume = i_volume * 200 * 2 / AOUT_VOLUME_MAX; if( i_gauge_volume == GetValue() ) return; SetValue( i_gauge_volume ); SetToolTip( wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"), i_gauge_volume / 2 ) );}#if defined(__WXGTK__)#define VLCVOL_HEIGHT p_parent->GetSize().GetHeight()#else#define VLCVOL_HEIGHT TOOLBAR_BMP_HEIGHT#endifVLCVolCtrl::VLCVolCtrl( intf_thread_t *_p_intf, wxWindow *p_parent ) :wxControl( p_parent, -1, wxDefaultPosition, wxSize(64, VLCVOL_HEIGHT ), wxBORDER_NONE ), i_y_offset((VLCVOL_HEIGHT - TOOLBAR_BMP_HEIGHT) / 2), b_mute(0), p_intf(_p_intf){ gauge = new wxVolCtrl( p_intf, this, -1, wxPoint( 18, i_y_offset ), wxSize( 44, TOOLBAR_BMP_HEIGHT ) );}void VLCVolCtrl::OnPaint( wxPaintEvent &evt ){ wxPaintDC dc( this ); wxBitmap mPlayBitmap( b_mute ? speaker_mute_xpm : speaker_xpm ); dc.DrawBitmap( mPlayBitmap, 0, i_y_offset, TRUE );}void VLCVolCtrl::OnChange( wxMouseEvent& event ){ if( event.GetX() < TOOLBAR_BMP_WIDTH ) { int i_volume; aout_VolumeMute( p_intf, (audio_volume_t *)&i_volume ); b_mute = !b_mute; Refresh(); }}void VLCVolCtrl::UpdateVolume(){ gauge->UpdateVolume(); int i_volume = gauge->GetValue(); if( !!i_volume == !b_mute ) return; b_mute = !b_mute; Refresh();}/***************************************************************************** * Systray class. *****************************************************************************//* wxCocoa pretends to support this, but at least 2.6.x doesn't */#ifndef __APPLE__#ifdef wxHAS_TASK_BAR_ICONBEGIN_EVENT_TABLE(Systray, wxTaskBarIcon) /* Mouse events */#ifdef WIN32 EVT_TASKBAR_LEFT_DCLICK(Systray::OnLeftClick)#else EVT_TASKBAR_LEFT_DOWN(Systray::OnLeftClick)#endif /* Menu events */ EVT_MENU(Iconize_Event, Systray::OnMenuIconize) EVT_MENU(Exit_Event, Systray::OnExit) EVT_MENU(PlayStream_Event, Systray::OnPlayStream) EVT_MENU(NextStream_Event, Systray::OnNextStream) EVT_MENU(PrevStream_Event, Systray::OnPrevStream) EVT_MENU(StopStream_Event, Systray::OnStopStream)END_EVENT_TABLE()Systray::Systray( Interface *_p_main_interface, intf_thread_t *_p_intf ){ p_main_interface = _p_main_interface; p_intf = _p_intf; SetIcon( wxIcon( vlc16x16_xpm ), wxT("VLC media player") ); if( !IsOk() || !IsIconInstalled() ) { msg_Warn(p_intf, "cannot set systray icon, weird things may happen"); }}/* Event handlers */void Systray::OnMenuIconize( wxCommandEvent& event ){ p_main_interface->Show( ! p_main_interface->IsShown() ); if ( p_main_interface->IsShown() ) p_main_interface->Raise();}void Systray::OnLeftClick( wxTaskBarIconEvent& event ){ wxCommandEvent cevent; OnMenuIconize(cevent);}void Systray::OnExit( wxCommandEvent& event ){ p_main_interface->Close(TRUE);}void Systray::OnPrevStream( wxCommandEvent& event ){ p_main_interface->PrevStream();}void Systray::OnNextStream( wxCommandEvent& event ){ p_main_interface->NextStream();}void Systray::OnPlayStream( wxCommandEvent& event ){ p_main_interface->PlayStream();}void Systray::OnStopStream( wxCommandEvent& event ){ p_main_interface->StopStream();}/* Systray popup menu */wxMenu* Systray::CreatePopupMenu(){ int minimal = config_GetInt( p_intf, "wx-minimal" ); wxMenu* systray_menu = new wxMenu; systray_menu->Append( Exit_Event, wxU(_("Quit VLC")) ); systray_menu->AppendSeparator(); systray_menu->Append( PlayStream_Event, wxU(_("Play/Pause")) ); if (!minimal) { systray_menu->Append( PrevStream_Event, wxU(_("Previous")) ); systray_menu->Append( NextStream_Event, wxU(_("Next")) ); systray_menu->Append( StopStream_Event, wxU(_("Stop")) ); } systray_menu->AppendSeparator(); systray_menu->Append( Iconize_Event, wxU(_("Show/Hide Interface")) ); return systray_menu;}void Systray::UpdateTooltip( const wxChar* tooltip ){ SetIcon( wxIcon( vlc16x16_xpm ), tooltip );}#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -