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

Side by Side Diff: ui/aura_shell/workspace/workspace.cc

Issue 8399027: Makes overview center the active workspace. This avoids leaving extra (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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) 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 4
5 #include "ui/aura_shell/workspace/workspace.h" 5 #include "ui/aura_shell/workspace/workspace.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/aura/window.h" 8 #include "ui/aura/window.h"
9 #include "ui/aura_shell/workspace/workspace_manager.h" 9 #include "ui/aura_shell/workspace/workspace_manager.h"
10 #include "ui/gfx/compositor/layer.h" 10 #include "ui/gfx/compositor/layer.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 return true; 54 return true;
55 } 55 }
56 56
57 void Workspace::RemoveWindow(aura::Window* window) { 57 void Workspace::RemoveWindow(aura::Window* window) {
58 DCHECK(Contains(window)); 58 DCHECK(Contains(window));
59 windows_.erase(std::find(windows_.begin(), windows_.end(), window)); 59 windows_.erase(std::find(windows_.begin(), windows_.end(), window));
60 Layout(NULL); 60 Layout(NULL);
61 } 61 }
62 62
63
64 bool Workspace::Contains(aura::Window* window) const { 63 bool Workspace::Contains(aura::Window* window) const {
65 return std::find(windows_.begin(), windows_.end(), window) != windows_.end(); 64 return std::find(windows_.begin(), windows_.end(), window) != windows_.end();
66 } 65 }
67 66
68 void Workspace::Activate() { 67 void Workspace::Activate() {
69 workspace_manager_->SetActiveWorkspace(this); 68 workspace_manager_->SetActiveWorkspace(this);
70 } 69 }
71 70
72 void Workspace::Layout(aura::Window* no_animation) { 71 void Workspace::Layout(aura::Window* no_animation) {
73 gfx::Rect work_area = workspace_manager_->GetWorkAreaBounds(bounds_); 72 gfx::Rect work_area = workspace_manager_->GetWorkAreaBounds(bounds_);
74 int total_width = 0; 73 int total_width = 0;
75 for (aura::Window::Windows::const_iterator i = windows_.begin(); 74 for (aura::Window::Windows::const_iterator i = windows_.begin();
76 i != windows_.end(); 75 i != windows_.end();
77 i++) { 76 ++i) {
78 if (total_width) 77 if (total_width)
79 total_width += kWindowHorizontalMargin; 78 total_width += kWindowHorizontalMargin;
80 // TODO(oshima): use restored bounds. 79 // TODO(oshima): use restored bounds.
81 total_width += (*i)->bounds().width(); 80 total_width += (*i)->bounds().width();
82 } 81 }
83 82
84 if (total_width < work_area.width()) { 83 if (total_width < work_area.width()) {
85 int dx = (work_area.width() - total_width) / 2; 84 int dx = (work_area.width() - total_width) / 2;
86 for (aura::Window::Windows::iterator i = windows_.begin(); 85 for (aura::Window::Windows::iterator i = windows_.begin();
87 i != windows_.end(); 86 i != windows_.end();
88 i++) { 87 ++i) {
89 MoveWindowTo(*i, 88 MoveWindowTo(*i,
90 gfx::Point(work_area.x() + dx, work_area.y()), 89 gfx::Point(work_area.x() + dx, work_area.y()),
91 no_animation != *i); 90 no_animation != *i);
92 dx += (*i)->bounds().width() + kWindowHorizontalMargin; 91 dx += (*i)->bounds().width() + kWindowHorizontalMargin;
93 } 92 }
94 } else { 93 } else {
95 DCHECK_LT(windows_.size(), 3U); 94 DCHECK_LT(windows_.size(), 3U);
96 // TODO(oshima): Figure out general algorithm to layout more than 95 // TODO(oshima): Figure out general algorithm to layout more than
97 // 2 windows. 96 // 2 windows.
98 MoveWindowTo(windows_[0], work_area.origin(), no_animation != windows_[0]); 97 MoveWindowTo(windows_[0], work_area.origin(), no_animation != windows_[0]);
(...skipping 30 matching lines...) Expand all
129 else { 128 else {
130 gfx::Rect bounds = window->GetTargetBounds(); 129 gfx::Rect bounds = window->GetTargetBounds();
131 bounds.set_origin(origin); 130 bounds.set_origin(origin);
132 if (animate) 131 if (animate)
133 window->layer()->SetAnimation(aura::Window::CreateDefaultAnimation()); 132 window->layer()->SetAnimation(aura::Window::CreateDefaultAnimation());
134 window->SetBounds(bounds); 133 window->SetBounds(bounds);
135 } 134 }
136 } 135 }
137 136
138 } // namespace aura_shell 137 } // namespace aura_shell
OLDNEW
« no previous file with comments | « no previous file | ui/aura_shell/workspace/workspace_manager.cc » ('j') | ui/aura_shell/workspace/workspace_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698