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

Side by Side Diff: ash/wm/workspace/workspace_cycler.cc

Issue 12212040: Make the workspace cycler animation parameters editable via chrome://gesture (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes per sadrul Created 7 years, 10 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
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/workspace/workspace_cycler.h" 5 #include "ash/wm/workspace/workspace_cycler.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/workspace/workspace_cycler_configuration.h"
10 #include "ash/wm/workspace/workspace_manager.h" 11 #include "ash/wm/workspace/workspace_manager.h"
11 #include "ui/base/events/event.h" 12 #include "ui/base/events/event.h"
12 #include "ui/base/events/event_utils.h" 13 #include "ui/base/events/event_utils.h"
13 14
15 typedef ash::WorkspaceCyclerConfiguration Config;
16
14 namespace ash { 17 namespace ash {
15 namespace internal { 18 namespace internal {
16 19
17 namespace { 20 namespace {
18 21
19 // The required vertical distance to initiate workspace cycling.
20 const float kDistanceToInitiateWorkspaceCycling = 10.0f;
21
22 // Returns true if cycling is allowed. 22 // Returns true if cycling is allowed.
23 bool IsCyclingAllowed() { 23 bool IsCyclingAllowed() {
24 // Cycling is disabled if the screen is locked or a modal dialog is open. 24 // Cycling is disabled if the screen is locked or a modal dialog is open.
25 return !Shell::GetInstance()->IsScreenLocked() && 25 return !Shell::GetInstance()->IsScreenLocked() &&
26 !Shell::GetInstance()->IsSystemModalWindowOpen(); 26 !Shell::GetInstance()->IsSystemModalWindowOpen();
27 } 27 }
28 28
29 } // namespace 29 } // namespace
30 30
31 WorkspaceCycler::WorkspaceCycler(WorkspaceManager* workspace_manager) 31 WorkspaceCycler::WorkspaceCycler(WorkspaceManager* workspace_manager)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 if (ui::IsNaturalScrollEnabled()) { 130 if (ui::IsNaturalScrollEnabled()) {
131 scroll_x_ += event->x_offset(); 131 scroll_x_ += event->x_offset();
132 scroll_y_ += event->y_offset(); 132 scroll_y_ += event->y_offset();
133 } else { 133 } else {
134 scroll_x_ -= event->x_offset(); 134 scroll_x_ -= event->x_offset();
135 scroll_y_ -= event->y_offset(); 135 scroll_y_ -= event->y_offset();
136 } 136 }
137 137
138 if (state_ == NOT_CYCLING_TRACKING_SCROLL) { 138 if (state_ == NOT_CYCLING_TRACKING_SCROLL) {
139 if (fabs(scroll_x_) > kDistanceToInitiateWorkspaceCycling) { 139 double distance_to_initiate_cycling = Config::GetDouble(
140 Config::DISTANCE_TO_INITIATE_CYCLING);
141
142 if (fabs(scroll_x_) > distance_to_initiate_cycling) {
140 // Only initiate workspace cycling if there recently was a significant 143 // Only initiate workspace cycling if there recently was a significant
141 // amount of vertical movement as opposed to vertical movement 144 // amount of vertical movement as opposed to vertical movement
142 // accumulated over a long horizontal three finger scroll. 145 // accumulated over a long horizontal three finger scroll.
143 scroll_x_ = 0.0f; 146 scroll_x_ = 0.0f;
144 scroll_y_ = 0.0f; 147 scroll_y_ = 0.0f;
145 } 148 }
146 149
147 if (fabs(scroll_y_) >= kDistanceToInitiateWorkspaceCycling) 150 if (fabs(scroll_y_) >= distance_to_initiate_cycling)
148 SetState(STARTING_CYCLING); 151 SetState(STARTING_CYCLING);
149 } 152 }
150 153
151 if (state_ == CYCLING && event->y_offset() != 0.0f) { 154 if (state_ == CYCLING && event->y_offset() != 0.0f) {
152 DCHECK(animator_.get()); 155 DCHECK(animator_.get());
153 animator_->AnimateCyclingByScrollDelta(event->y_offset()); 156 animator_->AnimateCyclingByScrollDelta(event->y_offset());
154 event->SetHandled(); 157 event->SetHandled();
155 } 158 }
156 } 159 }
157 160
158 void WorkspaceCycler::StartWorkspaceCyclerAnimationFinished() { 161 void WorkspaceCycler::StartWorkspaceCyclerAnimationFinished() {
159 DCHECK_EQ(STARTING_CYCLING, state_); 162 DCHECK_EQ(STARTING_CYCLING, state_);
160 SetState(CYCLING); 163 SetState(CYCLING);
161 } 164 }
162 165
163 void WorkspaceCycler::StopWorkspaceCyclerAnimationFinished() { 166 void WorkspaceCycler::StopWorkspaceCyclerAnimationFinished() {
164 DCHECK_EQ(STOPPING_CYCLING, state_); 167 DCHECK_EQ(STOPPING_CYCLING, state_);
165 Workspace* workspace_to_activate = animator_->get_selected_workspace(); 168 Workspace* workspace_to_activate = animator_->get_selected_workspace();
166 animator_.reset(); 169 animator_.reset();
167 SetState(NOT_CYCLING); 170 SetState(NOT_CYCLING);
168 171
169 // Activate the workspace after updating the state so that a call to 172 // Activate the workspace after updating the state so that a call to
170 // AbortCycling() as a result of SetActiveWorkspaceFromCycler() is a noop. 173 // AbortCycling() as a result of SetActiveWorkspaceFromCycler() is a noop.
171 workspace_manager_->SetActiveWorkspaceFromCycler(workspace_to_activate); 174 workspace_manager_->SetActiveWorkspaceFromCycler(workspace_to_activate);
172 } 175 }
173 176
174 } // namespace internal 177 } // namespace internal
175 } // namespace ash 178 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698