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 [DartPackage="mojo_services"] | 5 [DartPackage="mojo_services"] |
6 module mojo.ui; | 6 module mojo.ui; |
7 | 7 |
8 import "mojo/public/interfaces/application/service_provider.mojom"; | 8 import "mojo/public/interfaces/application/service_provider.mojom"; |
| 9 import "mojo/services/gfx/composition/interfaces/scenes.mojom"; |
9 import "mojo/services/ui/views/interfaces/layouts.mojom"; | 10 import "mojo/services/ui/views/interfaces/layouts.mojom"; |
10 | 11 |
11 // A view token is an opaque transferable reference to a view. | 12 // A view token is an opaque transferable reference to a view. |
12 // | 13 // |
13 // The ViewManager provides each view with a unique view token when | 14 // The ViewManager provides each view with a unique view token when |
14 // it is registered. The token can subsequently be passed to other | 15 // it is registered. The token can subsequently be passed to other |
15 // applications and may be used to add the view as a child of some | 16 // applications and may be used to add the view as a child of some |
16 // other view or to set it as the root of a view tree. | 17 // other view or to set it as the root of a view tree. |
17 // | 18 // |
18 // View tokens should be kept secret and should only be shared with | 19 // View tokens should be kept secret and should only be shared with |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // | 63 // |
63 // The implementation should invoke the callback once the event has | 64 // The implementation should invoke the callback once the event has |
64 // been handled and the view is ready to be shown in its new aspect. | 65 // been handled and the view is ready to be shown in its new aspect. |
65 // | 66 // |
66 // The result of the layout may cause the parent's layout to be invalidated. | 67 // The result of the layout may cause the parent's layout to be invalidated. |
67 // When this happens, the parent's own OnLayout() method will be called | 68 // When this happens, the parent's own OnLayout() method will be called |
68 // and will be informed that this child needs layout. | 69 // and will be informed that this child needs layout. |
69 // | 70 // |
70 // Recursive layout happens in any of the following circumstances: | 71 // Recursive layout happens in any of the following circumstances: |
71 // | 72 // |
72 // 1. If the resulting surface has changed since the last layout. | 73 // 1. If the resulting scene has changed since the last layout. |
73 // 2. If the resulting size has changed since the last layout. | 74 // 2. If the resulting size has changed since the last layout. |
74 // | 75 // |
75 // It is an error to return a malformed |info| which does not satisfy | 76 // It is an error to return a malformed |result| which does not satisfy |
76 // the requested |layout_params|, such as by returning a size which | 77 // the requested |layout_params|, such as by returning a size which |
77 // exceeds the requested constraints; the view's connection will be closed. | 78 // exceeds the requested constraints; the view's connection will be closed. |
78 OnLayout(mojo.ui.ViewLayoutParams layout_params, | 79 OnLayout(mojo.ui.ViewLayoutParams layout_params, |
79 array<uint32> children_needing_layout) => (mojo.ui.ViewLayoutInfo info); | 80 array<uint32> children_needing_layout) => (mojo.ui.ViewLayoutResult result); |
80 | 81 |
81 // Called when a child view has become unavailable. | 82 // Called when a child view has become unavailable. |
82 // | 83 // |
83 // A child may become unavailable for many reasons such being unregistered | 84 // A child may become unavailable for many reasons such being unregistered |
84 // by its application, abnormal termination of its application, or | 85 // by its application, abnormal termination of its application, or |
85 // cycles being introduced in the view tree. | 86 // cycles being introduced in the view tree. |
86 // | 87 // |
87 // To complete removal of an unavailable child, this view component must | 88 // To complete removal of an unavailable child, this view component must |
88 // call RemoveChild() on its view host with |child_key|. | 89 // call RemoveChild() on its view host with |child_key|. |
89 // | 90 // |
90 // The implementation should invoke the callback once the event has | 91 // The implementation should invoke the callback once the event has |
91 // been handled. | 92 // been handled. |
92 OnChildUnavailable(uint32 child_key) => (); | 93 OnChildUnavailable(uint32 child_key) => (); |
93 }; | 94 }; |
94 | 95 |
95 // The view host provides an interface for a view to configure itself and | 96 // The view host provides an interface for a view to configure itself and |
96 // interact with its local environment, such as adding and removing | 97 // interact with its local environment, such as adding and removing |
97 // children and specifying layout constraints. | 98 // children and specifying layout constraints. |
98 // | 99 // |
99 // Each view obtains its own view host when registered with the ViewManager. | 100 // Each view obtains its own view host when registered with the ViewManager. |
100 // To unregister the view, close its view host message pipe. | 101 // To unregister the view, close its view host message pipe. |
101 interface ViewHost { | 102 interface ViewHost { |
102 // Gets a service provider to access services which are associated with | 103 // Gets a service provider to access services which are associated with |
103 // the view such as input, accessibility and editing capabilities. | 104 // the view such as input, accessibility and editing capabilities. |
104 // The view service provider is private to the view and should not be | 105 // The view service provider is private to the view and should not be |
105 // shared with anyone else. | 106 // shared with anyone else. |
| 107 // |
| 108 // See |mojo.ui.InputConnection|. |
106 GetServiceProvider(mojo.ServiceProvider& service_provider); | 109 GetServiceProvider(mojo.ServiceProvider& service_provider); |
107 | 110 |
| 111 // Creates the view's scene, replacing any previous scene the view |
| 112 // might have had. |
| 113 // |
| 114 // The |scene| is used to supply content for the scene. The scene pipe |
| 115 // is private to the scene and should not be shared with anyone else. |
| 116 // |
| 117 // To destroy the scene, simply close the |scene| message pipe. |
| 118 // |
| 119 // See also: |mojo.gfx.composition.Compositor.CreateScene()|. |
| 120 CreateScene(mojo.gfx.composition.Scene& scene); |
| 121 |
108 // Requests that the view's OnLayout() method be called to compute a | 122 // Requests that the view's OnLayout() method be called to compute a |
109 // new layout due to a change in the view's layout information. | 123 // new layout due to a change in the view's layout information. |
110 RequestLayout(); | 124 RequestLayout(); |
111 | 125 |
112 // Adds the view referenced by |child_view_token| as a child and assigns | 126 // Adds the view referenced by |child_view_token| as a child and assigns |
113 // it the provided |child_key| to identify it among its children. | 127 // it the provided |child_key| to identify it among its children. |
114 // The parent may remove the child later by passing the same |child_key| | 128 // The parent may remove the child later by passing the same |child_key| |
115 // to RemoveChild(). | 129 // to RemoveChild(). |
116 // | 130 // |
117 // It is important for the parent to choose locally unique values for | 131 // It is important for the parent to choose locally unique values for |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 // or because the child has become unavailable. | 172 // or because the child has become unavailable. |
159 // | 173 // |
160 // It is an error to specify a |child_key| that does not appear in | 174 // It is an error to specify a |child_key| that does not appear in |
161 // the parent's list of children; the connection will be closed. | 175 // the parent's list of children; the connection will be closed. |
162 // | 176 // |
163 // It is an error to specify malformed |child_layout_params| such | 177 // It is an error to specify malformed |child_layout_params| such |
164 // as invalid size constraints; the connection will be closed. | 178 // as invalid size constraints; the connection will be closed. |
165 LayoutChild(uint32 child_key, mojo.ui.ViewLayoutParams child_layout_params) | 179 LayoutChild(uint32 child_key, mojo.ui.ViewLayoutParams child_layout_params) |
166 => (mojo.ui.ViewLayoutInfo? info); | 180 => (mojo.ui.ViewLayoutInfo? info); |
167 }; | 181 }; |
OLD | NEW |