submenu_button.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright (c) 2014 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
  5. #define ATOM_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_
  6. #include "ui/views/animation/ink_drop_highlight.h"
  7. #include "ui/views/controls/button/menu_button.h"
  8. namespace atom {
  9. // Special button that used by menu bar to show submenus.
  10. class SubmenuButton : public views::MenuButton {
  11. public:
  12. SubmenuButton(const base::string16& title,
  13. views::MenuButtonListener* menu_button_listener,
  14. const SkColor& background_color);
  15. ~SubmenuButton() override;
  16. void SetAcceleratorVisibility(bool visible);
  17. void SetUnderlineColor(SkColor color);
  18. base::char16 accelerator() const { return accelerator_; }
  19. // views::MenuButton:
  20. void PaintButtonContents(gfx::Canvas* canvas) override;
  21. // views::InkDropHostView:
  22. std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
  23. std::unique_ptr<views::InkDrop> CreateInkDrop() override;
  24. private:
  25. bool GetUnderlinePosition(const base::string16& text,
  26. base::char16* accelerator,
  27. int* start,
  28. int* end) const;
  29. void GetCharacterPosition(const base::string16& text,
  30. int index,
  31. int* pos) const;
  32. base::char16 accelerator_ = 0;
  33. bool show_underline_ = false;
  34. int underline_start_ = 0;
  35. int underline_end_ = 0;
  36. int text_width_ = 0;
  37. int text_height_ = 0;
  38. SkColor underline_color_ = SK_ColorBLACK;
  39. SkColor background_color_;
  40. DISALLOW_COPY_AND_ASSIGN(SubmenuButton);
  41. };
  42. } // namespace atom
  43. #endif // ATOM_BROWSER_UI_VIEWS_SUBMENU_BUTTON_H_