foobar2000 SDK  2015-08-03
menu_helpers.h
Go to the documentation of this file.
1 namespace menu_helpers {
2 #ifdef _WIN32
3  void win32_auto_mnemonics(HMENU menu);
4 #endif
5 
6  bool run_command_context(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t<metadb_handle_ptr> & data);
7  bool run_command_context_ex(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t<metadb_handle_ptr> & data,const GUID & caller);
8  bool run_command_context_playlist(const GUID & p_command,const GUID & p_subcommand);
9  bool run_command_context_now_playing(const GUID & p_command,const GUID & p_subcommand);
10 
11  bool test_command_context(const GUID & p_guid);
12 
13  bool is_command_checked_context(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t<metadb_handle_ptr> & data);
14  bool is_command_checked_context_playlist(const GUID & p_command,const GUID & p_subcommand);
15 
16  bool find_command_by_name(const char * p_name,service_ptr_t<contextmenu_item> & p_item,unsigned & p_index);
17  bool find_command_by_name(const char * p_name,GUID & p_command);
18 
19  bool context_get_description(const GUID& p_guid,pfc::string_base & out);
20 
21  bool guid_from_name(const char * p_name,unsigned p_name_len,GUID & p_out);
22  bool name_from_guid(const GUID & p_guid,pfc::string_base & p_out);
23 
25  {
26  public:
29  const char * search(const GUID & p_guid);
30  private:
31  struct entry {
32  char* m_name;
34  };
36  bool m_inited;
37 
38  static int entry_compare_search(const entry & entry1,const GUID & entry2);
39  static int entry_compare(const entry & entry1,const entry & entry2);
40  };
41 
43  {
44  public:
47  bool search(const char * p_name,unsigned p_name_len,GUID & p_out);
48  private:
49  struct entry {
50  char* m_name;
52  };
54  bool m_inited;
55  struct search_entry {
56  const char * m_name; unsigned m_name_len;
57  };
58 
59  static int entry_compare_search(const entry & entry1,const search_entry & entry2);
60  static int entry_compare(const entry & entry1,const entry & entry2);
61  };
62 
63 };
64 
65 
66 
68 {
69 public:
70  static const GUID
71  guid_context_file_properties, guid_context_file_open_directory, guid_context_copy_names,
72  guid_context_send_to_playlist, guid_context_reload_info, guid_context_reload_info_if_changed,
73  guid_context_rewrite_info, guid_context_remove_tags,
74  guid_context_convert_run, guid_context_convert_run_singlefile,guid_context_convert_run_withcue,
75  guid_context_write_cd,
76  guid_context_rg_scan_track, guid_context_rg_scan_album, guid_context_rg_scan_album_multi,
77  guid_context_rg_remove, guid_context_save_playlist, guid_context_masstag_edit,
78  guid_context_masstag_rename,
79  guid_main_always_on_top, guid_main_preferences, guid_main_about,
80  guid_main_exit, guid_main_restart, guid_main_activate,
81  guid_main_hide, guid_main_activate_or_hide, guid_main_titleformat_help,
82  guid_main_next, guid_main_previous,
83  guid_main_next_or_random, guid_main_random, guid_main_pause,
84  guid_main_play, guid_main_play_or_pause, guid_main_rg_set_album,
85  guid_main_rg_set_track, guid_main_rg_disable, guid_main_rg_byorder,
86  guid_main_stop,
87  guid_main_stop_after_current, guid_main_volume_down, guid_main_volume_up,
88  guid_main_volume_mute, guid_main_add_directory, guid_main_add_files,
89  guid_main_add_location, guid_main_add_playlist, guid_main_clear_playlist,
90  guid_main_create_playlist, guid_main_highlight_playing, guid_main_load_playlist,
91  guid_main_next_playlist, guid_main_previous_playlist, guid_main_open,
92  guid_main_remove_playlist, guid_main_remove_dead_entries, guid_main_remove_duplicates,
93  guid_main_rename_playlist, guid_main_save_all_playlists, guid_main_save_playlist,
94  guid_main_playlist_search, guid_main_playlist_sel_crop, guid_main_playlist_sel_remove,
95  guid_main_playlist_sel_invert, guid_main_playlist_undo, guid_main_show_console,
96  guid_main_play_cd, guid_main_restart_resetconfig, guid_main_record,
97  guid_main_playlist_moveback, guid_main_playlist_moveforward, guid_main_playlist_redo,
98  guid_main_playback_follows_cursor, guid_main_cursor_follows_playback, guid_main_saveconfig,
99  guid_main_playlist_select_all, guid_main_show_now_playing,
100 
101  guid_seek_ahead_1s, guid_seek_ahead_5s, guid_seek_ahead_10s, guid_seek_ahead_30s,
102  guid_seek_ahead_1min, guid_seek_ahead_2min, guid_seek_ahead_5min, guid_seek_ahead_10min,
103 
104  guid_seek_back_1s, guid_seek_back_5s, guid_seek_back_10s, guid_seek_back_30s,
105  guid_seek_back_1min, guid_seek_back_2min, guid_seek_back_5min, guid_seek_back_10min
106  ;
107 
108  static bool run_main(const GUID & guid);
109  static inline bool run_context(const GUID & guid,const pfc::list_base_const_t<metadb_handle_ptr> &data) {return menu_helpers::run_command_context(guid,pfc::guid_null,data);}
110  static inline bool run_context(const GUID & guid,const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller) {return menu_helpers::run_command_context_ex(guid,pfc::guid_null,data,caller);}
111 
112  static inline bool context_file_properties(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_file_properties,data,caller);}
113  static inline bool context_file_open_directory(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_file_open_directory,data,caller);}
114  static inline bool context_copy_names(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_copy_names,data,caller);}
115  static inline bool context_send_to_playlist(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_send_to_playlist,data,caller);}
116  static inline bool context_reload_info(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_reload_info,data,caller);}
117  static inline bool context_reload_info_if_changed(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_reload_info_if_changed,data,caller);}
118  static inline bool context_rewrite_info(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rewrite_info,data,caller);}
119  static inline bool context_remove_tags(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_remove_tags,data,caller);}
120  static inline bool context_convert_run(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_convert_run,data,caller);}
121  static inline bool context_convert_run_singlefile(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_convert_run_singlefile,data,caller);}
122  static inline bool context_write_cd(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_write_cd,data,caller);}
123  static inline bool context_rg_scan_track(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_scan_track,data,caller);}
124  static inline bool context_rg_scan_album(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_scan_album,data,caller);}
125  static inline bool context_rg_scan_album_multi(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_scan_album_multi,data,caller);}
126  static inline bool context_rg_remove(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_remove,data,caller);}
127  static inline bool context_save_playlist(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_save_playlist,data,caller);}
128  static inline bool context_masstag_edit(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_masstag_edit,data,caller);}
129  static inline bool context_masstag_rename(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_masstag_rename,data,caller);}
130  static inline bool main_always_on_top() {return run_main(guid_main_always_on_top);}
131  static inline bool main_preferences() {return run_main(guid_main_preferences);}
132  static inline bool main_about() {return run_main(guid_main_about);}
133  static inline bool main_exit() {return run_main(guid_main_exit);}
134  static inline bool main_restart() {return run_main(guid_main_restart);}
135  static inline bool main_activate() {return run_main(guid_main_activate);}
136  static inline bool main_hide() {return run_main(guid_main_hide);}
137  static inline bool main_activate_or_hide() {return run_main(guid_main_activate_or_hide);}
138  static inline bool main_titleformat_help() {return run_main(guid_main_titleformat_help);}
139  static inline bool main_playback_follows_cursor() {return run_main(guid_main_playback_follows_cursor);}
140  static inline bool main_next() {return run_main(guid_main_next);}
141  static inline bool main_previous() {return run_main(guid_main_previous);}
142  static inline bool main_next_or_random() {return run_main(guid_main_next_or_random);}
143  static inline bool main_random() {return run_main(guid_main_random);}
144  static inline bool main_pause() {return run_main(guid_main_pause);}
145  static inline bool main_play() {return run_main(guid_main_play);}
146  static inline bool main_play_or_pause() {return run_main(guid_main_play_or_pause);}
147  static inline bool main_rg_set_album() {return run_main(guid_main_rg_set_album);}
148  static inline bool main_rg_set_track() {return run_main(guid_main_rg_set_track);}
149  static inline bool main_rg_disable() {return run_main(guid_main_rg_disable);}
150  static inline bool main_stop() {return run_main(guid_main_stop);}
151  static inline bool main_stop_after_current() {return run_main(guid_main_stop_after_current);}
152  static inline bool main_volume_down() {return run_main(guid_main_volume_down);}
153  static inline bool main_volume_up() {return run_main(guid_main_volume_up);}
154  static inline bool main_volume_mute() {return run_main(guid_main_volume_mute);}
155  static inline bool main_add_directory() {return run_main(guid_main_add_directory);}
156  static inline bool main_add_files() {return run_main(guid_main_add_files);}
157  static inline bool main_add_location() {return run_main(guid_main_add_location);}
158  static inline bool main_add_playlist() {return run_main(guid_main_add_playlist);}
159  static inline bool main_clear_playlist() {return run_main(guid_main_clear_playlist);}
160  static inline bool main_create_playlist() {return run_main(guid_main_create_playlist);}
161  static inline bool main_highlight_playing() {return run_main(guid_main_highlight_playing);}
162  static inline bool main_load_playlist() {return run_main(guid_main_load_playlist);}
163  static inline bool main_next_playlist() {return run_main(guid_main_next_playlist);}
164  static inline bool main_previous_playlist() {return run_main(guid_main_previous_playlist);}
165  static inline bool main_open() {return run_main(guid_main_open);}
166  static inline bool main_remove_playlist() {return run_main(guid_main_remove_playlist);}
167  static inline bool main_remove_dead_entries() {return run_main(guid_main_remove_dead_entries);}
168  static inline bool main_remove_duplicates() {return run_main(guid_main_remove_duplicates);}
169  static inline bool main_rename_playlist() {return run_main(guid_main_rename_playlist);}
170  static inline bool main_save_all_playlists() {return run_main(guid_main_save_all_playlists);}
171  static inline bool main_save_playlist() {return run_main(guid_main_save_playlist);}
172  static inline bool main_playlist_search() {return run_main(guid_main_playlist_search);}
173  static inline bool main_playlist_sel_crop() {return run_main(guid_main_playlist_sel_crop);}
174  static inline bool main_playlist_sel_remove() {return run_main(guid_main_playlist_sel_remove);}
175  static inline bool main_playlist_sel_invert() {return run_main(guid_main_playlist_sel_invert);}
176  static inline bool main_playlist_undo() {return run_main(guid_main_playlist_undo);}
177  static inline bool main_show_console() {return run_main(guid_main_show_console);}
178  static inline bool main_play_cd() {return run_main(guid_main_play_cd);}
179  static inline bool main_restart_resetconfig() {return run_main(guid_main_restart_resetconfig);}
180  static inline bool main_playlist_moveback() {return run_main(guid_main_playlist_moveback);}
181  static inline bool main_playlist_moveforward() {return run_main(guid_main_playlist_moveforward);}
182  static inline bool main_saveconfig() {return run_main(guid_main_saveconfig);}
183 };
static bool main_hide()
Definition: menu_helpers.h:136
static bool main_highlight_playing()
Definition: menu_helpers.h:161
Definition: menu_helpers.h:55
bool context_get_description(const GUID &p_guid, pfc::string_base &out)
Definition: menu_helpers.cpp:4
bool name_from_guid(const GUID &p_guid, pfc::string_base &p_out)
static bool context_masstag_rename(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:129
static bool main_save_playlist()
Definition: menu_helpers.h:171
bool run_command_context_playlist(const GUID &p_command, const GUID &p_subcommand)
static bool context_reload_info_if_changed(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:117
static bool context_copy_names(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:114
static bool main_playlist_sel_invert()
Definition: menu_helpers.h:175
Definition: pfc.h:71
static bool context_reload_info(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:116
static bool main_next_or_random()
Definition: menu_helpers.h:142
static bool main_volume_down()
Definition: menu_helpers.h:152
static bool main_rename_playlist()
Definition: menu_helpers.h:169
static bool main_open()
Definition: menu_helpers.h:165
static bool main_play_cd()
Definition: menu_helpers.h:178
static bool context_convert_run_singlefile(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:121
void win32_auto_mnemonics(HMENU menu)
static bool main_remove_playlist()
Definition: menu_helpers.h:166
static bool context_rg_remove(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:126
bool run_command_context_now_playing(const GUID &p_command, const GUID &p_subcommand)
static bool main_create_playlist()
Definition: menu_helpers.h:160
static bool main_saveconfig()
Definition: menu_helpers.h:182
bool run_command_context(const GUID &p_command, const GUID &p_subcommand, const pfc::list_base_const_t< metadb_handle_ptr > &data)
static bool main_activate_or_hide()
Definition: menu_helpers.h:137
static bool main_exit()
Definition: menu_helpers.h:133
static bool main_pause()
Definition: menu_helpers.h:144
static int entry_compare(const entry &entry1, const entry &entry2)
static bool main_stop_after_current()
Definition: menu_helpers.h:151
static bool main_playback_follows_cursor()
Definition: menu_helpers.h:139
static bool main_restart_resetconfig()
Definition: menu_helpers.h:179
static bool main_add_playlist()
Definition: menu_helpers.h:158
static bool main_about()
Definition: menu_helpers.h:132
static bool run_context(const GUID &guid, const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller)
Definition: menu_helpers.h:110
static bool main_show_console()
Definition: menu_helpers.h:177
bool find_command_by_name(const char *p_name, service_ptr_t< contextmenu_item > &p_item, unsigned &p_index)
static bool main_add_files()
Definition: menu_helpers.h:156
static bool main_remove_dead_entries()
Definition: menu_helpers.h:167
static bool main_rg_set_album()
Definition: menu_helpers.h:147
static bool context_send_to_playlist(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:115
static bool main_add_directory()
Definition: menu_helpers.h:155
const char * search(const GUID &p_guid)
static bool main_next()
Definition: menu_helpers.h:140
static bool main_clear_playlist()
Definition: menu_helpers.h:159
static bool main_next_playlist()
Definition: menu_helpers.h:163
static bool main_volume_up()
Definition: menu_helpers.h:153
static bool main_restart()
Definition: menu_helpers.h:134
bool guid_from_name(const char *p_name, unsigned p_name_len, GUID &p_out)
static bool main_remove_duplicates()
Definition: menu_helpers.h:168
bool is_command_checked_context_playlist(const GUID &p_command, const GUID &p_subcommand)
static bool context_save_playlist(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:127
static bool main_playlist_undo()
Definition: menu_helpers.h:176
bool is_command_checked_context(const GUID &p_command, const GUID &p_subcommand, const pfc::list_base_const_t< metadb_handle_ptr > &data)
static const GUID caller_undefined
Definition: contextmenu.h:139
static bool main_playlist_moveforward()
Definition: menu_helpers.h:181
static bool context_rg_scan_album(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:124
static bool main_random()
Definition: menu_helpers.h:143
static bool main_rg_set_track()
Definition: menu_helpers.h:148
static bool main_rg_disable()
Definition: menu_helpers.h:149
static bool context_file_open_directory(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:113
static bool main_playlist_sel_remove()
Definition: menu_helpers.h:174
static bool run_context(const GUID &guid, const pfc::list_base_const_t< metadb_handle_ptr > &data)
Definition: menu_helpers.h:109
static bool main_save_all_playlists()
Definition: menu_helpers.h:170
static bool main_previous()
Definition: menu_helpers.h:141
pfc::array_t< entry > m_data
Definition: menu_helpers.h:35
static bool context_convert_run(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:120
static bool main_playlist_search()
Definition: menu_helpers.h:172
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
bool test_command_context(const GUID &p_guid)
static bool context_masstag_edit(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:128
static bool main_play_or_pause()
Definition: menu_helpers.h:146
static bool main_add_location()
Definition: menu_helpers.h:157
static bool context_rewrite_info(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:118
static bool main_titleformat_help()
Definition: menu_helpers.h:138
static bool context_file_properties(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:112
static bool main_volume_mute()
Definition: menu_helpers.h:154
static bool main_play()
Definition: menu_helpers.h:145
static bool main_playlist_moveback()
Definition: menu_helpers.h:180
static bool main_activate()
Definition: menu_helpers.h:135
static bool context_rg_scan_album_multi(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:125
static bool main_playlist_sel_crop()
Definition: menu_helpers.h:173
static bool main_previous_playlist()
Definition: menu_helpers.h:164
static const GUID guid_seek_back_5s
Definition: menu_helpers.h:71
static bool context_write_cd(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:122
const GUID guid_null
Definition: guid.cpp:175
static bool main_stop()
Definition: menu_helpers.h:150
static bool context_rg_scan_track(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:123
static bool main_preferences()
Definition: menu_helpers.h:131
static bool main_load_playlist()
Definition: menu_helpers.h:162
static bool main_always_on_top()
Definition: menu_helpers.h:130
bool run_command_context_ex(const GUID &p_command, const GUID &p_subcommand, const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller)
pfc::array_t< entry > m_data
Definition: menu_helpers.h:53
static bool context_remove_tags(const pfc::list_base_const_t< metadb_handle_ptr > &data, const GUID &caller=contextmenu_item::caller_undefined)
Definition: menu_helpers.h:119
static int entry_compare_search(const entry &entry1, const GUID &entry2)