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/mus/bridge/mus_layout_manager_adapter.h" | |
6 | |
7 #include "ash/common/wm_layout_manager.h" | |
8 #include "ash/mus/bridge/wm_window_mus.h" | |
9 #include "services/ui/public/cpp/window.h" | |
10 | |
11 namespace ash { | |
12 namespace mus { | |
13 | |
14 MusLayoutManagerAdapter::MusLayoutManagerAdapter( | |
15 ui::Window* window, | |
16 std::unique_ptr<WmLayoutManager> layout_manager) | |
17 : window_(window), | |
18 layout_manager_(std::move(layout_manager)) { | |
19 window_->AddObserver(this); | |
20 } | |
21 | |
22 MusLayoutManagerAdapter::~MusLayoutManagerAdapter() { | |
23 window_->RemoveObserver(this); | |
24 } | |
25 | |
26 void MusLayoutManagerAdapter::OnTreeChanging(const TreeChangeParams& params) { | |
27 if (params.old_parent == window_) { | |
28 layout_manager_->OnWillRemoveWindowFromLayout( | |
29 WmWindowMus::Get(params.target)); | |
30 } | |
31 } | |
32 | |
33 void MusLayoutManagerAdapter::OnTreeChanged(const TreeChangeParams& params) { | |
34 if (params.new_parent == window_) | |
35 layout_manager_->OnWindowAddedToLayout(WmWindowMus::Get(params.target)); | |
36 else if (params.old_parent == window_) | |
37 layout_manager_->OnWindowRemovedFromLayout(WmWindowMus::Get(params.target)); | |
38 } | |
39 | |
40 void MusLayoutManagerAdapter::OnWindowBoundsChanged( | |
41 ui::Window* window, | |
42 const gfx::Rect& old_bounds, | |
43 const gfx::Rect& new_bounds) { | |
44 layout_manager_->OnWindowResized(); | |
45 } | |
46 | |
47 void MusLayoutManagerAdapter::OnChildWindowVisibilityChanged(ui::Window* window, | |
48 bool visible) { | |
49 layout_manager_->OnChildWindowVisibilityChanged(WmWindowMus::Get(window), | |
50 visible); | |
51 } | |
52 | |
53 } // namespace mus | |
54 } // namespace ash | |
OLD | NEW |