The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
idunn_theme.h File Reference

idunn: the design tokens (colours, sizes, text styles, shadows). More...

#include <conf.h>
#include <gfx.h>
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  idunn_text_style_t
struct  idunn_theme_t

Macros

#define IDUNN_SHADOW_LAYERS   4
#define IDUNN_HIDPI_WIDTH   2400
 screens at least this wide get scale 2 when the scale is auto

Enumerations

enum  idunn_mode_t { IDUNN_LIGHT , IDUNN_DARK }
enum  idunn_color_t {
  IDUNN_COLOR_BACKGROUND , IDUNN_COLOR_FOREGROUND , IDUNN_COLOR_SURFACE , IDUNN_COLOR_SIDEBAR ,
  IDUNN_COLOR_CARD , IDUNN_COLOR_CARD_FOREGROUND , IDUNN_COLOR_MUTED , IDUNN_COLOR_MUTED_FOREGROUND ,
  IDUNN_COLOR_BORDER , IDUNN_COLOR_INPUT , IDUNN_COLOR_FIELD , IDUNN_COLOR_PRIMARY ,
  IDUNN_COLOR_PRIMARY_FOREGROUND , IDUNN_COLOR_SECONDARY , IDUNN_COLOR_SECONDARY_FOREGROUND , IDUNN_COLOR_HOVER ,
  IDUNN_COLOR_ACCENT , IDUNN_COLOR_ACCENT_FOREGROUND , IDUNN_COLOR_SELECTION , IDUNN_COLOR_DESTRUCTIVE ,
  IDUNN_COLOR_RING , IDUNN_COLOR_OVERLAY , IDUNN_COLOR_TITLE_TOP , IDUNN_COLOR_TITLE_BOTTOM ,
  IDUNN_COLOR_TOP_LIGHT , IDUNN_COLOR_COUNT
}
enum  idunn_text_t {
  IDUNN_TEXT_BODY , IDUNN_TEXT_LABEL , IDUNN_TEXT_SMALL , IDUNN_TEXT_TITLE ,
  IDUNN_TEXT_HEADING , IDUNN_TEXT_DISPLAY , IDUNN_TEXT_MONO , IDUNN_TEXT_CAPTION ,
  IDUNN_TEXT_HERO , IDUNN_TEXT_COUNT
}
enum  idunn_shadow_t { IDUNN_SHADOW_XS , IDUNN_SHADOW_MD , IDUNN_SHADOW_WINDOW , IDUNN_SHADOW_COUNT }

Functions

void idunn_theme_default (idunn_theme_t *theme)
 the default theme: dark, rose, 13 px text, 6 px radius.
void idunn_theme_from_conf (idunn_theme_t *theme, const conf_t *conf)
 a theme from a theme file (or from text, for tests); missing or bad values keep their defaults.
void idunn_theme_load (idunn_theme_t *theme)
 read the user's theme (conf_open("theme")).
bool idunn_theme_fit (idunn_theme_t *theme, int32_t screen_width)
 set the scale for a screen when the theme's scale is auto.
const char * idunn_color_name (idunn_color_t which)
 the name of a colour token in the theme file ("muted-foreground"), or NULL.
int32_t idunn_radius (const idunn_theme_t *theme)
 buttons, inputs, list rows
int32_t idunn_radius_sm (const idunn_theme_t *theme)
 check boxes, small items in menus: half the radius
int32_t idunn_radius_lg (const idunn_theme_t *theme)
 cards, dialogs, popovers, windows: the radius + 4
idunn_text_style_t idunn_text_style (const idunn_theme_t *theme, idunn_text_t which)
 a text style at the theme's font size and scale.
int idunn_shadow (const idunn_theme_t *theme, idunn_shadow_t which, gfx_shadow_t layers[IDUNN_SHADOW_LAYERS])
 the layers of a shadow, in the order to draw them (the CSS list from its end), at the theme's scale.

Detailed Description

idunn: the design tokens (colours, sizes, text styles, shadows).

the tokens are the only place colours and sizes are written: widgets and heimdalld use token names, never numbers. the values follow the agreed look (plans/idunn-ui-plan.md, section 2), shadcn's "zinc" theme with the user's accent colour.

the theme file (/etc/ginnos/theme.conf and ~/.config/ginnos/theme.conf) has these keys in [theme]: mode (light or dark), accent (rose, blue, green, orange, violet, neutral, or #rrggbb), font_size (13 to 15; all text styles follow), scale (1 or 2), motion (true or false) and radius (4 to 12; the small and large radii follow). the sections [light] and [dark] can change any colour token for that mode, by its name: "border = #ffffff1a".

Macro Definition Documentation

◆ IDUNN_SHADOW_LAYERS

#define IDUNN_SHADOW_LAYERS   4

◆ IDUNN_HIDPI_WIDTH

#define IDUNN_HIDPI_WIDTH   2400

screens at least this wide get scale 2 when the scale is auto

Enumeration Type Documentation

◆ idunn_mode_t

Enumerator
IDUNN_LIGHT 
IDUNN_DARK 

◆ idunn_color_t

Enumerator
IDUNN_COLOR_BACKGROUND 
IDUNN_COLOR_FOREGROUND 
IDUNN_COLOR_SURFACE 
IDUNN_COLOR_SIDEBAR 
IDUNN_COLOR_CARD 
IDUNN_COLOR_CARD_FOREGROUND 
IDUNN_COLOR_MUTED 
IDUNN_COLOR_MUTED_FOREGROUND 
IDUNN_COLOR_BORDER 
IDUNN_COLOR_INPUT 
IDUNN_COLOR_FIELD 
IDUNN_COLOR_PRIMARY 
IDUNN_COLOR_PRIMARY_FOREGROUND 
IDUNN_COLOR_SECONDARY 
IDUNN_COLOR_SECONDARY_FOREGROUND 
IDUNN_COLOR_HOVER 
IDUNN_COLOR_ACCENT 
IDUNN_COLOR_ACCENT_FOREGROUND 
IDUNN_COLOR_SELECTION 
IDUNN_COLOR_DESTRUCTIVE 
IDUNN_COLOR_RING 
IDUNN_COLOR_OVERLAY 
IDUNN_COLOR_TITLE_TOP 
IDUNN_COLOR_TITLE_BOTTOM 
IDUNN_COLOR_TOP_LIGHT 
IDUNN_COLOR_COUNT 

◆ idunn_text_t

Enumerator
IDUNN_TEXT_BODY 
IDUNN_TEXT_LABEL 
IDUNN_TEXT_SMALL 
IDUNN_TEXT_TITLE 
IDUNN_TEXT_HEADING 
IDUNN_TEXT_DISPLAY 
IDUNN_TEXT_MONO 
IDUNN_TEXT_CAPTION 
IDUNN_TEXT_HERO 
IDUNN_TEXT_COUNT 

◆ idunn_shadow_t

Enumerator
IDUNN_SHADOW_XS 
IDUNN_SHADOW_MD 
IDUNN_SHADOW_WINDOW 
IDUNN_SHADOW_COUNT 

Function Documentation

◆ idunn_theme_default()

void idunn_theme_default ( idunn_theme_t * theme)

the default theme: dark, rose, 13 px text, 6 px radius.

◆ idunn_theme_from_conf()

void idunn_theme_from_conf ( idunn_theme_t * theme,
const conf_t * conf )

a theme from a theme file (or from text, for tests); missing or bad values keep their defaults.

◆ idunn_theme_load()

void idunn_theme_load ( idunn_theme_t * theme)

read the user's theme (conf_open("theme")).

◆ idunn_theme_fit()

bool idunn_theme_fit ( idunn_theme_t * theme,
int32_t screen_width )

set the scale for a screen when the theme's scale is auto.

Returns
true if the scale changed.

◆ idunn_color_name()

const char * idunn_color_name ( idunn_color_t which)

the name of a colour token in the theme file ("muted-foreground"), or NULL.

◆ idunn_radius()

int32_t idunn_radius ( const idunn_theme_t * theme)

buttons, inputs, list rows

◆ idunn_radius_sm()

int32_t idunn_radius_sm ( const idunn_theme_t * theme)

check boxes, small items in menus: half the radius

◆ idunn_radius_lg()

int32_t idunn_radius_lg ( const idunn_theme_t * theme)

cards, dialogs, popovers, windows: the radius + 4

◆ idunn_text_style()

idunn_text_style_t idunn_text_style ( const idunn_theme_t * theme,
idunn_text_t which )

a text style at the theme's font size and scale.

◆ idunn_shadow()

int idunn_shadow ( const idunn_theme_t * theme,
idunn_shadow_t which,
gfx_shadow_t layers[IDUNN_SHADOW_LAYERS] )

the layers of a shadow, in the order to draw them (the CSS list from its end), at the theme's scale.

Returns
the number of layers (at most IDUNN_SHADOW_LAYERS).