2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-07-16 14:10:10 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_
|
|
|
|
#define ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_
|
|
|
|
|
2014-07-17 06:23:28 +00:00
|
|
|
#include "ui/views/controls/button/button.h"
|
|
|
|
#include "ui/views/controls/button/menu_button_listener.h"
|
2014-07-16 14:10:10 +00:00
|
|
|
#include "ui/views/view.h"
|
|
|
|
|
2014-07-17 06:23:28 +00:00
|
|
|
namespace ui {
|
|
|
|
class MenuModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace views {
|
|
|
|
class MenuButton;
|
|
|
|
}
|
|
|
|
|
2014-07-16 14:10:10 +00:00
|
|
|
namespace atom {
|
|
|
|
|
2014-07-17 06:23:28 +00:00
|
|
|
class MenuDelegate;
|
|
|
|
|
|
|
|
class MenuBar : public views::View,
|
|
|
|
public views::ButtonListener,
|
|
|
|
public views::MenuButtonListener {
|
2014-07-16 14:10:10 +00:00
|
|
|
public:
|
|
|
|
MenuBar();
|
|
|
|
virtual ~MenuBar();
|
|
|
|
|
2014-07-17 06:23:28 +00:00
|
|
|
// Replaces current menu with a new one.
|
|
|
|
void SetMenu(ui::MenuModel* menu_model);
|
|
|
|
|
2014-08-18 06:12:12 +00:00
|
|
|
// Shows underline under accelerators.
|
|
|
|
void SetAcceleratorVisibility(bool visible);
|
|
|
|
|
2014-08-18 06:52:44 +00:00
|
|
|
// Returns which submenu has accelerator |key|, -1 would be returned when
|
|
|
|
// there is no matching submenu.
|
|
|
|
int GetAcceleratorIndex(base::char16 key);
|
|
|
|
|
2014-08-18 06:42:21 +00:00
|
|
|
// Shows the submenu whose accelerator is |key|.
|
|
|
|
void ActivateAccelerator(base::char16 key);
|
|
|
|
|
2014-07-17 06:23:28 +00:00
|
|
|
// Returns there are how many items in the root menu.
|
|
|
|
int GetItemCount() const;
|
|
|
|
|
|
|
|
// Get the menu under specified screen point.
|
|
|
|
bool GetMenuButtonFromScreenPoint(const gfx::Point& point,
|
|
|
|
ui::MenuModel** menu_model,
|
|
|
|
views::MenuButton** button);
|
|
|
|
|
2014-07-16 14:10:10 +00:00
|
|
|
protected:
|
|
|
|
// views::View:
|
|
|
|
virtual const char* GetClassName() const OVERRIDE;
|
|
|
|
|
2014-07-17 06:23:28 +00:00
|
|
|
// views::ButtonListener:
|
|
|
|
virtual void ButtonPressed(views::Button* sender,
|
|
|
|
const ui::Event& event) OVERRIDE;
|
|
|
|
|
|
|
|
// views::MenuButtonListener:
|
|
|
|
virtual void OnMenuButtonClicked(views::View* source,
|
|
|
|
const gfx::Point& point) OVERRIDE;
|
|
|
|
|
2014-07-16 14:10:10 +00:00
|
|
|
private:
|
2014-08-05 01:41:29 +00:00
|
|
|
SkColor background_color_;
|
|
|
|
|
|
|
|
#if defined(USE_X11)
|
|
|
|
SkColor enabled_color_;
|
|
|
|
SkColor disabled_color_;
|
|
|
|
SkColor highlight_color_;
|
|
|
|
SkColor hover_color_;
|
|
|
|
#endif
|
|
|
|
|
2014-07-17 06:23:28 +00:00
|
|
|
ui::MenuModel* menu_model_;
|
|
|
|
scoped_ptr<MenuDelegate> menu_delegate_;
|
|
|
|
|
2014-07-16 14:10:10 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(MenuBar);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_UI_VIEWS_MENU_BAR_H_
|