| OLD | NEW |
| (Empty) |
| 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/common/system/status_area_widget.h" | |
| 8 #include "ash/common/wm_lookup.h" | |
| 9 #include "ash/common/wm_window.h" | |
| 10 #include "ash/shelf/shelf_layout_manager.h" | |
| 11 #include "ash/shelf/shelf_widget.h" | |
| 12 #include "base/auto_reset.h" | |
| 13 | |
| 14 namespace ash { | |
| 15 | |
| 16 //////////////////////////////////////////////////////////////////////////////// | |
| 17 // StatusAreaLayoutManager, public: | |
| 18 | |
| 19 StatusAreaLayoutManager::StatusAreaLayoutManager(ShelfWidget* shelf_widget) | |
| 20 : in_layout_(false), shelf_widget_(shelf_widget) {} | |
| 21 | |
| 22 StatusAreaLayoutManager::~StatusAreaLayoutManager() {} | |
| 23 | |
| 24 //////////////////////////////////////////////////////////////////////////////// | |
| 25 // StatusAreaLayoutManager, aura::LayoutManager implementation: | |
| 26 | |
| 27 void StatusAreaLayoutManager::OnWindowResized() { | |
| 28 LayoutStatusArea(); | |
| 29 } | |
| 30 | |
| 31 void StatusAreaLayoutManager::SetChildBounds( | |
| 32 WmWindow* child, | |
| 33 const gfx::Rect& requested_bounds) { | |
| 34 // Only need to have the shelf do a layout if the child changing is the status | |
| 35 // area and the shelf isn't in the process of doing a layout. | |
| 36 if (child != | |
| 37 WmLookup::Get()->GetWindowForWidget( | |
| 38 shelf_widget_->status_area_widget()) || | |
| 39 in_layout_) { | |
| 40 wm::WmSnapToPixelLayoutManager::SetChildBounds(child, requested_bounds); | |
| 41 return; | |
| 42 } | |
| 43 | |
| 44 // If the bounds match, no need to do anything. Check for target bounds to | |
| 45 // ensure any active animation is retargeted. | |
| 46 if (requested_bounds == child->GetTargetBounds()) | |
| 47 return; | |
| 48 | |
| 49 wm::WmSnapToPixelLayoutManager::SetChildBounds(child, requested_bounds); | |
| 50 LayoutStatusArea(); | |
| 51 } | |
| 52 | |
| 53 //////////////////////////////////////////////////////////////////////////////// | |
| 54 // StatusAreaLayoutManager, private: | |
| 55 | |
| 56 void StatusAreaLayoutManager::LayoutStatusArea() { | |
| 57 // Shelf layout manager may be already doing layout. | |
| 58 if (shelf_widget_->shelf_layout_manager()->updating_bounds()) | |
| 59 return; | |
| 60 | |
| 61 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | |
| 62 shelf_widget_->shelf_layout_manager()->LayoutShelf(); | |
| 63 } | |
| 64 | |
| 65 } // namespace ash | |
| OLD | NEW |