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
3 // found in the LICENSE file.
5 #include "ash/wm/status_area_layout_manager.h"
7 #include "ash/shelf/shelf_layout_manager.h"
8 #include "ash/shelf/shelf_widget.h"
9 #include "ash/system/status_area_widget.h"
10 #include "base/auto_reset.h"
11 #include "ui/aura/window.h"
12 #include "ui/views/widget/widget.h"
17 ////////////////////////////////////////////////////////////////////////////////
18 // StatusAreaLayoutManager, public:
20 StatusAreaLayoutManager::StatusAreaLayoutManager(ShelfWidget
* shelf
)
25 StatusAreaLayoutManager::~StatusAreaLayoutManager() {
28 ////////////////////////////////////////////////////////////////////////////////
29 // StatusAreaLayoutManager, aura::LayoutManager implementation:
31 void StatusAreaLayoutManager::OnWindowResized() {
35 void StatusAreaLayoutManager::OnWindowAddedToLayout(aura::Window
* child
) {
38 void StatusAreaLayoutManager::OnWillRemoveWindowFromLayout(
39 aura::Window
* child
) {
42 void StatusAreaLayoutManager::OnWindowRemovedFromLayout(aura::Window
* child
) {
45 void StatusAreaLayoutManager::OnChildWindowVisibilityChanged(
46 aura::Window
* child
, bool visible
) {
49 void StatusAreaLayoutManager::SetChildBounds(
51 const gfx::Rect
& requested_bounds
) {
52 // Only need to have the shelf do a layout if the child changing is the status
53 // area and the shelf isn't in the process of doing a layout.
54 if (child
!= shelf_
->status_area_widget()->GetNativeView() || in_layout_
) {
55 SetChildBoundsDirect(child
, requested_bounds
);
59 // If the size matches, no need to do anything. We don't check the location as
60 // that is managed by the shelf.
61 if (requested_bounds
== child
->bounds())
64 SetChildBoundsDirect(child
, requested_bounds
);
68 ////////////////////////////////////////////////////////////////////////////////
69 // StatusAreaLayoutManager, private:
71 void StatusAreaLayoutManager::LayoutStatusArea() {
72 // Shelf layout manager may be already doing layout.
73 if (shelf_
->shelf_layout_manager()->updating_bounds())
76 base::AutoReset
<bool> auto_reset_in_layout(&in_layout_
, true);
77 shelf_
->shelf_layout_manager()->LayoutShelf();
80 } // namespace internal