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

Side by Side 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: fix RTL support Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_
6 #define UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ 6 #define UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 static const int kMenuMarkerPaddingLeft; 47 static const int kMenuMarkerPaddingLeft;
48 static const int kMenuMarkerPaddingRight; 48 static const int kMenuMarkerPaddingRight;
49 49
50 // Create a Button. 50 // Create a Button.
51 MenuButton(const base::string16& text, 51 MenuButton(const base::string16& text,
52 MenuButtonListener* menu_button_listener, 52 MenuButtonListener* menu_button_listener,
53 bool show_menu_marker); 53 bool show_menu_marker);
54 ~MenuButton() override; 54 ~MenuButton() override;
55 55
56 bool show_menu_marker() const { return show_menu_marker_; } 56 bool show_menu_marker() const { return show_menu_marker_; }
57 void set_menu_marker(const gfx::ImageSkia* menu_marker) {
58 menu_marker_ = menu_marker;
59 }
60 const gfx::ImageSkia* menu_marker() const { return menu_marker_; }
61 57
62 const gfx::Point& menu_offset() const { return menu_offset_; } 58 const gfx::Point& menu_offset() const { return menu_offset_; }
63 void set_menu_offset(int x, int y) { menu_offset_.SetPoint(x, y); } 59 void set_menu_offset(int x, int y) { menu_offset_.SetPoint(x, y); }
64 60
65 // Activate the button (called when the button is pressed). |event| is the 61 // Activate the button (called when the button is pressed). |event| is the
66 // event triggering the activation, if any. 62 // event triggering the activation, if any.
67 bool Activate(const ui::Event* event); 63 bool Activate(const ui::Event* event);
68 64
69 // Returns true if the event is of the proper type to potentially trigger an 65 // Returns true if the event is of the proper type to potentially trigger an
70 // action. Since MenuButtons have properties other than event type (like 66 // action. Since MenuButtons have properties other than event type (like
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // is, if the menu is shown and the button is pressed, we need to close the 117 // is, if the menu is shown and the button is pressed, we need to close the
122 // menu. There is no clean way to get the second click event because the 118 // menu. There is no clean way to get the second click event because the
123 // menu is displayed using a modal loop and, unlike regular menus in Windows, 119 // menu is displayed using a modal loop and, unlike regular menus in Windows,
124 // the button is not part of the displayed menu. 120 // the button is not part of the displayed menu.
125 base::TimeTicks menu_closed_time_; 121 base::TimeTicks menu_closed_time_;
126 122
127 // Our listener. Not owned. 123 // Our listener. Not owned.
128 MenuButtonListener* listener_; 124 MenuButtonListener* listener_;
129 125
130 // Whether or not we're showing a drop marker. 126 // Whether or not we're showing a drop marker.
131 bool show_menu_marker_; 127 bool show_menu_marker_;
tapted 2016/04/21 06:06:46 can this be declared const? that might make it eas
Elly Fong-Jones 2016/04/21 15:30:26 Done.
132 128
133 // The down arrow used to differentiate the menu button from normal buttons.
134 const gfx::ImageSkia* menu_marker_;
135
136 // If non-null the destructor sets this to true. This is set while the menu is 129 // If non-null the destructor sets this to true. This is set while the menu is
137 // showing and used to detect if the menu was deleted while running. 130 // showing and used to detect if the menu was deleted while running.
138 bool* destroyed_flag_; 131 bool* destroyed_flag_;
139 132
140 // The current number of "pressed" locks this button has. 133 // The current number of "pressed" locks this button has.
141 int pressed_lock_count_; 134 int pressed_lock_count_;
142 135
143 // Used to let Activate() know if IncrementPressedLocked() was called. 136 // Used to let Activate() know if IncrementPressedLocked() was called.
144 bool* increment_pressed_lock_called_; 137 bool* increment_pressed_lock_called_;
145 138
146 // True if the button was in a disabled state when a menu was run, and should 139 // True if the button was in a disabled state when a menu was run, and should
147 // return to it once the press is complete. This can happen if, e.g., we 140 // return to it once the press is complete. This can happen if, e.g., we
148 // programmatically show a menu on a disabled button. 141 // programmatically show a menu on a disabled button.
149 bool should_disable_after_press_; 142 bool should_disable_after_press_;
150 143
151 base::WeakPtrFactory<MenuButton> weak_factory_; 144 base::WeakPtrFactory<MenuButton> weak_factory_;
152 145
153 DISALLOW_COPY_AND_ASSIGN(MenuButton); 146 DISALLOW_COPY_AND_ASSIGN(MenuButton);
154 }; 147 };
155 148
156 } // namespace views 149 } // namespace views
157 150
158 #endif // UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ 151 #endif // UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698