Line Widget¶
Overview¶
The Line widget draws a straight line between two points within its bounding area. Useful for dividers, graph axes, decorative separators, and simple diagrams.
Enable¶
No feature flag required — the Line widget is always available.
Creation¶
mgui_widget_t* line = mgui_allocate_widget(
parent,
MGUI_WIDGET_LINE,
(mgui_area_t){x, y, width, height},
MGUI_COLOR_WHITE
);
The bounding box
{x, y, width, height}implicitly defines the line's start and end points: - Horizontal line:height ≈ 1–2, widewidth- Vertical line:width ≈ 1–2, tallheight- Diagonal line: arbitrarywidthandheight
API Reference¶
Position & Size¶
mgui_widget_set_pos(line, int16_t x, int16_t y);
mgui_widget_set_size(line, int16_t width, int16_t height);
Appearance¶
mgui_widget_color_change(line, MGUI_COLOR_CYAN);
mgui_widget_border_property(line, MGUI_COLOR_WHITE, 1); // optional border
mgui_widget_set_visible(line, bool visible);
Examples¶
Horizontal Divider¶
mgui_widget_t* divider = mgui_allocate_widget(screen, MGUI_WIDGET_LINE,
(mgui_area_t){20, 100, 760, 2}, MGUI_COLOR_DARK_GRAY);
Vertical Separator¶
mgui_widget_t* vsep = mgui_allocate_widget(screen, MGUI_WIDGET_LINE,
(mgui_area_t){400, 20, 2, 440}, MGUI_COLOR_GRAY);
Diagonal Accent¶
mgui_widget_t* diag = mgui_allocate_widget(screen, MGUI_WIDGET_LINE,
(mgui_area_t){50, 50, 100, 60}, MGUI_COLOR_ELEM_LIGHT_CYAN);
Section Header with Underline¶
mgui_widget_t* header = mgui_allocate_widget(screen, MGUI_WIDGET_LABEL,
(mgui_area_t){20, 30, 200, 25}, MGUI_COLOR_BLACK);
mgui_widget_label_set_text(header, "Settings");
mgui_widget_t* underline = mgui_allocate_widget(screen, MGUI_WIDGET_LINE,
(mgui_area_t){20, 58, 200, 2}, MGUI_COLOR_ELEM_CYAN_BLUE);
Common Combinations¶
| Use Case | Setup |
|---|---|
| Section divider | 1–2 px thick horizontal line spanning full width |
| Left panel border | Vertical line at panel right edge |
| Grid lines | Multiple evenly-spaced lines inside a chart container |
| Axis indicator | Two lines forming an L-shape (X + Y axis) |