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

Side by Side Diff: ui/views/animation/ink_drop_host_view.cc

Issue 2125353002: Added tests and reworked ink-drop touch logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | ui/views/animation/ink_drop_host_view_unittest.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/animation/ink_drop_host_view.h" 5 #include "ui/views/animation/ink_drop_host_view.h"
6 6
7 #include "ui/events/event.h" 7 #include "ui/events/event.h"
8 #include "ui/events/scoped_target_handler.h" 8 #include "ui/events/scoped_target_handler.h"
9 #include "ui/gfx/color_palette.h" 9 #include "ui/gfx/color_palette.h"
10 #include "ui/gfx/geometry/size_conversions.h" 10 #include "ui/gfx/geometry/size_conversions.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 gfx::Point InkDropHostView::GetInkDropCenterBasedOnLastEvent() const { 171 gfx::Point InkDropHostView::GetInkDropCenterBasedOnLastEvent() const {
172 return last_ripple_triggering_event_ 172 return last_ripple_triggering_event_
173 ? last_ripple_triggering_event_->location() 173 ? last_ripple_triggering_event_->location()
174 : GetLocalBounds().CenterPoint(); 174 : GetLocalBounds().CenterPoint();
175 } 175 }
176 176
177 void InkDropHostView::AnimateInkDrop(InkDropState state, 177 void InkDropHostView::AnimateInkDrop(InkDropState state,
178 const ui::LocatedEvent* event) { 178 const ui::LocatedEvent* event) {
179 #if defined(OS_WIN) 179 #if defined(OS_WIN)
180 // On Windows, don't initiate ink-drops. Additionally, certain event states 180 // On Windows, don't initiate ink-drops for touch/gesture events.
181 // should dismiss existing ink-drop animations. 181 // Additionally, certain event states should dismiss existing ink-drop
182 if (event && event->IsGestureEvent()) { 182 // animations. If the state is already other than HIDDEN, presumably from
183 // Don't transition the ink-drop to a "pending" state from a touch event. 183 // a mouse or keyboard event, then the state should be allowed. Conversely,
184 if (state == InkDropState::ACTION_PENDING || 184 // if the requested state is ACTIVATED, then it should always be allowed.
185 state == InkDropState::ALTERNATE_ACTION_PENDING) 185 if (event && (event->IsTouchEvent() || event->IsGestureEvent()) &&
186 return; 186 ink_drop_->GetTargetInkDropState() == InkDropState::HIDDEN &&
187 // If the state is already pending, presumably from a mouse or keyboard 187 state != InkDropState::ACTIVATED)
188 // event, then a "triggered" action state should be allowed. Conversely, 188 return;
189 // if the state had already transitioned to hidden, then the touch event
190 // is ignored.
191 if ((state == InkDropState::ACTION_TRIGGERED ||
192 state == InkDropState::ALTERNATE_ACTION_TRIGGERED) &&
193 ink_drop_->GetTargetInkDropState() == InkDropState::HIDDEN)
194 return;
195 }
196 #endif 189 #endif
197 last_ripple_triggering_event_.reset( 190 last_ripple_triggering_event_.reset(
198 event ? ui::Event::Clone(*event).release()->AsLocatedEvent() : nullptr); 191 event ? ui::Event::Clone(*event).release()->AsLocatedEvent() : nullptr);
199 ink_drop_->AnimateToState(state); 192 ink_drop_->AnimateToState(state);
200 } 193 }
201 194
202 void InkDropHostView::VisibilityChanged(View* starting_from, bool is_visible) { 195 void InkDropHostView::VisibilityChanged(View* starting_from, bool is_visible) {
203 View::VisibilityChanged(starting_from, is_visible); 196 View::VisibilityChanged(starting_from, is_visible);
204 if (GetWidget() && !is_visible) { 197 if (GetWidget() && !is_visible) {
205 ink_drop()->AnimateToState(InkDropState::HIDDEN); 198 ink_drop()->AnimateToState(InkDropState::HIDDEN);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 gesture_handler_.reset(new InkDropGestureHandler(this, ink_drop_.get())); 242 gesture_handler_.reset(new InkDropGestureHandler(this, ink_drop_.get()));
250 else 243 else
251 gesture_handler_->SetInkDrop(ink_drop_.get()); 244 gesture_handler_->SetInkDrop(ink_drop_.get());
252 } else { 245 } else {
253 gesture_handler_.reset(); 246 gesture_handler_.reset();
254 ink_drop_.reset(new InkDropStub()); 247 ink_drop_.reset(new InkDropStub());
255 } 248 }
256 } 249 }
257 250
258 } // namespace views 251 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/animation/ink_drop_host_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698