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

idunn: what the widget classes share (not for apps). More...

#include "idunn.h"
#include <bragi.h>
#include <icon.h>

Go to the source code of this file.

Data Structures

struct  idunn_event_t
struct  idunn_anim_t
 a transition of one value (0 to 1) with the CSS ease-out curve. More...
struct  idunn_class_t
struct  idunn_widget
struct  idunn_context
struct  idunn_window
struct  idunn_edit_t

Macros

#define IDUNN_FOCUSABLE   0x01u
#define IDUNN_INTERACTIVE   0x02u
#define IDUNN_SHRINKS   0x04u
#define IDUNN_TEXT_INPUT   0x08u
#define IDUNN_CLIPS   0x10u
#define IDUNN_TAKES_TAB   0x20u
#define IDUNN_OWN_LOOK   0x40u
#define IDUNN_HOVER   0x01u
#define IDUNN_PRESSED   0x02u
#define IDUNN_FOCUSED   0x04u
#define IDUNN_DISABLED   0x08u
#define IDUNN_ERROR   0x10u
#define IDUNN_HIDDEN   0x20u
#define IDUNN_DAMAGE_MAX   8

Enumerations

enum  idunn_event_type_t {
  IDUNN_EV_CLICK , IDUNN_EV_KEY , IDUNN_EV_PRESS , IDUNN_EV_DRAG ,
  IDUNN_EV_RELEASE , IDUNN_EV_SCROLL , IDUNN_EV_FOCUS , IDUNN_EV_BLUR ,
  IDUNN_EV_TIMER , IDUNN_EV_PASTE , IDUNN_EV_MOTION , IDUNN_EV_MENU
}
enum  idunn_edit_result_t { IDUNN_EDIT_IGNORED , IDUNN_EDIT_USED , IDUNN_EDIT_MOVED , IDUNN_EDIT_CHANGED }
enum  idunn_side_t { IDUNN_SIDE_BELOW , IDUNN_SIDE_ABOVE , IDUNN_SIDE_RIGHT }

Functions

void idunn_window_add_damage (idunn_window_t *win, gfx_rect_t r)
 add a rect of the window that must be drawn again
int idunn_window_draw_parts (idunn_window_t *win, gfx_rect_t parts[IDUNN_DAMAGE_MAX+1])
 lay out and draw what changed, part by part.
void idunn_window_move_pixels (idunn_widget_t *w, gfx_rect_t area, int32_t dy)
 move the pixels of a rect of the window up (dy < 0) or down, as when its content scrolls: what stays in it is not drawn again, only the strip that comes into view.
bragi_face_t * idunn_face (idunn_context_t *ctx, idunn_text_t style)
const icon_t * idunn_icon (idunn_context_t *ctx, const char *name, int32_t size)
const icon_t * idunn_picture (idunn_context_t *ctx, const char *name, int32_t size)
 a colour icon of the Tela set (files, folders, apps), cached
idunn_widget_t * idunn_widget_new (const idunn_class_t *cls, void *data, uint32_t flags)
void idunn_measure (idunn_widget_t *w, int32_t max_width, int32_t *width, int32_t *height)
void idunn_place (idunn_widget_t *w, gfx_rect_t rect)
void idunn_dirty (idunn_widget_t *w)
void idunn_dirty_rect (idunn_widget_t *w, gfx_rect_t rect)
 draw a part of w again (a row of a list), with room for a ring
void idunn_relayout (idunn_widget_t *w)
void idunn_set_window (idunn_widget_t *w, idunn_window_t *win)
bool idunn_is_column (const idunn_widget_t *w)
void idunn_window_use_buffer (idunn_window_t *win, gfx_buffer_t *buf)
void idunn_window_free_widgets (idunn_window_t *win)
uint8_t idunn_hover_amount (idunn_widget_t *w)
 the hover and press looks now (0 to 255), for drawing
