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 | 4 |
5 #include "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 void Window::SetParent(Window* parent) { | 177 void Window::SetParent(Window* parent) { |
178 if (parent) | 178 if (parent) |
179 parent->AddChild(this); | 179 parent->AddChild(this); |
180 else if (Desktop::GetInstance()->stacking_client()) | 180 else if (Desktop::GetInstance()->stacking_client()) |
181 Desktop::GetInstance()->stacking_client()->AddChildToDefaultParent(this); | 181 Desktop::GetInstance()->stacking_client()->AddChildToDefaultParent(this); |
182 else | 182 else |
183 NOTREACHED(); | 183 NOTREACHED(); |
184 } | 184 } |
185 | 185 |
186 void Window::MoveChildToFront(Window* child) { | 186 void Window::StackChildAtTop(Window* child) { |
187 if (children_.size() <= 1 || child == children_.back()) | 187 if (children_.size() <= 1 || child == children_.back()) |
188 return; // In the front already. | 188 return; // In the front already. |
189 MoveChildAbove(child, children_.back()); | 189 StackChildAbove(child, children_.back()); |
190 } | 190 } |
191 | 191 |
192 void Window::MoveChildAbove(Window* child, Window* other) { | 192 void Window::StackChildAbove(Window* child, Window* other) { |
193 DCHECK_NE(child, other); | 193 DCHECK_NE(child, other); |
194 DCHECK(child); | 194 DCHECK(child); |
195 DCHECK(other); | 195 DCHECK(other); |
196 DCHECK_EQ(this, child->parent()); | 196 DCHECK_EQ(this, child->parent()); |
197 DCHECK_EQ(this, other->parent()); | 197 DCHECK_EQ(this, other->parent()); |
198 | 198 |
199 size_t child_i = | 199 size_t child_i = |
200 std::find(children_.begin(), children_.end(), child) - children_.begin(); | 200 std::find(children_.begin(), children_.end(), child) - children_.begin(); |
201 size_t other_i = | 201 size_t other_i = |
202 std::find(children_.begin(), children_.end(), other) - children_.begin(); | 202 std::find(children_.begin(), children_.end(), other) - children_.begin(); |
203 if (child_i > other_i) | 203 if (child_i > other_i) |
204 return; // Already in front of |other|. | 204 return; // Already in front of |other|. |
205 | 205 |
206 // Reorder children. | 206 // Reorder children. |
207 children_.erase(children_.begin() + child_i); | 207 children_.erase(children_.begin() + child_i); |
208 children_.insert(children_.begin() + other_i, child); | 208 children_.insert(children_.begin() + other_i, child); |
209 | 209 |
210 // Reorder the layer. | 210 // Reorder the layer. |
211 layer()->MoveAbove(child->layer(), other->layer()); | 211 layer()->StackAbove(child->layer(), other->layer()); |
212 | 212 |
213 // Move any transient children that share the same parent to be in front of | 213 // Stack any transient children that share the same parent to be in front of |
214 // 'child'. | 214 // 'child'. |
215 Window* last_transient = child; | 215 Window* last_transient = child; |
216 for (Windows::iterator i = child->transient_children_.begin(); | 216 for (Windows::iterator i = child->transient_children_.begin(); |
217 i != child->transient_children_.end(); ++i) { | 217 i != child->transient_children_.end(); ++i) { |
218 Window* transient_child = *i; | 218 Window* transient_child = *i; |
219 if (transient_child->parent_ == this) { | 219 if (transient_child->parent_ == this) { |
220 MoveChildAbove(transient_child, last_transient); | 220 StackChildAbove(transient_child, last_transient); |
221 last_transient = transient_child; | 221 last_transient = transient_child; |
222 } | 222 } |
223 } | 223 } |
224 | 224 |
225 child->OnStackingChanged(); | 225 child->OnStackingChanged(); |
226 } | 226 } |
227 | 227 |
228 bool Window::CanActivate() const { | 228 bool Window::CanActivate() const { |
229 return IsVisible() && (!delegate_ || delegate_->ShouldActivate(NULL)); | 229 return IsVisible() && (!delegate_ || delegate_->ShouldActivate(NULL)); |
230 } | 230 } |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 void Window::OnStackingChanged() { | 533 void Window::OnStackingChanged() { |
534 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowStackingChanged(this)); | 534 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowStackingChanged(this)); |
535 } | 535 } |
536 | 536 |
537 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 537 void Window::OnPaintLayer(gfx::Canvas* canvas) { |
538 if (delegate_) | 538 if (delegate_) |
539 delegate_->OnPaint(canvas); | 539 delegate_->OnPaint(canvas); |
540 } | 540 } |
541 | 541 |
542 } // namespace aura | 542 } // namespace aura |
OLD | NEW |