C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
Ui Backend
Collaboration diagram for Ui Backend:

Topics

 Ui_ncurses
 NCurses UI backend — lifecycle, surface management, and capabilities.

Files

file  ui_backend.h
 Backend API for terminal UI library.
file  ui_conformance_test.c
 Compile-time and smoke-test conformance test for the UALUI API.
file  ui_layout.c
 Backend-agnostic layout helpers.
file  ui_layout.h
 UI layout management.

Data Structures

struct  UiFramedSurface

Functions

void ui_framed_surface_destroy (UiFramedSurface *fs)
 Destroys a framed surface and releases its resources.
UiFramedSurface ui_framed_surface_new (UiSurface *parent, UiRect rect)
 Creates a new framed surface with the specified parent and rectangle.

Detailed Description

Function Documentation

◆ ui_framed_surface_destroy()

void ui_framed_surface_destroy ( UiFramedSurface * fs)

Destroys a framed surface and releases its resources.

Destroy a framed surface and release its resources.

Parameters
fsThe UiFramedSurface to destroy.
fsPointer to the UiFramedSurface to destroy.

Destroys a framed surface and releases its resources.

Parameters
fsPointer to the UiFramedSurface to destroy.

Definition at line 54 of file ui_layout.c.

54 {
55 if (!fs)
56 return;
57 /* Destroy inner before outer (child before parent). */
58 if (fs->inner)
60 if (fs->outer)
62 fs->inner = NULL;
63 fs->outer = NULL;
64}
void ui_surface_destroy(UiSurface *s)
Destroy a UiSurface, cleaning up its windows and panels.
Definition ui_ncurses.c:468
UiSurface * inner
Definition ui_layout.h:22
UiSurface * outer
Definition ui_layout.h:21

References UiFramedSurface::inner, UiFramedSurface::outer, and ui_surface_destroy().

Here is the call graph for this function:

◆ ui_framed_surface_new()

UiFramedSurface ui_framed_surface_new ( UiSurface * parent,
UiRect rect )

Creates a new framed surface with the specified parent and rectangle.

Create a framed surface (outer border + inner content area).

Parameters
uiThe UI runtime context.
parentThe parent surface to which the framed surface will be attached.
rectThe rectangle defining the position and size of the framed surface.
Returns
A new UiFramedSurface instance, or NULL on failure.

The returned UiFramedSurface.outer is the frame panel; .inner is one row and one column smaller on each side (the drawable content area). The caller is responsible for destroying the framed surface with ui_framed_surface_destroy() when it is no longer needed.

Parameters
uiThe UiRuntime context.
parentParent surface, or NULL to make the frame a top-level panel.
rectPosition and size of the outer frame (including the border).
Returns
A UiFramedSurface; both fields are NULL on failure.

Creates a new framed surface with the specified parent and rectangle.

The returned UiFramedSurface.outer is the frame panel; .inner is one row and one column smaller on each side (the drawable content area). The caller is responsible for destroying the framed surface with ui_framed_surface_destroy() when it is no longer needed.

Parameters
uiThe UiRuntime context.
parentParent surface, or NULL to make the frame a top-level panel.
rectPosition and size of the outer frame (including the border).
Returns
A UiFramedSurface; both fields are NULL on failure.

Definition at line 26 of file ui_layout.c.

26 {
27 int w = 0;
28 UiFramedSurface fs = {NULL, NULL};
29
30 if (!ui || rect.lines < 3 || rect.cols < 3)
31 return fs;
32
33 // char title[64] = {};
34 fs.outer = ui_surface_new(w, parent, 0, rect.lines, rect.cols, rect.y, rect.x);
35 if (!fs.outer)
36 return fs;
37
38 rect.y = 1,
39 rect.x = 1,
40 rect.lines = rect.lines - 2,
41 rect.cols = rect.cols - 2,
42 fs.inner = ui_surface_new(w, fs.outer, 0, rect.lines, rect.cols, rect.y, rect.x);
43 if (!fs.inner) {
45 fs.outer = NULL;
46 }
47
48 return fs;
49}
UiSurface * ui_surface_new(ss_t w, UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x)
Create a new UI surface with the specified parameters.
Definition ui_ncurses.c:229
UiRuntime * ui
Definition ui_ncurses.c:39
int cols
Definition ui_backend.h:186
int lines
Definition ui_backend.h:185

References UiRect::cols, UiFramedSurface::inner, UiRect::lines, UiFramedSurface::outer, ui, ui_surface_destroy(), ui_surface_new(), UiRect::x, and UiRect::y.

Here is the call graph for this function: