OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef MASH_WM_BRIDGE_MUS_LAYOUT_MANAGER_ADAPTER_H_ | 5 #ifndef ASH_MUS_BRIDGE_MUS_LAYOUT_MANAGER_ADAPTER_H_ |
6 #define MASH_WM_BRIDGE_MUS_LAYOUT_MANAGER_ADAPTER_H_ | 6 #define ASH_MUS_BRIDGE_MUS_LAYOUT_MANAGER_ADAPTER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "components/mus/public/cpp/window_observer.h" | 11 #include "components/mus/public/cpp/window_observer.h" |
12 | 12 |
13 namespace ash { | 13 namespace ash { |
14 namespace wm { | 14 namespace wm { |
15 class WmLayoutManager; | 15 class WmLayoutManager; |
16 } | 16 } |
17 } | |
18 | 17 |
19 namespace mash { | 18 namespace mus { |
20 namespace wm { | |
21 | 19 |
22 // Used to associate a mus::Window with an ash::wm::WmLayoutManager. This | 20 // Used to associate a mus::Window with an wm::WmLayoutManager. This |
23 // attaches an observer to the mus::Window and calls the appropriate methods on | 21 // attaches an observer to the mus::Window and calls the appropriate methods on |
24 // the WmLayoutManager at the appropriate time. | 22 // the WmLayoutManager at the appropriate time. |
25 // | 23 // |
26 // NOTE: WmLayoutManager provides the function SetChildBounds(). This is | 24 // NOTE: WmLayoutManager provides the function SetChildBounds(). This is |
27 // expected to be called to change the bounds of the Window. For aura this | 25 // expected to be called to change the bounds of the Window. For aura this |
28 // function is called by way of aura exposing a hook (aura::LayoutManager). Mus | 26 // function is called by way of aura exposing a hook (aura::LayoutManager). Mus |
29 // has no such hook. To ensure SetChildBounds() is called correctly all bounds | 27 // has no such hook. To ensure SetChildBounds() is called correctly all bounds |
30 // changes to mus::Windows must be routed through WmWindowMus. WmWindowMus | 28 // changes to mus::Windows must be routed through WmWindowMus. WmWindowMus |
31 // ensures WmLayoutManager::SetChildBounds() is called appropriately. | 29 // ensures WmLayoutManager::SetChildBounds() is called appropriately. |
32 class MusLayoutManagerAdapter : public mus::WindowObserver { | 30 class MusLayoutManagerAdapter : public ::mus::WindowObserver { |
33 public: | 31 public: |
34 MusLayoutManagerAdapter( | 32 MusLayoutManagerAdapter(::mus::Window* window, |
35 mus::Window* window, | 33 std::unique_ptr<wm::WmLayoutManager> layout_manager); |
36 std::unique_ptr<ash::wm::WmLayoutManager> layout_manager); | |
37 ~MusLayoutManagerAdapter() override; | 34 ~MusLayoutManagerAdapter() override; |
38 | 35 |
39 ash::wm::WmLayoutManager* layout_manager() { return layout_manager_.get(); } | 36 wm::WmLayoutManager* layout_manager() { return layout_manager_.get(); } |
40 | 37 |
41 private: | 38 private: |
42 // WindowObserver attached to child windows. A separate class is used to | 39 // WindowObserver attached to child windows. A separate class is used to |
43 // easily differentiate WindowObserver calls on the mus::Window associated | 40 // easily differentiate WindowObserver calls on the mus::Window associated |
44 // with the MusLayoutManagerAdapter, vs children. | 41 // with the MusLayoutManagerAdapter, vs children. |
45 class ChildWindowObserver : public mus::WindowObserver { | 42 class ChildWindowObserver : public ::mus::WindowObserver { |
46 public: | 43 public: |
47 explicit ChildWindowObserver(MusLayoutManagerAdapter* adapter); | 44 explicit ChildWindowObserver(MusLayoutManagerAdapter* adapter); |
48 ~ChildWindowObserver() override; | 45 ~ChildWindowObserver() override; |
49 | 46 |
50 private: | 47 private: |
51 // mus::WindowObserver: | 48 // mus::WindowObserver: |
52 void OnWindowVisibilityChanged(mus::Window* window) override; | 49 void OnWindowVisibilityChanged(::mus::Window* window) override; |
53 | 50 |
54 MusLayoutManagerAdapter* adapter_; | 51 MusLayoutManagerAdapter* adapter_; |
55 | 52 |
56 DISALLOW_COPY_AND_ASSIGN(ChildWindowObserver); | 53 DISALLOW_COPY_AND_ASSIGN(ChildWindowObserver); |
57 }; | 54 }; |
58 | 55 |
59 // mus::WindowObserver: | 56 // mus::WindowObserver: |
60 void OnTreeChanging(const TreeChangeParams& params) override; | 57 void OnTreeChanging(const TreeChangeParams& params) override; |
61 void OnTreeChanged(const TreeChangeParams& params) override; | 58 void OnTreeChanged(const TreeChangeParams& params) override; |
62 void OnWindowBoundsChanged(mus::Window* window, | 59 void OnWindowBoundsChanged(::mus::Window* window, |
63 const gfx::Rect& old_bounds, | 60 const gfx::Rect& old_bounds, |
64 const gfx::Rect& new_bounds) override; | 61 const gfx::Rect& new_bounds) override; |
65 | 62 |
66 mus::Window* window_; | 63 ::mus::Window* window_; |
67 ChildWindowObserver child_window_observer_; | 64 ChildWindowObserver child_window_observer_; |
68 std::unique_ptr<ash::wm::WmLayoutManager> layout_manager_; | 65 std::unique_ptr<wm::WmLayoutManager> layout_manager_; |
69 | 66 |
70 DISALLOW_COPY_AND_ASSIGN(MusLayoutManagerAdapter); | 67 DISALLOW_COPY_AND_ASSIGN(MusLayoutManagerAdapter); |
71 }; | 68 }; |
72 | 69 |
73 } // namespace wm | 70 } // namespace mus |
74 } // namespace mash | 71 } // namespace ash |
75 | 72 |
76 #endif // MASH_WM_BRIDGE_MUS_LAYOUT_MANAGER_ADAPTER_H_ | 73 #endif // ASH_MUS_BRIDGE_MUS_LAYOUT_MANAGER_ADAPTER_H_ |
OLD | NEW |