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

icons from the icon packs in /usr/share/icons. More...

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

Go to the source code of this file.

Data Structures

struct  icon_t

Macros

#define ICON_DIR   "/usr/share/icons/"
#define ICON_NAME_MAX   31

Typedefs

typedef struct icon_set icon_set_t

Functions

icon_set_t * icon_set_open (const char *path)
 open a pack file.
icon_set_t * icon_set_named (const char *name)
 open a set by its name: ICON_DIR "<name>.pack".
void icon_set_close (icon_set_t *set)
bool icon_set_is_mask (const icon_set_t *set)
 true if the set is of masks (lucide), false if of colour images (tela).
bool icon_set_has (const icon_set_t *set, const char *name)
 true if the set has an icon of exactly this name.
icon_t * icon_load (icon_set_t *set, const char *name, int32_t size, int32_t scale)
 load an icon.
void icon_free (icon_t *icon)
void icon_draw_mask (gfx_buffer_t *buf, const icon_t *icon, int32_t x, int32_t y, gfx_color_t color)
 draw an icon in a colour: a mask's coverage, or a colour image's alpha.
void icon_draw (gfx_buffer_t *buf, const icon_t *icon, int32_t x, int32_t y, uint8_t opacity)
 draw an icon as it is, with an opacity (255: opaque).

Detailed Description

icons from the icon packs in /usr/share/icons.

two sets: "lucide" has line icons as coverage masks, drawn in a colour given at draw time (window controls, toolbars); "tela" has full colour icons (apps, places, file types, devices). tools/icons/build.py makes the packs; the format is described there.

an icon is loaded at a size and a scale (1, or 2 for a 2x screen). when the pack has no image of that many pixels, the next larger one is scaled down (or the largest one up).

Macro Definition Documentation

◆ ICON_DIR

#define ICON_DIR   "/usr/share/icons/"

◆ ICON_NAME_MAX

#define ICON_NAME_MAX   31

Typedef Documentation

◆ icon_set_t

typedef struct icon_set icon_set_t

Function Documentation

◆ icon_set_open()

icon_set_t * icon_set_open ( const char * path)

open a pack file.

Returns
the set, or NULL (no file, or not an icon pack).

◆ icon_set_named()

icon_set_t * icon_set_named ( const char * name)

open a set by its name: ICON_DIR "<name>.pack".

◆ icon_set_close()

void icon_set_close ( icon_set_t * set)

◆ icon_set_is_mask()

bool icon_set_is_mask ( const icon_set_t * set)

true if the set is of masks (lucide), false if of colour images (tela).

◆ icon_set_has()

bool icon_set_has ( const icon_set_t * set,
const char * name )

true if the set has an icon of exactly this name.

◆ icon_load()

icon_t * icon_load ( icon_set_t * set,
const char * name,
int32_t size,
int32_t scale )

load an icon.

a name the set does not have falls back as in the freedesktop icon naming spec: the last part after a dash is removed until a name is found (text-x-csrc, text-x, text), then "unknown".

Parameters
sizethe icon size in points (16, 20, 24, 32, 48, 64, or any).
scale1 to 4 (2 for a 2x screen); the icon is size * scale pixels, at most 1024.
Returns
the icon (free it with icon_free), or NULL.

◆ icon_free()

void icon_free ( icon_t * icon)

◆ icon_draw_mask()

void icon_draw_mask ( gfx_buffer_t * buf,
const icon_t * icon,
int32_t x,
int32_t y,
gfx_color_t color )

draw an icon in a colour: a mask's coverage, or a colour image's alpha.

◆ icon_draw()

void icon_draw ( gfx_buffer_t * buf,
const icon_t * icon,
int32_t x,
int32_t y,
uint8_t opacity )

draw an icon as it is, with an opacity (255: opaque).

a mask is drawn in black.