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. 4 5 #include "ash/wm/status_area_layout_manager.h" 6 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" 13 14 namespace ash { 15 namespace internal { 16 17 //////////////////////////////////////////////////////////////////////////////// 18 // StatusAreaLayoutManager, public: 19 20 StatusAreaLayoutManager::StatusAreaLayoutManager(ShelfWidget* shelf) 21 : in_layout_(false), 22 shelf_(shelf) { 23 } 24 25 StatusAreaLayoutManager::~StatusAreaLayoutManager() { 26 } 27 28 //////////////////////////////////////////////////////////////////////////////// 29 // StatusAreaLayoutManager, aura::LayoutManager implementation: 30 31 void StatusAreaLayoutManager::OnWindowResized() { 32 LayoutStatusArea(); 33 } 34 35 void StatusAreaLayoutManager::OnWindowAddedToLayout(aura::Window* child) { 36 } 37 38 void StatusAreaLayoutManager::OnWillRemoveWindowFromLayout( 39 aura::Window* child) { 40 } 41 42 void StatusAreaLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { 43 } 44 45 void StatusAreaLayoutManager::OnChildWindowVisibilityChanged( 46 aura::Window* child, bool visible) { 47 } 48 49 void StatusAreaLayoutManager::SetChildBounds( 50 aura::Window* child, 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); 56 return; 57 } 58 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()) 62 return; 63 64 SetChildBoundsDirect(child, requested_bounds); 65 LayoutStatusArea(); 66 } 67 68 //////////////////////////////////////////////////////////////////////////////// 69 // StatusAreaLayoutManager, private: 70 71 void StatusAreaLayoutManager::LayoutStatusArea() { 72 // Shelf layout manager may be already doing layout. 73 if (shelf_->shelf_layout_manager()->updating_bounds()) 74 return; 75 76 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 77 shelf_->shelf_layout_manager()->LayoutShelf(); 78 } 79 80 } // namespace internal 81 } // namespace ash 82