| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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/aura/aura_layout_manager_adapter.h" | |
| 6 | |
| 7 #include "ash/wm_layout_manager.h" | |
| 8 #include "ash/wm_window.h" | |
| 9 #include "ui/aura/window.h" | |
| 10 #include "ui/base/class_property.h" | |
| 11 | |
| 12 DECLARE_UI_CLASS_PROPERTY_TYPE(ash::AuraLayoutManagerAdapter*); | |
| 13 | |
| 14 namespace ash { | |
| 15 namespace { | |
| 16 // AuraLayoutManagerAdapter is an aura::LayoutManager, so it's owned by the | |
| 17 // aura::Window it is installed on. This property is used to lookup the | |
| 18 // AuraLayoutManagerAdapter given only an aura::Window. | |
| 19 DEFINE_UI_CLASS_PROPERTY_KEY(AuraLayoutManagerAdapter*, | |
| 20 kAuraLayoutManagerAdapter, | |
| 21 nullptr); | |
| 22 } // namespace | |
| 23 | |
| 24 AuraLayoutManagerAdapter::AuraLayoutManagerAdapter( | |
| 25 aura::Window* window, | |
| 26 std::unique_ptr<WmLayoutManager> wm_layout_manager) | |
| 27 : window_(window), wm_layout_manager_(std::move(wm_layout_manager)) { | |
| 28 window->SetProperty(kAuraLayoutManagerAdapter, this); | |
| 29 } | |
| 30 | |
| 31 AuraLayoutManagerAdapter::~AuraLayoutManagerAdapter() { | |
| 32 // Only one AuraLayoutManagerAdapter is created per window at a time, so this | |
| 33 // AuraLayoutManagerAdapter should be the installed AuraLayoutManagerAdapter. | |
| 34 DCHECK_EQ(this, window_->GetProperty(kAuraLayoutManagerAdapter)); | |
| 35 window_->ClearProperty(kAuraLayoutManagerAdapter); | |
| 36 } | |
| 37 | |
| 38 // static | |
| 39 AuraLayoutManagerAdapter* AuraLayoutManagerAdapter::Get(aura::Window* window) { | |
| 40 return window->GetProperty(kAuraLayoutManagerAdapter); | |
| 41 } | |
| 42 | |
| 43 void AuraLayoutManagerAdapter::OnWindowResized() { | |
| 44 wm_layout_manager_->OnWindowResized(); | |
| 45 } | |
| 46 | |
| 47 void AuraLayoutManagerAdapter::OnWindowAddedToLayout(aura::Window* child) { | |
| 48 wm_layout_manager_->OnWindowAddedToLayout(WmWindow::Get(child)); | |
| 49 } | |
| 50 | |
| 51 void AuraLayoutManagerAdapter::OnWillRemoveWindowFromLayout( | |
| 52 aura::Window* child) { | |
| 53 wm_layout_manager_->OnWillRemoveWindowFromLayout(WmWindow::Get(child)); | |
| 54 } | |
| 55 | |
| 56 void AuraLayoutManagerAdapter::OnWindowRemovedFromLayout(aura::Window* child) { | |
| 57 wm_layout_manager_->OnWindowRemovedFromLayout(WmWindow::Get(child)); | |
| 58 } | |
| 59 | |
| 60 void AuraLayoutManagerAdapter::OnChildWindowVisibilityChanged( | |
| 61 aura::Window* child, | |
| 62 bool visible) { | |
| 63 wm_layout_manager_->OnChildWindowVisibilityChanged(WmWindow::Get(child), | |
| 64 visible); | |
| 65 } | |
| 66 | |
| 67 void AuraLayoutManagerAdapter::SetChildBounds( | |
| 68 aura::Window* child, | |
| 69 const gfx::Rect& requested_bounds) { | |
| 70 wm_layout_manager_->SetChildBounds(WmWindow::Get(child), requested_bounds); | |
| 71 } | |
| 72 | |
| 73 } // namespace ash | |
| OLD | NEW |