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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_button.cc

Issue 2042073002: Centered flood fill style ink drop ripples on mouse/touch points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Polished for review. Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/views/toolbar/toolbar_button.h" 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 int left_bound = display.bounds().x(); 213 int left_bound = display.bounds().x();
214 #endif 214 #endif
215 if (menu_position.x() < left_bound) 215 if (menu_position.x() < left_bound)
216 menu_position.set_x(left_bound); 216 menu_position.set_x(left_bound);
217 217
218 // Make the button look depressed while the menu is open. 218 // Make the button look depressed while the menu is open.
219 SetState(STATE_PRESSED); 219 SetState(STATE_PRESSED);
220 220
221 menu_showing_ = true; 221 menu_showing_ = true;
222 222
223 AnimateInkDrop(views::InkDropState::ACTIVATED); 223 AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr /* event */);
224 224
225 // Exit if the model is null. 225 // Exit if the model is null.
226 if (!model_.get()) 226 if (!model_.get())
227 return; 227 return;
228 228
229 // Create and run menu. 229 // Create and run menu.
230 menu_model_adapter_.reset(new views::MenuModelAdapter( 230 menu_model_adapter_.reset(new views::MenuModelAdapter(
231 model_.get(), 231 model_.get(),
232 base::Bind(&ToolbarButton::OnMenuClosed, base::Unretained(this)))); 232 base::Bind(&ToolbarButton::OnMenuClosed, base::Unretained(this))));
233 menu_model_adapter_->set_triggerable_event_flags(triggerable_event_flags()); 233 menu_model_adapter_->set_triggerable_event_flags(triggerable_event_flags());
234 menu_runner_.reset(new views::MenuRunner( 234 menu_runner_.reset(new views::MenuRunner(
235 menu_model_adapter_->CreateMenu(), 235 menu_model_adapter_->CreateMenu(),
236 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::ASYNC)); 236 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::ASYNC));
237 ignore_result(menu_runner_->RunMenuAt( 237 ignore_result(menu_runner_->RunMenuAt(
238 GetWidget(), nullptr, gfx::Rect(menu_position, gfx::Size(0, 0)), 238 GetWidget(), nullptr, gfx::Rect(menu_position, gfx::Size(0, 0)),
239 views::MENU_ANCHOR_TOPLEFT, source_type)); 239 views::MENU_ANCHOR_TOPLEFT, source_type));
240 } 240 }
241 241
242 void ToolbarButton::OnMenuClosed() { 242 void ToolbarButton::OnMenuClosed() {
243 AnimateInkDrop(views::InkDropState::DEACTIVATED); 243 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr /* event */);
244 244
245 menu_showing_ = false; 245 menu_showing_ = false;
246 246
247 // Need to explicitly clear mouse handler so that events get sent 247 // Need to explicitly clear mouse handler so that events get sent
248 // properly after the menu finishes running. If we don't do this, then 248 // properly after the menu finishes running. If we don't do this, then
249 // the first click to other parts of the UI is eaten. 249 // the first click to other parts of the UI is eaten.
250 SetMouseHandler(nullptr); 250 SetMouseHandler(nullptr);
251 251
252 // Set the state back to normal after the drop down menu is closed. 252 // Set the state back to normal after the drop down menu is closed.
253 if (state() != STATE_DISABLED) 253 if (state() != STATE_DISABLED)
254 SetState(STATE_NORMAL); 254 SetState(STATE_NORMAL);
255 255
256 menu_runner_.reset(); 256 menu_runner_.reset();
257 menu_model_adapter_.reset(); 257 menu_model_adapter_.reset();
258 } 258 }
259 259
260 const char* ToolbarButton::GetClassName() const { 260 const char* ToolbarButton::GetClassName() const {
261 return "ToolbarButton"; 261 return "ToolbarButton";
262 } 262 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698