uint8_t idunn_press_amount (idunn_widget_t *w)
bool idunn_ring_visible (const idunn_widget_t *w)
 true when the focus ring shows
void idunn_anim_to (idunn_anim_t *a, float to, uint32_t now, uint32_t duration)
float idunn_anim_value (const idunn_anim_t *a, uint32_t now)
bool idunn_anim_running (const idunn_anim_t *a, uint32_t now)
void idunn_draw_text (idunn_context_t *ctx, gfx_buffer_t *buf, idunn_text_t style, int32_t x, int32_t y, int32_t max_width, const char *text, gfx_color_t color)
 a line of text in a style with the top of its line box at y; it ends with "..." if it is wider than max_width (0: any width).
bool idunn_send (idunn_widget_t *w, const idunn_event_t *ev)
 send an event to a widget: true if it used it
void idunn_wake (idunn_widget_t *w, uint32_t at)
 a TIMER event for w at a time (ms, as window->now); one time per widget
void idunn_copy (idunn_widget_t *w, const char *text, size_t length)
 put text on the clipboard; ask for its text (a PASTE event comes)
void idunn_paste (idunn_widget_t *w)
bool idunn_edit_set (idunn_edit_t *e, const char *text, size_t length)
void idunn_edit_free (idunn_edit_t *e)
size_t idunn_edit_start (const idunn_edit_t *e)
size_t idunn_edit_end (const idunn_edit_t *e)
size_t idunn_edit_prev (const idunn_edit_t *e, size_t pos)
size_t idunn_edit_next (const idunn_edit_t *e, size_t pos)
size_t idunn_edit_word_left (const idunn_edit_t *e, size_t pos)
size_t idunn_edit_word_right (const idunn_edit_t *e, size_t pos)
void idunn_edit_move (idunn_edit_t *e, size_t pos, bool extend)
void idunn_edit_select_word (idunn_edit_t *e, size_t pos)
bool idunn_edit_insert (idunn_edit_t *e, const char *text, size_t length)
 replace the selection with text
void idunn_edit_delete (idunn_edit_t *e, bool forward, bool word)
 delete the selection, or a character or a word before or after the caret
idunn_edit_result_t idunn_edit_key (idunn_widget_t *w, idunn_edit_t *e, const idunn_event_t *ev, bool multiline)
 the keys of editing: arrows, Home, End, Backspace, Delete, Ctrl+A/C/X/V, typing
bool idunn_edit_paste (idunn_edit_t *e, const char *text, size_t length, bool multiline)
 insert clipboard text (a single line keeps one line)
void idunn_option_measure (idunn_widget_t *w, int32_t control_w, int32_t control_h, const char *label, int32_t *width, int32_t *height)
gfx_rect_t idunn_option_control (const idunn_widget_t *w, int32_t control_w, int32_t control_h)
void idunn_option_draw_label (idunn_widget_t *w, gfx_buffer_t *buf, int32_t control_w, const char *label)
gfx_color_t idunn_option_border (const idunn_theme_t *t)
 the border of check boxes and radios (firmer than inputs in dark mode)
void idunn_reveal (idunn_widget_t *w, gfx_rect_t r)
 scroll the views w is in so that r (in the window) can be seen: a focused widget, the current row of a list.
bool idunn_shown (const idunn_widget_t *w)
 true if w and its parents are not hidden
