lv_span.h

Typedefs

typedef struct _lv_span_coords_t lv_span_coords_t

Coords of a span

Enums

enum lv_span_overflow_t

Values:

enumerator LV_SPAN_OVERFLOW_CLIP
enumerator LV_SPAN_OVERFLOW_ELLIPSIS
enumerator LV_SPAN_OVERFLOW_LAST

Fence member

enum lv_span_mode_t

Values:

enumerator LV_SPAN_MODE_FIXED

fixed the obj size

enumerator LV_SPAN_MODE_EXPAND

Expand the object size to the text size

enumerator LV_SPAN_MODE_BREAK

Keep width, break the too long lines and expand height

enumerator LV_SPAN_MODE_LAST

Fence member

Functions

void lv_span_stack_init(void)
void lv_span_stack_deinit(void)
lv_obj_t *lv_spangroup_create(lv_obj_t *parent)

Create a spangroup object

Parameters:

parent – pointer to an object, it will be the parent of the new spangroup

Returns:

pointer to the created spangroup

lv_span_t *lv_spangroup_new_span(lv_obj_t *obj)

Create a span string descriptor and add to spangroup.

Parameters:

obj – pointer to a spangroup object.

Returns:

pointer to the created span.

void lv_spangroup_delete_span(lv_obj_t *obj, lv_span_t *span)

Remove the span from the spangroup and free memory.

Parameters:
  • obj – pointer to a spangroup object.

  • span – pointer to a span.

void lv_span_set_text(lv_span_t *span, const char *text)

Set a new text for a span. Memory will be allocated to store the text by the span.

Parameters:
  • span – pointer to a span.

  • text – pointer to a text.

void lv_span_set_text_static(lv_span_t *span, const char *text)

Set a static text. It will not be saved by the span so the 'text' variable has to be 'alive' while the span exist.

Parameters:
  • span – pointer to a span.

  • text – pointer to a text.

void lv_spangroup_set_align(lv_obj_t *obj, lv_text_align_t align)

Set the align of the spangroup.

Parameters:
  • obj – pointer to a spangroup object.

  • align – see lv_text_align_t for details.

void lv_spangroup_set_overflow(lv_obj_t *obj, lv_span_overflow_t overflow)

Set the overflow of the spangroup.

Parameters:
  • obj – pointer to a spangroup object.

  • overflow – see lv_span_overflow_t for details.

void lv_spangroup_set_indent(lv_obj_t *obj, int32_t indent)

Set the indent of the spangroup.

Parameters:
  • obj – pointer to a spangroup object.

  • indent – the first line indentation

void lv_spangroup_set_mode(lv_obj_t *obj, lv_span_mode_t mode)

Set the mode of the spangroup.

Parameters:
  • obj – pointer to a spangroup object.

  • mode – see lv_span_mode_t for details.

void lv_spangroup_set_max_lines(lv_obj_t *obj, int32_t lines)

Set maximum lines of the spangroup.

Parameters:
  • obj – pointer to a spangroup object.

  • lines – max lines that can be displayed in LV_SPAN_MODE_BREAK mode. < 0 means no limit.

lv_style_t *lv_span_get_style(lv_span_t *span)

Get a pointer to the style of a span

Parameters:

span – pointer to the span

Returns:

pointer to the style. valid as long as the span is valid

const char *lv_span_get_text(lv_span_t *span)

Get a pointer to the text of a span

Parameters:

span – pointer to the span

Returns:

pointer to the text

lv_span_t *lv_spangroup_get_child(const lv_obj_t *obj, int32_t id)

Get a spangroup child by its index.

Parameters:
  • obj – The spangroup object

  • id – the index of the child. 0: the oldest (firstly created) child 1: the second oldest child count-1: the youngest -1: the youngest -2: the second youngest

Returns:

The child span at index id, or NULL if the ID does not exist

uint32_t lv_spangroup_get_span_count(const lv_obj_t *obj)

Get number of spans

Parameters:

obj – the spangroup object to get the child count of.

Returns:

the span count of the spangroup.

lv_text_align_t lv_spangroup_get_align(lv_obj_t *obj)

Get the align of the spangroup.

Parameters:

obj – pointer to a spangroup object.

Returns:

the align value.

lv_span_overflow_t lv_spangroup_get_overflow(lv_obj_t *obj)

Get the overflow of the spangroup.

Parameters:

obj – pointer to a spangroup object.

Returns:

the overflow value.

int32_t lv_spangroup_get_indent(lv_obj_t *obj)

Get the indent of the spangroup.

Parameters:

obj – pointer to a spangroup object.

Returns:

the indent value.

lv_span_mode_t lv_spangroup_get_mode(lv_obj_t *obj)

Get the mode of the spangroup.

Parameters:

obj – pointer to a spangroup object.

int32_t lv_spangroup_get_max_lines(lv_obj_t *obj)

Get maximum lines of the spangroup.

Parameters:

obj – pointer to a spangroup object.

Returns:

the max lines value.

int32_t lv_spangroup_get_max_line_height(lv_obj_t *obj)

Get max line height of all span in the spangroup.

Parameters:

obj – pointer to a spangroup object.

uint32_t lv_spangroup_get_expand_width(lv_obj_t *obj, uint32_t max_width)

Get the text content width when all span of spangroup on a line.

Parameters:
  • obj – pointer to a spangroup object.

  • max_width – if text content width >= max_width, return max_width to reduce computation, if max_width == 0, returns the text content width.

Returns:

text content width or max_width.

int32_t lv_spangroup_get_expand_height(lv_obj_t *obj, int32_t width)

Get the text content height with width fixed.

Parameters:
  • obj – pointer to a spangroup object.

  • width – the width of the span group.

lv_span_coords_t lv_spangroup_get_span_coords(lv_obj_t *obj, const lv_span_t *span)

Get the span's coords in the spangroup.

Note

Before calling this function, please make sure that the layout of span group has been updated. Like calling lv_obj_update_layout() like function.

+--------+
|Heading +--->------------------+
|  Pos   |   |     Heading      |
+--------+---+------------------+
|                               |
|                               |
|                               |
|            Middle   +--------+|
|                     |Trailing||
|                   +-|  Pos   ||
|                   | +--------+|
+-------------------v-----------+
|     Trailing      |
+-------------------+

Parameters:
  • obj – pointer to a spangroup object.

  • span – pointer to a span.

Returns:

the span's coords in the spangroup.

lv_span_t *lv_spangroup_get_span_by_point(lv_obj_t *obj, const lv_point_t *point)

Get the span object by point.

Parameters:
  • obj – pointer to a spangroup object.

  • point – pointer to point containing absolute coordinates

Returns:

pointer to the span under the point or NULL if not found.

void lv_spangroup_refr_mode(lv_obj_t *obj)

Update the mode of the spangroup.

Parameters:

obj – pointer to a spangroup object.

Variables

const lv_obj_class_t lv_spangroup_class
struct _lv_span_coords_t
#include <lv_span.h>

Coords of a span

Public Members

lv_area_t heading
lv_area_t middle
lv_area_t trailing