PROTOCOLS
View
Defined in fuchsia.ui.app/view.fidl
A View is an interface that a component implements to offer a Scenic view to its clients. A Scenic view is container of Scenic graph nodes, which, when rendered, might display a graphical user interface, such as a module, shell, or on-screen keyboard.
A client of the View
interface will:
- Launch (or bind to) the component that provides the interface.
- Connect to the component's
View
interface. - Call
SetConfig()
at least once to configure the view's presentation parameters. - Call
AttachView()
to ask theView
to attach its graphical content to the Scenic scene graph using the providedview_token
. - Optionally, while the View is attached, call
SetConfig()
again to modify any presentation parameters as needed.
When the client no longer needs the View, it should disconnect from the interface and terminate (or unbind) from the component.
NOTE: Unlike with ViewProvider
, the client owns the View
instance and
must retain it for the lifetime of the UI that it displays. If the View
instance is destroyed, the connection will be dropped.
On the implementation side, a component that exposes the
View
interface has the following responsibilities:
- Initialize and attach the View's content to the Scenic scene graph
using the
fuchsia.ui.view.CreateViewCmd
and passing the providedview_token
. - Adjust the appearance and/or contents of the view's content whenever
its
ViewConfig
changes. - Provide graphical content for the view and handle user interface
events such as touches, key presses, and
fuchsia.ui.view.ViewProperty
changes using other Scenic interfaces such asfuchsia.ui.Scenic
andfuchsia.ui.SessionListener
.
TODO(fxbug.dev/24402): Migrate all implementations of ViewProvider
to use View
.
Attach
Attaches the View to Scenic's scene graph. Must only be called once per
View
lifetime.
The View's implementation should pass the view_token
to Scenic
using a fuchsia.ui.view.CreateViewCmd
.
Request
Name | Type |
---|---|
view_token |
handle<eventpair>
|
SetConfig
Updates the View's configuration.
To prevent triggering UI changes shortly after a client starts up, the
View's client should set the configuration prior to calling
AttachView()
unless the default is adequate.
May be called again at any time to modify the view's configuration.
Request
Name | Type |
---|---|
config |
ViewConfig
|
ViewProvider
Defined in fuchsia.ui.app/view_provider.fidl
ViewProvider is the standard mechanism for two modules to each obtain half of a shared eventpair token. The shared token is a capability allowing the modules to ask Scenic to create a ViewHolder/View pair. The resulting View and ViewHolder are linked together until either one is destroyed.
Modules are free to use any other mechanism to agree upon the shared eventpair token, and use this to create the linked ViewHolder/View. ViewProvider is given for the convenience of clients that don't require a more complex implementation.
CreateView2
Creates a new View under the control of the ViewProvider.
The args are provided as a table, for forward compatibility. See documentation on the individual table fields.
Request
Name | Type |
---|---|
args |
CreateView2Args
|
CreateViewWithViewRef
Creates a new View under the control of the ViewProvider.
token
is one half of the shared eventpair which will bind the new View
to its associated ViewHolder. The ViewProvider will use token
to
create its internal View representation. The caller is expected to use
its half to create corresponding ViewHolder object.
view_ref_control
and view_ref
are two typed handles to each half of the
same event pair. The view_ref
can be cloned before passing it to this method,
which will allow clients to track the view (e.g., in a focus chain update).
view_ref_control
must not have the ZX_RIGHT_DUPLICATE set, or view creation
will fail.
Request
Name | Type |
---|---|
token |
handle<eventpair>
|
view_ref_control |
fuchsia.ui.views/ViewRefControl
|
view_ref |
fuchsia.ui.views/ViewRef
|
STRUCTS
ViewConfig
Defined in fuchsia.ui.app/view_config.fidl
Collection of properties that provide affect the rendering of a view's contents. This might include internationalization settings, font scaling, night mode, high contrast mode, etc.
Field | Type | Description | Default |
---|---|---|---|
intl_profile |
fuchsia.intl/Profile
|
No default |
TABLES
CreateView2Args resource
Defined in fuchsia.ui.app/view_provider.fidl
Ordinal | Field | Type | Description |
---|---|---|---|
1 |
view_creation_token |
fuchsia.ui.views/ViewCreationToken
|
Non-optional. This token can be provided to Flatland to attach the client's child view to the parent's viewport. |