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