2014-10-31 11:17:05 -07:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-08-18 13:36:00 +08:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 13:56:58 -07:00
|
|
|
#ifndef SHELL_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
|
|
|
|
#define SHELL_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
|
2014-08-18 13:36:00 +08:00
|
|
|
|
2018-09-12 19:25:56 -05:00
|
|
|
#include <memory>
|
|
|
|
|
2018-10-29 19:08:47 +01:00
|
|
|
#include "ui/accessibility/ax_node_data.h"
|
2016-09-29 09:15:12 -07:00
|
|
|
#include "ui/views/animation/ink_drop_highlight.h"
|
2014-08-18 13:36:00 +08:00
|
|
|
#include "ui/views/controls/button/menu_button.h"
|
|
|
|
|
2019-06-19 14:23:04 -07:00
|
|
|
namespace electron {
|
2014-08-18 13:36:00 +08:00
|
|
|
|
|
|
|
// Special button that used by menu bar to show submenus.
|
|
|
|
class SubmenuButton : public views::MenuButton {
|
|
|
|
public:
|
2021-01-30 05:43:51 +09:00
|
|
|
SubmenuButton(PressedCallback callback,
|
|
|
|
const base::string16& title,
|
|
|
|
const SkColor& background_color);
|
2018-05-16 12:12:45 -07:00
|
|
|
~SubmenuButton() override;
|
2014-08-18 13:36:00 +08:00
|
|
|
|
2014-08-18 14:12:12 +08:00
|
|
|
void SetAcceleratorVisibility(bool visible);
|
2014-08-18 13:36:00 +08:00
|
|
|
void SetUnderlineColor(SkColor color);
|
|
|
|
|
2014-08-18 14:42:21 +08:00
|
|
|
base::char16 accelerator() const { return accelerator_; }
|
|
|
|
|
2018-10-29 19:08:47 +01:00
|
|
|
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
|
|
|
|
|
2014-08-18 13:36:00 +08:00
|
|
|
// views::MenuButton:
|
2017-09-14 00:04:52 +03:00
|
|
|
void PaintButtonContents(gfx::Canvas* canvas) override;
|
2014-08-18 13:36:00 +08:00
|
|
|
|
2016-09-29 09:15:12 -07:00
|
|
|
// views::InkDropHostView:
|
|
|
|
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
|
2017-01-26 16:10:28 +09:00
|
|
|
std::unique_ptr<views::InkDrop> CreateInkDrop() override;
|
2016-09-29 09:15:12 -07:00
|
|
|
|
2014-08-18 13:36:00 +08:00
|
|
|
private:
|
2014-08-18 16:05:41 +08:00
|
|
|
bool GetUnderlinePosition(const base::string16& text,
|
|
|
|
base::char16* accelerator,
|
2018-04-17 21:44:10 -04:00
|
|
|
int* start,
|
|
|
|
int* end) const;
|
|
|
|
void GetCharacterPosition(const base::string16& text,
|
|
|
|
int index,
|
|
|
|
int* pos) const;
|
2014-08-18 13:36:00 +08:00
|
|
|
|
2018-05-22 00:18:38 +02:00
|
|
|
base::char16 accelerator_ = 0;
|
2014-08-18 14:42:21 +08:00
|
|
|
|
2018-05-22 00:18:38 +02:00
|
|
|
bool show_underline_ = false;
|
2014-08-18 14:12:12 +08:00
|
|
|
|
2018-05-22 00:18:38 +02:00
|
|
|
int underline_start_ = 0;
|
|
|
|
int underline_end_ = 0;
|
|
|
|
int text_width_ = 0;
|
|
|
|
int text_height_ = 0;
|
|
|
|
SkColor underline_color_ = SK_ColorBLACK;
|
2016-09-29 09:15:12 -07:00
|
|
|
SkColor background_color_;
|
2014-08-18 13:36:00 +08:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(SubmenuButton);
|
|
|
|
};
|
|
|
|
|
2019-06-19 14:23:04 -07:00
|
|
|
} // namespace electron
|
2014-08-18 13:36:00 +08:00
|
|
|
|
2019-06-19 13:56:58 -07:00
|
|
|
#endif // SHELL_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
|