idunn_window_t * idunn_popup_open (idunn_widget_t *owner, idunn_widget_t *root, gfx_rect_t anchor, idunn_side_t side, int32_t margin, bool tooltip)
 open a popup window next to anchor (a rect in owner's window) with root in it, margin pixels of room around root for its shadow.
void idunn_popup_close (idunn_window_t *popup)
 close a popup and the popups it has open.
void idunn_reap (idunn_context_t *ctx)
 free the closed popups (the app loop does it before each event)
void idunn_popup_close_all (idunn_window_t *popup)
 close a popup and the popups it came from (a chosen menu item)
idunn_window_t * idunn_menu_open (idunn_menu_t *menu, idunn_widget_t *owner, gfx_rect_t anchor, int current, void(*on_closed)(void *data), void *data)
 open a menu next to anchor (a rect in owner's window), with item current (or -1) as the current one; on_closed (or NULL) is called when it closes.
void idunn_focus (idunn_widget_t *w)
 give w the keyboard (without the ring)
void idunn_focus_first (idunn_widget_t *w)
 give the keyboard to the first widget that takes it in w
void idunn_tooltip_show (idunn_widget_t *w)
 show w's tooltip over it
idunn_widget_t * idunn_card_box (int gap, int padding, idunn_shadow_t shadow)
 a box with the card look and another shadow (popovers: md, dialogs: window)
void idunn_dialog_dismiss (idunn_window_t *win)
 close the dialog in win (Escape)
void idunn_draw_well (idunn_widget_t *w, gfx_buffer_t *buf)
 the well of a text input: fill, inset shadow, border and ring (text_field.c)
void idunn_draw_shadow (const idunn_theme_t *t, gfx_buffer_t *buf, gfx_rect_t box, int32_t radius, idunn_shadow_t which)
 all the layers of a shadow token around a round box
void idunn_draw_ring (const idunn_widget_t *w, gfx_buffer_t *buf, gfx_rect_t box, int32_t radius)
 the 3 px focus ring around a round box
int32_t idunn_overdraw (const idunn_theme_t *theme)
 how far drawing goes out of a widget's rect (rings and shadows)
int idunn_list_columns_at (const idunn_widget_t *list, int32_t *name_x, int32_t *row_x, int32_t *left, int32_t *right)
 the columns of a list view, in the window (for its heads).
bool idunn_list_column_left (const idunn_widget_t *list, int column)
 true if a column of a list is drawn at its left
void idunn_list_set_heads (idunn_widget_t *list, idunn_widget_t *heads)
 the heads over a list (NULL: none); the list draws them again on layout
void idunn_list_heads_forget (idunn_widget_t *heads)
 the list of these heads is freed
void idunn_draw_picture (const idunn_theme_t *t, gfx_buffer_t *buf, const icon_t *icon, int32_t x, int32_t y, uint8_t opacity)
 draw a Tela picture.

Detailed Description

idunn: what the widget classes share (not for apps).

Macro Definition Documentation

◆ IDUNN_FOCUSABLE

#define IDUNN_FOCUSABLE   0x01u

◆ IDUNN_INTERACTIVE

#define IDUNN_INTERACTIVE   0x02u

◆ IDUNN_SHRINKS

#define IDUNN_SHRINKS   0x04u

◆ IDUNN_TEXT_INPUT

#define IDUNN_TEXT_INPUT   0x08u

◆ IDUNN_CLIPS

#define IDUNN_CLIPS   0x10u

◆ IDUNN_TAKES_TAB

#define IDUNN_TAKES_TAB   0x20u

◆ IDUNN_OWN_LOOK

#define IDUNN_OWN_LOOK   0x40u

◆ IDUNN_HOVER

#define IDUNN_HOVER   0x01u

◆ IDUNN_PRESSED

#define IDUNN_PRESSED   0x02u

◆ IDUNN_FOCUSED

#define IDUNN_FOCUSED   0x04u

◆ IDUNN_DISABLED

#define IDUNN_DISABLED   0x08u

◆ IDUNN_ERROR

#define IDUNN_ERROR   0x10u

◆ IDUNN_HIDDEN

#define IDUNN_HIDDEN   0x20u

◆ IDUNN_DAMAGE_MAX

#define IDUNN_DAMAGE_MAX   8

Enumeration Type Documentation

◆ idunn_event_type_t

Enumerator
IDUNN_EV_CLICK 
IDUNN_EV_KEY 
IDUNN_EV_PRESS 
IDUNN_EV_DRAG 
IDUNN_EV_RELEASE 
IDUNN_EV_SCROLL 
IDUNN_EV_FOCUS 
IDUNN_EV_BLUR 
IDUNN_EV_TIMER 
IDUNN_EV_PASTE 
IDUNN_EV_MOTION 
IDUNN_EV_MENU 

◆ idunn_edit_result_t

Enumerator
IDUNN_EDIT_IGNORED 
IDUNN_EDIT_USED 
IDUNN_EDIT_MOVED 
IDUNN_EDIT_CHANGED 

◆ idunn_side_t

Enumerator
IDUNN_SIDE_BELOW 
IDUNN_SIDE_ABOVE 
IDUNN_SIDE_RIGHT 

Function Documentation

◆ idunn_window_add_damage()

void idunn_window_add_damage ( idunn_window_t * win,
gfx_rect_t r )

add a rect of the window that must be drawn again

◆ idunn_window_draw_parts()

int idunn_window_draw_parts ( idunn_window_t * win,
gfx_rect_t parts[IDUNN_DAMAGE_MAX+1] )

lay out and draw what changed, part by part.

Returns
how many parts were drawn (in parts).

◆ idunn_window_move_pixels()

void idunn_window_move_pixels ( idunn_widget_t * w,
gfx_rect_t area,
int32_t dy )

move the pixels of a rect of the window up (dy < 0) or down, as when its content scrolls: what stays in it is not drawn again, only the strip that comes into view.

w is the widget the rect belongs to (its clip).

◆ idunn_face()

bragi_face_t * idunn_face ( idunn_context_t * ctx,
idunn_text_t style )

◆ idunn_icon()

const icon_t * idunn_icon ( idunn_context_t * ctx,
const char * name,
int32_t size )

◆ idunn_picture()

const icon_t * idunn_picture ( idunn_context_t * ctx,
const char * name,
int32_t size )

a colour icon of the Tela set (files, folders, apps), cached

◆ idunn_widget_new()

idunn_widget_t * idunn_widget_new ( const idunn_class_t * cls,
void * data,
uint32_t flags )

◆ idunn_measure()

void idunn_measure ( idunn_widget_t * w,
int32_t max_width,
int32_t * width,
int32_t * height )

◆ idunn_place()

void idunn_place ( idunn_widget_t * w,
gfx_rect_t rect )

◆ idunn_dirty()

void idunn_dirty ( idunn_widget_t * w)

◆ idunn_dirty_rect()

void idunn_dirty_rect ( idunn_widget_t * w,
gfx_rect_t rect )

draw a part of w again (a row of a list), with room for a ring

◆ idunn_relayout()

void idunn_relayout ( idunn_widget_t * w)

◆ idunn_set_window()

void idunn_set_window ( idunn_widget_t * w,
idunn_window_t * win )

◆ idunn_is_column()

bool idunn_is_column ( const idunn_widget_t * w)

◆ idunn_window_use_buffer()

void idunn_window_use_buffer ( idunn_window_t * win,
gfx_buffer_t * buf )

◆ idunn_window_free_widgets()

void idunn_window_free_widgets ( idunn_window_t * win)

◆ idunn_hover_amount()

uint8_t idunn_hover_amount ( idunn_widget_t * w)

the hover and press looks now (0 to 255), for drawing

◆ idunn_press_amount()

uint8_t idunn_press_amount ( idunn_widget_t * w)

◆ idunn_ring_visible()

bool idunn_ring_visible ( const idunn_widget_t * w)

true when the focus ring shows

◆ idunn_anim_to()

void idunn_anim_to ( idunn_anim_t * a,
float to,
uint32_t now,
uint32_t duration )

◆ idunn_anim_value()

float idunn_anim_value ( const idunn_anim_t * a,
uint32_t now )

◆ idunn_anim_running()

bool idunn_anim_running ( const idunn_anim_t * a,
uint32_t now )

◆ idunn_draw_text()

void idunn_draw_text ( idunn_context_t * ctx,
gfx_buffer_t * buf,
idunn_text_t style,
int32_t x,
int32_t y,
int32_t max_width,
const char * text,
gfx_color_t color )

a line of text in a style with the top of its line box at y; it ends with "..." if it is wider than max_width (0: any width).

◆ idunn_send()

bool idunn_send ( idunn_widget_t * w,
const idunn_event_t * ev )

send an event to a widget: true if it used it

◆ idunn_wake()

void idunn_wake ( idunn_widget_t * w,
uint32_t at )

a TIMER event for w at a time (ms, as window->now); one time per widget

◆ idunn_copy()

void idunn_copy ( idunn_widget_t * w,
const char * text,
size_t length )

put text on the clipboard; ask for its text (a PASTE event comes)

◆ idunn_paste()

void idunn_paste ( idunn_widget_t * w)

◆ idunn_edit_set()

bool idunn_edit_set ( idunn_edit_t * e,
const char * text,
size_t length )

◆ idunn_edit_free()

void idunn_edit_free ( idunn_edit_t * e)

◆ idunn_edit_start()

size_t idunn_edit_start ( const idunn_edit_t * e)

◆ idunn_edit_end()

size_t idunn_edit_end ( const idunn_edit_t * e)

◆ idunn_edit_prev()

size_t idunn_edit_prev ( const idunn_edit_t * e,
size_t pos )

◆ idunn_edit_next()

size_t idunn_edit_next ( const idunn_edit_t * e,
size_t pos )

◆ idunn_edit_word_left()

size_t idunn_edit_word_left ( const idunn_edit_t * e,
size_t pos )

◆ idunn_edit_word_right()

size_t idunn_edit_word_right ( const idunn_edit_t * e,
size_t pos )

◆ idunn_edit_move()

void idunn_edit_move ( idunn_edit_t * e,
size_t pos,
bool extend )

◆ idunn_edit_select_word()

void idunn_edit_select_word ( idunn_edit_t * e,
size_t pos )

◆ idunn_edit_insert()

bool idunn_edit_insert ( idunn_edit_t * e,
const char * text,
size_t length )

replace the selection with text

◆ idunn_edit_delete()

void idunn_edit_delete ( idunn_edit_t * e,
bool forward,
bool word )

delete the selection, or a character or a word before or after the caret

◆ idunn_edit_key()

idunn_edit_result_t idunn_edit_key ( idunn_widget_t * w,
idunn_edit_t * e,
const idunn_event_t * ev,
bool multiline )

the keys of editing: arrows, Home, End, Backspace, Delete, Ctrl+A/C/X/V, typing

◆ idunn_edit_paste()

bool idunn_edit_paste ( idunn_edit_t * e,
const char * text,
size_t length,
bool multiline )

insert clipboard text (a single line keeps one line)

◆ idunn_option_measure()

void idunn_option_measure ( idunn_widget_t * w,
int32_t control_w,
int32_t control_h,
const char * label,
int32_t * width,
int32_t * height )

◆ idunn_option_control()

gfx_rect_t idunn_option_control ( const idunn_widget_t * w,
int32_t control_w,
int32_t control_h )

◆ idunn_option_draw_label()

void idunn_option_draw_label ( idunn_widget_t * w,
gfx_buffer_t * buf,
int32_t control_w,
const char * label )

◆ idunn_option_border()

gfx_color_t idunn_option_border ( const idunn_theme_t * t)

the border of check boxes and radios (firmer than inputs in dark mode)

◆ idunn_reveal()

void idunn_reveal ( idunn_widget_t * w,
gfx_rect_t r )

scroll the views w is in so that r (in the window) can be seen: a focused widget, the current row of a list.

◆ idunn_shown()

bool idunn_shown ( const idunn_widget_t * w)

true if w and its parents are not hidden

◆ idunn_popup_open()

idunn_window_t * idunn_popup_open ( idunn_widget_t * owner,
idunn_widget_t * root,
gfx_rect_t anchor,
idunn_side_t side,
int32_t margin,
bool tooltip )

open a popup window next to anchor (a rect in owner's window) with root in it, margin pixels of room around root for its shadow.

a popup that owner's window has open already is closed first.

Returns
the popup, or NULL.

◆ idunn_popup_close()

void idunn_popup_close ( idunn_window_t * popup)

close a popup and the popups it has open.

it is freed by idunn_reap: the event that closed it can still be using it.

◆ idunn_reap()

void idunn_reap ( idunn_context_t * ctx)

free the closed popups (the app loop does it before each event)

◆ idunn_popup_close_all()

void idunn_popup_close_all ( idunn_window_t * popup)

close a popup and the popups it came from (a chosen menu item)

◆ idunn_menu_open()

idunn_window_t * idunn_menu_open ( idunn_menu_t * menu,
idunn_widget_t * owner,
gfx_rect_t anchor,
int current,
void(* on_closed )(void *data),
void * data )

open a menu next to anchor (a rect in owner's window), with item current (or -1) as the current one; on_closed (or NULL) is called when it closes.

◆ idunn_focus()

void idunn_focus ( idunn_widget_t * w)

give w the keyboard (without the ring)

◆ idunn_focus_first()

void idunn_focus_first ( idunn_widget_t * w)

give the keyboard to the first widget that takes it in w

◆ idunn_tooltip_show()

void idunn_tooltip_show ( idunn_widget_t * w)

show w's tooltip over it

◆ idunn_card_box()

idunn_widget_t * idunn_card_box ( int gap,
int padding,
idunn_shadow_t shadow )

a box with the card look and another shadow (popovers: md, dialogs: window)

◆ idunn_dialog_dismiss()

void idunn_dialog_dismiss ( idunn_window_t * win)

close the dialog in win (Escape)

◆ idunn_draw_well()

void idunn_draw_well ( idunn_widget_t * w,
gfx_buffer_t * buf )

the well of a text input: fill, inset shadow, border and ring (text_field.c)

◆ idunn_draw_shadow()

void idunn_draw_shadow ( const idunn_theme_t * t,
gfx_buffer_t * buf,
gfx_rect_t box,
int32_t radius,
idunn_shadow_t which )

all the layers of a shadow token around a round box

◆ idunn_draw_ring()

void idunn_draw_ring ( const idunn_widget_t * w,
gfx_buffer_t * buf,
gfx_rect_t box,
int32_t radius )

the 3 px focus ring around a round box

◆ idunn_overdraw()

int32_t idunn_overdraw ( const idunn_theme_t * theme)

how far drawing goes out of a widget's rect (rings and shadows)

◆ idunn_list_columns_at()

int idunn_list_columns_at ( const idunn_widget_t * list,
int32_t * name_x,
int32_t * row_x,
int32_t * left,
int32_t * right )

the columns of a list view, in the window (for its heads).

Parameters
name_xwhere the names start.
row_xwhere the rows start.
left,rightthe edges of each column (COLUMNS_MAX at most).
Returns
the column count (0 for a grid).

◆ idunn_list_column_left()

bool idunn_list_column_left ( const idunn_widget_t * list,
int column )

true if a column of a list is drawn at its left

◆ idunn_list_set_heads()

void idunn_list_set_heads ( idunn_widget_t * list,
idunn_widget_t * heads )

the heads over a list (NULL: none); the list draws them again on layout

◆ idunn_list_heads_forget()

void idunn_list_heads_forget ( idunn_widget_t * heads)

the list of these heads is freed

◆ idunn_draw_picture()

void idunn_draw_picture ( const idunn_theme_t * t,
gfx_buffer_t * buf,
const icon_t * icon,
int32_t x,
int32_t y,
uint8_t opacity )

draw a Tela picture.

in the light theme a faint edge of its own shape goes under it, so a white page (a text file) shows on a white ground.