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

Side by Side Diff: ui/views/controls/button/menu_button.cc

Issue 674163003: MenuButtons enter Hover state upon Tap Down (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | ui/views/controls/button/menu_button_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ui/views/controls/button/menu_button.h" 5 #include "ui/views/controls/button/menu_button.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/accessibility/ax_view_state.h" 8 #include "ui/accessibility/ax_view_state.h"
9 #include "ui/base/dragdrop/drag_drop_types.h" 9 #include "ui/base/dragdrop/drag_drop_types.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/base/ui_base_switches_util.h"
12 #include "ui/events/event.h" 13 #include "ui/events/event.h"
13 #include "ui/events/event_constants.h" 14 #include "ui/events/event_constants.h"
14 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
15 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
16 #include "ui/gfx/screen.h" 17 #include "ui/gfx/screen.h"
17 #include "ui/gfx/text_constants.h" 18 #include "ui/gfx/text_constants.h"
18 #include "ui/resources/grit/ui_resources.h" 19 #include "ui/resources/grit/ui_resources.h"
19 #include "ui/strings/grit/ui_strings.h" 20 #include "ui/strings/grit/ui_strings.h"
20 #include "ui/views/controls/button/button.h" 21 #include "ui/views/controls/button/button.h"
21 #include "ui/views/controls/button/menu_button_listener.h" 22 #include "ui/views/controls/button/menu_button_listener.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if (pressed_lock_count_ == 0) // Ignore mouse movement if state is locked. 199 if (pressed_lock_count_ == 0) // Ignore mouse movement if state is locked.
199 LabelButton::OnMouseExited(event); 200 LabelButton::OnMouseExited(event);
200 } 201 }
201 202
202 void MenuButton::OnMouseMoved(const ui::MouseEvent& event) { 203 void MenuButton::OnMouseMoved(const ui::MouseEvent& event) {
203 if (pressed_lock_count_ == 0) // Ignore mouse movement if state is locked. 204 if (pressed_lock_count_ == 0) // Ignore mouse movement if state is locked.
204 LabelButton::OnMouseMoved(event); 205 LabelButton::OnMouseMoved(event);
205 } 206 }
206 207
207 void MenuButton::OnGestureEvent(ui::GestureEvent* event) { 208 void MenuButton::OnGestureEvent(ui::GestureEvent* event) {
208 if (state() != STATE_DISABLED && ShouldEnterPushedState(*event) && 209 if (state() != STATE_DISABLED) {
209 !Activate()) { 210 if (ShouldEnterPushedState(*event) && !Activate()) {
210 // When |Activate()| returns |false|, it means that a menu is shown and 211 // When |Activate()| returns |false|, it means that a menu is shown and
211 // has handled the gesture event. So, there is no need to further process 212 // has handled the gesture event. So, there is no need to further process
212 // the gesture event here. 213 // the gesture event here.
213 return; 214 return;
215 }
216 if (switches::IsTouchFeedbackEnabled()) {
217 if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
218 event->SetHandled();
219 SetState(Button::STATE_HOVERED);
220 } else if (state() == Button::STATE_HOVERED &&
221 (event->type() == ui::ET_GESTURE_TAP_CANCEL ||
222 event->type() == ui::ET_GESTURE_END)) {
223 SetState(Button::STATE_NORMAL);
224 }
225 }
214 } 226 }
215 LabelButton::OnGestureEvent(event); 227 LabelButton::OnGestureEvent(event);
216 } 228 }
217 229
218 bool MenuButton::OnKeyPressed(const ui::KeyEvent& event) { 230 bool MenuButton::OnKeyPressed(const ui::KeyEvent& event) {
219 switch (event.key_code()) { 231 switch (event.key_code()) {
220 case ui::VKEY_SPACE: 232 case ui::VKEY_SPACE:
221 // Alt-space on windows should show the window menu. 233 // Alt-space on windows should show the window menu.
222 if (event.IsAltDown()) 234 if (event.IsAltDown())
223 break; 235 break;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 if (!GetWidget()) { 330 if (!GetWidget()) {
319 NOTREACHED(); 331 NOTREACHED();
320 return 0; 332 return 0;
321 } 333 }
322 334
323 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); 335 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
324 return monitor_bounds.right() - 1; 336 return monitor_bounds.right() - 1;
325 } 337 }
326 338
327 } // namespace views 339 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/button/menu_button_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698