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

idunn: the widget tree, sizes, what must be drawn again, and transitions. More...

#include "idunn_internal.h"
#include <stdlib.h>
#include <string.h>

Functions

idunn_widget_t * idunn_widget_new (const idunn_class_t *cls, void *data, uint32_t flags)
idunn_widget_t * idunn_add (idunn_widget_t *parent, idunn_widget_t *child)
 add child at the end of parent.
void idunn_set_tooltip (idunn_widget_t *w, const char *text)
 a tooltip: shown over the widget after 600 ms under the pointer (NULL: none)
void idunn_free_later (idunn_widget_t *w)
 free w (and its children) after the event that is running: for a widget that may be in its own callback (a button that rebuilds the view it is in).
void idunn_widget_free (idunn_widget_t *w)
 take a widget out of its parent and free it and its children.
void idunn_set_window (idunn_widget_t *w, idunn_window_t *win)
idunn_widget_t * idunn_grow (idunn_widget_t *w, int weight)
 let a widget take a share of the free space along its box.
void idunn_set_size (idunn_widget_t *w, int32_t width, int32_t height)
 a size a widget must have, in design pixels (0: its own size).
void idunn_set_disabled (idunn_widget_t *w, bool disabled)
 a disabled widget is drawn at half opacity and gets no input.
void idunn_set_error (idunn_widget_t *w, bool error)
 a control with a wrong value: its border and ring are red (a field sets this on its control with idunn_field_set_error).
gfx_rect_t idunn_widget_rect (const idunn_widget_t *w)
 where a widget is in its window, after layout.
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_set_hidden (idunn_widget_t *w, bool hidden)
 a hidden widget is not drawn, takes no room in its box and gets no input.
bool idunn_shown (const idunn_widget_t *w)
 true if w and its parents are not hidden
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.
void idunn_relayout (idunn_widget_t *w)
bool idunn_ring_visible (const idunn_widget_t *w)
 true when the focus ring shows
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)
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_on_middle_click (idunn_widget_t *w, idunn_callback_t on_middle, void *data)
 on_middle on a press of the middle button on the widget or in it (the nearest widget that has one): a task button closes its window.
void idunn_on_key (idunn_widget_t *w, idunn_widget_key_t on_key, void *data)
void idunn_on_menu (idunn_widget_t *w, idunn_callback_t on_menu, void *data)
 on_menu on a right click on the widget or in it, when no widget in it used the click (a list view uses it on its items: idunn_list_view_on_menu).
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: the widget tree, sizes, what must be drawn again, and transitions.

Function Documentation

◆ idunn_widget_new()

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

◆ idunn_add()

idunn_widget_t * idunn_add ( idunn_widget_t * parent,
idunn_widget_t * child )

add child at the end of parent.

Returns
child.

◆ idunn_set_tooltip()

void idunn_set_tooltip ( idunn_widget_t * w,
const char * text )

a tooltip: shown over the widget after 600 ms under the pointer (NULL: none)

◆ idunn_free_later()

void idunn_free_later ( idunn_widget_t * w)

free w (and its children) after the event that is running: for a widget that may be in its own callback (a button that rebuilds the view it is in).

◆ idunn_widget_free()

void idunn_widget_free ( idunn_widget_t * w)

take a widget out of its parent and free it and its children.

◆ idunn_set_window()

void idunn_set_window ( idunn_widget_t * w,
idunn_window_t * win )

◆ idunn_grow()

idunn_widget_t * idunn_grow ( idunn_widget_t * w,
int weight )

let a widget take a share of the free space along its box.

Returns
w.

◆ idunn_set_size()

void idunn_set_size ( idunn_widget_t * w,
int32_t width,
int32_t height )

a size a widget must have, in design pixels (0: its own size).

◆ idunn_set_disabled()

void idunn_set_disabled ( idunn_widget_t * w,
bool disabled )

a disabled widget is drawn at half opacity and gets no input.

◆ idunn_set_error()

void idunn_set_error ( idunn_widget_t * w,
bool error )

a control with a wrong value: its border and ring are red (a field sets this on its control with idunn_field_set_error).

◆ idunn_widget_rect()

gfx_rect_t idunn_widget_rect ( const idunn_widget_t * w)

where a widget is in its window, after layout.

◆ 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_set_hidden()

void idunn_set_hidden ( idunn_widget_t * w,
bool hidden )

a hidden widget is not drawn, takes no room in its box and gets no input.

◆ idunn_shown()

bool idunn_shown ( const idunn_widget_t * w)

true if w and its parents are not hidden

◆ 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_relayout()

void idunn_relayout ( idunn_widget_t * w)

◆ idunn_ring_visible()

bool idunn_ring_visible ( const idunn_widget_t * w)

true when the focus ring shows

◆ 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_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_on_middle_click()

void idunn_on_middle_click ( idunn_widget_t * w,
idunn_callback_t on_middle,
void * data )

on_middle on a press of the middle button on the widget or in it (the nearest widget that has one): a task button closes its window.

◆ idunn_on_key()

void idunn_on_key ( idunn_widget_t * w,
idunn_widget_key_t on_key,
void * data )

◆ idunn_on_menu()

void idunn_on_menu ( idunn_widget_t * w,
idunn_callback_t on_menu,
void * data )

on_menu on a right click on the widget or in it, when no widget in it used the click (a list view uses it on its items: idunn_list_view_on_menu).

open a menu with idunn_menu_popup_at_pointer.

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