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

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

Issue 1411833006: Refactoring to make adding ink drop animations easier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor ink drop animations (more comments in ui/views/, test) Created 5 years 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 #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/base/ui_base_switches_util.h"
13 #include "ui/events/event.h" 13 #include "ui/events/event.h"
14 #include "ui/events/event_constants.h" 14 #include "ui/events/event_constants.h"
15 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
17 #include "ui/gfx/screen.h" 17 #include "ui/gfx/screen.h"
18 #include "ui/gfx/text_constants.h" 18 #include "ui/gfx/text_constants.h"
19 #include "ui/resources/grit/ui_resources.h" 19 #include "ui/resources/grit/ui_resources.h"
20 #include "ui/strings/grit/ui_strings.h" 20 #include "ui/strings/grit/ui_strings.h"
21 #include "ui/views/animation/ink_drop_delegate.h"
21 #include "ui/views/controls/button/button.h" 22 #include "ui/views/controls/button/button.h"
22 #include "ui/views/controls/button/menu_button_listener.h" 23 #include "ui/views/controls/button/menu_button_listener.h"
23 #include "ui/views/mouse_constants.h" 24 #include "ui/views/mouse_constants.h"
24 #include "ui/views/resources/grit/views_resources.h" 25 #include "ui/views/resources/grit/views_resources.h"
25 #include "ui/views/widget/root_view.h" 26 #include "ui/views/widget/root_view.h"
26 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
27 28
28 using base::TimeTicks; 29 using base::TimeTicks;
29 using base::TimeDelta; 30 using base::TimeDelta;
30 31
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // to NULL. 120 // to NULL.
120 static_cast<internal::RootView*>(GetWidget()->GetRootView())-> 121 static_cast<internal::RootView*>(GetWidget()->GetRootView())->
121 SetMouseHandler(NULL); 122 SetMouseHandler(NULL);
122 123
123 bool destroyed = false; 124 bool destroyed = false;
124 destroyed_flag_ = &destroyed; 125 destroyed_flag_ = &destroyed;
125 126
126 // We don't set our state here. It's handled in the MenuController code or 127 // We don't set our state here. It's handled in the MenuController code or
127 // by our click listener. 128 // by our click listener.
128 129
130 if (ink_drop_delegate())
131 ink_drop_delegate()->OnAction(InkDropState::QUICK_ACTION);
129 listener_->OnMenuButtonClicked(this, menu_position); 132 listener_->OnMenuButtonClicked(this, menu_position);
130 133
131 if (destroyed) { 134 if (destroyed) {
132 // The menu was deleted while showing. Don't attempt any processing. 135 // The menu was deleted while showing. Don't attempt any processing.
133 return false; 136 return false;
134 } 137 }
135 138
136 destroyed_flag_ = NULL; 139 destroyed_flag_ = NULL;
137 140
138 menu_closed_time_ = TimeTicks::Now(); 141 menu_closed_time_ = TimeTicks::Now();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return Activate(); 185 return Activate();
183 } 186 }
184 return true; 187 return true;
185 } 188 }
186 189
187 void MenuButton::OnMouseReleased(const ui::MouseEvent& event) { 190 void MenuButton::OnMouseReleased(const ui::MouseEvent& event) {
188 if (state() != STATE_DISABLED && ShouldEnterPushedState(event) && 191 if (state() != STATE_DISABLED && ShouldEnterPushedState(event) &&
189 HitTestPoint(event.location()) && !InDrag()) { 192 HitTestPoint(event.location()) && !InDrag()) {
190 Activate(); 193 Activate();
191 } else { 194 } else {
195 if (ink_drop_delegate())
196 ink_drop_delegate()->OnAction(InkDropState::HIDDEN);
192 LabelButton::OnMouseReleased(event); 197 LabelButton::OnMouseReleased(event);
193 } 198 }
194 } 199 }
195 200
196 void MenuButton::OnMouseEntered(const ui::MouseEvent& event) { 201 void MenuButton::OnMouseEntered(const ui::MouseEvent& event) {
197 if (pressed_lock_count_ == 0) // Ignore mouse movement if state is locked. 202 if (pressed_lock_count_ == 0) // Ignore mouse movement if state is locked.
198 LabelButton::OnMouseEntered(event); 203 LabelButton::OnMouseEntered(event);
199 } 204 }
200 205
201 void MenuButton::OnMouseExited(const ui::MouseEvent& event) { 206 void MenuButton::OnMouseExited(const ui::MouseEvent& event) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 if (!GetWidget()) { 360 if (!GetWidget()) {
356 NOTREACHED(); 361 NOTREACHED();
357 return 0; 362 return 0;
358 } 363 }
359 364
360 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); 365 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
361 return monitor_bounds.right() - 1; 366 return monitor_bounds.right() - 1;
362 } 367 }
363 368
364 } // namespace views 369 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698