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

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: 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
« no previous file with comments | « ash/ash.gyp ('k') | ash/wm/workspace/workspace_cycler_animator.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/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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 if (ui::IsNaturalScrollEnabled()) { 127 if (ui::IsNaturalScrollEnabled()) {
128 scroll_x_ += event->x_offset(); 128 scroll_x_ += event->x_offset();
129 scroll_y_ += event->y_offset(); 129 scroll_y_ += event->y_offset();
130 } else { 130 } else {
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 } 133 }
134 134
135 if (state_ == NOT_CYCLING_TRACKING_SCROLL) { 135 if (state_ == NOT_CYCLING_TRACKING_SCROLL) {
136 if (fabs(scroll_x_) > kDistanceToInitiateWorkspaceCycling) { 136 double distance_to_initiate_cycling = Config::GetDouble(
137 Config::DISTANCE_TO_INITIATE_CYCLING);
138
139 if (fabs(scroll_x_) > distance_to_initiate_cycling) {
137 // Only initiate workspace cycling if there recently was a significant 140 // Only initiate workspace cycling if there recently was a significant
138 // amount of vertical movement as opposed to vertical movement 141 // amount of vertical movement as opposed to vertical movement
139 // accumulated over a long horizontal three finger scroll. 142 // accumulated over a long horizontal three finger scroll.
140 scroll_x_ = 0.0f; 143 scroll_x_ = 0.0f;
141 scroll_y_ = 0.0f; 144 scroll_y_ = 0.0f;
142 } 145 }
143 146
144 if (fabs(scroll_y_) >= kDistanceToInitiateWorkspaceCycling) 147 if (fabs(scroll_y_) >= distance_to_initiate_cycling)
145 SetState(STARTING_CYCLING); 148 SetState(STARTING_CYCLING);
146 } 149 }
147 150
148 if (state_ == CYCLING && event->y_offset() != 0.0f) { 151 if (state_ == CYCLING && event->y_offset() != 0.0f) {
149 DCHECK(animator_.get()); 152 DCHECK(animator_.get());
150 animator_->AnimateCyclingByScrollDelta(event->y_offset()); 153 animator_->AnimateCyclingByScrollDelta(event->y_offset());
151 event->SetHandled(); 154 event->SetHandled();
152 } 155 }
153 } 156 }
154 157
155 void WorkspaceCycler::StartWorkspaceCyclerAnimationFinished() { 158 void WorkspaceCycler::StartWorkspaceCyclerAnimationFinished() {
156 DCHECK_EQ(STARTING_CYCLING, state_); 159 DCHECK_EQ(STARTING_CYCLING, state_);
157 SetState(CYCLING); 160 SetState(CYCLING);
158 } 161 }
159 162
160 void WorkspaceCycler::StopWorkspaceCyclerAnimationFinished() { 163 void WorkspaceCycler::StopWorkspaceCyclerAnimationFinished() {
161 DCHECK_EQ(STOPPING_CYCLING, state_); 164 DCHECK_EQ(STOPPING_CYCLING, state_);
162 Workspace* workspace_to_activate = animator_->get_selected_workspace(); 165 Workspace* workspace_to_activate = animator_->get_selected_workspace();
163 animator_.reset(); 166 animator_.reset();
164 SetState(NOT_CYCLING); 167 SetState(NOT_CYCLING);
165 168
166 // Activate the workspace after updating the state so that a call to 169 // Activate the workspace after updating the state so that a call to
167 // AbortCycling() as a result of SetActiveWorkspaceFromCycler() is a noop. 170 // AbortCycling() as a result of SetActiveWorkspaceFromCycler() is a noop.
168 workspace_manager_->SetActiveWorkspaceFromCycler(workspace_to_activate); 171 workspace_manager_->SetActiveWorkspaceFromCycler(workspace_to_activate);
169 } 172 }
170 173
171 } // namespace internal 174 } // namespace internal
172 } // namespace ash 175 } // namespace ash
OLDNEW
« no previous file with comments | « ash/ash.gyp ('k') | ash/wm/workspace/workspace_cycler_animator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698