Separate common accelerator utils out.
This commit is contained in:
parent
5e2c975758
commit
e3a3c342de
6 changed files with 62 additions and 92 deletions
|
@ -5,14 +5,20 @@
|
|||
#ifndef BROWSER_UI_ACCELERATOR_UTIL_H_
|
||||
#define BROWSER_UI_ACCELERATOR_UTIL_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "ui/base/accelerators/accelerator.h"
|
||||
|
||||
namespace ui {
|
||||
class Accelerator;
|
||||
class MenuModel;
|
||||
}
|
||||
|
||||
namespace accelerator_util {
|
||||
|
||||
typedef struct { int position; ui::MenuModel* model; } MenuItem;
|
||||
typedef std::map<ui::Accelerator, MenuItem> AcceleratorTable;
|
||||
|
||||
// Parse a string as an accelerator.
|
||||
bool StringToAccelerator(const std::string& description,
|
||||
ui::Accelerator* accelerator);
|
||||
|
@ -20,6 +26,13 @@ bool StringToAccelerator(const std::string& description,
|
|||
// Set platform accelerator for the Accelerator.
|
||||
void SetPlatformAccelerator(ui::Accelerator* accelerator);
|
||||
|
||||
// Generate a table that contains memu model's accelerators and command ids.
|
||||
void GenerateAcceleratorTable(AcceleratorTable* table, ui::MenuModel* model);
|
||||
|
||||
// Trigger command from the accelerators table.
|
||||
bool TriggerAcceleratorTableCommand(AcceleratorTable* table,
|
||||
const ui::Accelerator& accelerator);
|
||||
|
||||
} // namespace accelerator_util
|
||||
|
||||
#endif // BROWSER_UI_ACCELERATOR_UTIL_H_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue