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