Compact, declarative construction of GTextNode trees for layouts.
More...
|
| #define | ToLayoutTextAlignment(alignment) (alignment + 1) |
| | Convert a GTextAlignment to a LayoutTextAlignment.
|
| |
| #define | ToGTextAlignment(alignment) (alignment - 1) |
| | Convert a LayoutTextAlignment other than auto to a GTextAlignment.
|
| |
| #define | ToLayoutVerticalAlignment(alignment) (alignment + 1) |
| | Convert a GVerticalAlignment to a LayoutVerticalAlignment.
|
| |
| #define | ToGVerticalAlignment(alignment) (alignment - 1) |
| | Convert a LayoutVerticalAlignment other than auto to a GVerticalAlignment.
|
| |
| #define | ToLayoutContentSize(size) ((LayoutContentSize)((size) + 1)) |
| | Convert a PreferredContentSize to a LayoutContentSize.
|
| |
| #define | ToPreferredContentSize(size) ((PreferredContentSize)((size) - 1)) |
| | Convert a LayoutContentSize other than auto to a PreferredContentSize.
|
| |
|
| enum | LayoutTextAlignment { LayoutTextAlignment_Auto = 0
, LayoutTextAlignment_Left = GTextAlignmentLeft + 1
, LayoutTextAlignment_Center = GTextAlignmentCenter + 1
, LayoutTextAlignment_Right = GTextAlignmentRight + 1
} |
| | Horizontal text alignment; GTextAlignment shifted so that 0 means automatic. More...
|
| |
| enum | LayoutVerticalAlignment { LayoutVerticalAlignment_Auto = 0
, LayoutVerticalAlignment_Left = GVerticalAlignmentTop + 1
, LayoutVerticalAlignment_Center = GVerticalAlignmentCenter + 1
, LayoutVerticalAlignment_Right = GVerticalAlignmentBottom + 1
} |
| | Vertical alignment; GVerticalAlignment shifted so that 0 means automatic. More...
|
| |
| enum | LayoutColor { LayoutColor_None = 0
, LayoutColor_Primary
, LayoutColor_Secondary
, LayoutColor_Background
} |
| | Layout color used for text. More...
|
| |
| enum | LayoutContentSize {
LayoutContentSize_Auto = 0
, LayoutContentSize_Small = PreferredContentSizeSmall + 1
, LayoutContentSize_Medium = PreferredContentSizeMedium + 1
, LayoutContentSize_Large = PreferredContentSizeLarge + 1
,
LayoutContentSize_ExtraLarge = PreferredContentSizeExtraLarge + 1
, LayoutContentSizeDefault = PreferredContentSizeDefault + 1
} |
| | Content size; PreferredContentSize shifted so that 0 means the system size. More...
|
| |
| enum | LayoutNodeType {
LayoutNodeType_TextAttribute = 0
, LayoutNodeType_TextBuffer
, LayoutNodeType_TextDynamic
, LayoutNodeType_Text
,
LayoutNodeType_Horizontal
, LayoutNodeType_Vertical
, LayoutNodeType_Constructor
, LayoutNodeType_HeadingsParagraphs
,
LayoutNodeType_Icon
, LayoutNodeType_TimelineIcon
, LayoutNodeType_TimelinePageBreak
, LayoutNodeType_TimelineMetrics
} |
| | Type of a node config, selecting the config struct. More...
|
| |
Compact, declarative construction of GTextNode trees for layouts.
A hierarchy of packed LayoutNode configs describes a tree of text nodes, instantiated with layout_create_text_node_from_config(). Whole layouts, such as the timeline cards, are described this way; the generic layout is the simplest example. Every config starts with a LayoutNodeConfig whose type tells which config struct it is.
For the best code size, use static configs without one-use callbacks. Configs on the stack cost stack space, so create the nodes and return immediately, avoiding deeper work such as measuring the view with graphics_text_node_get_size(), which is very stack intensive.
.text.style_font = TextStyleFont_Header,
};
.text.style_font = TextStyleFont_Body,
};
};
};
@ AttributeIdTitle
(string) Title shown in a detailed view, at most 64 bytes.
Definition attribute.h:82
@ AttributeIdBody
(string) Body text of the view, at most 512 bytes.
Definition attribute.h:86
AttributeId attr_id
String attribute to show.
Definition layout_node.h:261
LayoutNodeExtentConfig extent
Extent.
Definition layout_node.h:304
LayoutNodeContainerConfig container
Container config.
Definition layout_node.h:324
LayoutNodeType type
Config type.
Definition layout_node.h:196
LayoutNodeTextConfig text
Text config.
Definition layout_node.h:259
LayoutNodeConfig node
Base config.
Definition layout_node.h:202
LayoutNodeExtentConfig extent
Extent.
Definition layout_node.h:222
Attribute text node config; no node is created if the attribute is empty.
Definition layout_node.h:257
Base of every node config.
Definition layout_node.h:194
Vertical container node config.
Definition layout_node.h:322
GTextNode * layout_create_text_node_from_config(const LayoutLayer *layout, const LayoutNodeConfig *config)
Create a tree of text nodes from a config.
@ LayoutNodeType_TextAttribute
Text node whose text points to a string attribute (LayoutNodeTextAttributeConfig).
Definition layout_node.h:150
@ LayoutNodeType_Vertical
Vertical container populated with the given nodes (LayoutNodeVerticalConfig).
Definition layout_node.h:163
#define ARRAY_LENGTH(array)
Calculate the length of an array, based on the size of the element type.
Definition size.h:18
◆ LayoutNodeConfig
Base of every node config.
◆ LayoutNodeExtentConfig
| struct LayoutNodeExtentConfig |
Node config with an extent, added to the node's own.
◆ LayoutNodeTextConfig
| struct LayoutNodeTextConfig |
| Data Fields |
|
LayoutTextAlignment |
alignment: 2 |
Horizontal alignment. |
|
LayoutNodeExtentConfig |
extent |
Extent. |
|
uint8_t |
fixed_lines: 2 |
Fixed height as a multiple of the font height (number of lines), 0 for none. Only use for text on the first page: text after the first page fold with fixed lines is not guaranteed to draw.
|
|
const char * |
font_key |
Font key; if NULL the font is taken from style and style_font. |
|
int8_t |
line_spacing_delta: 4 |
Line spacing delta in pixels. |
|
LayoutContentSize |
style: 8 |
Content size used to pick the font. |
|
TextStyleFont |
style_font: 8 |
System theme font used to pick the font. |
◆ LayoutNodeHeadingsParagraphsConfig
| struct LayoutNodeHeadingsParagraphsConfig |
Headings and paragraphs node config.
| Data Fields |
|
LayoutNodeExtentConfig |
extent |
Extent. |
|
TextStyleFont |
heading_style_font: 8 |
Font of the headings. |
|
TextStyleFont |
paragraph_style_font: 8 |
Font of the paragraphs. |
|
LayoutContentSize |
size: 8 |
Content size used to pick the fonts. |
◆ LayoutNodeTextAttributeConfig
| struct LayoutNodeTextAttributeConfig |
Attribute text node config; no node is created if the attribute is empty.
◆ LayoutNodeTextBufferConfig
| struct LayoutNodeTextBufferConfig |
Buffer text node config; no node is created for an empty string.
| Data Fields |
|
const char * |
str |
String copied into the node. |
|
LayoutNodeTextConfig |
text |
Text config. |
|
bool |
use_i18n |
Whether str is an i18n key to translate. |
◆ LayoutNodeTextDynamicConfig
| struct LayoutNodeTextDynamicConfig |
Dynamic text node config.
◆ LayoutNodeContainerConfig
| struct LayoutNodeContainerConfig |
| Data Fields |
|
LayoutNodeExtentConfig |
extent |
Extent. |
|
uint8_t |
extra_capacity |
Extra child capacity, for nodes added after creation. |
|
LayoutNodeConfig ** |
nodes |
Configs of the child nodes. |
|
uint8_t |
num_nodes |
Number of child configs. |
◆ LayoutNodeHorizontalConfig
| struct LayoutNodeHorizontalConfig |
Horizontal container node config.
◆ LayoutNodeVerticalConfig
| struct LayoutNodeVerticalConfig |
Vertical container node config.
◆ LayoutNodeConstructorConfig
| struct LayoutNodeConstructorConfig |
◆ LayoutNodeIconConfig
| struct LayoutNodeIconConfig |
| Data Fields |
|
GAlign |
align |
Alignment of the icon. |
|
LayoutNodeExtentConfig |
extent |
Extent. |
|
KinoLayer ** |
icon_layer |
Set to the created KinoLayer, which is added to the layout; the caller destroys it. |
|
AppResourceInfo * |
res_info |
Resource of the icon. |
◆ LayoutNodeExtentConfig.offset
| struct LayoutNodeExtentConfig.offset |
Position delta, not affecting neighboring nodes.
| Data Fields |
|
int8_t |
x |
Horizontal offset in pixels. |
|
int8_t |
y |
Vertical offset in pixels. |
◆ LayoutNodeExtentConfig.margin
| struct LayoutNodeExtentConfig.margin |
Size delta, not affecting the node's internal positioning.
| Data Fields |
|
int8_t |
h |
Height delta in pixels. |
|
int8_t |
w |
Width delta in pixels. |
◆ ToGTextAlignment
| #define ToGTextAlignment |
( |
|
alignment | ) |
(alignment - 1) |
Convert a LayoutTextAlignment other than auto to a GTextAlignment.
- Parameters
-
| alignment | LayoutTextAlignment. |
◆ ToGVerticalAlignment
| #define ToGVerticalAlignment |
( |
|
alignment | ) |
(alignment - 1) |
Convert a LayoutVerticalAlignment other than auto to a GVerticalAlignment.
- Parameters
-
| alignment | LayoutVerticalAlignment. |
◆ ToLayoutContentSize
Convert a PreferredContentSize to a LayoutContentSize.
- Parameters
-
| size | PreferredContentSize. |
◆ ToLayoutTextAlignment
| #define ToLayoutTextAlignment |
( |
|
alignment | ) |
(alignment + 1) |
Convert a GTextAlignment to a LayoutTextAlignment.
- Parameters
-
◆ ToLayoutVerticalAlignment
| #define ToLayoutVerticalAlignment |
( |
|
alignment | ) |
(alignment + 1) |
Convert a GVerticalAlignment to a LayoutVerticalAlignment.
- Parameters
-
| alignment | GVerticalAlignment. |
◆ ToPreferredContentSize
| #define ToPreferredContentSize |
( |
|
size | ) |
((PreferredContentSize)((size) - 1)) |
Convert a LayoutContentSize other than auto to a PreferredContentSize.
- Parameters
-
◆ LayoutNodeConstructor
Build the node of a constructor node config.
- Parameters
-
| layout | Layout the node belongs to. |
| config | Config of the node. |
- Returns
- New node, or NULL.
◆ LayoutNodeTextDynamicUpdate
Fill the buffer of a dynamic text node.
- Parameters
-
| layout | Layout the node belongs to. |
| config | Config of the node. |
| [out] | buffer | Text buffer of config->buffer_size bytes. |
| render | true when drawing, false when measuring. |
◆ LayoutColor
Layout color used for text.
| Enumerator |
|---|
| LayoutColor_None | Keep the node's default color.
|
| LayoutColor_Primary | Primary color of the layout.
|
| LayoutColor_Secondary | Secondary color of the layout.
|
| LayoutColor_Background | Background color of the layout.
|
◆ LayoutContentSize
Content size; PreferredContentSize shifted so that 0 means the system size.
| Enumerator |
|---|
| LayoutContentSize_Auto | System content size.
|
| LayoutContentSize_Small | Small.
|
| LayoutContentSize_Medium | Medium.
|
| LayoutContentSize_Large | Large.
|
| LayoutContentSize_ExtraLarge | Extra large.
|
| LayoutContentSizeDefault | Platform default size.
|
◆ LayoutNodeType
Type of a node config, selecting the config struct.
◆ LayoutTextAlignment
Horizontal text alignment; GTextAlignment shifted so that 0 means automatic.
| Enumerator |
|---|
| LayoutTextAlignment_Auto | Left on rectangular displays, centered on round ones.
|
| LayoutTextAlignment_Left | Left aligned.
|
| LayoutTextAlignment_Center | Centered.
|
| LayoutTextAlignment_Right | Right aligned.
|
◆ LayoutVerticalAlignment
Vertical alignment; GVerticalAlignment shifted so that 0 means automatic.
| Enumerator |
|---|
| LayoutVerticalAlignment_Auto | Default alignment of the node.
|
| LayoutVerticalAlignment_Left | Top aligned.
|
| LayoutVerticalAlignment_Center | Centered.
|
| LayoutVerticalAlignment_Right | Bottom aligned.
|
◆ layout_create_headings_paragraphs_node()
Create a vertical node with the layout's headings and paragraphs.
- Parameters
-
| layout | Layout whose headings and paragraphs attributes are shown. |
| config | Fonts and content size. |
- Returns
- New node, or NULL if there are no headings.
◆ layout_create_text_node_from_config()
Create a tree of text nodes from a config.
- Parameters
-
| layout | Layout the nodes belong to. |
| config | Root config, may be NULL. |
- Returns
- New node tree, or NULL.
◆ layout_node_create_kino_layer_wrapper()
| GTextNodeCustom * layout_node_create_kino_layer_wrapper |
( |
KinoLayer * |
kino_layer | ) |
|
Wrap a KinoLayer in a custom text node that positions the layer during layout.
- Parameters
-
| kino_layer | Layer to position; not owned. |
- Returns
- New node.