?? interface.cpp
字號:
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 ); TogglePlayButton( PLAYING_S ); vlc_object_release( p_playlist ); 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 ); TogglePlayButton( state.i_int ); vlc_object_release( p_input ); vlc_object_release( p_playlist ); } else { /* If the playlist is empty, open a file requester instead */ vlc_object_release( p_playlist ); OnShowDialog( dummy ); }}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 ); TogglePlayButton( PAUSE_S ); vlc_object_release( p_playlist );}void Interface::OnSliderUpdate( wxScrollEvent& event ){ vlc_mutex_lock( &p_intf->change_lock );#ifdef WIN32 if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL ) {#endif if( p_intf->p_sys->i_slider_pos != event.GetPosition() && p_intf->p_sys->p_input ) { vlc_value_t pos; pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS; var_Set( p_intf->p_sys->p_input, "position", pos ); }#ifdef WIN32 p_intf->p_sys->b_slider_free = VLC_TRUE; } else { p_intf->p_sys->b_slider_free = VLC_FALSE; if( p_intf->p_sys->p_input ) { /* Update stream date */ char psz_time[ MSTRTIME_MAX_SIZE ], psz_total[ MSTRTIME_MAX_SIZE ]; mtime_t i_seconds; i_seconds = var_GetTime( p_intf->p_sys->p_input, "length" ) / I64C(1000000 ); secstotimestr( psz_total, i_seconds ); i_seconds = var_GetTime( p_intf->p_sys->p_input, "time" ) / I64C(1000000 ); secstotimestr( psz_time, i_seconds ); statusbar->SetStatusText( wxU(psz_time) + wxString(wxT(" / ") ) + wxU(psz_total), 0 ); } }#endif#undef WIN32 vlc_mutex_unlock( &p_intf->change_lock );}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; } /* FIXME --fenrir */#if 0 if( p_playlist->p_input != NULL ) { vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock ); if( p_playlist->p_input->stream.p_selected_area->i_id > 1 ) { vlc_value_t val; val.b_bool = VLC_TRUE; vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock ); var_Set( p_playlist->p_input, "prev-title", val ); } else vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock ); } vlc_mutex_unlock( &p_playlist->object_lock );#endif 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; } /* FIXME --fenrir */#if 0 var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL ); vlc_mutex_lock( &p_playlist->object_lock ); if( p_playlist->p_input != NULL ) { vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock ); if( p_playlist->p_input->stream.i_area_nb > 1 && p_playlist->p_input->stream.p_selected_area->i_id < p_playlist->p_input->stream.i_area_nb - 1 ) { vlc_value_t val; val.b_bool = VLC_TRUE; vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock ); var_Set( p_playlist->p_input, "next-title", val ); } else vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock ); } vlc_mutex_unlock( &p_playlist->object_lock );#endif 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 ){ if( i_playing_status == i_old_playing_status ) return; 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(); GetToolBar()->ToggleTool( PlayStream_Event, true ); GetToolBar()->ToggleTool( PlayStream_Event, false ); i_old_playing_status = i_playing_status;}void Interface::OnDiscMenu( 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.i_int = 2; var_Set( p_input, "title 0", val); vlc_object_release( p_input ); }}void Interface::OnDiscPrev( wxCommandEvent& WXUNUSED(event) ){ input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input ) { int i_type = var_Type( p_input, "prev-chapter" ); vlc_value_t val; val.b_bool = VLC_TRUE; var_Set( p_input, ( i_type & VLC_VAR_TYPE ) != 0 ? "prev-chapter" : "prev-title", val ); vlc_object_release( p_input ); }}void Interface::OnDiscNext( wxCommandEvent& WXUNUSED(event) ){ input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input ) { int i_type = var_Type( p_input, "next-chapter" ); vlc_value_t val; val.b_bool = VLC_TRUE; var_Set( p_input, ( i_type & VLC_VAR_TYPE ) != 0 ? "next-chapter" : "next-title", val ); vlc_object_release( p_input ); }}#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; } for( size_t i = 0; i < filenames.GetCount(); i++ ) playlist_Add( p_playlist, (const char *)filenames[i].mb_str(), (const char *)filenames[i].mb_str(), PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO), PLAYLIST_END ); 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. *****************************************************************************/#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;}/* 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, "wxwin-minimal" ); wxMenu* systray_menu = new wxMenu; systray_menu->Append( Exit_Event, wxU(_("Quit VLC")) ); systray_menu->AppendSeparator(); systray_menu->Append( PlayStream_Event, wxU(_("Play/Pause")) ); if (!minimal) { systray_menu->Append( PrevStream_Event, wxU(_("Previous")) ); systray_menu->Append( NextStream_Event, wxU(_("Next")) ); systray_menu->Append( StopStream_Event, wxU(_("Stop")) ); } systray_menu->AppendSeparator(); systray_menu->Append( Iconize_Event, wxU(_("Show/Hide interface")) ); return systray_menu;}void Systray::UpdateTooltip( const wxChar* tooltip ){ SetIcon( wxIcon( vlc16x16_xpm ), tooltip );}#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -