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
|
|
|
|
2016-07-06 23:04:18 +00:00
|
|
|
#include "atom/browser/ui/atom_menu_model.h"
|
2014-03-15 08:36:29 +00:00
|
|
|
#include "ui/base/accelerators/accelerator.h"
|
|
|
|
|
2013-05-14 13:12:27 +00:00
|
|
|
namespace accelerator_util {
|
|
|
|
|
2018-04-18 01:44:10 +00:00
|
|
|
typedef struct {
|
|
|
|
int position;
|
|
|
|
atom::AtomMenuModel* model;
|
|
|
|
} MenuItem;
|
2014-03-15 08:36:29 +00:00
|
|
|
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);
|
|
|
|
|
2014-03-15 08:36:29 +00:00
|
|
|
// Generate a table that contains memu model's accelerators and command ids.
|
2016-07-06 23:04:18 +00:00
|
|
|
void GenerateAcceleratorTable(AcceleratorTable* table,
|
|
|
|
atom::AtomMenuModel* model);
|
2014-03-15 08:36:29 +00:00
|
|
|
|
|
|
|
// 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_
|