OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 MASH_WM_LAYOUT_MANAGER_H_ | |
6 #define MASH_WM_LAYOUT_MANAGER_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include "base/macros.h" | |
11 #include "components/mus/public/cpp/window_observer.h" | |
12 | |
13 namespace mash { | |
14 namespace wm { | |
15 | |
16 // Base class for container layout managers. Derived classes override | |
17 // LayoutWindow() to perform layout and register properties to which | |
18 // changes trigger layout. | |
19 // LayoutManagers observe both the bound container and all its children. | |
20 // They must be attached prior to any windows being added to the | |
21 // container. | |
22 class LayoutManager : public mus::WindowObserver { | |
23 public: | |
24 ~LayoutManager() override; | |
25 | |
26 protected: | |
27 explicit LayoutManager(mus::Window* owner); | |
28 | |
29 void Uninstall(); | |
30 | |
31 // Overridden from mus::WindowObserver: | |
32 void OnTreeChanged( | |
33 const mus::WindowObserver::TreeChangeParams& params) override; | |
34 void OnWindowDestroying(mus::Window* window) override; | |
35 void OnWindowBoundsChanged(mus::Window* window, | |
36 const gfx::Rect& old_bounds, | |
37 const gfx::Rect& new_bounds) override; | |
38 void OnWindowSharedPropertyChanged( | |
39 mus::Window* window, | |
40 const std::string& name, | |
41 const std::vector<uint8_t>* old_data, | |
42 const std::vector<uint8_t>* new_data) override; | |
43 | |
44 virtual void WindowAdded(mus::Window* window); | |
45 virtual void WindowRemoved(mus::Window* window); | |
46 virtual void LayoutWindow(mus::Window* window) = 0; | |
47 | |
48 // Add a property that triggers layout when changed. | |
49 void AddLayoutProperty(const std::string& property); | |
50 | |
51 mus::Window* owner() { return owner_; } | |
52 | |
53 private: | |
54 mus::Window* owner_; | |
55 | |
56 std::set<std::string> layout_properties_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(LayoutManager); | |
59 }; | |
60 | |
61 } // namespace wm | |
62 } // namespace mash | |
63 | |
64 #endif // MASH_WM_LAYOUT_MANAGER_H_ | |
OLD | NEW |