| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 root_window, &point); | 154 root_window, &point); |
| 155 widget_->SetBounds(gfx::Rect( | 155 widget_->SetBounds(gfx::Rect( |
| 156 point.x() - (kAffordanceOuterRadius + kAffordanceGlowWidth), | 156 point.x() - (kAffordanceOuterRadius + kAffordanceGlowWidth), |
| 157 point.y() - (kAffordanceOuterRadius + kAffordanceGlowWidth), | 157 point.y() - (kAffordanceOuterRadius + kAffordanceGlowWidth), |
| 158 GetPreferredSize().width(), | 158 GetPreferredSize().width(), |
| 159 GetPreferredSize().height())); | 159 GetPreferredSize().height())); |
| 160 widget_->Show(); | 160 widget_->Show(); |
| 161 widget_->GetNativeView()->layer()->SetOpacity(kAffordanceOpacityStartValue); | 161 widget_->GetNativeView()->layer()->SetOpacity(kAffordanceOpacityStartValue); |
| 162 } | 162 } |
| 163 | 163 |
| 164 virtual ~LongPressAffordanceView() { | 164 ~LongPressAffordanceView() override {} |
| 165 } | |
| 166 | 165 |
| 167 void UpdateWithGrowAnimation(gfx::Animation* animation) { | 166 void UpdateWithGrowAnimation(gfx::Animation* animation) { |
| 168 // Update the portion of the circle filled so far and re-draw. | 167 // Update the portion of the circle filled so far and re-draw. |
| 169 current_angle_ = animation->CurrentValueBetween(kAffordanceAngleStartValue, | 168 current_angle_ = animation->CurrentValueBetween(kAffordanceAngleStartValue, |
| 170 kAffordanceAngleEndValue); | 169 kAffordanceAngleEndValue); |
| 171 current_scale_ = animation->CurrentValueBetween(kAffordanceScaleStartValue, | 170 current_scale_ = animation->CurrentValueBetween(kAffordanceScaleStartValue, |
| 172 kAffordanceScaleEndValue); | 171 kAffordanceScaleEndValue); |
| 173 widget_->GetNativeView()->layer()->SetOpacity( | 172 widget_->GetNativeView()->layer()->SetOpacity( |
| 174 animation->CurrentValueBetween(kAffordanceOpacityStartValue, | 173 animation->CurrentValueBetween(kAffordanceOpacityStartValue, |
| 175 kAffordanceOpacityEndValue)); | 174 kAffordanceOpacityEndValue)); |
| 176 SchedulePaint(); | 175 SchedulePaint(); |
| 177 } | 176 } |
| 178 | 177 |
| 179 void UpdateWithShrinkAnimation(gfx::Animation* animation) { | 178 void UpdateWithShrinkAnimation(gfx::Animation* animation) { |
| 180 current_scale_ = animation->CurrentValueBetween(kAffordanceScaleEndValue, | 179 current_scale_ = animation->CurrentValueBetween(kAffordanceScaleEndValue, |
| 181 kAffordanceShrinkScaleEndValue); | 180 kAffordanceShrinkScaleEndValue); |
| 182 widget_->GetNativeView()->layer()->SetOpacity( | 181 widget_->GetNativeView()->layer()->SetOpacity( |
| 183 animation->CurrentValueBetween(kAffordanceOpacityEndValue, | 182 animation->CurrentValueBetween(kAffordanceOpacityEndValue, |
| 184 kAffordanceOpacityStartValue)); | 183 kAffordanceOpacityStartValue)); |
| 185 SchedulePaint(); | 184 SchedulePaint(); |
| 186 } | 185 } |
| 187 | 186 |
| 188 private: | 187 private: |
| 189 // Overridden from views::View. | 188 // Overridden from views::View. |
| 190 virtual gfx::Size GetPreferredSize() const override { | 189 gfx::Size GetPreferredSize() const override { |
| 191 return gfx::Size(2 * (kAffordanceOuterRadius + kAffordanceGlowWidth), | 190 return gfx::Size(2 * (kAffordanceOuterRadius + kAffordanceGlowWidth), |
| 192 2 * (kAffordanceOuterRadius + kAffordanceGlowWidth)); | 191 2 * (kAffordanceOuterRadius + kAffordanceGlowWidth)); |
| 193 } | 192 } |
| 194 | 193 |
| 195 virtual void OnPaint(gfx::Canvas* canvas) override { | 194 void OnPaint(gfx::Canvas* canvas) override { |
| 196 gfx::Point center(GetPreferredSize().width() / 2, | 195 gfx::Point center(GetPreferredSize().width() / 2, |
| 197 GetPreferredSize().height() / 2); | 196 GetPreferredSize().height() / 2); |
| 198 canvas->Save(); | 197 canvas->Save(); |
| 199 | 198 |
| 200 gfx::Transform scale; | 199 gfx::Transform scale; |
| 201 scale.Scale(current_scale_, current_scale_); | 200 scale.Scale(current_scale_, current_scale_); |
| 202 // We want to scale from the center. | 201 // We want to scale from the center. |
| 203 canvas->Translate(center.OffsetFromOrigin()); | 202 canvas->Translate(center.OffsetFromOrigin()); |
| 204 canvas->Transform(scale); | 203 canvas->Transform(scale); |
| 205 canvas->Translate(-center.OffsetFromOrigin()); | 204 canvas->Translate(-center.OffsetFromOrigin()); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 break; | 356 break; |
| 358 } | 357 } |
| 359 } | 358 } |
| 360 | 359 |
| 361 void LongPressAffordanceHandler::OnWindowDestroying(aura::Window* window) { | 360 void LongPressAffordanceHandler::OnWindowDestroying(aura::Window* window) { |
| 362 DCHECK_EQ(tap_down_target_, window); | 361 DCHECK_EQ(tap_down_target_, window); |
| 363 StopAffordance(); | 362 StopAffordance(); |
| 364 } | 363 } |
| 365 | 364 |
| 366 } // namespace ash | 365 } // namespace ash |
| OLD | NEW |