RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
input.h File Reference

input.h — the one input event and result every element input function shares. More...

#include <stddef.h>
#include <stdint.h>
#include <limits.h>
#include "mask.h"

Data Structures

struct  rmgui_input_t
 One event in logical framebuffer pixels. More...
struct  rmgui_input_result_t
 An element input function's report: what happened, and how the host routes the next events. More...

Macros

#define RMGUI_INPUT_MOD_SHIFT   1u
 KEY modifier bits (rmgui_input_t.u.key.mods).
#define RMGUI_INPUT_MOD_CTRL   2u
#define RMGUI_INPUT_MOD_ALT   4u
#define RMGUI_INPUT_MOD_META   8u

Enumerations

enum  rmgui_input_kind_t {
  RMGUI_INPUT_KIND_POINTER_MOVE , RMGUI_INPUT_KIND_POINTER_PRESS , RMGUI_INPUT_KIND_POINTER_RELEASE , RMGUI_INPUT_KIND_POINTER_LEAVE ,
  RMGUI_INPUT_KIND_WHEEL , RMGUI_INPUT_KIND_KEY , RMGUI_INPUT_KIND_TEXT , RMGUI_INPUT_KIND_FOCUS_IN ,
  RMGUI_INPUT_KIND_FOCUS_OUT , RMGUI_INPUT_KIND_AUX_PRESS , RMGUI_INPUT_KIND_AUX_RELEASE , RMGUI_INPUT_KIND_TOUCH_DOWN ,
  RMGUI_INPUT_KIND_TOUCH_MOVE , RMGUI_INPUT_KIND_TOUCH_UP , RMGUI_INPUT_KIND_TOUCH_CANCEL , RMGUI_INPUT_KIND_COMPOSITION
}
 What an input event reports. More...
enum  rmgui_input_key_t {
  RMGUI_INPUT_KEY_TAB , RMGUI_INPUT_KEY_LEFT , RMGUI_INPUT_KEY_RIGHT , RMGUI_INPUT_KEY_UP ,
  RMGUI_INPUT_KEY_DOWN , RMGUI_INPUT_KEY_HOME , RMGUI_INPUT_KEY_END , RMGUI_INPUT_KEY_PAGE_UP ,
  RMGUI_INPUT_KEY_PAGE_DOWN , RMGUI_INPUT_KEY_SPACE , RMGUI_INPUT_KEY_ENTER , RMGUI_INPUT_KEY_BACKSPACE ,
  RMGUI_INPUT_KEY_DELETE , RMGUI_INPUT_KEY_ESCAPE , RMGUI_INPUT_KEY_CHAR
}
 A key the elements act on; hosts map their platform keys onto these. More...
enum  rmgui_cursor_t {
  RMGUI_CURSOR_NONE , RMGUI_CURSOR_ARROW , RMGUI_CURSOR_TEXT , RMGUI_CURSOR_POINTER ,
  RMGUI_CURSOR_RESIZE_EW , RMGUI_CURSOR_RESIZE_NS , RMGUI_CURSOR_RESIZE_NWSE , RMGUI_CURSOR_RESIZE_NESW
}
 Host cursor request. More...
enum  rmgui_input_result_kind_t {
  RMGUI_INPUT_RESULT_NONE , RMGUI_INPUT_RESULT_ACTIVATE , RMGUI_INPUT_RESULT_CHANGE , RMGUI_INPUT_RESULT_SUBMIT ,
  RMGUI_INPUT_RESULT_ACTION , RMGUI_INPUT_RESULT_OPEN , RMGUI_INPUT_RESULT_CANCEL , RMGUI_INPUT_RESULT_REFUSED
}
 What an element reports for one event. More...

Functions

static void rmgui_input_shape (const rmgui_mask_t *shape, rmgui_rect_t rect, const rmgui_input_t *in, rmgui_input_t *out)
 Copy *in to *out, filtering MOVE, PRESS, RELEASE and WHEEL positions through shape stretched over rect.

Detailed Description

input.h — the one input event and result every element input function shares.

Key routing: the host delivers KEY and TEXT events only to the element it considers focused (an open popup counts as focused while it is open); every element acts on every KEY and TEXT event it is given. FOCUS_IN and FOCUS_OUT only tell an element that the host's focus moved (its FOCUSED bit), they never gate keys. Pointer events go to the element under the pointer, and to the element holding the capture while it holds it.

Macro Definition Documentation

◆ RMGUI_INPUT_MOD_SHIFT

#define RMGUI_INPUT_MOD_SHIFT   1u

KEY modifier bits (rmgui_input_t.u.key.mods).

◆ RMGUI_INPUT_MOD_CTRL

#define RMGUI_INPUT_MOD_CTRL   2u

