OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "ui/aura_shell/workspace/workspace_manager.h" | 4 #include "ui/aura_shell/workspace/workspace_manager.h" |
5 | 5 |
6 #include <algorithm> | 6 #include <algorithm> |
7 | 7 |
8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
9 #include "ui/aura/desktop.h" | 9 #include "ui/aura/desktop.h" |
10 #include "ui/aura/screen_aura.h" | 10 #include "ui/aura/screen_aura.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 } | 85 } |
86 | 86 |
87 gfx::Rect WorkspaceManager::GetDragAreaBounds() { | 87 gfx::Rect WorkspaceManager::GetDragAreaBounds() { |
88 return GetWorkAreaBounds(gfx::Rect(viewport_->bounds().size())); | 88 return GetWorkAreaBounds(gfx::Rect(viewport_->bounds().size())); |
89 } | 89 } |
90 | 90 |
91 void WorkspaceManager::SetOverview(bool overview) { | 91 void WorkspaceManager::SetOverview(bool overview) { |
92 if (is_overview_ == overview) | 92 if (is_overview_ == overview) |
93 return; | 93 return; |
94 is_overview_ = overview; | 94 is_overview_ = overview; |
95 gfx::Rect bounds = viewport_->GetTargetBounds(); | |
96 | 95 |
97 ui::Transform transform; | 96 ui::Transform transform; |
98 if (is_overview_) { | 97 if (is_overview_) { |
99 // TODO(oshima|sky): We limit the how small windows can be shrinked | 98 // TODO(oshima|sky): We limit the how small windows can be shrinked |
100 // in overview mode, thus part of the viewport may not be visible. | 99 // in overview mode, thus part of the viewport may not be visible. |
101 // We need to add capability to scroll/move viewport in overview mode. | 100 // We need to add capability to scroll/move viewport in overview mode. |
102 float scale = std::min( | 101 float scale = std::min( |
103 kMaxOverviewScale, | 102 kMaxOverviewScale, |
104 workspace_size_.width() / | 103 workspace_size_.width() / |
105 static_cast<float>(viewport_->bounds().width())); | 104 static_cast<float>(viewport_->bounds().width())); |
106 scale = std::max(kMinOverviewScale, scale); | 105 scale = std::max(kMinOverviewScale, scale); |
107 | 106 |
108 transform.SetScale(scale, scale); | 107 transform.SetScale(scale, scale); |
109 | 108 |
110 int overview_width = viewport_->bounds().width() * scale; | 109 int overview_width = viewport_->bounds().width() * scale; |
111 int dx = overview_width < workspace_size_.width() ? | 110 int dx = 0; |
112 (workspace_size_.width() - overview_width) / 2 : 0; | 111 if (overview_width < workspace_size_.width()) { |
112 dx = (workspace_size_.width() - overview_width) / 2; | |
113 } else if (active_workspace_) { | |
114 // Center the active workspace. | |
115 int active_workspace_mid_x = (active_workspace_->bounds().x() + | |
116 active_workspace_->bounds().width() / 2) * scale; | |
117 dx = workspace_size_.width() / 2 - active_workspace_mid_x; | |
118 dx = std::min(0, std::max(dx, workspace_size_.width() - overview_width)); | |
119 } | |
113 | 120 |
114 transform.SetTranslateX(-viewport_->GetTargetBounds().x() + dx); | 121 transform.SetTranslateX(-viewport_->GetTargetBounds().x() + dx); |
oshima
2011/10/27 08:43:05
can you remove -viewport->GetTargetBounds().x().?
| |
115 transform.SetTranslateY(workspace_size_.height() * (1.0f - scale) / 2); | 122 transform.SetTranslateY(workspace_size_.height() * (1.0f - scale) / 2); |
116 } else { | 123 } else { |
117 transform.SetTranslateX(-active_workspace_->bounds().x()); | 124 transform.SetTranslateX(-active_workspace_->bounds().x()); |
118 } | 125 } |
119 | 126 |
120 viewport_->layer()->SetAnimation(aura::Window::CreateDefaultAnimation()); | 127 viewport_->layer()->SetAnimation(aura::Window::CreateDefaultAnimation()); |
121 viewport_->layer()->SetTransform(transform); | 128 viewport_->layer()->SetTransform(transform); |
122 } | 129 } |
123 | 130 |
124 //////////////////////////////////////////////////////////////////////////////// | 131 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 // Move to active workspace. | 198 // Move to active workspace. |
192 if (active_workspace_) { | 199 if (active_workspace_) { |
193 ui::Transform transform; | 200 ui::Transform transform; |
194 transform.SetTranslateX(-active_workspace_->bounds().x()); | 201 transform.SetTranslateX(-active_workspace_->bounds().x()); |
195 viewport_->layer()->SetAnimation(aura::Window::CreateDefaultAnimation()); | 202 viewport_->layer()->SetAnimation(aura::Window::CreateDefaultAnimation()); |
196 viewport_->SetTransform(transform); | 203 viewport_->SetTransform(transform); |
197 } | 204 } |
198 } | 205 } |
199 | 206 |
200 } // namespace aura_shell | 207 } // namespace aura_shell |
OLD | NEW |