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