OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_WM_CORE_WINDOW_UTIL_H_ | 5 #ifndef UI_WM_CORE_WINDOW_UTIL_H_ |
6 #define UI_WM_CORE_WINDOW_UTIL_H_ | 6 #define UI_WM_CORE_WINDOW_UTIL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
| 12 #include "base/callback_forward.h" |
11 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
12 #include "ui/wm/wm_export.h" | 14 #include "ui/wm/wm_export.h" |
13 | 15 |
14 namespace aura { | 16 namespace aura { |
15 class Window; | 17 class Window; |
16 } | 18 } |
17 | 19 |
18 namespace ui { | 20 namespace ui { |
19 class Layer; | 21 class Layer; |
20 class LayerOwner; | 22 class LayerOwner; |
(...skipping 18 matching lines...) Expand all Loading... |
39 | 41 |
40 // Returns the existing Layer for |root| (and all its descendants) and creates | 42 // Returns the existing Layer for |root| (and all its descendants) and creates |
41 // a new layer for |root| and all its descendants. This is intended for | 43 // a new layer for |root| and all its descendants. This is intended for |
42 // animations that want to animate between the existing visuals and a new state. | 44 // animations that want to animate between the existing visuals and a new state. |
43 // | 45 // |
44 // As a result of this |root| has freshly created layers, meaning the layers | 46 // As a result of this |root| has freshly created layers, meaning the layers |
45 // have not yet been painted to. | 47 // have not yet been painted to. |
46 WM_EXPORT std::unique_ptr<ui::LayerTreeOwner> RecreateLayers( | 48 WM_EXPORT std::unique_ptr<ui::LayerTreeOwner> RecreateLayers( |
47 ui::LayerOwner* root); | 49 ui::LayerOwner* root); |
48 | 50 |
| 51 using MapLayerFunc = |
| 52 base::RepeatingCallback<std::unique_ptr<ui::Layer>(ui::LayerOwner*)>; |
| 53 |
| 54 // Maps |map_func| over each layer of the layer tree and returns a copy of the |
| 55 // layer tree. The recursion stops at the level when |map_func| returns nullptr |
| 56 // on the owner's layer. MapLayers might return nullptr when |map_func| returns |
| 57 // nullptr on the root layer's owner. |
| 58 WM_EXPORT std::unique_ptr<ui::LayerTreeOwner> RecreateLayersWithClosure( |
| 59 ui::LayerOwner* root, |
| 60 const MapLayerFunc& map_func); |
| 61 |
49 // Returns a layer tree that mirrors |root|. Used for live window previews. If | 62 // Returns a layer tree that mirrors |root|. Used for live window previews. If |
50 // |sync_bounds| is true, the bounds of all mirror layers except the root are | 63 // |sync_bounds| is true, the bounds of all mirror layers except the root are |
51 // synchronized. See |sync_bounds_| in ui::Layer. | 64 // synchronized. See |sync_bounds_| in ui::Layer. |
52 WM_EXPORT std::unique_ptr<ui::LayerTreeOwner> MirrorLayers( | 65 WM_EXPORT std::unique_ptr<ui::LayerTreeOwner> MirrorLayers( |
53 ui::LayerOwner* root, bool sync_bounds); | 66 ui::LayerOwner* root, bool sync_bounds); |
54 | 67 |
55 // Convenience functions that get the TransientWindowManager for the window and | 68 // Convenience functions that get the TransientWindowManager for the window and |
56 // redirect appropriately. These are preferable to calling functions on | 69 // redirect appropriately. These are preferable to calling functions on |
57 // TransientWindowManager as they handle the appropriate NULL checks. | 70 // TransientWindowManager as they handle the appropriate NULL checks. |
58 WM_EXPORT aura::Window* GetTransientParent(aura::Window* window); | 71 WM_EXPORT aura::Window* GetTransientParent(aura::Window* window); |
59 WM_EXPORT const aura::Window* GetTransientParent( | 72 WM_EXPORT const aura::Window* GetTransientParent( |
60 const aura::Window* window); | 73 const aura::Window* window); |
61 WM_EXPORT const std::vector<aura::Window*>& GetTransientChildren( | 74 WM_EXPORT const std::vector<aura::Window*>& GetTransientChildren( |
62 const aura::Window* window); | 75 const aura::Window* window); |
63 WM_EXPORT void AddTransientChild(aura::Window* parent, aura::Window* child); | 76 WM_EXPORT void AddTransientChild(aura::Window* parent, aura::Window* child); |
64 WM_EXPORT void RemoveTransientChild(aura::Window* parent, aura::Window* child); | 77 WM_EXPORT void RemoveTransientChild(aura::Window* parent, aura::Window* child); |
65 | 78 |
66 // Returns true if |window| has |ancestor| as a transient ancestor. A transient | 79 // Returns true if |window| has |ancestor| as a transient ancestor. A transient |
67 // ancestor is found by following the transient parent chain of the window. | 80 // ancestor is found by following the transient parent chain of the window. |
68 WM_EXPORT bool HasTransientAncestor(const aura::Window* window, | 81 WM_EXPORT bool HasTransientAncestor(const aura::Window* window, |
69 const aura::Window* ancestor); | 82 const aura::Window* ancestor); |
70 | 83 |
71 } // namespace wm | 84 } // namespace wm |
72 | 85 |
73 #endif // UI_WM_CORE_WINDOW_UTIL_H_ | 86 #endif // UI_WM_CORE_WINDOW_UTIL_H_ |
OLD | NEW |