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

idunn: a window's widgets: layout, drawing what changed, and the pointer and the keys. More...

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

Macros

#define HOVER_MS   100
#define DOUBLE_CLICK_MS   500
#define DOUBLE_CLICK_PX   4
#define TIP_MS   600
#define TIP_AGAIN_MS   300

Functions

idunn_window_t * idunn_window_offscreen (idunn_context_t *ctx, int32_t width, int32_t height)
 a window that draws into its own buffer, of that many pixels.
void idunn_window_free_widgets (idunn_window_t *win)
void idunn_window_set_root (idunn_window_t *win, idunn_widget_t *root)
 the widget that fills the window (a row or a column, usually).
void idunn_window_use_buffer (idunn_window_t *win, gfx_buffer_t *buf)
void idunn_window_resize (idunn_window_t *win, int32_t width, int32_t height)
 a new size for the window's buffer (the window lays out again).
gfx_buffer_t * idunn_window_buffer (const idunn_window_t *win)
void idunn_window_invalidate (idunn_window_t *win)
 the whole window must be drawn again (after a theme change).
void idunn_window_add_damage (idunn_window_t *win, gfx_rect_t r)
 add a rect of the window that must be drawn again
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.
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.
gfx_rect_t idunn_window_draw (idunn_window_t *win)
 lay out and draw what changed.
bool idunn_window_tick (idunn_window_t *win, uint32_t now)
 the time now in ms, for transitions.
uint32_t idunn_window_next_wake (const idunn_window_t *win)
 the next time (ms) the window must be ticked for a timer, or 0 for none.
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)
void idunn_window_paste (idunn_window_t *win, const char *text, size_t length)
 the clipboard text a widget asked for came (from the window server).
uint32_t idunn_window_cursor (const idunn_window_t *win)
 the pointer shape for where the pointer is (IDUNN_CURSOR_).
idunn_widget_t * idunn_window_focus (const idunn_window_t *win)
 the widget with the keyboard focus, or NULL.
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_window_pointer (idunn_window_t *win, idunn_pointer_t kind, int32_t x, int32_t y, uint32_t mods)
 the pointer moved, or the left button went down or up, at (x, y), with these modifier keys held (Shift+click extends a selection).
void idunn_window_on_key (idunn_window_t *win, idunn_key_hook_t on_key, void *data)
void idunn_window_key (idunn_window_t *win, uint16_t code, uint32_t mods, const char *text)
 a key press (or repeat).
void idunn_focus (idunn_widget_t *w)
 give w the keyboard (without the ring)
void idunn_set_focus (idunn_widget_t *w)
 give the keyboard to a widget in a window (a canvas at the start).
void idunn_focus_first (idunn_widget_t *w)
 give the keyboard to the first widget that takes it in w
void idunn_window_scroll (idunn_window_t *win, int32_t x, int32_t y, int32_t steps)
 the wheel turned over (x, y): steps, up is positive.

Detailed Description

idunn: a window's widgets: layout, drawing what changed, and the pointer and the keys.

no window server here (app.c has it), so the host tests can drive a window.

Macro Definition Documentation

◆ HOVER_MS

#define HOVER_MS   100

◆ DOUBLE_CLICK_MS

#define DOUBLE_CLICK_MS   500

◆ DOUBLE_CLICK_PX

#define DOUBLE_CLICK_PX   4

◆ TIP_MS

#define TIP_MS   600

◆ TIP_AGAIN_MS

#define TIP_AGAIN_MS   300

Function Documentation

◆ idunn_window_offscreen()

idunn_window_t * idunn_window_offscreen ( idunn_context_t * ctx,
int32_t width,
int32_t height )

a window that draws into its own buffer, of that many pixels.

◆ idunn_window_free_widgets()

void idunn_window_free_widgets ( idunn_window_t * win)

◆ idunn_window_set_root()

void idunn_window_set_root ( idunn_window_t * win,
idunn_widget_t * root )

the widget that fills the window (a row or a column, usually).

the window owns the tree from now on.

◆ idunn_window_use_buffer()

void idunn_window_use_buffer ( idunn_window_t * win,
gfx_buffer_t * buf )

◆ idunn_window_resize()

void idunn_window_resize ( idunn_window_t * win,
int32_t width,
int32_t height )

a new size for the window's buffer (the window lays out again).

◆ idunn_window_buffer()

gfx_buffer_t * idunn_window_buffer ( const idunn_window_t * win)

◆ idunn_window_invalidate()

void idunn_window_invalidate ( idunn_window_t * win)

the whole window must be drawn again (after a theme change).

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

gfx_rect_t idunn_window_draw ( idunn_window_t * win)

lay out and draw what changed.

Returns
the part of the buffer that changed (empty: none).

◆ idunn_window_tick()

bool idunn_window_tick ( idunn_window_t * win,
uint32_t now )

the time now in ms, for transitions.

Returns
true while a transition runs (draw again in a frame).

◆ idunn_window_next_wake()

uint32_t idunn_window_next_wake ( const idunn_window_t * win)

the next time (ms) the window must be ticked for a timer, or 0 for none.

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

void idunn_window_paste ( idunn_window_t * win,
const char * text,
size_t length )

the clipboard text a widget asked for came (from the window server).

◆ idunn_window_cursor()

uint32_t idunn_window_cursor ( const idunn_window_t * win)

the pointer shape for where the pointer is (IDUNN_CURSOR_).

◆ idunn_window_focus()

idunn_widget_t * idunn_window_focus ( const idunn_window_t * win)

the widget with the keyboard focus, or NULL.

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

void idunn_window_pointer ( idunn_window_t * win,
idunn_pointer_t kind,
int32_t x,
int32_t y,
uint32_t mods )

the pointer moved, or the left button went down or up, at (x, y), with these modifier keys held (Shift+click extends a selection).

◆ idunn_window_on_key()

void idunn_window_on_key ( idunn_window_t * win,
idunn_key_hook_t on_key,
void * data )

◆ idunn_window_key()

void idunn_window_key ( idunn_window_t * win,
uint16_t code,
uint32_t mods,
const char * text )

a key press (or repeat).

Parameters
codea Linux key code (KEY_ in sys/input.h).
textthe characters it types (UTF-8), or "".

◆ idunn_focus()

void idunn_focus ( idunn_widget_t * w)

give w the keyboard (without the ring)

◆ idunn_set_focus()

void idunn_set_focus ( idunn_widget_t * w)

give the keyboard to a widget in a window (a canvas at the start).

◆ idunn_focus_first()

void idunn_focus_first ( idunn_widget_t * w)

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

◆ idunn_window_scroll()

void idunn_window_scroll ( idunn_window_t * win,
int32_t x,
int32_t y,
int32_t steps )

the wheel turned over (x, y): steps, up is positive.