BSB Developer Docs
Loading...
Searching...
No Matches
label.h File Reference

A simple text label widget. More...

#include <gui/widget.h>
#include <gui/gui.h>
#include <toolbox/color.h>
#include <font_registry/fonts.h>

Go to the source code of this file.

Typedefs

typedef struct Label Label
 Label opaque structure.
 

Enumerations

enum  TextAlign {
  TextAlignAuto , TextAlignLeft , TextAlignCenter , TextAlignRight ,
  TextAlignMax
}
 Enumeration of possible text alignment types. More...
 
enum  LabelLongContentMode {
  LabelLongContentModeWrap , LabelLongContentModeDots , LabelLongContentModeScroll , LabelLongContentModeScrollCircular ,
  LabelLongContentModeClip , LabelLongContentModeCount
}
 Enumeration of possible behaviour with long content. More...
 
enum  LabelFontSize { LabelFontSizeSmall , LabelFontSizeNormal , LabelFontSizeLarge }
 

Functions

Label * label_alloc (Widget *parent)
 Create a new Label instance.
 
void label_free (Label *instance)
 Delete a Label instance.
 
Widget * label_get_base (Label *instance)
 Get a pointer to the base class instance.
 
void label_set_text (Label *instance, const char *text)
 Set the label text.
 
void label_set_text_color (Label *instance, Color color)
 Set the label text color.
 
void label_set_inline_text_color_formatting (Label *instance, bool enable)
 Enable or disable inline text color formatting Example: "This is a #ff0000 red# word".
 
void label_set_text_font_size (Label *instance, LabelFontSize size)
 Set the label font size.
 
void label_set_text_fmt (Label *instance, const char *fmt,...) __attribute__((__format__(__printf__
 Set the label text with printf-like formatting.
 
void void label_set_line_spacing (Label *instance, int32_t spacing)
 Set the label line spacing.
 
void label_set_text_align (Label *instance, TextAlign align)
 Set the label text alignment.
 
void label_set_long_content_mode (Label *instance, LabelLongContentMode mode)
 Set label long content mode.
 
void label_set_long_content_anim_start_delay (Label *instance, uint32_t delay)
 Set the initial delay before the long content animation starts.
 
void label_set_long_content_anim_repeat_delay (Label *instance, uint32_t delay)
 Set the pause duration between the long content animation repetitions.
 
void label_set_long_content_anim_speed (Label *instance, uint32_t speed)
 Set the scroll animation speed for a label.
 
void label_set_font (Label *instance, const char *font_path)
 Set font of label text.
 

Detailed Description

A simple text label widget.

Enumeration Type Documentation

◆ LabelLongContentMode

Enumeration of possible behaviour with long content.

Enumerator
LabelLongContentModeWrap 

Keep the object width, wrap lines longer than object width and expand the object height.

LabelLongContentModeDots 

Keep the size and write dots at the end if the text is too long.

LabelLongContentModeScroll 

Keep the size and roll the text back and forth.

LabelLongContentModeScrollCircular 

Keep the size and roll the text circularly.

LabelLongContentModeClip 

Keep the size and clip the text out of it.

LabelLongContentModeCount 

Count of possible choices.

◆ TextAlign

enum TextAlign

Enumeration of possible text alignment types.

Enumerator
TextAlignAuto 

Align text automatically.

TextAlignLeft 

Align text to the left.

TextAlignCenter 

Align text to the centre.

TextAlignRight 

Align text to the right.

TextAlignMax 

Special value, not to be used in application code.

Function Documentation

◆ label_alloc()

Label * label_alloc ( Widget * parent)

Create a new Label instance.

Parameters
[in,out]parentpointer to the parent Widget instance
Returns
pointer to the newly created Label instance

◆ label_free()

void label_free ( Label * instance)

Delete a Label instance.

Parameters
[in,out]instancepointer to the Label instance to be deleted

◆ label_get_base()

Widget * label_get_base ( Label * instance)

Get a pointer to the base class instance.

The return value can be used in all Widget methods.

Parameters
[in,out]instancepointer to the Label instance to be queried
Returns
pointer to the base class instance

◆ label_set_font()

void label_set_font ( Label * instance,
const char * font_path )

Set font of label text.

Parameters
[in,out]instancepointer to the Label instance to be modified
[in]font_pathpath to font file

◆ label_set_inline_text_color_formatting()

void label_set_inline_text_color_formatting ( Label * instance,
bool enable )

Enable or disable inline text color formatting Example: "This is a #ff0000 red# word".

Parameters
[in,out]instancepointer to the Label instance to be modified
[in]enabletrue to enable recoloring, false otherwise

◆ label_set_line_spacing()

void void label_set_line_spacing ( Label * instance,
int32_t spacing )

Set the label line spacing.

Parameters
[in,out]instancepointer to the Label instance to be modified
[in]spacingspacing value in pixels

◆ label_set_long_content_anim_repeat_delay()

void label_set_long_content_anim_repeat_delay ( Label * instance,
uint32_t delay )

Set the pause duration between the long content animation repetitions.

Only applies to scrollable modes (LabelLongContentModeScroll, LabelLongContentModeScrollCircular).

Parameters
[in,out]instancepointer to the Label instance to be modified
[in]delaypause duration in milliseconds between successive scroll cycles

◆ label_set_long_content_anim_speed()

void label_set_long_content_anim_speed ( Label * instance,
uint32_t speed )

Set the scroll animation speed for a label.

Warning
Only valid for LabelLongContentModeScrollCircular.
Parameters
[in,out]instancepointer to the Label instance
[in]speedscroll speed in pixels per minute (must be > 0)

◆ label_set_long_content_anim_start_delay()

void label_set_long_content_anim_start_delay ( Label * instance,
uint32_t delay )

Set the initial delay before the long content animation starts.

Only applies to scrollable modes (LabelLongContentModeScroll, LabelLongContentModeScrollCircular).

Parameters
[in,out]instancepointer to the Label instance to be modified
[in]delaydelay in milliseconds before the animation begins

◆ label_set_long_content_mode()

void label_set_long_content_mode ( Label * instance,
LabelLongContentMode mode )

Set label long content mode.

Parameters
[in,out]instancepointer to the Label instance to be modified
[in]modenew long content mode for label

◆ label_set_text()

void label_set_text ( Label * instance,
const char * text )

Set the label text.

Parameters
[in,out]instancepointer to the Label instance to be modified
[in]textzero-terminated string containing the text to be shown

◆ label_set_text_align()

void label_set_text_align ( Label * instance,
TextAlign align )

Set the label text alignment.

Parameters
[in,out]instancepointer to the Label instance to be modified
[in]alignenum value to determine the alignment type

◆ label_set_text_color()

void label_set_text_color ( Label * instance,
Color color )

Set the label text color.

Parameters
[in,out]instancepointer to the Label instance to be modified
[in]colortext color

◆ label_set_text_fmt()

void label_set_text_fmt ( Label * instance,
const char * fmt,
... )

Set the label text with printf-like formatting.

Parameters
[in,out]instancepointer to the Label instance to be modified
[in]fmtzero-terminated format string
[in]...variadic list of arguments according to the format string

◆ label_set_text_font_size()

void label_set_text_font_size ( Label * instance,
LabelFontSize size )

Set the label font size.

Parameters
[in,out]instancepointer to the Label instance to be modified
[in]sizefont size