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 #ifndef ASH_MUS_BRIDGE_MUS_LAYOUT_MANAGER_ADAPTER_H_ | |
6 #define ASH_MUS_BRIDGE_MUS_LAYOUT_MANAGER_ADAPTER_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/macros.h" | |
11 #include "services/ui/public/cpp/window_observer.h" | |
12 | |
13 namespace ash { | |
14 class WmLayoutManager; | |
15 | |
16 namespace mus { | |
17 | |
18 // Used to associate a ui::Window with an WmLayoutManager. This | |
19 // attaches an observer to the ui::Window and calls the appropriate methods on | |
20 // the WmLayoutManager at the appropriate time. | |
21 // | |
22 // NOTE: WmLayoutManager provides the function SetChildBounds(). This is | |
23 // expected to be called to change the bounds of the Window. For aura this | |
24 // function is called by way of aura exposing a hook (aura::LayoutManager). Mus | |
25 // has no such hook. To ensure SetChildBounds() is called correctly all bounds | |
26 // changes to ui::Windows must be routed through WmWindowMus. WmWindowMus | |
27 // ensures WmLayoutManager::SetChildBounds() is called appropriately. | |
28 class MusLayoutManagerAdapter : public ui::WindowObserver { | |
29 public: | |
30 MusLayoutManagerAdapter(ui::Window* window, | |
31 std::unique_ptr<WmLayoutManager> layout_manager); | |
32 ~MusLayoutManagerAdapter() override; | |
33 | |
34 WmLayoutManager* layout_manager() { return layout_manager_.get(); } | |
35 | |
36 private: | |
37 // ui::WindowObserver: | |
38 void OnTreeChanging(const TreeChangeParams& params) override; | |
39 void OnTreeChanged(const TreeChangeParams& params) override; | |
40 void OnWindowBoundsChanged(ui::Window* window, | |
41 const gfx::Rect& old_bounds, | |
42 const gfx::Rect& new_bounds) override; | |
43 void OnChildWindowVisibilityChanged(ui::Window* window, | |
44 bool visible) override; | |
45 | |
46 ui::Window* window_; | |
47 std::unique_ptr<WmLayoutManager> layout_manager_; | |
48 | |
49 DISALLOW_COPY_AND_ASSIGN(MusLayoutManagerAdapter); | |
50 }; | |
51 | |
52 } // namespace mus | |
53 } // namespace ash | |
54 | |
55 #endif // ASH_MUS_BRIDGE_MUS_LAYOUT_MANAGER_ADAPTER_H_ | |
OLD | NEW |