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" |
(...skipping 236 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 timer_.Start( |
258 ui::GestureConfiguration::semi_long_press_time_in_seconds() * 1000; | 258 FROM_HERE, |
259 timer_.Start(FROM_HERE, | 259 base::TimeDelta::FromMilliseconds( |
260 base::TimeDelta::FromMilliseconds(timer_start_time_ms), | 260 ui::GestureConfiguration::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( | 289 SetDuration(ui::GestureConfiguration::long_press_time_in_ms() - |
290 ui::GestureConfiguration::long_press_time_in_seconds() * 1000 - | 290 ui::GestureConfiguration::semi_long_press_time_in_ms() - |
291 ui::GestureConfiguration::semi_long_press_time_in_seconds() * 1000 - | |
292 kAffordanceDelayBeforeShrinkMs); | 291 kAffordanceDelayBeforeShrinkMs); |
293 Start(); | 292 Start(); |
294 break; | 293 break; |
295 } | 294 } |
296 case SHRINK_ANIMATION: | 295 case SHRINK_ANIMATION: |
297 SetDuration(kAffordanceShrinkAnimationDurationMs); | 296 SetDuration(kAffordanceShrinkAnimationDurationMs); |
298 Start(); | 297 Start(); |
299 break; | 298 break; |
300 default: | 299 default: |
301 NOTREACHED(); | 300 NOTREACHED(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 break; | 357 break; |
359 } | 358 } |
360 } | 359 } |
361 | 360 |
362 void LongPressAffordanceHandler::OnWindowDestroying(aura::Window* window) { | 361 void LongPressAffordanceHandler::OnWindowDestroying(aura::Window* window) { |
363 DCHECK_EQ(tap_down_target_, window); | 362 DCHECK_EQ(tap_down_target_, window); |
364 StopAffordance(); | 363 StopAffordance(); |
365 } | 364 } |
366 | 365 |
367 } // namespace ash | 366 } // namespace ash |
OLD | NEW |