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