|
1
|
1 #pragma once
|
|
|
2
|
|
|
3 #include "menu_common.h"
|
|
|
4 #include "metadb.h"
|
|
|
5 #include "contextmenu.h"
|
|
|
6
|
|
|
7 #ifdef FOOBAR2000_HAVE_KEYBOARD_SHORTCUTS
|
|
|
8 class NOVTABLE keyboard_shortcut_manager : public service_base {
|
|
|
9 public:
|
|
|
10 enum shortcut_type
|
|
|
11 {
|
|
|
12 TYPE_MAIN,
|
|
|
13 TYPE_CONTEXT,
|
|
|
14 TYPE_CONTEXT_PLAYLIST,
|
|
|
15 TYPE_CONTEXT_NOW_PLAYING,
|
|
|
16 };
|
|
|
17
|
|
|
18
|
|
|
19 virtual bool process_keydown(shortcut_type type,metadb_handle_list_cref data,unsigned keycode)=0;
|
|
|
20 virtual bool process_keydown_ex(shortcut_type type,metadb_handle_list_cref data,unsigned keycode,const GUID & caller)=0;
|
|
|
21
|
|
|
22 #ifdef _WIN32
|
|
|
23 bool on_keydown(shortcut_type type,WPARAM wp);
|
|
|
24 bool on_keydown_context(const pfc::list_base_const_t<metadb_handle_ptr> & data,WPARAM wp,const GUID & caller);
|
|
|
25
|
|
|
26 bool on_keydown_auto(WPARAM wp);
|
|
|
27 bool on_keydown_auto_playlist(WPARAM wp);
|
|
|
28 bool on_keydown_auto_context(const pfc::list_base_const_t<metadb_handle_ptr> & data,WPARAM wp,const GUID & caller);
|
|
|
29
|
|
|
30 bool on_keydown_restricted_auto(WPARAM wp);
|
|
|
31 bool on_keydown_restricted_auto_playlist(WPARAM wp);
|
|
|
32 bool on_keydown_restricted_auto_context(const pfc::list_base_const_t<metadb_handle_ptr> & data,WPARAM wp,const GUID & caller);
|
|
|
33 #endif
|
|
|
34 virtual bool get_key_description_for_action(const GUID & p_command,const GUID & p_subcommand, pfc::string_base & out, shortcut_type type, bool is_global)=0;
|
|
|
35
|
|
|
36 #ifdef _WIN32
|
|
|
37 static bool is_text_key(t_uint32 vkCode);
|
|
|
38 static bool is_typing_key(t_uint32 vkCode);
|
|
|
39 static bool is_typing_key_combo(t_uint32 vkCode, t_uint32 modifiers);
|
|
|
40 static bool is_typing_modifier(t_uint32 flags);
|
|
|
41 static bool is_typing_message(HWND editbox, const MSG * msg);
|
|
|
42 static bool is_typing_message(const MSG * msg);
|
|
|
43 #endif
|
|
|
44
|
|
|
45 FB2K_MAKE_SERVICE_COREAPI(keyboard_shortcut_manager);
|
|
|
46 };
|
|
|
47
|
|
|
48
|
|
|
49 //! New in 0.9.5.
|
|
|
50 class keyboard_shortcut_manager_v2 : public keyboard_shortcut_manager {
|
|
|
51 public:
|
|
|
52 //! Deprecates old keyboard_shortcut_manager methods. If the action requires selected items, they're obtained from ui_selection_manager API automatically.
|
|
|
53 virtual bool process_keydown_simple(t_uint32 keycode) = 0;
|
|
|
54
|
|
|
55 #ifdef _WIN32
|
|
|
56 //! Helper for use with message filters.
|
|
|
57 bool pretranslate_message(const MSG * msg, HWND thisPopupWnd);
|
|
|
58 #endif
|
|
|
59
|
|
|
60 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(keyboard_shortcut_manager_v2,keyboard_shortcut_manager);
|
|
|
61 };
|
|
|
62 #endif
|
|
|
63
|
|
|
64 class NOVTABLE contextmenu_node {
|
|
|
65 public:
|
|
|
66 virtual contextmenu_item_node::t_type get_type()=0;
|
|
|
67 virtual const char * get_name()=0;
|
|
|
68 virtual t_size get_num_children()=0;//TYPE_POPUP only
|
|
|
69 virtual contextmenu_node * get_child(t_size n)=0;//TYPE_POPUP only
|
|
|
70 virtual unsigned get_display_flags()=0;//TYPE_COMMAND/TYPE_POPUP only, see contextmenu_item::FLAG_*
|
|
|
71 virtual unsigned get_id()=0;//TYPE_COMMAND only, returns zero-based index (helpful for win32 menu command ids)
|
|
|
72 virtual void execute()=0;//TYPE_COMMAND only
|
|
|
73 virtual bool get_description(pfc::string_base & out)=0;//TYPE_COMMAND only
|
|
|
74 virtual bool get_full_name(pfc::string_base & out)=0;//TYPE_COMMAND only
|
|
|
75 virtual void * get_glyph()=0;//RESERVED, do not use
|
|
|
76 protected:
|
|
|
77 contextmenu_node() {}
|
|
|
78 ~contextmenu_node() {}
|
|
|
79 };
|
|
|
80
|
|
|
81
|
|
|
82
|
|
|
83 class NOVTABLE contextmenu_manager : public service_base
|
|
|
84 {
|
|
|
85 public:
|
|
|
86 enum
|
|
|
87 {
|
|
|
88 flag_show_shortcuts = 1 << 0,
|
|
|
89 flag_show_shortcuts_global = 1 << 1,
|
|
|
90 //! \since 1.0
|
|
|
91 //! To control which commands are shown, you should specify either flag_view_reduced or flag_view_full. If neither is specified, the implementation will decide automatically based on shift key being pressed, for backwards compatibility.
|
|
|
92 flag_view_reduced = 1 << 2,
|
|
|
93 //! \since 1.0
|
|
|
94 //! To control which commands are shown, you should specify either flag_view_reduced or flag_view_full. If neither is specified, the implementation will decide automatically based on shift key being pressed, for backwards compatibility.
|
|
|
95 flag_view_full = 1 << 3,
|
|
|
96
|
|
|
97 //for compatibility
|
|
|
98 FLAG_SHOW_SHORTCUTS = 1,
|
|
|
99 FLAG_SHOW_SHORTCUTS_GLOBAL = 2,
|
|
|
100 };
|
|
|
101
|
|
|
102 virtual void init_context(metadb_handle_list_cref data,unsigned flags) = 0;
|
|
|
103 virtual void init_context_playlist(unsigned flags) = 0;
|
|
|
104 virtual contextmenu_node * get_root() = 0;//releasing contextmenu_manager service releaases nodes; root may be null in case of error or something
|
|
|
105 virtual contextmenu_node * find_by_id(unsigned id)=0;
|
|
|
106 #ifdef _WIN32
|
|
|
107 virtual void set_shortcut_preference(const keyboard_shortcut_manager::shortcut_type * data,unsigned count)=0;
|
|
|
108 #endif
|
|
|
109
|
|
|
110 static void g_create(service_ptr_t<contextmenu_manager>& p_out);
|
|
|
111 static service_ptr_t<contextmenu_manager> g_create();
|
|
|
112
|
|
|
113 #ifdef WIN32
|
|
|
114 static void win32_build_menu(HMENU menu,contextmenu_node * parent,int base_id,int max_id);//menu item identifiers are base_id<=N<base_id+max_id (if theres too many items, they will be clipped)
|
|
|
115 static void win32_run_menu_context(HWND parent,metadb_handle_list_cref data, const POINT * pt = 0,unsigned flags = 0);
|
|
|
116 static void win32_run_menu_context_playlist(HWND parent,const POINT * pt = 0,unsigned flags = 0);
|
|
|
117 void win32_run_menu_popup(HWND parent,const POINT * pt = 0);
|
|
|
118 void win32_build_menu(HMENU menu,int base_id,int max_id) {win32_build_menu(menu,get_root(),base_id,max_id);}
|
|
|
119 #endif
|
|
|
120
|
|
|
121 virtual void init_context_ex(metadb_handle_list_cref data,unsigned flags,const GUID & caller)=0;
|
|
|
122 virtual bool init_context_now_playing(unsigned flags)=0;//returns false if not playing
|
|
|
123
|
|
|
124 bool execute_by_id(unsigned id) noexcept;
|
|
|
125
|
|
|
126 bool get_description_by_id(unsigned id,pfc::string_base & out);
|
|
|
127
|
|
|
128 //! Safely prevent destruction from worker threads (some components attempt that).
|
|
|
129 static bool serviceRequiresMainThreadDestructor() { return true; }
|
|
|
130
|
|
|
131 FB2K_MAKE_SERVICE_COREAPI(contextmenu_manager);
|
|
|
132 };
|
|
|
133
|
|
|
134 //! \since 1.0
|
|
|
135 class NOVTABLE contextmenu_group_manager : public service_base {
|
|
|
136 FB2K_MAKE_SERVICE_COREAPI(contextmenu_group_manager)
|
|
|
137 public:
|
|
|
138 virtual GUID path_to_group(const char * path) = 0;
|
|
|
139 virtual void group_to_path(const GUID & group, pfc::string_base & path) = 0;
|
|
|
140 };
|
|
|
141
|
|
|
142
|
|
|
143 //! \since 2.0
|
|
|
144 class contextmenu_manager_v2 : public contextmenu_manager {
|
|
|
145 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(contextmenu_manager_v2, contextmenu_manager)
|
|
|
146 public:
|
|
|
147 virtual menu_tree_item::ptr build_menu() = 0;
|
|
|
148 };
|