📄 interfacewindow.cpp
字号:
entry_ref ref; for( int i = 0; p_message->FindRef( "refs", i, &ref ) == B_OK; i++ ) { BPath path( &ref ); /* TODO: find out if this is a DVD icon */ if( p_playlist ) { playlist_Add( p_playlist, path.Path(), path.Path(), PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END ); } } _UpdatePlaylist(); break; } case OPEN_PREFERENCES: { if( fPreferencesWindow->Lock() ) { if (fPreferencesWindow->IsHidden()) fPreferencesWindow->Show(); else fPreferencesWindow->Activate(); fPreferencesWindow->Unlock(); } break; } case OPEN_MESSAGES: { if( fMessagesWindow->Lock() ) { if (fMessagesWindow->IsHidden()) fMessagesWindow->Show(); else fMessagesWindow->Activate(); fMessagesWindow->Unlock(); } break; } case MSG_UPDATE: UpdateInterface(); break; default: BWindow::MessageReceived( p_message ); break; }}/***************************************************************************** * InterfaceWindow::QuitRequested *****************************************************************************/bool InterfaceWindow::QuitRequested(){ if( p_playlist ) { playlist_Stop( p_playlist ); } p_mediaControl->SetStatus(-1, INPUT_RATE_DEFAULT); _StoreSettings(); p_intf->b_die = 1; return( true );}/***************************************************************************** * InterfaceWindow::UpdateInterface *****************************************************************************/void InterfaceWindow::UpdateInterface(){ /* Manage the input part */ if( !p_playlist ) { p_playlist = (playlist_t *) vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); } if( !p_input ) { p_input = (input_thread_t *) vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); } else if( p_input->b_dead ) { vlc_object_release( p_input ); p_input = NULL; } /* Get ready to update the interface */ if( LockWithTimeout( INTERFACE_LOCKING_TIMEOUT ) != B_OK ) { return; } if( p_input ) { vlc_value_t val; p_mediaControl->SetEnabled( true ); bool hasTitles = !var_Get( p_input, "title", &val ); bool hasChapters = !var_Get( p_input, "chapter", &val ); p_mediaControl->SetStatus( var_GetInteger( p_input, "state" ), var_GetInteger( p_input, "rate" ) ); var_Get( p_input, "position", &val ); p_mediaControl->SetProgress( val.f_float ); _SetMenusEnabled( true, hasChapters, hasTitles ); _UpdateSpeedMenu( var_GetInteger( p_input, "rate" ) ); // enable/disable skip buttons#if 0 bool canSkipPrev; bool canSkipNext; p_wrapper->GetNavCapabilities( &canSkipPrev, &canSkipNext ); p_mediaControl->SetSkippable( canSkipPrev, canSkipNext );#endif audio_volume_t i_volume; aout_VolumeGet( p_intf, &i_volume ); p_mediaControl->SetAudioEnabled( true ); p_mediaControl->SetMuted( i_volume ); // update playlist as well if( fPlaylistWindow->LockWithTimeout( INTERFACE_LOCKING_TIMEOUT ) == B_OK ) { fPlaylistWindow->UpdatePlaylist(); fPlaylistWindow->Unlock(); } } else { p_mediaControl->SetAudioEnabled( false ); _SetMenusEnabled( false ); if( !playlist_IsEmpty( p_playlist ) ) { p_mediaControl->SetProgress( 0 );#if 0 // enable/disable skip buttons bool canSkipPrev; bool canSkipNext; p_wrapper->GetNavCapabilities( &canSkipPrev, &canSkipNext ); p_mediaControl->SetSkippable( canSkipPrev, canSkipNext );#endif } else { p_mediaControl->SetEnabled( false ); } } Unlock(); fLastUpdateTime = system_time();}/***************************************************************************** * InterfaceWindow::IsStopped *****************************************************************************/boolInterfaceWindow::IsStopped() const{ return (system_time() - fLastUpdateTime > INTERFACE_UPDATE_TIMEOUT);}/***************************************************************************** * InterfaceWindow::_UpdatePlaylist *****************************************************************************/voidInterfaceWindow::_UpdatePlaylist(){ if( fPlaylistWindow->Lock() ) { fPlaylistWindow->UpdatePlaylist( true ); fPlaylistWindow->Unlock(); } p_mediaControl->SetEnabled( p_playlist->i_size );}/***************************************************************************** * InterfaceWindow::_SetMenusEnabled *****************************************************************************/voidInterfaceWindow::_SetMenusEnabled(bool hasFile, bool hasChapters, bool hasTitles){ if (!hasFile) { hasChapters = false; hasTitles = false; } if ( LockWithTimeout( INTERFACE_LOCKING_TIMEOUT ) == B_OK) { if ( fNextChapterMI->IsEnabled() != hasChapters ) fNextChapterMI->SetEnabled( hasChapters ); if ( fPrevChapterMI->IsEnabled() != hasChapters ) fPrevChapterMI->SetEnabled( hasChapters ); if ( fChapterMenu->IsEnabled() != hasChapters ) fChapterMenu->SetEnabled( hasChapters ); if ( fNextTitleMI->IsEnabled() != hasTitles ) fNextTitleMI->SetEnabled( hasTitles ); if ( fPrevTitleMI->IsEnabled() != hasTitles ) fPrevTitleMI->SetEnabled( hasTitles ); if ( fTitleMenu->IsEnabled() != hasTitles ) fTitleMenu->SetEnabled( hasTitles ); if ( fAudioMenu->IsEnabled() != hasFile ) fAudioMenu->SetEnabled( hasFile ); if ( fNavigationMenu->IsEnabled() != hasFile ) fNavigationMenu->SetEnabled( hasFile ); if ( fLanguageMenu->IsEnabled() != hasFile ) fLanguageMenu->SetEnabled( hasFile ); if ( fSubtitlesMenu->IsEnabled() != hasFile ) fSubtitlesMenu->SetEnabled( hasFile ); if ( fSpeedMenu->IsEnabled() != hasFile ) fSpeedMenu->SetEnabled( hasFile ); Unlock(); }}/***************************************************************************** * InterfaceWindow::_UpdateSpeedMenu *****************************************************************************/voidInterfaceWindow::_UpdateSpeedMenu( int rate ){ BMenuItem * toMark = NULL; switch( rate ) { case ( INPUT_RATE_DEFAULT * 8 ): toMark = fHeighthMI; break; case ( INPUT_RATE_DEFAULT * 4 ): toMark = fQuarterMI; break; case ( INPUT_RATE_DEFAULT * 2 ): toMark = fHalfMI; break; case ( INPUT_RATE_DEFAULT ): toMark = fNormalMI; break; case ( INPUT_RATE_DEFAULT / 2 ): toMark = fTwiceMI; break; case ( INPUT_RATE_DEFAULT / 4 ): toMark = fFourMI; break; case ( INPUT_RATE_DEFAULT / 8 ): toMark = fHeightMI; break; } if ( toMark && !toMark->IsMarked() ) { toMark->SetMarked( true ); }}/***************************************************************************** * InterfaceWindow::_ShowFilePanel *****************************************************************************/voidInterfaceWindow::_ShowFilePanel( uint32 command, const char* windowTitle ){ if( !fFilePanel ) { fFilePanel = new BFilePanel( B_OPEN_PANEL, NULL, NULL, B_FILE_NODE | B_DIRECTORY_NODE ); fFilePanel->SetTarget( this ); } fFilePanel->Window()->SetTitle( windowTitle ); BMessage message( command ); fFilePanel->SetMessage( &message ); if ( !fFilePanel->IsShowing() ) { fFilePanel->Refresh(); fFilePanel->Show(); }}// set_window_posvoidset_window_pos( BWindow* window, BRect frame ){ // sanity checks: make sure window is not too big/small // and that it's not off-screen float minWidth, maxWidth, minHeight, maxHeight; window->GetSizeLimits( &minWidth, &maxWidth, &minHeight, &maxHeight ); make_sure_frame_is_within_limits( frame, minWidth, minHeight, maxWidth, maxHeight ); if ( make_sure_frame_is_on_screen( frame ) ) { window->MoveTo( frame.LeftTop() ); window->ResizeTo( frame.Width(), frame.Height() ); }}// set_window_posvoidlaunch_window( BWindow* window, bool showing ){ if ( window->Lock() ) { if ( showing ) { if ( window->IsHidden() ) window->Show(); } else { if ( !window->IsHidden() ) window->Hide(); } window->Unlock(); }}/***************************************************************************** * InterfaceWindow::_RestoreSettings *****************************************************************************/voidInterfaceWindow::_RestoreSettings(){ if ( load_settings( fSettings, "interface_settings", "VideoLAN Client" ) == B_OK ) { BRect frame; if ( fSettings->FindRect( "main frame", &frame ) == B_OK ) set_window_pos( this, frame ); if (fSettings->FindRect( "playlist frame", &frame ) == B_OK ) set_window_pos( fPlaylistWindow, frame ); if (fSettings->FindRect( "messages frame", &frame ) == B_OK ) set_window_pos( fMessagesWindow, frame ); if (fSettings->FindRect( "settings frame", &frame ) == B_OK ) { /* FIXME: Preferences resizing doesn't work correctly yet */ frame.right = frame.left + fPreferencesWindow->Frame().Width(); frame.bottom = frame.top + fPreferencesWindow->Frame().Height(); set_window_pos( fPreferencesWindow, frame ); } bool showing; if ( fSettings->FindBool( "playlist showing", &showing ) == B_OK ) launch_window( fPlaylistWindow, showing ); if ( fSettings->FindBool( "messages showing", &showing ) == B_OK ) launch_window( fMessagesWindow, showing ); if ( fSettings->FindBool( "settings showing", &showing ) == B_OK ) launch_window( fPreferencesWindow, showing ); uint32 displayMode;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -