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

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

Issue 1409183003: Adds ripple animation to extension buttons on a toolbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds ripple animation to extension buttons on a toolbar (fix for bug 546683) Created 5 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
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"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 menu_closed_time_ = TimeTicks::Now(); 138 menu_closed_time_ = TimeTicks::Now();
139 139
140 // We must return false here so that the RootView does not get stuck 140 // We must return false here so that the RootView does not get stuck
141 // sending all mouse pressed events to us instead of the appropriate 141 // sending all mouse pressed events to us instead of the appropriate
142 // target. 142 // target.
143 return false; 143 return false;
144 } 144 }
145 return true; 145 return true;
146 } 146 }
147 147
148 void MenuButton::WillNotActivate() {
149 if (listener_) {
150 listener_->OnMenuButtonClickCanceled(this);
sadrul 2015/11/18 22:56:31 no {} for this
varkha 2015/11/18 23:27:54 This is inlined in OnMouseReleased (see https://co
151 }
152 }
153
148 void MenuButton::OnPaint(gfx::Canvas* canvas) { 154 void MenuButton::OnPaint(gfx::Canvas* canvas) {
149 LabelButton::OnPaint(canvas); 155 LabelButton::OnPaint(canvas);
150 156
151 if (show_menu_marker_) 157 if (show_menu_marker_)
152 PaintMenuMarker(canvas); 158 PaintMenuMarker(canvas);
153 } 159 }
154 160
155 //////////////////////////////////////////////////////////////////////////////// 161 ////////////////////////////////////////////////////////////////////////////////
156 // 162 //
157 // MenuButton - Events 163 // MenuButton - Events
(...skipping 24 matching lines...) Expand all
182 return Activate(); 188 return Activate();
183 } 189 }
184 return true; 190 return true;
185 } 191 }
186 192
187 void MenuButton::OnMouseReleased(const ui::MouseEvent& event) { 193 void MenuButton::OnMouseReleased(const ui::MouseEvent& event) {
188 if (state() != STATE_DISABLED && ShouldEnterPushedState(event) && 194 if (state() != STATE_DISABLED && ShouldEnterPushedState(event) &&
189 HitTestPoint(event.location()) && !InDrag()) { 195 HitTestPoint(event.location()) && !InDrag()) {
190 Activate(); 196 Activate();
191 } else { 197 } else {
198 WillNotActivate();
sadrul 2015/11/18 22:56:31 Can this directly call into listener_->OnMenuButto
varkha 2015/11/18 23:27:54 Done in https://codereview.chromium.org/1411833006
192 LabelButton::OnMouseReleased(event); 199 LabelButton::OnMouseReleased(event);
193 } 200 }
194 } 201 }
195 202
196 void MenuButton::OnMouseEntered(const ui::MouseEvent& event) { 203 void MenuButton::OnMouseEntered(const ui::MouseEvent& event) {
197 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.
198 LabelButton::OnMouseEntered(event); 205 LabelButton::OnMouseEntered(event);
199 } 206 }
200 207
201 void MenuButton::OnMouseExited(const ui::MouseEvent& event) { 208 void MenuButton::OnMouseExited(const ui::MouseEvent& event) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 if (!GetWidget()) { 362 if (!GetWidget()) {
356 NOTREACHED(); 363 NOTREACHED();
357 return 0; 364 return 0;
358 } 365 }
359 366
360 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); 367 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
361 return monitor_bounds.right() - 1; 368 return monitor_bounds.right() - 1;
362 } 369 }
363 370
364 } // namespace views 371 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698