| 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/system_pinch_handler.h" | 5 #include "ash/wm/gestures/system_pinch_handler.h" |
| 6 | 6 |
| 7 #include "ash/screen_ash.h" | 7 #include "ash/screen_ash.h" |
| 8 #include "ash/shelf/shelf.h" | 8 #include "ash/shelf/shelf.h" |
| 9 #include "ash/shelf/shelf_widget.h" | 9 #include "ash/shelf/shelf_widget.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 const double kPinchThresholdForMaximize = 1.5; | 23 const double kPinchThresholdForMaximize = 1.5; |
| 24 const double kPinchThresholdForMinimize = 0.7; | 24 const double kPinchThresholdForMinimize = 0.7; |
| 25 | 25 |
| 26 namespace ash { | 26 namespace ash { |
| 27 namespace internal { | 27 namespace internal { |
| 28 | 28 |
| 29 const int SystemPinchHandler::kSystemGesturePoints = 4; | 29 const int SystemPinchHandler::kSystemGesturePoints = 4; |
| 30 | 30 |
| 31 SystemPinchHandler::SystemPinchHandler(aura::Window* target) | 31 SystemPinchHandler::SystemPinchHandler(aura::Window* target) |
| 32 : target_(target), | 32 : target_(target), |
| 33 phantom_(target), |
| 33 phantom_state_(PHANTOM_WINDOW_NORMAL), | 34 phantom_state_(PHANTOM_WINDOW_NORMAL), |
| 34 pinch_factor_(1.) { | 35 pinch_factor_(1.) { |
| 35 widget_ = views::Widget::GetWidgetForNativeWindow(target_); | 36 widget_ = views::Widget::GetWidgetForNativeWindow(target_); |
| 36 } | 37 } |
| 37 | 38 |
| 38 SystemPinchHandler::~SystemPinchHandler() { | 39 SystemPinchHandler::~SystemPinchHandler() { |
| 39 } | 40 } |
| 40 | 41 |
| 41 SystemGestureStatus SystemPinchHandler::ProcessGestureEvent( | 42 SystemGestureStatus SystemPinchHandler::ProcessGestureEvent( |
| 42 const ui::GestureEvent& event) { | 43 const ui::GestureEvent& event) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 64 } | 65 } |
| 65 } | 66 } |
| 66 return SYSTEM_GESTURE_END; | 67 return SYSTEM_GESTURE_END; |
| 67 } | 68 } |
| 68 | 69 |
| 69 case ui::ET_GESTURE_PINCH_UPDATE: { | 70 case ui::ET_GESTURE_PINCH_UPDATE: { |
| 70 // The PINCH_UPDATE events contain incremental scaling updates. | 71 // The PINCH_UPDATE events contain incremental scaling updates. |
| 71 pinch_factor_ *= event.details().scale(); | 72 pinch_factor_ *= event.details().scale(); |
| 72 gfx::Rect bounds = | 73 gfx::Rect bounds = |
| 73 GetPhantomWindowScreenBounds(target_, event.location()); | 74 GetPhantomWindowScreenBounds(target_, event.location()); |
| 74 if (phantom_state_ != PHANTOM_WINDOW_NORMAL || phantom_.get()) { | 75 if (phantom_state_ != PHANTOM_WINDOW_NORMAL || phantom_.IsShowing()) |
| 75 if (!phantom_.get()) | 76 phantom_.Show(bounds); |
| 76 phantom_.reset(new internal::PhantomWindowController(target_)); | |
| 77 phantom_->Show(bounds); | |
| 78 } | |
| 79 break; | 77 break; |
| 80 } | 78 } |
| 81 | 79 |
| 82 case ui::ET_GESTURE_MULTIFINGER_SWIPE: { | 80 case ui::ET_GESTURE_MULTIFINGER_SWIPE: { |
| 83 phantom_.reset(); | 81 phantom_.Hide(); |
| 84 pinch_factor_ = 1.0; | 82 pinch_factor_ = 1.0; |
| 85 phantom_state_ = PHANTOM_WINDOW_NORMAL; | 83 phantom_state_ = PHANTOM_WINDOW_NORMAL; |
| 86 | 84 |
| 87 if (event.details().swipe_left() || event.details().swipe_right()) { | 85 if (event.details().swipe_left() || event.details().swipe_right()) { |
| 88 // Snap for left/right swipes. | 86 // Snap for left/right swipes. |
| 89 ui::ScopedLayerAnimationSettings settings( | 87 ui::ScopedLayerAnimationSettings settings( |
| 90 target_->layer()->GetAnimator()); | 88 target_->layer()->GetAnimator()); |
| 91 internal::SnapSizer::SnapWindow(window_state, | 89 internal::SnapSizer::SnapWindow(window_state, |
| 92 event.details().swipe_left() ? internal::SnapSizer::LEFT_EDGE : | 90 event.details().swipe_left() ? internal::SnapSizer::LEFT_EDGE : |
| 93 internal::SnapSizer::RIGHT_EDGE); | 91 internal::SnapSizer::RIGHT_EDGE); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 phantom_state_ = PHANTOM_WINDOW_MINIMIZED; | 133 phantom_state_ = PHANTOM_WINDOW_MINIMIZED; |
| 136 return rect; | 134 return rect; |
| 137 } | 135 } |
| 138 | 136 |
| 139 phantom_state_ = PHANTOM_WINDOW_NORMAL; | 137 phantom_state_ = PHANTOM_WINDOW_NORMAL; |
| 140 return window->bounds(); | 138 return window->bounds(); |
| 141 } | 139 } |
| 142 | 140 |
| 143 } // namespace internal | 141 } // namespace internal |
| 144 } // namespace ash | 142 } // namespace ash |
| OLD | NEW |