blob: a1bf98ea8c8b96441459d1d8e60f971674979843 [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// 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.
4
5#include "ash/wm/status_area_layout_manager.h"
6
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +00007#include "ash/shelf/shelf_layout_manager.h"
8#include "ash/shelf/shelf_widget.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +00009#include "ash/system/status_area_widget.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000010#include "base/auto_reset.h"
11#include "ui/aura/window.h"
12#include "ui/views/widget/widget.h"
13
14namespace ash {
Torne (Richard Coles)58218062012-11-14 11:43:16 +000015
16////////////////////////////////////////////////////////////////////////////////
17// StatusAreaLayoutManager, public:
18
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000019StatusAreaLayoutManager::StatusAreaLayoutManager(ShelfWidget* shelf)
Torne (Richard Coles)58218062012-11-14 11:43:16 +000020 : in_layout_(false),
21 shelf_(shelf) {
22}
23
24StatusAreaLayoutManager::~StatusAreaLayoutManager() {
25}
26
27////////////////////////////////////////////////////////////////////////////////
28// StatusAreaLayoutManager, aura::LayoutManager implementation:
29
30void StatusAreaLayoutManager::OnWindowResized() {
31 LayoutStatusArea();
32}
33
34void StatusAreaLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
35}
36
37void StatusAreaLayoutManager::OnWillRemoveWindowFromLayout(
38 aura::Window* child) {
39}
40
41void StatusAreaLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
42}
43
44void StatusAreaLayoutManager::OnChildWindowVisibilityChanged(
45 aura::Window* child, bool visible) {
46}
47
48void StatusAreaLayoutManager::SetChildBounds(
49 aura::Window* child,
50 const gfx::Rect& requested_bounds) {
51 // Only need to have the shelf do a layout if the child changing is the status
52 // area and the shelf isn't in the process of doing a layout.
53 if (child != shelf_->status_area_widget()->GetNativeView() || in_layout_) {
54 SetChildBoundsDirect(child, requested_bounds);
55 return;
56 }
57
58 // If the size matches, no need to do anything. We don't check the location as
59 // that is managed by the shelf.
60 if (requested_bounds == child->bounds())
61 return;
62
63 SetChildBoundsDirect(child, requested_bounds);
64 LayoutStatusArea();
65}
66
67////////////////////////////////////////////////////////////////////////////////
68// StatusAreaLayoutManager, private:
69
70void StatusAreaLayoutManager::LayoutStatusArea() {
71 // Shelf layout manager may be already doing layout.
Torne (Richard Coles)3551c9c2013-08-23 16:39:15 +010072 if (shelf_->shelf_layout_manager()->updating_bounds())
Torne (Richard Coles)58218062012-11-14 11:43:16 +000073 return;
74
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000075 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
76 shelf_->shelf_layout_manager()->LayoutShelf();
Torne (Richard Coles)58218062012-11-14 11:43:16 +000077}
78
Torne (Richard Coles)58218062012-11-14 11:43:16 +000079} // namespace ash