2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-08-18 05:36:00 +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_SUBMENU_BUTTON_H_
|
|
|
|
#define ATOM_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
|
|
|
|
|
2016-09-29 16:15:12 +00:00
|
|
|
#include "ui/views/animation/ink_drop_highlight.h"
|
2014-08-18 05:36:00 +00:00
|
|
|
#include "ui/views/controls/button/menu_button.h"
|
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
// Special button that used by menu bar to show submenus.
|
|
|
|
class SubmenuButton : public views::MenuButton {
|
|
|
|
public:
|
2016-10-03 17:26:18 +00:00
|
|
|
SubmenuButton(const base::string16& title,
|
2016-09-29 16:15:12 +00:00
|
|
|
views::MenuButtonListener* menu_button_listener,
|
|
|
|
const SkColor& background_color);
|
2014-08-18 05:36:00 +00:00
|
|
|
virtual ~SubmenuButton();
|
|
|
|
|
2014-08-18 06:12:12 +00:00
|
|
|
void SetAcceleratorVisibility(bool visible);
|
2014-08-18 05:36:00 +00:00
|
|
|
void SetUnderlineColor(SkColor color);
|
|
|
|
|
2014-09-01 12:10:14 +00:00
|
|
|
void SetEnabledColor(SkColor color);
|
|
|
|
void SetBackgroundColor(SkColor color);
|
|
|
|
|
2014-08-18 06:42:21 +00:00
|
|
|
base::char16 accelerator() const { return accelerator_; }
|
|
|
|
|
2014-08-18 05:36:00 +00:00
|
|
|
// views::MenuButton:
|
2014-11-16 07:54:40 +00:00
|
|
|
void OnPaint(gfx::Canvas* canvas) override;
|
2014-08-18 05:36:00 +00:00
|
|
|
|
2016-09-29 16:15:12 +00:00
|
|
|
// views::InkDropHostView:
|
|
|
|
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
|
|
|
|
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
|
|
|
|
const override;
|
|
|
|
bool ShouldShowInkDropForFocus() const override;
|
|
|
|
|
2014-08-18 05:36:00 +00:00
|
|
|
private:
|
2014-08-18 08:05:41 +00:00
|
|
|
bool GetUnderlinePosition(const base::string16& text,
|
|
|
|
base::char16* accelerator,
|
|
|
|
int* start, int* end);
|
2014-08-18 05:36:00 +00:00
|
|
|
void GetCharacterPosition(
|
|
|
|
const base::string16& text, int index, int* pos);
|
|
|
|
|
2014-08-18 06:42:21 +00:00
|
|
|
base::char16 accelerator_;
|
|
|
|
|
2014-08-18 06:12:12 +00:00
|
|
|
bool show_underline_;
|
|
|
|
|
2014-08-18 05:36:00 +00:00
|
|
|
int underline_start_;
|
|
|
|
int underline_end_;
|
|
|
|
int text_width_;
|
|
|
|
int text_height_;
|
|
|
|
SkColor underline_color_;
|
2016-09-29 16:15:12 +00:00
|
|
|
SkColor background_color_;
|
2014-08-18 05:36:00 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(SubmenuButton);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
|