| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 const int kAffordanceAngleEndValue = 380; | 52 const int kAffordanceAngleEndValue = 380; |
| 53 const int kAffordanceDelayBeforeShrinkMs = 200; | 53 const int kAffordanceDelayBeforeShrinkMs = 200; |
| 54 const int kAffordanceShrinkAnimationDurationMs = 100; | 54 const int kAffordanceShrinkAnimationDurationMs = 100; |
| 55 | 55 |
| 56 // Visual constants. | 56 // Visual constants. |
| 57 const SkColor kAffordanceGlowStartColor = SkColorSetARGB(24, 255, 255, 255); | 57 const SkColor kAffordanceGlowStartColor = SkColorSetARGB(24, 255, 255, 255); |
| 58 const SkColor kAffordanceGlowEndColor = SkColorSetARGB(0, 255, 255, 255); | 58 const SkColor kAffordanceGlowEndColor = SkColorSetARGB(0, 255, 255, 255); |
| 59 const SkColor kAffordanceArcColor = SkColorSetARGB(80, 0, 0, 0); | 59 const SkColor kAffordanceArcColor = SkColorSetARGB(80, 0, 0, 0); |
| 60 const int kAffordanceFrameRateHz = 60; | 60 const int kAffordanceFrameRateHz = 60; |
| 61 | 61 |
| 62 views::Widget* CreateAffordanceWidget(aura::RootWindow* root_window) { | 62 views::Widget* CreateAffordanceWidget(aura::Window* root_window) { |
| 63 views::Widget* widget = new views::Widget; | 63 views::Widget* widget = new views::Widget; |
| 64 views::Widget::InitParams params; | 64 views::Widget::InitParams params; |
| 65 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; | 65 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; |
| 66 params.keep_on_top = true; | 66 params.keep_on_top = true; |
| 67 params.accept_events = false; | 67 params.accept_events = false; |
| 68 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 68 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 69 params.context = root_window; | 69 params.context = root_window; |
| 70 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 70 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 71 widget->Init(params); | 71 widget->Init(params); |
| 72 widget->SetOpacity(0xFF); | 72 widget->SetOpacity(0xFF); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 } // namespace | 134 } // namespace |
| 135 | 135 |
| 136 // View of the LongPressAffordanceHandler. Draws the actual contents and | 136 // View of the LongPressAffordanceHandler. Draws the actual contents and |
| 137 // updates as the animation proceeds. It also maintains the views::Widget that | 137 // updates as the animation proceeds. It also maintains the views::Widget that |
| 138 // the animation is shown in. | 138 // the animation is shown in. |
| 139 class LongPressAffordanceHandler::LongPressAffordanceView | 139 class LongPressAffordanceHandler::LongPressAffordanceView |
| 140 : public views::View { | 140 : public views::View { |
| 141 public: | 141 public: |
| 142 LongPressAffordanceView(const gfx::Point& event_location, | 142 LongPressAffordanceView(const gfx::Point& event_location, |
| 143 aura::RootWindow* root_window) | 143 aura::Window* root_window) |
| 144 : views::View(), | 144 : views::View(), |
| 145 widget_(CreateAffordanceWidget(root_window)), | 145 widget_(CreateAffordanceWidget(root_window)), |
| 146 current_angle_(kAffordanceAngleStartValue), | 146 current_angle_(kAffordanceAngleStartValue), |
| 147 current_scale_(kAffordanceScaleStartValue) { | 147 current_scale_(kAffordanceScaleStartValue) { |
| 148 widget_->SetContentsView(this); | 148 widget_->SetContentsView(this); |
| 149 widget_->SetAlwaysOnTop(true); | 149 widget_->SetAlwaysOnTop(true); |
| 150 | 150 |
| 151 // We are owned by the LongPressAffordance. | 151 // We are owned by the LongPressAffordance. |
| 152 set_owned_by_client(); | 152 set_owned_by_client(); |
| 153 gfx::Point point = event_location; | 153 gfx::Point point = event_location; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 // On all other touch and gesture events, we hide the animation. | 285 // On all other touch and gesture events, we hide the animation. |
| 286 StopAnimation(); | 286 StopAnimation(); |
| 287 break; | 287 break; |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 | 290 |
| 291 //////////////////////////////////////////////////////////////////////////////// | 291 //////////////////////////////////////////////////////////////////////////////// |
| 292 // LongPressAffordanceHandler, private | 292 // LongPressAffordanceHandler, private |
| 293 | 293 |
| 294 void LongPressAffordanceHandler::StartAnimation() { | 294 void LongPressAffordanceHandler::StartAnimation() { |
| 295 aura::RootWindow* root_window = NULL; | 295 aura::Window* root_window = NULL; |
| 296 switch (current_animation_type_) { | 296 switch (current_animation_type_) { |
| 297 case GROW_ANIMATION: | 297 case GROW_ANIMATION: |
| 298 root_window = Shell::GetInstance()->display_controller()-> | 298 root_window = Shell::GetInstance()->display_controller()-> |
| 299 GetRootWindowForDisplayId(tap_down_display_id_); | 299 GetRootWindowForDisplayId(tap_down_display_id_); |
| 300 if (!root_window) { | 300 if (!root_window) { |
| 301 StopAnimation(); | 301 StopAnimation(); |
| 302 return; | 302 return; |
| 303 } | 303 } |
| 304 view_.reset(new LongPressAffordanceView(tap_down_location_, root_window)); | 304 view_.reset(new LongPressAffordanceView(tap_down_location_, root_window)); |
| 305 SetDuration( | 305 SetDuration( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 default: | 366 default: |
| 367 view_.reset(); | 367 view_.reset(); |
| 368 tap_down_touch_id_ = -1; | 368 tap_down_touch_id_ = -1; |
| 369 tap_down_display_id_ = 0; | 369 tap_down_display_id_ = 0; |
| 370 break; | 370 break; |
| 371 } | 371 } |
| 372 } | 372 } |
| 373 | 373 |
| 374 } // namespace internal | 374 } // namespace internal |
| 375 } // namespace ash | 375 } // namespace ash |
| OLD | NEW |