2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 09:49:37 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-05-14 13:12:27 +00:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-03-16 00:58:59 +00:00
|
|
|
#ifndef ATOM_BROWSER_UI_ACCELERATOR_UTIL_H_
|
|
|
|
#define ATOM_BROWSER_UI_ACCELERATOR_UTIL_H_
|
2013-05-14 13:12:27 +00:00
|
|
|
|
2014-03-15 08:36:29 +00:00
|
|
|
#include <map>
|
2013-07-01 13:56:46 +00:00
|
|
|
#include <string>
|
2013-05-14 13:12:27 +00:00
|
|
|
|
2014-03-15 08:36:29 +00:00
|
|
|
#include "ui/base/accelerators/accelerator.h"
|
|
|
|
|
2013-05-14 13:12:27 +00:00
|
|
|
namespace ui {
|
2014-03-15 08:36:29 +00:00
|
|
|
class MenuModel;
|
2013-05-14 13:12:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace accelerator_util {
|
|
|
|
|
2014-03-15 08:36:29 +00:00
|
|
|
typedef struct { int position; ui::MenuModel* model; } MenuItem;
|
|
|
|
typedef std::map<ui::Accelerator, MenuItem> AcceleratorTable;
|
|
|
|
|
2013-05-14 13:12:27 +00:00
|
|
|
// Parse a string as an accelerator.
|
|
|
|
bool StringToAccelerator(const std::string& description,
|
|
|
|
ui::Accelerator* accelerator);
|
|
|
|
|
2013-05-16 07:24:18 +00:00
|
|
|
// Set platform accelerator for the Accelerator.
|
|
|
|
void SetPlatformAccelerator(ui::Accelerator* accelerator);
|
|
|
|
|
2014-03-15 08:36:29 +00:00
|
|
|
// 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);
|
|
|
|
|
2013-05-14 13:12:27 +00:00
|
|
|
} // namespace accelerator_util
|
|
|
|
|
2014-03-16 00:58:59 +00:00
|
|
|
#endif // ATOM_BROWSER_UI_ACCELERATOR_UTIL_H_
|