| 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/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 point.y() - (kAffordanceOuterRadius + kAffordanceGlowWidth), | 158 point.y() - (kAffordanceOuterRadius + kAffordanceGlowWidth), |
| 159 GetPreferredSize().width(), | 159 GetPreferredSize().width(), |
| 160 GetPreferredSize().height())); | 160 GetPreferredSize().height())); |
| 161 widget_->Show(); | 161 widget_->Show(); |
| 162 widget_->GetNativeView()->layer()->SetOpacity(kAffordanceOpacityStartValue); | 162 widget_->GetNativeView()->layer()->SetOpacity(kAffordanceOpacityStartValue); |
| 163 } | 163 } |
| 164 | 164 |
| 165 virtual ~LongPressAffordanceView() { | 165 virtual ~LongPressAffordanceView() { |
| 166 } | 166 } |
| 167 | 167 |
| 168 void UpdateWithGrowAnimation(ui::Animation* animation) { | 168 void UpdateWithGrowAnimation(gfx::Animation* animation) { |
| 169 // Update the portion of the circle filled so far and re-draw. | 169 // Update the portion of the circle filled so far and re-draw. |
| 170 current_angle_ = animation->CurrentValueBetween(kAffordanceAngleStartValue, | 170 current_angle_ = animation->CurrentValueBetween(kAffordanceAngleStartValue, |
| 171 kAffordanceAngleEndValue); | 171 kAffordanceAngleEndValue); |
| 172 current_scale_ = animation->CurrentValueBetween(kAffordanceScaleStartValue, | 172 current_scale_ = animation->CurrentValueBetween(kAffordanceScaleStartValue, |
| 173 kAffordanceScaleEndValue); | 173 kAffordanceScaleEndValue); |
| 174 widget_->GetNativeView()->layer()->SetOpacity( | 174 widget_->GetNativeView()->layer()->SetOpacity( |
| 175 animation->CurrentValueBetween(kAffordanceOpacityStartValue, | 175 animation->CurrentValueBetween(kAffordanceOpacityStartValue, |
| 176 kAffordanceOpacityEndValue)); | 176 kAffordanceOpacityEndValue)); |
| 177 SchedulePaint(); | 177 SchedulePaint(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void UpdateWithShrinkAnimation(ui::Animation* animation) { | 180 void UpdateWithShrinkAnimation(gfx::Animation* animation) { |
| 181 current_scale_ = animation->CurrentValueBetween(kAffordanceScaleEndValue, | 181 current_scale_ = animation->CurrentValueBetween(kAffordanceScaleEndValue, |
| 182 kAffordanceShrinkScaleEndValue); | 182 kAffordanceShrinkScaleEndValue); |
| 183 widget_->GetNativeView()->layer()->SetOpacity( | 183 widget_->GetNativeView()->layer()->SetOpacity( |
| 184 animation->CurrentValueBetween(kAffordanceOpacityEndValue, | 184 animation->CurrentValueBetween(kAffordanceOpacityEndValue, |
| 185 kAffordanceOpacityStartValue)); | 185 kAffordanceOpacityStartValue)); |
| 186 SchedulePaint(); | 186 SchedulePaint(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 private: | 189 private: |
| 190 // Overridden from views::View. | 190 // Overridden from views::View. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 int current_angle_; | 229 int current_angle_; |
| 230 double current_scale_; | 230 double current_scale_; |
| 231 | 231 |
| 232 DISALLOW_COPY_AND_ASSIGN(LongPressAffordanceView); | 232 DISALLOW_COPY_AND_ASSIGN(LongPressAffordanceView); |
| 233 }; | 233 }; |
| 234 | 234 |
| 235 //////////////////////////////////////////////////////////////////////////////// | 235 //////////////////////////////////////////////////////////////////////////////// |
| 236 // LongPressAffordanceHandler, public | 236 // LongPressAffordanceHandler, public |
| 237 | 237 |
| 238 LongPressAffordanceHandler::LongPressAffordanceHandler() | 238 LongPressAffordanceHandler::LongPressAffordanceHandler() |
| 239 : ui::LinearAnimation(kAffordanceFrameRateHz, this), | 239 : gfx::LinearAnimation(kAffordanceFrameRateHz, this), |
| 240 tap_down_touch_id_(-1), | 240 tap_down_touch_id_(-1), |
| 241 tap_down_display_id_(0), | 241 tap_down_display_id_(0), |
| 242 current_animation_type_(NONE) {} | 242 current_animation_type_(NONE) {} |
| 243 | 243 |
| 244 LongPressAffordanceHandler::~LongPressAffordanceHandler() {} | 244 LongPressAffordanceHandler::~LongPressAffordanceHandler() {} |
| 245 | 245 |
| 246 void LongPressAffordanceHandler::ProcessEvent(aura::Window* target, | 246 void LongPressAffordanceHandler::ProcessEvent(aura::Window* target, |
| 247 ui::LocatedEvent* event, | 247 ui::LocatedEvent* event, |
| 248 int touch_id) { | 248 int touch_id) { |
| 249 // Once we have a touch id, we are only interested in event of that touch id. | 249 // Once we have a touch id, we are only interested in event of that touch id. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 NOTREACHED(); | 344 NOTREACHED(); |
| 345 break; | 345 break; |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 | 348 |
| 349 bool LongPressAffordanceHandler::ShouldSendCanceledFromStop() { | 349 bool LongPressAffordanceHandler::ShouldSendCanceledFromStop() { |
| 350 return false; | 350 return false; |
| 351 } | 351 } |
| 352 | 352 |
| 353 void LongPressAffordanceHandler::AnimationEnded( | 353 void LongPressAffordanceHandler::AnimationEnded( |
| 354 const ui::Animation* animation) { | 354 const gfx::Animation* animation) { |
| 355 switch (current_animation_type_) { | 355 switch (current_animation_type_) { |
| 356 case GROW_ANIMATION: | 356 case GROW_ANIMATION: |
| 357 current_animation_type_ = SHRINK_ANIMATION; | 357 current_animation_type_ = SHRINK_ANIMATION; |
| 358 timer_.Start(FROM_HERE, | 358 timer_.Start(FROM_HERE, |
| 359 base::TimeDelta::FromMilliseconds(kAffordanceDelayBeforeShrinkMs), | 359 base::TimeDelta::FromMilliseconds(kAffordanceDelayBeforeShrinkMs), |
| 360 this, &LongPressAffordanceHandler::StartAnimation); | 360 this, &LongPressAffordanceHandler::StartAnimation); |
| 361 break; | 361 break; |
| 362 case SHRINK_ANIMATION: | 362 case SHRINK_ANIMATION: |
| 363 current_animation_type_ = NONE; | 363 current_animation_type_ = NONE; |
| 364 // fall through to reset the view. | 364 // fall through to reset the view. |
| 365 default: | 365 default: |
| 366 view_.reset(); | 366 view_.reset(); |
| 367 tap_down_touch_id_ = -1; | 367 tap_down_touch_id_ = -1; |
| 368 tap_down_display_id_ = 0; | 368 tap_down_display_id_ = 0; |
| 369 break; | 369 break; |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 | 372 |
| 373 } // namespace internal | 373 } // namespace internal |
| 374 } // namespace ash | 374 } // namespace ash |
| OLD | NEW |