Automated generation of display layouts
A client device executes a display layout application that receives a size of each display item included in a set of display items. The set of display items is associated with a first frame included in a bounding box associated with a display screen. The display layout application determines a reference size based on the sizes of the set of display items. The display layout application determines a size of the first frame based on the reference size. The display layout application determines a position for a first display item included in the set of display items based on a position of the first frame within the bounding box. The display layout application generates a layout for display on the display screen, where the layout includes the first display item.
1. A computer-implemented method, comprising:
receiving a set of layout instructions and a plurality of display items, wherein the set of layout instructions specifies that a first subset of the plurality of display items are to be contained in a first frame;
determining a first available display area associated with a display screen, wherein an initial size of the first available display area is determined based on dimensions of the display screen;
determining a first frame size of the first frame based on:
the set of layout instructions, and
a first maximum height or a first maximum length of the first subset of the plurality of display items;
generating the first frame;
when the first available display area exceeds the first frame size, reducing the first available display area based on the first frame size to generate a modified available display area;
upon generating the modified available display area, determining a second frame size of a second frame associated with a second subset of the plurality of display items, wherein the second frame size is based on at least one of:
the set of layout instructions,
the modified available display area, or
a second maximum height or a second maximum length of the second subset of the plurality of display items;
generating the second frame; and
generating a layout for display on the display screen, wherein the layout includes the first frame and the second frame.
2. The computer-implemented method of claim 1 , wherein determining the first frame size comprises:
determining, for each display item included in the first subset of the plurality of display items, a respective value for a first dimension, wherein the first dimension comprises one of a height or a width; and
determining, from among the respective values of the first dimension, the first maximum height or the first maximum length.
3. The computer-implemented method of claim 1 , further comprising:
retrieving one or more alignment layout properties from the set of layout instructions; and
setting, based on the one or more alignment layout properties, a first position for a first display item in the first subset of the plurality of display items.
4. The computer-implemented method of claim 1 , wherein determining the first frame size of the first frame further comprises:
determining a first dimension of the first available display area;
setting a first dimension of the first frame based on the first maximum height or the first maximum length; and
setting a second dimension of the first frame based on the first dimension of the first available display area.
5. The computer-implemented method of claim 1 , further comprising determining, from a data store, the first available display area, wherein:
reducing the first available display area is based on a first layout property included in the set of layout instructions, and
the first frame size is further based on the first available display area.
6. The computer-implemented method of claim 3 , further comprising determining a second position for a second display item included in first subset of the plurality of display items based on a size of the first display item.
7. The computer-implemented method of claim 6 , wherein the first position for the first display item is further based on a padding distance between the first display item and the second display item.
8. The computer-implemented method of claim 3 , wherein the first position for the first display item is further based on a padding distance between the first display item and an edge of the first available display area.
9. The computer-implemented method of claim 1 , further comprising:
retrieving one or more style properties from a style property data structure; and
rendering a first display item in the first subset of the plurality of display items for display within the layout based on the one or more style properties.
10. The computer-implemented method of claim 3 , further comprising adjusting the first display item to move to a second position based on a relative position property.
11. One or more non-transitory computer-readable storage media including instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of:
receiving a set of layout instructions and a plurality of display items, wherein the set of layout instructions specifies that a first subset of the plurality of display items are to be contained in a first frame;
determining a first available display area associated with a display screen, wherein an initial size of the first available display area is determined based on dimensions of the display screen;
determining a first frame size of the first frame based on:
the set of layout instructions, and
a first maximum height or a first maximum length of the first subset of the plurality of display items;
generating the first frame;
when the first available display area exceeds the first frame size, reducing the first available display area based on the first frame size to generate a modified available display area;
upon generating the modified available display area, determining a second frame size of a second frame associated with a second subset of the plurality of display items, wherein the second frame size is based on at least one of:
the set of layout instructions,
the modified available display area, or
a second maximum height or a second maximum length of the second subset of the plurality of display items;
generating the second frame; and
generating a layout for display on the display screen, wherein the layout includes the first frame and the second frame.
12. The one or more non-transitory computer-readable storage media of claim 11 , wherein determining the first frame size comprises:
determining, for each display item included in the first subset of the plurality of display items, a respective value for a first dimension, wherein the first dimension comprises one of a height or a width; and
determining, from among the respective values of the first dimension, the first maximum height or the first maximum length.
13. The one or more non-transitory computer-readable storage media of claim 11 , further comprising instructions that, when executed by the one or more processors, cause the one or more processors to perform the steps of:
retrieving one or more alignment layout properties from the set of layout instructions; and
setting, based on the one or more alignment layout properties, a first position for a first display item in the first subset of the plurality of display items.
14. The one or more non-transitory computer-readable storage media of claim 11 , wherein determining the first frame size of the first frame further comprises:
determining a first dimension of the first available display area;
setting a first dimension of the first frame based on the first maximum height or the first maximum length; and
setting a second dimension of the first frame based on the first dimension of the first available display area.
15. A computing device, comprising:
a memory that includes instructions; and
a processor that is coupled to the memory and, when executing the instructions:
receives a set of layout instructions and a plurality of display items, wherein the set of layout instructions specifies that a first subset of the plurality of display items are to be contained in a first frame;
determines a first available display area associated with a display screen, wherein an initial size of the first available display area is determined based on dimensions of the display screen;
determines a first frame size of the first frame based on:
the set of layout instructions, and
a first maximum height or a first maximum length of the first subset of the plurality of display items;
generates the first frame;
when the first available display area exceeds the first frame size, reduces the first available display area based on the first frame size to generate a modified available display area;
upon generating the modified available display area, determines a second frame size of a second frame associated with a second subset of the plurality of display items, wherein the second frame size is based on at least one of:
the set of layout instructions,
the modified available display area, or
a second maximum height or a second maximum length of the second subset of the plurality of display items;
generates the second frame; and
generates a layout for display on the display screen, wherein the layout includes the first frame and the second frame.
16. The computing device of claim 15 , wherein determining the first frame size comprises:
determining, for each display item included in the first subset of the plurality of display items, a respective value for a first dimension, wherein the first dimension comprises one of a height or a width; and
determining, from among the respective values of the first dimension, the first maximum height or the first maximum length.
17. The computing device of claim 15 , wherein the processor, when executing the instructions, further:
retrieving one or more alignment layout properties from the set of layout instructions; and
setting, based on the one or more alignment layout properties, a first position for a first display item in the first subset of the plurality of display items.
18. The computing device of claim 15 , wherein determining the first frame size of the first frame further comprises:
determining a first dimension of the first available display area;
setting a first dimension of the first frame based on the first maximum height or the first maximum length; and
setting a second dimension of the first frame based on the first dimension of the first available display area.
19. The computer-implemented method of claim 1 , further comprising attaching the layout to a shadow node, wherein:
a first display application, operating on a first device executing a first operating system type, retrieves the layout from the shadow node when rendering the layout,
a second display application, operating on a second device executing a second operating system type, retrieves the layout from the shadow node when rendering the layout, and
the first operating system type is distinct from the second operating system type.