C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
ui_layout.h File Reference

UI layout management. More...

#include "ui_backend.h"
Include dependency graph for ui_layout.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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

UI layout management.

This module provides functions for creating and managing framed surfaces, which consist of an outer surface (the frame) and an inner surface (the content area).

Definition in file ui_layout.h.

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)
Definition ui_ncurses.c:377
UiSurface * inner
Definition ui_layout.h:20
UiSurface * outer
Definition ui_layout.h:19

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] = {0};
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(uint w, UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x)
Definition ui_ncurses.c:414
UiRuntime * ui
int cols
Definition ui_backend.h:121
int lines
Definition ui_backend.h:120

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: