OLD | NEW |
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 "ash/wm/gestures/long_press_affordance_handler.h" | 5 #include "ash/wm/gestures/long_press_affordance_handler.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
11 #include "third_party/skia/include/core/SkColor.h" | 11 #include "third_party/skia/include/core/SkColor.h" |
12 #include "third_party/skia/include/core/SkPaint.h" | 12 #include "third_party/skia/include/core/SkPaint.h" |
13 #include "third_party/skia/include/core/SkPath.h" | 13 #include "third_party/skia/include/core/SkPath.h" |
14 #include "third_party/skia/include/core/SkRect.h" | 14 #include "third_party/skia/include/core/SkRect.h" |
15 #include "third_party/skia/include/effects/SkGradientShader.h" | 15 #include "third_party/skia/include/effects/SkGradientShader.h" |
16 #include "ui/aura/client/screen_position_client.h" | 16 #include "ui/aura/client/screen_position_client.h" |
17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
18 #include "ui/aura/window_event_dispatcher.h" | 18 #include "ui/aura/window_event_dispatcher.h" |
19 #include "ui/compositor/layer.h" | 19 #include "ui/compositor/layer.h" |
20 #include "ui/events/gestures/gesture_configuration.h" | 20 #include "ui/events/gesture_detection/gesture_configuration.h" |
21 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
22 #include "ui/gfx/screen.h" | 22 #include "ui/gfx/screen.h" |
23 #include "ui/gfx/transform.h" | 23 #include "ui/gfx/transform.h" |
24 #include "ui/views/view.h" | 24 #include "ui/views/view.h" |
25 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
26 | 26 |
27 namespace ash { | 27 namespace ash { |
28 namespace { | 28 namespace { |
29 | 29 |
30 const int kAffordanceOuterRadius = 60; | 30 const int kAffordanceOuterRadius = 60; |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 ui::GestureEvent* event) { | 247 ui::GestureEvent* event) { |
248 // Once we have a target, we are only interested in events with that target. | 248 // Once we have a target, we are only interested in events with that target. |
249 if (tap_down_target_ && tap_down_target_ != target) | 249 if (tap_down_target_ && tap_down_target_ != target) |
250 return; | 250 return; |
251 switch (event->type()) { | 251 switch (event->type()) { |
252 case ui::ET_GESTURE_TAP_DOWN: { | 252 case ui::ET_GESTURE_TAP_DOWN: { |
253 // Start timer that will start animation on "semi-long-press". | 253 // Start timer that will start animation on "semi-long-press". |
254 tap_down_location_ = event->root_location(); | 254 tap_down_location_ = event->root_location(); |
255 SetTapDownTarget(target); | 255 SetTapDownTarget(target); |
256 current_animation_type_ = GROW_ANIMATION; | 256 current_animation_type_ = GROW_ANIMATION; |
257 timer_.Start( | 257 timer_.Start(FROM_HERE, |
258 FROM_HERE, | 258 base::TimeDelta::FromMilliseconds( |
259 base::TimeDelta::FromMilliseconds( | 259 ui::GestureConfiguration::GetInstance() |
260 ui::GestureConfiguration::semi_long_press_time_in_ms()), | 260 ->semi_long_press_time_in_ms()), |
261 this, | 261 this, |
262 &LongPressAffordanceHandler::StartAnimation); | 262 &LongPressAffordanceHandler::StartAnimation); |
263 break; | 263 break; |
264 } | 264 } |
265 case ui::ET_GESTURE_TAP: | 265 case ui::ET_GESTURE_TAP: |
266 case ui::ET_GESTURE_TAP_CANCEL: | 266 case ui::ET_GESTURE_TAP_CANCEL: |
267 StopAffordance(); | 267 StopAffordance(); |
268 break; | 268 break; |
269 case ui::ET_GESTURE_LONG_PRESS: | 269 case ui::ET_GESTURE_LONG_PRESS: |
270 End(); | 270 End(); |
271 break; | 271 break; |
272 default: | 272 default: |
273 break; | 273 break; |
274 } | 274 } |
275 } | 275 } |
276 | 276 |
277 //////////////////////////////////////////////////////////////////////////////// | 277 //////////////////////////////////////////////////////////////////////////////// |
278 // LongPressAffordanceHandler, private | 278 // LongPressAffordanceHandler, private |
279 | 279 |
280 void LongPressAffordanceHandler::StartAnimation() { | 280 void LongPressAffordanceHandler::StartAnimation() { |
281 switch (current_animation_type_) { | 281 switch (current_animation_type_) { |
282 case GROW_ANIMATION: { | 282 case GROW_ANIMATION: { |
283 aura::Window* root_window = tap_down_target_->GetRootWindow(); | 283 aura::Window* root_window = tap_down_target_->GetRootWindow(); |
284 if (!root_window) { | 284 if (!root_window) { |
285 StopAffordance(); | 285 StopAffordance(); |
286 return; | 286 return; |
287 } | 287 } |
288 view_.reset(new LongPressAffordanceView(tap_down_location_, root_window)); | 288 view_.reset(new LongPressAffordanceView(tap_down_location_, root_window)); |
289 SetDuration(ui::GestureConfiguration::long_press_time_in_ms() - | 289 SetDuration( |
290 ui::GestureConfiguration::semi_long_press_time_in_ms() - | 290 ui::GestureConfiguration::GetInstance()->long_press_time_in_ms() - |
| 291 ui::GestureConfiguration::GetInstance() |
| 292 ->semi_long_press_time_in_ms() - |
291 kAffordanceDelayBeforeShrinkMs); | 293 kAffordanceDelayBeforeShrinkMs); |
292 Start(); | 294 Start(); |
293 break; | 295 break; |
294 } | 296 } |
295 case SHRINK_ANIMATION: | 297 case SHRINK_ANIMATION: |
296 SetDuration(kAffordanceShrinkAnimationDurationMs); | 298 SetDuration(kAffordanceShrinkAnimationDurationMs); |
297 Start(); | 299 Start(); |
298 break; | 300 break; |
299 default: | 301 default: |
300 NOTREACHED(); | 302 NOTREACHED(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 break; | 359 break; |
358 } | 360 } |
359 } | 361 } |
360 | 362 |
361 void LongPressAffordanceHandler::OnWindowDestroying(aura::Window* window) { | 363 void LongPressAffordanceHandler::OnWindowDestroying(aura::Window* window) { |
362 DCHECK_EQ(tap_down_target_, window); | 364 DCHECK_EQ(tap_down_target_, window); |
363 StopAffordance(); | 365 StopAffordance(); |
364 } | 366 } |
365 | 367 |
366 } // namespace ash | 368 } // namespace ash |
OLD | NEW |