rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
ui_tabs.c File Reference

The pane selector: rows of tabs, their touch and their look. See ui_tabs.h. More...

#include "ui_tabs.h"
#include <string.h>
#include "ui_text.h"
#include "ui_theme.h"
#include "ui_widgets.h"

Functions

void ui_tabs_init (ui_tabs_t *t, const char *const *labels, int count, gfx_rect_t row)
 Tabs whose labels are drawn as given, in every language: row split into count tabs 4px apart, the first selected.
void ui_tabs_init_text (ui_tabs_t *t, const ui_text_id_t *ids, int count, gfx_rect_t row)
 Tabs whose labels are looked up at every draw, so they follow the language.
static const char * ui_tabs_label (const ui_tabs_t *t, int i)
bool ui_tabs_event (ui_tabs_t *t, const touch_event_t *evt)
 One touch event: a tab is selected on the release, as a tap, of the press that began on it.
void ui_tabs_cancel (ui_tabs_t *t)
 Abandon a press in progress.
const gfx_font_t * ui_tabs_font (const ui_tabs_t *t)
 The face the tabs' labels are drawn in now.
void ui_tabs_render (const ui_tabs_t *t, gfx_canvas_t *c)
 The tabs' labels in the face of ui_tabs_font(), centred in each tab; the selected tab raised in a sunk trough 3px around the row.
void ui_tabs_render_locked (const ui_tabs_t *t, gfx_canvas_t *c, bool locked)
 The tabs as ui_tabs_render() draws them, or with locked as a control that takes no press: the trough outlined, the selected tab's label dim rather than in the accent, a press under way not drawn. The screen feeds a locked control no event.

Detailed Description

The pane selector: rows of tabs, their touch and their look. See ui_tabs.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ ui_tabs_cancel()

void ui_tabs_cancel ( ui_tabs_t * t)

Abandon a press in progress.

A screen calls it when told its record of the glass is stale: a latched press owns a track id the controller reuses, so a later contact that began elsewhere and lifts over the tab would otherwise be taken for the missing release and switch the pane.

Parameters
tThe tabs; NULL does nothing.

◆ ui_tabs_event()

bool ui_tabs_event ( ui_tabs_t * t,
const touch_event_t * evt )

One touch event: a tab is selected on the release, as a tap, of the press that began on it.

Parameters
tThe tabs.
evtThe event.
Returns
True when the selection changed.

◆ ui_tabs_font()

const gfx_font_t * ui_tabs_font ( const ui_tabs_t * t)

The face the tabs' labels are drawn in now.

Parameters
tThe tabs.
Returns
The 10 x 20 face or UI_FONT_LABEL, as UI_TABS_LABEL_H says; UI_FONT_LABEL for NULL or no tab.

◆ ui_tabs_init()

void ui_tabs_init ( ui_tabs_t * t,
const char *const * labels,
int count,
gfx_rect_t row )

Tabs whose labels are drawn as given, in every language: row split into count tabs 4px apart, the first selected.

Parameters
tThe tabs; NULL does nothing.
labelsThe labels; NULL does nothing.
countThe tabs, at most UI_TABS_MAX.
rowThe row.

◆ ui_tabs_init_text()

void ui_tabs_init_text ( ui_tabs_t * t,
const ui_text_id_t * ids,
int count,
gfx_rect_t row )

Tabs whose labels are looked up at every draw, so they follow the language.

Parameters
tThe tabs; NULL does nothing.
idsThe labels' texts; NULL does nothing.
countThe tabs, at most UI_TABS_MAX.
rowThe row.

◆ ui_tabs_label()

const char * ui_tabs_label ( const ui_tabs_t * t,
int i )
static

Tab i's label as it is drawn now.

◆ ui_tabs_render()

void ui_tabs_render ( const ui_tabs_t * t,
gfx_canvas_t * c )

The tabs' labels in the face of ui_tabs_font(), centred in each tab; the selected tab raised in a sunk trough 3px around the row.

Parameters
tThe tabs.
cCanvas.

◆ ui_tabs_render_locked()

void ui_tabs_render_locked ( const ui_tabs_t * t,
gfx_canvas_t * c,
bool locked )

The tabs as ui_tabs_render() draws them, or with locked as a control that takes no press: the trough outlined, the selected tab's label dim rather than in the accent, a press under way not drawn. The screen feeds a locked control no event.

Parameters
tThe tabs.
cCanvas.
lockedDraw them as taking no press.