| 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 int64 timer_start_time_ms = | 257 int64 timer_start_time_ms = ui::GestureConfiguration::GetInstance() |
| 258 ui::GestureConfiguration::semi_long_press_time_in_seconds() * 1000; | 258 ->semi_long_press_time_in_seconds() * |
| 259 1000; |
| 259 timer_.Start(FROM_HERE, | 260 timer_.Start(FROM_HERE, |
| 260 base::TimeDelta::FromMilliseconds(timer_start_time_ms), | 261 base::TimeDelta::FromMilliseconds(timer_start_time_ms), |
| 261 this, | 262 this, |
| 262 &LongPressAffordanceHandler::StartAnimation); | 263 &LongPressAffordanceHandler::StartAnimation); |
| 263 break; | 264 break; |
| 264 } | 265 } |
| 265 case ui::ET_GESTURE_TAP: | 266 case ui::ET_GESTURE_TAP: |
| 266 case ui::ET_GESTURE_TAP_CANCEL: | 267 case ui::ET_GESTURE_TAP_CANCEL: |
| 267 StopAffordance(); | 268 StopAffordance(); |
| 268 break; | 269 break; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 280 void LongPressAffordanceHandler::StartAnimation() { | 281 void LongPressAffordanceHandler::StartAnimation() { |
| 281 switch (current_animation_type_) { | 282 switch (current_animation_type_) { |
| 282 case GROW_ANIMATION: { | 283 case GROW_ANIMATION: { |
| 283 aura::Window* root_window = tap_down_target_->GetRootWindow(); | 284 aura::Window* root_window = tap_down_target_->GetRootWindow(); |
| 284 if (!root_window) { | 285 if (!root_window) { |
| 285 StopAffordance(); | 286 StopAffordance(); |
| 286 return; | 287 return; |
| 287 } | 288 } |
| 288 view_.reset(new LongPressAffordanceView(tap_down_location_, root_window)); | 289 view_.reset(new LongPressAffordanceView(tap_down_location_, root_window)); |
| 289 SetDuration( | 290 SetDuration( |
| 290 ui::GestureConfiguration::long_press_time_in_seconds() * 1000 - | 291 ui::GestureConfiguration::GetInstance()->long_press_timeout_in_ms() - |
| 291 ui::GestureConfiguration::semi_long_press_time_in_seconds() * 1000 - | 292 ui::GestureConfiguration::GetInstance() |
| 293 ->semi_long_press_time_in_seconds() * |
| 294 1000 - |
| 292 kAffordanceDelayBeforeShrinkMs); | 295 kAffordanceDelayBeforeShrinkMs); |
| 293 Start(); | 296 Start(); |
| 294 break; | 297 break; |
| 295 } | 298 } |
| 296 case SHRINK_ANIMATION: | 299 case SHRINK_ANIMATION: |
| 297 SetDuration(kAffordanceShrinkAnimationDurationMs); | 300 SetDuration(kAffordanceShrinkAnimationDurationMs); |
| 298 Start(); | 301 Start(); |
| 299 break; | 302 break; |
| 300 default: | 303 default: |
| 301 NOTREACHED(); | 304 NOTREACHED(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 break; | 361 break; |
| 359 } | 362 } |
| 360 } | 363 } |
| 361 | 364 |
| 362 void LongPressAffordanceHandler::OnWindowDestroying(aura::Window* window) { | 365 void LongPressAffordanceHandler::OnWindowDestroying(aura::Window* window) { |
| 363 DCHECK_EQ(tap_down_target_, window); | 366 DCHECK_EQ(tap_down_target_, window); |
| 364 StopAffordance(); | 367 StopAffordance(); |
| 365 } | 368 } |
| 366 | 369 |
| 367 } // namespace ash | 370 } // namespace ash |
| OLD | NEW |