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.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
|
2014-08-18 05:36:00 +00:00
|
|
|
|
2023-06-14 18:07:18 +00:00
|
|
|
#include <string>
|
2018-09-13 00:25:56 +00:00
|
|
|
|
2018-10-29 18:08:47 +00:00
|
|
|
#include "ui/accessibility/ax_node_data.h"
|
2023-11-28 21:40:12 +00:00
|
|
|
#include "ui/base/metadata/metadata_header_macros.h"
|
|
|
|
#include "ui/base/metadata/metadata_impl_macros.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 {
|
2023-11-28 21:40:12 +00:00
|
|
|
METADATA_HEADER(SubmenuButton, views::MenuButton)
|
|
|
|
|
2014-08-18 05:36:00 +00:00
|
|
|
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
|
|
|
|
2021-11-03 11:41:45 +00:00
|
|
|
// disable copy
|
|
|
|
SubmenuButton(const SubmenuButton&) = delete;
|
|
|
|
SubmenuButton& operator=(const SubmenuButton&) = delete;
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2014-08-18 05:36:00 +00:00
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
|