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.
|
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#ifndef SHELL_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
|
|
|
|
#define SHELL_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
|
2014-08-18 05:36:00 +00:00
|
|
|
|
2018-09-13 00:25:56 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2018-10-29 18:08:47 +00:00
|
|
|
#include "ui/accessibility/ax_node_data.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"
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2014-08-18 05:36:00 +00:00
|
|
|
|
|
|
|
// Special button that used by menu bar to show submenus.
|
|
|
|
class SubmenuButton : public views::MenuButton {
|
|
|
|
public:
|
2021-01-29 20:43:51 +00:00
|
|
|
SubmenuButton(PressedCallback callback,
|
2021-03-16 16:18:45 +00:00
|
|
|
const std::u16string& title,
|
2021-01-29 20:43:51 +00:00
|
|
|
const SkColor& background_color);
|
2018-05-16 19:12:45 +00:00
|
|
|
~SubmenuButton() override;
|
2014-08-18 05:36:00 +00:00
|
|
|
|
2014-08-18 06:12:12 +00:00
|
|
|
void SetAcceleratorVisibility(bool visible);
|
2014-08-18 05:36:00 +00:00
|
|
|
void SetUnderlineColor(SkColor color);
|
|
|
|
|
2021-03-16 01:21:27 +00:00
|
|
|
char16_t accelerator() const { return accelerator_; }
|
2014-08-18 06:42:21 +00:00
|
|
|
|
2018-10-29 18:08:47 +00:00
|
|
|
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
|
|
|
|
|
2014-08-18 05:36:00 +00:00
|
|
|
// views::MenuButton:
|
2017-09-13 21:04:52 +00:00
|
|
|
void PaintButtonContents(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;
|
2017-01-26 07:10:28 +00:00
|
|
|
std::unique_ptr<views::InkDrop> CreateInkDrop() override;
|
2016-09-29 16:15:12 +00:00
|
|
|
|
2014-08-18 05:36:00 +00:00
|
|
|
private:
|
2021-03-16 16:18:45 +00:00
|
|
|
bool GetUnderlinePosition(const std::u16string& text,
|
2021-03-16 01:21:27 +00:00
|
|
|
char16_t* accelerator,
|
2018-04-18 01:44:10 +00:00
|
|
|
int* start,
|
|
|
|
int* end) const;
|
2021-03-16 16:18:45 +00:00
|
|
|
void GetCharacterPosition(const std::u16string& text,
|
2018-04-18 01:44:10 +00:00
|
|
|
int index,
|
|
|
|
int* pos) const;
|
2014-08-18 05:36:00 +00:00
|
|
|
|
2021-03-16 01:21:27 +00:00
|
|
|
char16_t accelerator_ = 0;
|
2014-08-18 06:42:21 +00:00
|
|
|
|
2018-05-21 22:18:38 +00:00
|
|
|
bool show_underline_ = false;
|
2014-08-18 06:12:12 +00:00
|
|
|
|
2018-05-21 22:18:38 +00: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 16:15:12 +00:00
|
|
|
SkColor background_color_;
|
2014-08-18 05:36:00 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(SubmenuButton);
|
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2014-08-18 05:36:00 +00:00
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#endif // SHELL_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
|