Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: ash/wm/gestures/system_pinch_handler.cc

Issue 10937038: gesture recognizer: Recognizer rotation gestures. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/base/gestures/gesture_sequence.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <math.h>
8
7 #include "ash/launcher/launcher.h" 9 #include "ash/launcher/launcher.h"
8 #include "ash/screen_ash.h" 10 #include "ash/screen_ash.h"
9 #include "ash/shell.h" 11 #include "ash/shell.h"
10 #include "ash/wm/property_util.h" 12 #include "ash/wm/property_util.h"
11 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
12 #include "ash/wm/workspace/snap_sizer.h" 14 #include "ash/wm/workspace/snap_sizer.h"
13 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
14 #include "ui/base/events/event_constants.h" 16 #include "ui/base/events/event_constants.h"
15 #include "ui/base/gestures/gesture_types.h" 17 #include "ui/base/gestures/gesture_types.h"
16 #include "ui/compositor/scoped_layer_animation_settings.h" 18 #include "ui/compositor/scoped_layer_animation_settings.h"
(...skipping 24 matching lines...) Expand all
41 const ui::GestureEvent& event) { 43 const ui::GestureEvent& event) {
42 // The target has changed, somehow. Let's bale. 44 // The target has changed, somehow. Let's bale.
43 if (!widget_ || !widget_->widget_delegate()->CanResize()) 45 if (!widget_ || !widget_->widget_delegate()->CanResize())
44 return SYSTEM_GESTURE_END; 46 return SYSTEM_GESTURE_END;
45 47
46 switch (event.type()) { 48 switch (event.type()) {
47 case ui::ET_GESTURE_END: { 49 case ui::ET_GESTURE_END: {
48 if (event.details().touch_points() > kSystemGesturePoints) 50 if (event.details().touch_points() > kSystemGesturePoints)
49 break; 51 break;
50 52
53 target_->SetTransform(ui::Transform());
54
51 if (phantom_state_ == PHANTOM_WINDOW_MAXIMIZED) { 55 if (phantom_state_ == PHANTOM_WINDOW_MAXIMIZED) {
52 if (!wm::IsWindowMaximized(target_) && 56 if (!wm::IsWindowMaximized(target_) &&
53 !wm::IsWindowFullscreen(target_)) 57 !wm::IsWindowFullscreen(target_))
54 wm::MaximizeWindow(target_); 58 wm::MaximizeWindow(target_);
55 } else if (phantom_state_ == PHANTOM_WINDOW_MINIMIZED) { 59 } else if (phantom_state_ == PHANTOM_WINDOW_MINIMIZED) {
56 if (wm::IsWindowMaximized(target_) || 60 if (wm::IsWindowMaximized(target_) ||
57 wm::IsWindowFullscreen(target_)) { 61 wm::IsWindowFullscreen(target_)) {
58 wm::RestoreWindow(target_); 62 wm::RestoreWindow(target_);
59 } else { 63 } else {
60 wm::MinimizeWindow(target_); 64 wm::MinimizeWindow(target_);
61 65
62 // NOTE: Minimizing the window will cause this handler to be 66 // NOTE: Minimizing the window will cause this handler to be
63 // destroyed. So do not access anything from |this| from here. 67 // destroyed. So do not access anything from |this| from here.
64 return SYSTEM_GESTURE_END; 68 return SYSTEM_GESTURE_END;
65 } 69 }
66 } 70 }
67 return SYSTEM_GESTURE_END; 71 return SYSTEM_GESTURE_END;
68 } 72 }
69 73
70 case ui::ET_GESTURE_PINCH_UPDATE: { 74 case ui::ET_GESTURE_PINCH_UPDATE: {
71 // The PINCH_UPDATE events contain incremental scaling updates. 75 // The PINCH_UPDATE events contain incremental scaling updates.
72 pinch_factor_ *= event.details().scale(); 76 pinch_factor_ *= event.details().scale();
73 gfx::Rect bounds = 77 gfx::Rect bounds =
74 GetPhantomWindowScreenBounds(target_, event.location()); 78 GetPhantomWindowScreenBounds(target_, event.location());
75 if (phantom_state_ != PHANTOM_WINDOW_NORMAL || phantom_.IsShowing()) 79 if (phantom_state_ != PHANTOM_WINDOW_NORMAL || phantom_.IsShowing())
76 phantom_.Show(bounds, NULL); 80 phantom_.Show(bounds, NULL);
81
82 float rotation = event.details().rotation();
83 LOG(ERROR) << "Rotation: " << rotation;
84 ui::Transform transform = target_->layer()->transform();
85 transform.ConcatRotate(-rotation * 180 / M_PI);
86 target_->SetTransform(transform);
77 break; 87 break;
78 } 88 }
79 89
80 case ui::ET_GESTURE_MULTIFINGER_SWIPE: { 90 case ui::ET_GESTURE_MULTIFINGER_SWIPE: {
81 phantom_.Hide(); 91 phantom_.Hide();
82 pinch_factor_ = 1.0; 92 pinch_factor_ = 1.0;
83 phantom_state_ = PHANTOM_WINDOW_NORMAL; 93 phantom_state_ = PHANTOM_WINDOW_NORMAL;
84 94
85 if (event.details().swipe_left() || event.details().swipe_right()) { 95 if (event.details().swipe_left() || event.details().swipe_right()) {
86 // Snap for left/right swipes. In case the window is 96 // Snap for left/right swipes. In case the window is
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 phantom_state_ = PHANTOM_WINDOW_MINIMIZED; 155 phantom_state_ = PHANTOM_WINDOW_MINIMIZED;
146 return rect; 156 return rect;
147 } 157 }
148 158
149 phantom_state_ = PHANTOM_WINDOW_NORMAL; 159 phantom_state_ = PHANTOM_WINDOW_NORMAL;
150 return window->bounds(); 160 return window->bounds();
151 } 161 }
152 162
153 } // namespace internal 163 } // namespace internal
154 } // namespace ash 164 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/base/gestures/gesture_sequence.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698