◆ RMGUI_INPUT_MOD_ALT

#define RMGUI_INPUT_MOD_ALT   4u

◆ RMGUI_INPUT_MOD_META

#define RMGUI_INPUT_MOD_META   8u

Enumeration Type Documentation

◆ rmgui_input_kind_t

What an input event reports.

Enumerator
RMGUI_INPUT_KIND_POINTER_MOVE 
RMGUI_INPUT_KIND_POINTER_PRESS 
RMGUI_INPUT_KIND_POINTER_RELEASE 
RMGUI_INPUT_KIND_POINTER_LEAVE 

pointer left the surface: clears hover/press, ends capture

RMGUI_INPUT_KIND_WHEEL 
RMGUI_INPUT_KIND_KEY 
RMGUI_INPUT_KIND_TEXT 
RMGUI_INPUT_KIND_FOCUS_IN 

host focus moved onto the element

RMGUI_INPUT_KIND_FOCUS_OUT 

host focus left the element

RMGUI_INPUT_KIND_AUX_PRESS 
RMGUI_INPUT_KIND_AUX_RELEASE 
RMGUI_INPUT_KIND_TOUCH_DOWN 
RMGUI_INPUT_KIND_TOUCH_MOVE 
RMGUI_INPUT_KIND_TOUCH_UP 
RMGUI_INPUT_KIND_TOUCH_CANCEL 
RMGUI_INPUT_KIND_COMPOSITION 

◆ rmgui_input_key_t

A key the elements act on; hosts map their platform keys onto these.

Enumerator
RMGUI_INPUT_KEY_TAB 
RMGUI_INPUT_KEY_LEFT 
RMGUI_INPUT_KEY_RIGHT 
RMGUI_INPUT_KEY_UP 
RMGUI_INPUT_KEY_DOWN 
RMGUI_INPUT_KEY_HOME 
RMGUI_INPUT_KEY_END 
RMGUI_INPUT_KEY_PAGE_UP 
RMGUI_INPUT_KEY_PAGE_DOWN 
RMGUI_INPUT_KEY_SPACE 
RMGUI_INPUT_KEY_ENTER 
RMGUI_INPUT_KEY_BACKSPACE 
RMGUI_INPUT_KEY_DELETE 
RMGUI_INPUT_KEY_ESCAPE 
RMGUI_INPUT_KEY_CHAR 

Unicode scalar in u.key.codepoint; never inserts text.

◆ rmgui_cursor_t

Host cursor request.

NONE leaves the host's current arbitration unchanged; ARROW explicitly restores the default. Results are requests, not OS calls.

Enumerator
RMGUI_CURSOR_NONE 
RMGUI_CURSOR_ARROW 
RMGUI_CURSOR_TEXT 
RMGUI_CURSOR_POINTER 
RMGUI_CURSOR_RESIZE_EW 
RMGUI_CURSOR_RESIZE_NS 
RMGUI_CURSOR_RESIZE_NWSE 
RMGUI_CURSOR_RESIZE_NESW 

◆ rmgui_input_result_kind_t

What an element reports for one event.

Enumerator
RMGUI_INPUT_RESULT_NONE 

nothing to report

RMGUI_INPUT_RESULT_ACTIVATE 

the element was activated (value: element-defined, 0 if none)

RMGUI_INPUT_RESULT_CHANGE 

the element's value changed (value: new value / index)

RMGUI_INPUT_RESULT_SUBMIT 

the element's value was submitted (field ENTER)

RMGUI_INPUT_RESULT_ACTION 

a command was picked (value: element's action/control enum)

RMGUI_INPUT_RESULT_OPEN 

a popup opened: the host re-declares its overlay nodes

RMGUI_INPUT_RESULT_CANCEL 

a popup closed without a pick, or ESC dropped a transient edit

RMGUI_INPUT_RESULT_REFUSED 

disabled primary press inside: value=0, consumed=1, captured=0

Function Documentation

◆ rmgui_input_shape()

void rmgui_input_shape ( const rmgui_mask_t * shape,
rmgui_rect_t rect,
const rmgui_input_t * in,
rmgui_input_t * out )
inlinestatic

Copy *in to *out, filtering MOVE, PRESS, RELEASE and WHEEL positions through shape stretched over rect.

A position inside rect but below the mask hit threshold is moved outside by changing x to rect.x - 1, or rect.x + rect.w when rect.x == INT_MIN. Both are representable: the latter is used only for a positive width. y and every other field remain unchanged; LEAVE, KEY, TEXT and FOCUS events are copied unchanged. NULL shape copies unchanged. NULL in/out is a no-op; in == out is allowed. For grouped element input, rect must enclose all of its input regions. Filtering does not cancel capture: the element handles the outside event according to its normal drag/release contract.