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

The pane selector: one bench, several views of it. More...

#include <stdbool.h>
#include "gfx.h"
#include "touch_types.h"
#include "ui_text.h"

Go to the source code of this file.

Data Structures

struct  ui_tabs_t
 A row of tabs: their labels, where they are, which is selected and the press under way. More...

Macros

#define UI_TABS_MAX   6
 The most tabs one row holds.
#define UI_TABS_LABEL_H   32
 A row UI_TABS_LABEL_H (32px) tall or taller whose every label fits its tab in the 10 x 20 face, UI_TABS_PAD px clear each side, draws its labels in that face; another row in UI_FONT_LABEL (8 x 16). The test runs in the language shown, so one row draws in one face.
#define UI_TABS_PAD   6
 The room a tab keeps left and right of a 10 x 20 label: 6px.

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.
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.
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.
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_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: one bench, several views of it.

Readings and controls stay in place while the pane switches, so a change of view never moves a control that is about to be pressed.

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_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.