Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Unified Diff: ui/views/controls/button/menu_button.h

Issue 1904753002: MenuButton: support Mac look & feel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add basic tests Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/button/menu_button.h
diff --git a/ui/views/controls/button/menu_button.h b/ui/views/controls/button/menu_button.h
index 696a94146f3f9868e01e2eca55a00dfab53f5e8e..882a3406ae42259e5acaa4ee7d581b32007faddb 100644
--- a/ui/views/controls/button/menu_button.h
+++ b/ui/views/controls/button/menu_button.h
@@ -43,22 +43,12 @@ class VIEWS_EXPORT MenuButton : public LabelButton {
static const char kViewClassName[];
- // How much padding to put on the left and right of the menu marker.
- static const int kMenuMarkerPaddingLeft;
- static const int kMenuMarkerPaddingRight;
-
// Create a Button.
MenuButton(const base::string16& text,
MenuButtonListener* menu_button_listener,
bool show_menu_marker);
~MenuButton() override;
- bool show_menu_marker() const { return show_menu_marker_; }
- void set_menu_marker(const gfx::ImageSkia* menu_marker) {
- menu_marker_ = menu_marker;
- }
- const gfx::ImageSkia* menu_marker() const { return menu_marker_; }
-
const gfx::Point& menu_offset() const { return menu_offset_; }
void set_menu_offset(int x, int y) { menu_offset_.SetPoint(x, y); }
@@ -85,11 +75,17 @@ class VIEWS_EXPORT MenuButton : public LabelButton {
bool OnKeyPressed(const ui::KeyEvent& event) override;
bool OnKeyReleased(const ui::KeyEvent& event) override;
void GetAccessibleState(ui::AXViewState* state) override;
+ void OnEnabledChanged() override;
+ void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
protected:
// Paint the menu marker image.
void PaintMenuMarker(gfx::Canvas* canvas);
+ // Subclasses that want to use a border can override this method.
+ virtual bool ShouldUsePlatformStyleBackground() const;
+ virtual bool ShouldUsePlatformStyleBorder() const;
tapted 2016/05/09 08:01:35 So I think there is a nicer solution that doesn't
+
// Overridden from LabelButton:
gfx::Rect GetChildAreaBounds() override;
@@ -116,6 +112,10 @@ class VIEWS_EXPORT MenuButton : public LabelButton {
// use this to make sure a menu is never shown off screen.
int GetMaximumScreenXCoordinate();
+ // Returns the width of the "shoulder" of the MenuButton, which is the area
+ // containing the menu marker, and any padding surrounding it.
+ int GetShoulderWidth() const;
+
// We use a time object in order to keep track of when the menu was closed.
// The time is used for simulating menu behavior for the menu button; that
// is, if the menu is shown and the button is pressed, we need to close the
@@ -128,10 +128,10 @@ class VIEWS_EXPORT MenuButton : public LabelButton {
MenuButtonListener* listener_;
// Whether or not we're showing a drop marker.
- bool show_menu_marker_;
+ const bool show_menu_marker_;
// The down arrow used to differentiate the menu button from normal buttons.
- const gfx::ImageSkia* menu_marker_;
+ gfx::ImageSkia menu_marker_;
// If non-null the destructor sets this to true. This is set while the menu is
// showing and used to detect if the menu was deleted while running.

Powered by Google App Engine
This is Rietveld 408576698