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 ASH_MUS_LAYOUT_MANAGER_H_ | |
6 #define ASH_MUS_LAYOUT_MANAGER_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include "base/macros.h" | |
11 #include "services/ui/public/cpp/window_observer.h" | |
12 | |
13 namespace ash { | |
14 namespace mus { | |
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 ui::WindowObserver { | |
23 public: | |
24 ~LayoutManager() override; | |
25 | |
26 protected: | |
27 explicit LayoutManager(ui::Window* owner); | |
28 | |
29 void Uninstall(); | |
30 | |
31 // Overridden from ui::WindowObserver: | |
32 void OnTreeChanged( | |
33 const ui::WindowObserver::TreeChangeParams& params) override; | |
34 void OnWindowDestroying(ui::Window* window) override; | |
35 void OnWindowBoundsChanged(ui::Window* window, | |
36 const gfx::Rect& old_bounds, | |
37 const gfx::Rect& new_bounds) override; | |
38 void OnWindowSharedPropertyChanged( | |
39 ui::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(ui::Window* window); | |
45 virtual void WindowRemoved(ui::Window* window); | |
46 virtual void LayoutWindow(ui::Window* window) = 0; | |
47 | |
48 // Add a property that triggers layout when changed. | |
49 void AddLayoutProperty(const std::string& property); | |
50 | |
51 ui::Window* owner() { return owner_; } | |
52 | |
53 private: | |
54 ui::Window* owner_; | |
55 | |
56 std::set<std::string> layout_properties_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(LayoutManager); | |
59 }; | |
60 | |
61 } // namespace mus | |
62 } // namespace ash | |
63 | |
64 #endif // ASH_MUS_LAYOUT_MANAGER_H_ | |
OLD | NEW |