📄 menus.cpp
字号:
ppsz_varnames[i] = "visual"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "equalizer"; pi_objects[i++] = p_object->i_object_id; 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( i, ppsz_varnames, pi_objects ); return p_vlc_menu;}wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu ){#define MAX_VIDEO_ITEMS 15 vlc_object_t *p_object; char *ppsz_varnames[MAX_VIDEO_ITEMS]; int pi_objects[MAX_VIDEO_ITEMS]; int i = 0; /* Initializations */ memset( pi_objects, 0, MAX_VIDEO_ITEMS * sizeof(int) ); p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_object != NULL ) { ppsz_varnames[i] = "video-es"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "spu-es"; pi_objects[i++] = p_object->i_object_id; vlc_object_release( p_object ); } p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE ); if( p_object != NULL ) { vlc_object_t *p_dec_obj; ppsz_varnames[i] = "fullscreen"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "zoom"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "deinterlace"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "aspect-ratio"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "crop"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "video-on-top"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "directx-wallpaper"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "video-snapshot"; pi_objects[i++] = p_object->i_object_id; p_dec_obj = (vlc_object_t *)vlc_object_find( p_object, VLC_OBJECT_DECODER, FIND_PARENT ); if( p_dec_obj != NULL ) { ppsz_varnames[i] = "ffmpeg-pp-q"; pi_objects[i++] = p_dec_obj->i_object_id; vlc_object_release( p_dec_obj ); } 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( i, ppsz_varnames, pi_objects ); return p_vlc_menu;}wxMenu *NavigMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu ){#define MAX_NAVIG_ITEMS 15 vlc_object_t *p_object; char *ppsz_varnames[MAX_NAVIG_ITEMS]; int pi_objects[MAX_NAVIG_ITEMS]; int i = 0; /* Initializations */ memset( pi_objects, 0, MAX_NAVIG_ITEMS * sizeof(int) ); p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_object != NULL ) { ppsz_varnames[i] = "bookmark"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "title"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "chapter"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "program"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "navigation"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "dvd_menus"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "prev-title"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "next-title"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "prev-chapter"; pi_objects[i++] = p_object->i_object_id; ppsz_varnames[i] = "next-chapter"; pi_objects[i++] = p_object->i_object_id; 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( i, ppsz_varnames, pi_objects ); return p_vlc_menu;}wxMenu *SettingsMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu ){#define MAX_SETTINGS_ITEMS 10 vlc_object_t *p_object; char *ppsz_varnames[MAX_SETTINGS_ITEMS]; int pi_objects[MAX_SETTINGS_ITEMS]; int i = 0; /* Initializations */ memset( pi_objects, 0, MAX_SETTINGS_ITEMS * sizeof(int) ); p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INTF, FIND_PARENT ); if( p_object != NULL ) {#if (wxCHECK_VERSION(2,5,0)) ppsz_varnames[i] = "intf-switch"; pi_objects[i++] = p_object->i_object_id;#endif ppsz_varnames[i] = "intf-add"; pi_objects[i++] = p_object->i_object_id; 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( i, ppsz_varnames, pi_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( int i_count, char **ppsz_varnames, int *pi_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 < i_count; i++ ) { if( !ppsz_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( !pi_objects[i] ) { Append( MenuDummy_Event, wxU(ppsz_varnames[i]) ); b_section_empty = VLC_FALSE; continue; } p_object = (vlc_object_t *)vlc_object_get( p_intf, pi_objects[i] ); if( p_object == NULL ) continue; b_section_empty = VLC_FALSE; CreateMenuItem( this, ppsz_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( 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 ) { 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, 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 ); if( i_type & VLC_VAR_HASCHOICE ) { menu->Append( MenuDummy_Event, wxU(text.psz_string ? text.psz_string : psz_var),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -