electron/atom/browser/ui/accelerator_util.h

39 lines
1.2 KiB
C
Raw Normal View History

// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// 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_
2014-03-15 08:36:29 +00:00
#include <map>
#include <string>
2014-03-15 08:36:29 +00:00
#include "ui/base/accelerators/accelerator.h"
namespace ui {
2014-03-15 08:36:29 +00:00
class MenuModel;
}
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;
// Parse a string as an accelerator.
bool StringToAccelerator(const std::string& description,
ui::Accelerator* accelerator);
// 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);
} // namespace accelerator_util
2014-03-16 00:58:59 +00:00
#endif // ATOM_BROWSER_UI_ACCELERATOR_UTIL_H_