| OLD | NEW |
| 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 Loading... |
| 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 for touch/gesture events. | 180 // On Windows, don't initiate ink-drops. Additionally, certain event states |
| 181 // Additionally, certain event states should dismiss existing ink-drop | 181 // should dismiss existing ink-drop animations. |
| 182 // animations. If the state is already other than HIDDEN, presumably from | 182 if (event && event->IsGestureEvent()) { |
| 183 // a mouse or keyboard event, then the state should be allowed. Conversely, | 183 // Don't transition the ink-drop to a "pending" state from a touch event. |
| 184 // if the requested state is ACTIVATED, then it should always be allowed. | 184 if (state == InkDropState::ACTION_PENDING || |
| 185 if (event && (event->IsTouchEvent() || event->IsGestureEvent()) && | 185 state == InkDropState::ALTERNATE_ACTION_PENDING) |
| 186 ink_drop_->GetTargetInkDropState() == InkDropState::HIDDEN && | 186 return; |
| 187 state != InkDropState::ACTIVATED) | 187 // If the state is already pending, presumably from a mouse or keyboard |
| 188 return; | 188 // event, then a "triggered" action state should be allowed. Conversely, |
| 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 } |
| 189 #endif | 196 #endif |
| 190 last_ripple_triggering_event_.reset( | 197 last_ripple_triggering_event_.reset( |
| 191 event ? ui::Event::Clone(*event).release()->AsLocatedEvent() : nullptr); | 198 event ? ui::Event::Clone(*event).release()->AsLocatedEvent() : nullptr); |
| 192 ink_drop_->AnimateToState(state); | 199 ink_drop_->AnimateToState(state); |
| 193 } | 200 } |
| 194 | 201 |
| 195 void InkDropHostView::VisibilityChanged(View* starting_from, bool is_visible) { | 202 void InkDropHostView::VisibilityChanged(View* starting_from, bool is_visible) { |
| 196 View::VisibilityChanged(starting_from, is_visible); | 203 View::VisibilityChanged(starting_from, is_visible); |
| 197 if (GetWidget() && !is_visible) { | 204 if (GetWidget() && !is_visible) { |
| 198 ink_drop()->AnimateToState(InkDropState::HIDDEN); | 205 ink_drop()->AnimateToState(InkDropState::HIDDEN); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 gesture_handler_.reset(new InkDropGestureHandler(this, ink_drop_.get())); | 249 gesture_handler_.reset(new InkDropGestureHandler(this, ink_drop_.get())); |
| 243 else | 250 else |
| 244 gesture_handler_->SetInkDrop(ink_drop_.get()); | 251 gesture_handler_->SetInkDrop(ink_drop_.get()); |
| 245 } else { | 252 } else { |
| 246 gesture_handler_.reset(); | 253 gesture_handler_.reset(); |
| 247 ink_drop_.reset(new InkDropStub()); | 254 ink_drop_.reset(new InkDropStub()); |
| 248 } | 255 } |
| 249 } | 256 } |
| 250 | 257 |
| 251 } // namespace views | 258 } // namespace views |
| OLD | NEW |