1// Modifiers for composable layout elements.
2syntax = "proto3";
3
4package androidx.wear.protolayout.proto;
5
6import "action.proto";
7import "animation_parameters.proto";
8import "color.proto";
9import "dimension.proto";
10import "types.proto";
11
12option java_package = "androidx.wear.protolayout.proto";
13option java_outer_classname = "ModifiersProto";
14
15// A modifier for an element which can have associated Actions for click events.
16// When an element with a ClickableModifier is clicked it will fire the
17// associated action.
18message Clickable {
19  // The ID associated with this action.
20  string id = 1;
21
22  // The action to perform when the element this modifier is attached to is
23  // clicked.
24  Action on_click = 2;
25
26  // The minimum width of the clickable area.
27  //
28  // The default value is 48dp, following the Material design accessibility
29  // guideline. Note that this value does not affect the layout, so the minimum
30  // clickable width is not guaranteed unless there is enough space around the
31  // element within its parent bounds.
32  DpProp minimum_clickable_width = 3;
33
34  // The minimum height of the clickable area.
35  //
36  // The default value is 48dp, following the Material design accessibility
37  // guideline. Note that this value does not affect the layout, so the minimum
38  // clickable height is not guaranteed unless there is enough space around the
39  // element within its parent bounds.
40  DpProp minimum_clickable_height = 4;
41
42  oneof optional_visual_feedback_enabled {
43    // Whether the click visual feedback (such as a ripple) should be enabled.
44    // Defaults to true.
45    bool visual_feedback_enabled = 5;
46  }
47}
48
49// The type of user interface element. Accessibility services might use this to
50// describe the element or do customizations.
51enum SemanticsRole {
52  // Role is undefined. It may be automatically populated.
53  SEMANTICS_ROLE_NONE = 0;
54
55  // The element is an image.
56  SEMANTICS_ROLE_IMAGE = 1;
57
58  // The element is a Button control.
59  SEMANTICS_ROLE_BUTTON = 2;
60
61  // The element is a Checkbox which is a component that represents two states
62  // (checked / unchecked).
63  SEMANTICS_ROLE_CHECKBOX = 3;
64
65  // The element is a Switch which is a two state toggleable component that
66  // provides on/off like options.
67  SEMANTICS_ROLE_SWITCH = 4;
68
69  // This element is a RadioButton which is a component to represent two states,
70  // selected and not selected.
71  SEMANTICS_ROLE_RADIOBUTTON = 5;
72}
73
74// A modifier for an element which has accessibility semantics associated with
75// it. This should generally be used sparingly, and in most cases should only be
76// applied to the top-level layout element or to Clickables.
77message Semantics {
78  // The content description associated with this element. This will be dictated
79  // when the element is focused by the screen reader.
80  // @deprecated Use content_description instead.
81  string obsolete_content_description = 1;
82
83  // The content description associated with this element. This will be dictated
84  // when the element is focused by the screen reader.
85  //
86  // While this field is statically accessible from 1.0, it's only bindable
87  // since version 1.2 and renderers supporting version 1.2 will use the dynamic
88  // value (if set).
89  StringProp content_description = 4;
90
91  // The type of user interface element. Accessibility services might use this
92  // to describe the element or do customizations.
93  SemanticsRole role = 2;
94
95  // The localized state description of the semantics node.
96  // For example: "on" or "off". This will be dictated when the element is
97  // focused by the screen reader.
98  //
99  // This field is bindable and will use the dynamic value (if set).
100  StringProp state_description = 3;
101}
102
103// A modifier to apply padding around an element.
104message Padding {
105  // The padding on the end of the content, depending on the layout direction,
106  // in DP and the value of "rtl_aware".
107  DpProp end = 1;
108
109  // The padding on the start of the content, depending on the layout direction,
110  // in DP and the value of "rtl_aware".
111  DpProp start = 2;
112
113  // The padding at the top, in DP.
114  DpProp top = 3;
115
116  // The padding at the bottom, in DP.
117  DpProp bottom = 4;
118
119  // Whether the start/end padding is aware of RTL support. If true, the values
120  // for start/end will follow the layout direction (i.e. start will refer to
121  // the right hand side of the container if the device is using an RTL locale).
122  // If false, start/end will always map to left/right, accordingly.
123  BoolProp rtl_aware = 5;
124}
125
126// A modifier to apply a border around an element.
127message Border {
128  // The width of the border, in DP.
129  DpProp width = 1;
130
131  // The color of the border.
132  //
133  // While this field is statically accessible from 1.0, it's only bindable
134  // since version 1.2 and renderers supporting version 1.2 will use the dynamic
135  // value (if set).
136  ColorProp color = 2;
137}
138
139// A radius for either circular or elliptical shapes.
140message CornerRadius {
141  // The radius value in dp on the horizontal axis.
142  DpProp x = 1;
143  // The radius value in dp on the vertical axis.
144  DpProp y = 2;
145}
146
147// The corner of a Box element.
148message Corner {
149  // The radius of the corner in DP.
150  // <p>The shape for a specific corner can be overridden by setting that corner separately.
151  DpProp radius = 1;
152
153  // The radius for the top-left corner of either circular or elliptical shapes.
154  // If not set, defaults to radius for both horizontal and vertical
155  // axes when radius is set; or defaults to zeros when radius is also not set.
156  CornerRadius top_left_radius = 2;
157
158  // The radius for the top-right corner of either circular or elliptical shapes.
159  // If not set, defaults to radius for both horizontal and vertical
160  // axes when radius is set; or defaults to zeros when radius is also not set.
161  CornerRadius top_right_radius = 3;
162
163  // The radius for the bottom-right corner of either circular or elliptical shapes.
164  // If not set, defaults to radius for both horizontal and vertical
165  // axes when radius is set; or defaults to zeros when radius is also not set.
166  CornerRadius bottom_right_radius = 4;
167
168  // The radius for the bottom-left corner of either circular or elliptical shapes.
169  // If not set, defaults to radius for both horizontal and vertical
170  // axes when radius is set; or defaults to zeros when radius is also not set.
171  CornerRadius bottom_left_radius = 5;
172}
173
174// A modifier to apply a background to an element.
175message Background {
176  // The background color for this element. If not defined, defaults to being
177  // transparent.
178  //
179  // While this field is statically accessible from 1.0, it's only bindable
180  // since version 1.2 and renderers supporting version 1.2 will use the dynamic
181  // value (if set).
182  //
183  // If a brush is set, this color will only be used if brush is not supported
184  // by the renderer (versions below 1.5).
185  ColorProp color = 1;
186
187  // The corner properties of this element. This only affects the drawing of
188  // this element if it has a background color or border. If not defined,
189  // defaults to having a square corner.
190  Corner corner = 2;
191
192  // A brush used to draw the background. If set and supported, the brush will be
193  // used instead of the color provided in {@code setColor()}.
194  //
195  // Only LinearGradient is supported.
196  Brush brush = 3;
197}
198
199// Metadata about an element. For use by libraries building higher-level
200// components only. This can be used to track component metadata.
201message ElementMetadata {
202  // Property describing the element with which it is associated. For use by
203  // libraries building higher-level components only. This can be used to track
204  // component metadata.
205  bytes tag_data = 1;
206}
207
208// A modifier to apply transformations to the element. All of these
209// transformations can be animated by setting dynamic values.
210// This modifier is not layout affecting.
211message Transformation {
212  // The horizontal offset of this element relative to the location where the
213  // element's layout placed it.
214  DpProp translation_x = 1;
215
216  // The vertical offset of this element in addition to the location where the
217  // element's layout placed it.
218  DpProp translation_y = 2;
219
220  // The scale of this element in the x direction around the pivot point, as a
221  // proportion of the element's unscaled width .
222  FloatProp scale_x = 3;
223
224  // The scale of this element in the y direction around the pivot point, as a
225  // proportion of the element's unscaled height.
226  FloatProp scale_y = 4;
227
228  // The clockwise degrees that the element is rotated around the pivot point.
229  DegreesProp rotation = 5;
230
231  // The horizontal location of the point around which the element is rotated
232  // and scaled. With type DpProp, it is the offset from the element center;
233  // otherwise with type BoundingBoxRatio, it is the location proportional to
234  // the bounding box width.
235  PivotDimension pivot_x = 6;
236
237  // The vertical location of the point around which the element is rotated and
238  // scaled. With type DpProp, it is the offset from the element center;
239  // otherwise with type BoundingBoxRatio, it is the location proportional to
240  // the bounding box height.
241  PivotDimension pivot_y = 7;
242}
243
244// Modifiers for an element. These may change the way they are drawn (e.g.
245// Padding or Background), or change their behaviour (e.g. Clickable, or
246// Semantics).
247message Modifiers {
248  // The clickable property of the modified element. It allows its wrapped
249  // element to have actions associated with it, which will be executed when the
250  // element is tapped.
251  Clickable clickable = 1;
252
253  // The semantics of the modified element. This can be used to add metadata to
254  // the modified element (eg. screen reader content descriptions).
255  Semantics semantics = 2;
256
257  // The padding of the modified element.
258  Padding padding = 3;
259
260  // The border of the modified element.
261  Border border = 4;
262
263  // The background (with optional corner radius) of the modified element.
264  Background background = 5;
265
266  // Metadata about an element. For use by libraries building higher-level
267  // components only. This can be used to track component metadata
268  ElementMetadata metadata = 6;
269
270  // The content transition of an element. Any update to the element or its
271  // children will trigger this animation for this element and everything
272  // underneath it.
273  AnimatedVisibility content_update_animation = 7;
274
275  // Whether the attached element is hidden, or visible. If the element is
276  // hidden, then it will still consume space in the layout, but will not render
277  // any contents, nor will any children render any contents.
278  //
279  // Note that a hidden element also cannot be clickable (i.e. a Clickable
280  // modifier would be ignored).
281  //
282  // Defaults to false (i.e. not hidden).
283  // This field is deprecated and is only kept for backward compatibility.
284  BoolProp hidden = 8;
285
286  // The optional identifier for the layout element.
287  string id = 9;
288
289  // Whether the attached element is visible, or hidden. If the element is
290  // hidden, then it will still consume space in the layout, but will not render
291  // any contents, nor will any children render any contents. Defaults to
292  // visible.
293  //
294  // Note that a hidden element also cannot be clickable (i.e. a Clickable
295  // modifier would be ignored).
296  BoolProp visible = 10;
297
298  // The transformation applied to the element post-layout
299  Transformation transformation = 11;
300
301  // The opacity of the element with a value from 0 to 1, where 0 means
302  // the element is completely transparent and 1 means the element is
303  // completely opaque. Defaults to 1.
304  FloatProp opacity = 12;
305}
306
307// The content transition of an element. Any update to the element or its
308// children will trigger this animation for this element and everything
309// underneath it.
310message AnimatedVisibility {
311  // The content transition that is triggered when element enters the layout.
312  EnterTransition enter_transition = 1;
313
314  // The content transition that is triggered when element exits the layout.
315  // Note that indefinite exit animations are ignored.
316  ExitTransition exit_transition = 2;
317}
318
319// The content transition that is triggered when element enters the layout.
320message EnterTransition {
321  // The fading in animation for content transition of an element and its
322  // children happening when entering the layout.
323  FadeInTransition fade_in = 1;
324
325  // The sliding in animation for content transition of an element and its
326  // children happening when entering the layout.
327  SlideInTransition slide_in = 2;
328}
329
330// The fading animation for content transition of an element and its children,
331// from the specified starting alpha to fully visible.
332message FadeInTransition {
333  // The starting alpha of the fade in transition. It should be between 0 and 1.
334  // If not set, defaults to fully transparent, i.e. 0.
335  float initial_alpha = 1;
336
337  // The animation parameters for duration, delay, etc.
338  androidx.wear.protolayout.expression.proto.AnimationSpec animation_spec = 2;
339}
340
341// The sliding in animation for content transition of an element and its
342// children.
343message SlideInTransition {
344  // The slide direction used for slide animations on any element, from the
345  // specified point to its destination in the layout. If not set, defaults to
346  // horizontal from left to the right.
347  SlideDirection direction = 1;
348
349  // The initial offset for animation. By default the transition starts from the
350  // left parent boundary for horizontal orientation and from the top for
351  // vertical orientation. Note that sliding from the screen boundaries can only
352  // be achieved if all parent's sizes are big enough to accommodate it.
353  SlideBound initial_slide_bound = 2;
354
355  // The animation parameters for duration, delay, etc.
356  androidx.wear.protolayout.expression.proto.AnimationSpec animation_spec = 3;
357}
358
359// The content transition that is triggered when element exits the layout.
360message ExitTransition {
361  // The fading out animation for content transition of an element and its
362  // children happening when exiting the layout.
363  FadeOutTransition fade_out = 1;
364
365  // The sliding out animation for content transition of an element and its
366  // children happening when exiting the layout.
367  SlideOutTransition slide_out = 2;
368}
369
370// The fading animation for content transition of an element and its children,
371// from fully visible to the specified target alpha.
372message FadeOutTransition {
373  // The target alpha of the fade out transition. It should be between 0 and 1.
374  // If not set, defaults to fully invisible, i.e. 0.
375  float target_alpha = 1;
376
377  // The animation parameters for duration, delay, etc.
378  androidx.wear.protolayout.expression.proto.AnimationSpec animation_spec = 2;
379}
380
381// The sliding out animation for content transition of an element and its
382// children.
383message SlideOutTransition {
384  // The slide direction used for slide animations on any element, from its
385  // destination in the layout to the specified point. If not set, defaults to
386  // horizontal from right to the left.
387  SlideDirection direction = 1;
388
389  // The target offset for animation. By default the transition will end at the
390  // left parent boundary for horizontal orientation and at the top for
391  // vertical orientation. Note that sliding from the screen boundaries can only
392  // be achieved if all parent's sizes are big enough to accommodate it.
393  SlideBound target_slide_bound = 2;
394
395  // The animation parameters for duration, delay, etc.
396  androidx.wear.protolayout.expression.proto.AnimationSpec animation_spec = 3;
397}
398
399// The boundary that a Slide animation will use for start/end.
400message SlideBound {
401  oneof inner {
402    SlideParentBound parent_bound = 1;
403    SlideLinearBound linear_bound = 2;
404  }
405}
406
407// The slide animation will animate from/to the parent elements boundaries.
408message SlideParentBound {
409  // The snap options to use when sliding using parent boundaries. Defaults to
410  // SLIDE_PARENT_SNAP_TO_INSIDE if not specified.
411  SlideParentSnapOption snap_to = 1;
412}
413
414// The snap options to use when sliding using parent boundaries.
415enum SlideParentSnapOption {
416  // The undefined snapping option.
417  SLIDE_PARENT_SNAP_UNDEFINED = 0;
418
419  // The option that snaps insides of the element and its parent at start/end.
420  SLIDE_PARENT_SNAP_TO_INSIDE = 1;
421
422  // The option that snaps outsides of the element and its parent at start/end.
423  SLIDE_PARENT_SNAP_TO_OUTSIDE = 2;
424}
425
426// The slide animation will use the explicit offset for the animation boundary.
427message SlideLinearBound {
428  // The absolute delta linear distance to animate from/to. A direction will be
429  // defined by SlideDirection and this value should be a positive offset.
430  float offset_dp = 1;
431}
432
433// The slide direction used for slide animations on any element, from the
434// specified point to its destination in the layout for in animation or reverse
435// for out animation.
436enum SlideDirection {
437  // The undefined sliding orientation.
438  SLIDE_DIRECTION_UNDEFINED = 0;
439
440  // The sliding orientation that moves an element horizontally from left to the
441  // right.
442  SLIDE_DIRECTION_LEFT_TO_RIGHT = 1;
443
444  // The sliding orientation that moves an element horizontally from right to
445  // the left.
446  SLIDE_DIRECTION_RIGHT_TO_LEFT = 2;
447
448  // The sliding orientation that moves an element vertically from top to the
449  // bottom.
450  SLIDE_DIRECTION_TOP_TO_BOTTOM = 3;
451
452  // The sliding orientation that moves an element vertically from bottom to the
453  // top.
454  SLIDE_DIRECTION_BOTTOM_TO_TOP = 4;
455}
456
457// Modifiers that can be used with ArcLayoutElements. These may change the way
458// they are drawn, or change their behaviour.
459message ArcModifiers {
460  // Allows its wrapped element to have actions associated with it, which will
461  // be executed when the element is tapped.
462  Clickable clickable = 1;
463
464  // Adds metadata for the modified element, for example, screen reader content
465  // descriptions.
466  Semantics semantics = 2;
467
468  // The opacity of the element with a value from 0 to 1, where 0 means
469  // the element is completely transparent and 1 means the element is
470  // completely opaque. Defaults to 1.
471  FloatProp opacity = 4;
472
473  reserved 3;
474}
475
476// Modifiers that can be used with Span elements. These may change the way
477// they are drawn, or change their behaviour.
478message SpanModifiers {
479  // Allows its wrapped element to have actions associated with it, which will
480  // be executed when the element is tapped.
481  Clickable clickable = 1;
482}
483
484// The shadow definition. The shadow is drawn as a blur region around the
485// element.
486message Shadow {
487  // The blur radius of the shadow. It controls the size of the blur that is
488  // drawn. When set to zero, the shadow is not drawn. Defaults to zero.
489  DpProp blur_radius = 1;
490
491  // The color used in the shadow. Defaults to Black.
492  ColorProp color = 2;
493}
494