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

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

Issue 10534092: Add touch gestures to views menu controls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ReleaseCapture if capture was started. Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/button/menu_button.h ('k') | ui/views/controls/menu/menu_controller.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/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "grit/ui_strings.h" 9 #include "grit/ui_strings.h"
10 #include "ui/base/accessibility/accessible_view_state.h" 10 #include "ui/base/accessibility/accessible_view_state.h"
11 #include "ui/base/dragdrop/drag_drop_types.h" 11 #include "ui/base/dragdrop/drag_drop_types.h"
12 #include "ui/base/events.h"
12 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
13 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.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/views/controls/button/button.h" 18 #include "ui/views/controls/button/button.h"
18 #include "ui/views/controls/button/menu_button_listener.h" 19 #include "ui/views/controls/button/menu_button_listener.h"
19 #include "ui/views/events/event.h" 20 #include "ui/views/events/event.h"
20 #include "ui/views/widget/root_view.h" 21 #include "ui/views/widget/root_view.h"
21 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // we display the menu. If we don't override this method then 213 // we display the menu. If we don't override this method then
213 // BaseButton::OnMouseExited will get the event and will set the button's state 214 // BaseButton::OnMouseExited will get the event and will set the button's state
214 // to BS_NORMAL instead of keeping the state BM_PUSHED. This, in turn, will 215 // to BS_NORMAL instead of keeping the state BM_PUSHED. This, in turn, will
215 // cause the button to appear depressed while the menu is displayed. 216 // cause the button to appear depressed while the menu is displayed.
216 void MenuButton::OnMouseExited(const MouseEvent& event) { 217 void MenuButton::OnMouseExited(const MouseEvent& event) {
217 if ((state_ != BS_DISABLED) && (!menu_visible_) && (!InDrag())) { 218 if ((state_ != BS_DISABLED) && (!menu_visible_) && (!InDrag())) {
218 SetState(BS_NORMAL); 219 SetState(BS_NORMAL);
219 } 220 }
220 } 221 }
221 222
223 ui::GestureStatus MenuButton::OnGestureEvent(const GestureEvent& event) {
224 if (state() != BS_DISABLED && event.type() == ui::ET_GESTURE_TAP) {
225 if (Activate())
226 return ui::GESTURE_STATUS_CONSUMED;
227 }
228 return TextButton::OnGestureEvent(event);
229 }
230
222 bool MenuButton::OnKeyPressed(const KeyEvent& event) { 231 bool MenuButton::OnKeyPressed(const KeyEvent& event) {
223 switch (event.key_code()) { 232 switch (event.key_code()) {
224 case ui::VKEY_SPACE: 233 case ui::VKEY_SPACE:
225 // Alt-space on windows should show the window menu. 234 // Alt-space on windows should show the window menu.
226 if (event.IsAltDown()) 235 if (event.IsAltDown())
227 break; 236 break;
228 case ui::VKEY_RETURN: 237 case ui::VKEY_RETURN:
229 case ui::VKEY_UP: 238 case ui::VKEY_UP:
230 case ui::VKEY_DOWN: { 239 case ui::VKEY_DOWN: {
231 // WARNING: we may have been deleted by the time Activate returns. 240 // WARNING: we may have been deleted by the time Activate returns.
(...skipping 23 matching lines...) Expand all
255 if (!GetWidget()) { 264 if (!GetWidget()) {
256 NOTREACHED(); 265 NOTREACHED();
257 return 0; 266 return 0;
258 } 267 }
259 268
260 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); 269 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
261 return monitor_bounds.right() - 1; 270 return monitor_bounds.right() - 1;
262 } 271 }
263 272
264 } // namespace views 273 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/menu_button.h ('k') | ui/views/controls/menu/menu_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698