📄 menus.cpp
字号:
p_parent->PopupMenu( &popupmenu, pos.x, pos.y ); p_intf->p_sys->p_popup_menu = NULL; vlc_object_release( p_playlist );}void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent, const wxPoint& pos ){ int minimal = config_GetInt( p_intf, "wx-minimal" ); POPUP_BOILERPLATE; if( p_input ) { vlc_object_yield( p_input ); InputAutoMenuBuilder( VLC_OBJECT(p_input), ai_objects, as_varnames ); /* Video menu */ PUSH_SEPARATOR; as_varnames.Add( "video-es" ); ai_objects.Add( p_input->i_object_id ); as_varnames.Add( "spu-es" ); ai_objects.Add( p_input->i_object_id ); vlc_object_t *p_vout = (vlc_object_t *)vlc_object_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD ); if( p_vout ) { VideoAutoMenuBuilder( p_vout, ai_objects, as_varnames ); vlc_object_release( p_vout ); } /* Audio menu */ PUSH_SEPARATOR as_varnames.Add( "audio-es" ); ai_objects.Add( p_input->i_object_id ); vlc_object_t *p_aout = (vlc_object_t *)vlc_object_find( p_input, VLC_OBJECT_AOUT, FIND_ANYWHERE ); if( p_aout ) { AudioAutoMenuBuilder( p_aout, ai_objects, as_varnames ); vlc_object_release( p_aout ); } } /* Interface menu */ PUSH_SEPARATOR IntfAutoMenuBuilder( p_intf, ai_objects, as_varnames, true ); /* Build menu */ Menu popupmenu( p_intf, PopupMenu_Events ); popupmenu.Populate( as_varnames, ai_objects ); POPUP_STATIC_ENTRIES; if (!minimal) { popupmenu.Append( MenuDummy_Event, wxU(_("Open")), OpenStreamMenu( p_intf ), wxT("") ); } p_intf->p_sys->p_popup_menu = &popupmenu; p_parent->PopupMenu( &popupmenu, pos.x, pos.y ); p_intf->p_sys->p_popup_menu = NULL; vlc_object_release( p_playlist );}/***************************************************************************** * Auto menus *****************************************************************************/wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu ){ vlc_object_t *p_object; ArrayOfInts ai_objects; ArrayOfStrings as_varnames; p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_object != NULL ) { PUSH_VAR( "audio-es" ); vlc_object_release( p_object ); } p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE ); if( p_object ) { AudioAutoMenuBuilder( p_object, ai_objects, as_varnames ); vlc_object_release( p_object ); } /* Build menu */ Menu *p_vlc_menu = (Menu *)p_menu; if( !p_vlc_menu ) p_vlc_menu = new Menu( _p_intf, AudioMenu_Events ); else p_vlc_menu->Clear(); p_vlc_menu->Populate( as_varnames, ai_objects ); return p_vlc_menu;}wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu ){ vlc_object_t *p_object; ArrayOfInts ai_objects; ArrayOfStrings as_varnames; p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_object != NULL ) { PUSH_VAR( "video-es" ); PUSH_VAR( "spu-es" ); vlc_object_release( p_object ); } p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE ); if( p_object != NULL ) { VideoAutoMenuBuilder( p_object, ai_objects, as_varnames ); vlc_object_release( p_object ); } /* Build menu */ Menu *p_vlc_menu = (Menu *)p_menu; if( !p_vlc_menu ) p_vlc_menu = new Menu( _p_intf, VideoMenu_Events ); else p_vlc_menu->Clear(); p_vlc_menu->Populate( as_varnames, ai_objects ); return p_vlc_menu;}wxMenu *NavigMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu ){ vlc_object_t *p_object; ArrayOfInts ai_objects; ArrayOfStrings as_varnames; p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_object != NULL ) { InputAutoMenuBuilder( p_object, ai_objects, as_varnames ); PUSH_VAR( "prev-title"); PUSH_VAR ( "next-title" ); PUSH_VAR( "prev-chapter"); PUSH_VAR( "next-chapter" ); vlc_object_release( p_object ); } /* Build menu */ Menu *p_vlc_menu = (Menu *)p_menu; if( !p_vlc_menu ) p_vlc_menu = new Menu( _p_intf, NavigMenu_Events ); else p_vlc_menu->Clear(); p_vlc_menu->Populate( as_varnames, ai_objects ); return p_vlc_menu;}wxMenu *SettingsMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu ){ vlc_object_t *p_object; ArrayOfInts ai_objects; ArrayOfStrings as_varnames; p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INTF, FIND_PARENT ); if( p_object != NULL ) { PUSH_VAR( "intf-switch" ); PUSH_VAR( "intf-add" ); vlc_object_release( p_object ); } /* Build menu */ Menu *p_vlc_menu = (Menu *)p_menu; if( !p_vlc_menu ) p_vlc_menu = new Menu( _p_intf, SettingsMenu_Events ); else p_vlc_menu->Clear(); p_vlc_menu->Populate( as_varnames, ai_objects ); return p_vlc_menu;}/***************************************************************************** * Constructor. *****************************************************************************/Menu::Menu( intf_thread_t *_p_intf, int _i_start_id ) : wxMenu( ){ /* Initializations */ p_intf = _p_intf; i_start_id = _i_start_id;}Menu::~Menu(){}/***************************************************************************** * Public methods. *****************************************************************************/void Menu::Populate( ArrayOfStrings & ras_varnames, ArrayOfInts & rai_objects ){ vlc_object_t *p_object; vlc_bool_t b_section_empty = VLC_FALSE; int i; i_item_id = i_start_id; for( i = 0; i < (int)rai_objects.GetCount() ; i++ ) { if( !ras_varnames[i] || !*ras_varnames[i] ) { if( b_section_empty ) { Append( MenuDummy_Event + i, wxU(_("Empty")) ); Enable( MenuDummy_Event + i, FALSE ); } AppendSeparator(); b_section_empty = VLC_TRUE; continue; } if( rai_objects[i] == 0 ) { Append( MenuDummy_Event, wxU(ras_varnames[i]) ); b_section_empty = VLC_FALSE; continue; } p_object = (vlc_object_t *)vlc_object_get( p_intf, rai_objects[i] ); if( p_object == NULL ) continue; b_section_empty = VLC_FALSE; CreateMenuItem( this, ras_varnames[i], p_object ); vlc_object_release( p_object ); } /* Special case for empty menus */ if( GetMenuItemCount() == 0 || b_section_empty ) { Append( MenuDummy_Event + i, wxU(_("Empty")) ); Enable( MenuDummy_Event + i, FALSE ); }}/* Work-around helper for buggy wxGTK */static void RecursiveDestroy( wxMenu *menu ){ wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); for( ; node; ) { wxMenuItem *item = node->GetData(); node = node->GetNext(); /* Delete the submenus */ wxMenu *submenu = item->GetSubMenu(); if( submenu ) { RecursiveDestroy( submenu ); } menu->Delete( item ); }}void Menu::Clear( ){ RecursiveDestroy( this );}/***************************************************************************** * Private methods. *****************************************************************************/static bool IsMenuEmpty( const char *psz_var, vlc_object_t *p_object, bool b_root = TRUE ){ vlc_value_t val, val_list; int i_type, i_result, i; /* Check the type of the object variable */ i_type = var_Type( p_object, psz_var ); /* Check if we want to display the variable */ if( !(i_type & VLC_VAR_HASCHOICE) ) return FALSE; var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL ); if( val.i_int == 0 ) return TRUE; if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE ) { /* Very evil hack ! intf-switch can have only one value */ if( !strcmp( psz_var, "intf-switch" ) ) return FALSE; if( val.i_int == 1 && b_root ) return TRUE; else return FALSE; } /* Check children variables in case of VLC_VAR_VARIABLE */ if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, NULL ) < 0 ) { return TRUE; } for( i = 0, i_result = TRUE; i < val_list.p_list->i_count; i++ ) { if( !IsMenuEmpty( val_list.p_list->p_values[i].psz_string, p_object, FALSE ) ) { i_result = FALSE; break; } } /* clean up everything */ var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, NULL ); return i_result;}void Menu::CreateMenuItem( wxMenu *menu, const char *psz_var, vlc_object_t *p_object ){ wxMenuItemExt *menuitem; vlc_value_t val, text; int i_type; /* Check the type of the object variable */ i_type = var_Type( p_object, psz_var ); switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VOID: case VLC_VAR_BOOL: case VLC_VAR_VARIABLE: case VLC_VAR_STRING: case VLC_VAR_INTEGER: case VLC_VAR_FLOAT: break; default: /* Variable doesn't exist or isn't handled */ return; } /* Make sure we want to display the variable */ if( IsMenuEmpty( psz_var, p_object ) ) return; /* Get the descriptive name of the variable */ var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -