1// Dimensions for layout elements.
2syntax = "proto3";
3
4package androidx.wear.tiles.testing.proto;
5
6
7option java_package = "androidx.wear.tiles.testing.proto";
8option java_outer_classname = "DimensionProto";
9
10// A type for linear dimensions, measured in dp.
11message DpProp {
12  // The value, in dp.
13  float value = 1;
14}
15
16// A type for font sizes, measured in sp.
17message SpProp {
18  // The value, in sp.
19  float value = 2;
20
21  reserved 1;
22}
23
24// A type for font spacing, measured in em.
25message EmProp {
26  // The value, in em.
27  float value = 1;
28}
29
30// A type for angular dimensions, measured in degrees.
31message DegreesProp {
32  // The value, in degrees.
33  float value = 1;
34}
35
36// A type for a dimension that fills all the space it can (i.e. MATCH_PARENT in
37// Android parlance)
38message ExpandedDimensionProp {}
39
40// A type for a dimension that sizes itself to the size of its children (i.e.
41// WRAP_CONTENT in Android parlance)
42message WrappedDimensionProp {}
43
44// A type for a dimension that scales itself proportionally to another dimension
45// such that the aspect ratio defined by the given width and height values is
46// preserved.
47//
48// Note that the width and height are unitless; only their ratio is relevant.
49// This allows for specifying an element's size using common ratios (e.g.
50// width=4, height=3), or to allow an element to be resized proportionally based
51// on the size of an underlying asset (e.g. an 800x600 image being added to a
52// smaller container and resized accordingly).
53message ProportionalDimensionProp {
54  // The width to be used when calculating the aspect ratio to preserve.
55  uint32 aspect_ratio_width = 1;
56
57  // The height to be used when calculating the aspect ratio ratio to preserve.
58  uint32 aspect_ratio_height = 2;
59}
60
61// A dimension that can be applied to a container.
62message ContainerDimension {
63  oneof inner {
64    DpProp linear_dimension = 1;
65    ExpandedDimensionProp expanded_dimension = 2;
66    WrappedDimensionProp wrapped_dimension = 3;
67  }
68}
69
70// A dimension that can be applied to an image.
71message ImageDimension {
72  oneof inner {
73    DpProp linear_dimension = 1;
74    ExpandedDimensionProp expanded_dimension = 2;
75    ProportionalDimensionProp proportional_dimension = 3;
76  }
77}
78
79// A dimension that can be applied to a spacer.
80message SpacerDimension {
81  oneof inner {
82    DpProp linear_dimension = 1;
83    // TODO(b/169137847): Add ExpandedDimensionProp
84  }
85}
86