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

Side by Side Diff: chrome/browser/ui/views/location_bar/bubble_icon_view.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/location_bar/bubble_icon_view.h" 5 #include "chrome/browser/ui/views/location_bar/bubble_icon_view.h"
6 6
7 #include "chrome/browser/command_updater.h" 7 #include "chrome/browser/command_updater.h"
8 #include "ui/accessibility/ax_view_state.h" 8 #include "ui/accessibility/ax_view_state.h"
9 #include "ui/base/material_design/material_design_controller.h" 9 #include "ui/base/material_design/material_design_controller.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 void BubbleIconView::Layout() { 68 void BubbleIconView::Layout() {
69 View::Layout(); 69 View::Layout();
70 image_->SetBoundsRect(GetLocalBounds()); 70 image_->SetBoundsRect(GetLocalBounds());
71 } 71 }
72 72
73 bool BubbleIconView::OnMousePressed(const ui::MouseEvent& event) { 73 bool BubbleIconView::OnMousePressed(const ui::MouseEvent& event) {
74 // If the bubble is showing then don't reshow it when the mouse is released. 74 // If the bubble is showing then don't reshow it when the mouse is released.
75 suppress_mouse_released_action_ = IsBubbleShowing(); 75 suppress_mouse_released_action_ = IsBubbleShowing();
76 if (!suppress_mouse_released_action_ && event.IsOnlyLeftMouseButton()) 76 if (!suppress_mouse_released_action_ && event.IsOnlyLeftMouseButton())
77 AnimateInkDrop(views::InkDropState::ACTION_PENDING); 77 AnimateInkDrop(views::InkDropState::ACTION_PENDING, &event);
78 78
79 // We want to show the bubble on mouse release; that is the standard behavior 79 // We want to show the bubble on mouse release; that is the standard behavior
80 // for buttons. 80 // for buttons.
81 return true; 81 return true;
82 } 82 }
83 83
84 void BubbleIconView::OnMouseReleased(const ui::MouseEvent& event) { 84 void BubbleIconView::OnMouseReleased(const ui::MouseEvent& event) {
85 // If this is the second click on this view then the bubble was showing on the 85 // If this is the second click on this view then the bubble was showing on the
86 // mouse pressed event and is hidden now. Prevent the bubble from reshowing by 86 // mouse pressed event and is hidden now. Prevent the bubble from reshowing by
87 // doing nothing here. 87 // doing nothing here.
88 if (suppress_mouse_released_action_) { 88 if (suppress_mouse_released_action_) {
89 suppress_mouse_released_action_ = false; 89 suppress_mouse_released_action_ = false;
90 OnPressed(false); 90 OnPressed(false);
91 return; 91 return;
92 } 92 }
93 if (!event.IsLeftMouseButton()) 93 if (!event.IsLeftMouseButton())
94 return; 94 return;
95 95
96 const bool activated = HitTestPoint(event.location()); 96 const bool activated = HitTestPoint(event.location());
97 AnimateInkDrop(activated ? views::InkDropState::ACTIVATED 97 AnimateInkDrop(
98 : views::InkDropState::HIDDEN); 98 activated ? views::InkDropState::ACTIVATED : views::InkDropState::HIDDEN,
99 &event);
99 if (activated) 100 if (activated)
100 ExecuteCommand(EXECUTE_SOURCE_MOUSE); 101 ExecuteCommand(EXECUTE_SOURCE_MOUSE);
101 OnPressed(activated); 102 OnPressed(activated);
102 } 103 }
103 104
104 bool BubbleIconView::OnKeyPressed(const ui::KeyEvent& event) { 105 bool BubbleIconView::OnKeyPressed(const ui::KeyEvent& event) {
105 if (event.key_code() != ui::VKEY_RETURN && event.key_code() != ui::VKEY_SPACE) 106 if (event.key_code() != ui::VKEY_RETURN && event.key_code() != ui::VKEY_SPACE)
106 return false; 107 return false;
107 108
108 AnimateInkDrop(views::InkDropState::ACTIVATED); 109 AnimateInkDrop(views::InkDropState::ACTIVATED, &event);
109 // As with CustomButton, return activates on key down and space activates on 110 // As with CustomButton, return activates on key down and space activates on
110 // key up. 111 // key up.
111 if (event.key_code() == ui::VKEY_RETURN) 112 if (event.key_code() == ui::VKEY_RETURN)
112 ExecuteCommand(EXECUTE_SOURCE_KEYBOARD); 113 ExecuteCommand(EXECUTE_SOURCE_KEYBOARD);
113 return true; 114 return true;
114 } 115 }
115 116
116 bool BubbleIconView::OnKeyReleased(const ui::KeyEvent& event) { 117 bool BubbleIconView::OnKeyReleased(const ui::KeyEvent& event) {
117 if (event.key_code() != ui::VKEY_SPACE) 118 if (event.key_code() != ui::VKEY_SPACE)
118 return false; 119 return false;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return color_utils::DeriveDefaultIconColor(GetNativeTheme()->GetSystemColor( 154 return color_utils::DeriveDefaultIconColor(GetNativeTheme()->GetSystemColor(
154 ui::NativeTheme::kColorId_TextfieldDefaultColor)); 155 ui::NativeTheme::kColorId_TextfieldDefaultColor));
155 } 156 }
156 157
157 bool BubbleIconView::ShouldShowInkDropForFocus() const { 158 bool BubbleIconView::ShouldShowInkDropForFocus() const {
158 return true; 159 return true;
159 } 160 }
160 161
161 void BubbleIconView::OnGestureEvent(ui::GestureEvent* event) { 162 void BubbleIconView::OnGestureEvent(ui::GestureEvent* event) {
162 if (event->type() == ui::ET_GESTURE_TAP) { 163 if (event->type() == ui::ET_GESTURE_TAP) {
163 AnimateInkDrop(views::InkDropState::ACTIVATED); 164 AnimateInkDrop(views::InkDropState::ACTIVATED, event);
164 ExecuteCommand(EXECUTE_SOURCE_GESTURE); 165 ExecuteCommand(EXECUTE_SOURCE_GESTURE);
165 event->SetHandled(); 166 event->SetHandled();
166 } 167 }
167 } 168 }
168 169
169 void BubbleIconView::OnWidgetDestroying(views::Widget* widget) { 170 void BubbleIconView::OnWidgetDestroying(views::Widget* widget) {
170 widget->RemoveObserver(this); 171 widget->RemoveObserver(this);
171 } 172 }
172 173
173 void BubbleIconView::OnWidgetVisibilityChanged(views::Widget* widget, 174 void BubbleIconView::OnWidgetVisibilityChanged(views::Widget* widget,
174 bool visible) { 175 bool visible) {
175 // |widget| is a bubble that has just got shown / hidden. 176 // |widget| is a bubble that has just got shown / hidden.
176 if (!visible) 177 if (!visible)
177 AnimateInkDrop(views::InkDropState::DEACTIVATED); 178 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr /* event */);
178 } 179 }
179 180
180 void BubbleIconView::ExecuteCommand(ExecuteSource source) { 181 void BubbleIconView::ExecuteCommand(ExecuteSource source) {
181 OnExecuting(source); 182 OnExecuting(source);
182 if (command_updater_) 183 if (command_updater_)
183 command_updater_->ExecuteCommand(command_id_); 184 command_updater_->ExecuteCommand(command_id_);
184 } 185 }
185 186
186 gfx::VectorIconId BubbleIconView::GetVectorIcon() const { 187 gfx::VectorIconId BubbleIconView::GetVectorIcon() const {
187 return gfx::VectorIconId::VECTOR_ICON_NONE; 188 return gfx::VectorIconId::VECTOR_ICON_NONE;
(...skipping 23 matching lines...) Expand all
211 image_->SetImage( 212 image_->SetImage(
212 gfx::CreateVectorIcon(GetVectorIcon(), icon_size, icon_color)); 213 gfx::CreateVectorIcon(GetVectorIcon(), icon_size, icon_color));
213 } 214 }
214 215
215 void BubbleIconView::SetActiveInternal(bool active) { 216 void BubbleIconView::SetActiveInternal(bool active) {
216 if (active_ == active) 217 if (active_ == active)
217 return; 218 return;
218 active_ = active; 219 active_ = active;
219 UpdateIcon(); 220 UpdateIcon();
220 } 221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698