|
RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
|
chart_axis.h — the visible range of a chart, 1/2/5 tick selection for value and time axes, time labels, and the axis grid painter. More...
#include <stddef.h>#include <stdint.h>#include "fb.h"#include "font.h"#include "geom.h"#include "style.h"#include "draw_target.h"#include "ui_context.h"Data Structures | |
| struct | rmgui_chart_view_t |
| Visible chart value range [v0, v1] and time window [t0, t1] in ms. More... | |
Macros | |
| #define | RMGUI_CHART_VIEW_T_DEFINED |
Functions | |
| size_t | rmgui_chart_ticks (int32_t v0, int32_t v1, int max_ticks, int32_t *out, size_t cap) |
| Ticks for the value range [v0, v1]: the step is the least of 1, 2, 5, 10, 20, 50, ... whose multiples in [v0, v1] number at most max_ticks, and the ticks are those multiples in ascending order (possibly none). | |
| size_t | rmgui_chart_time_ticks (uint32_t t0, uint32_t t1, int max_ticks, uint32_t *out, size_t cap) |
| rmgui_chart_ticks for the time window [t0, t1] in ms: the step is the least of 1, 2, 5, 10, ... ms whose multiples in [t0, t0 + (t1 - t0)] (counted without wrapping) number at most max_ticks; each tick is written as that multiple reduced mod 2^32, ascending in wrapping order. | |
| size_t | rmgui_chart_time_label (uint32_t t_ms, char *out, size_t cap) |
| Formats t_ms, floored to whole seconds, as "m:ss" below one hour and "h:mm:ss" from one hour on (0 -> "0:00", 59999 -> "0:59", 3600000 -> "1:00:00"; at most 10 characters). | |
| void | rmgui_chart_axis_paint (rmgui_fb_t *fb, rmgui_rect_t rect, rmgui_rect_t clip, const rmgui_chart_view_t *view, const rmgui_style_resolved_t *rs, rmgui_font_t *font, int font_px) |
| Paints the grid of view inside rect, with L = rmgui_font_line_height(
font_px): | |
| void | rmgui_chart_axis_paint_to (rmgui_target_t *, rmgui_rect_t, rmgui_rect_t, const rmgui_chart_view_t *, const rmgui_style_resolved_t *, rmgui_font_t *, int) |
| Explicit destination axis paint; prepared glyphs are required for RECORD. | |
| int | rmgui_chart_axis_prepare (const rmgui_ui_t *ui) |
| Prepare the time-label glyphs before recording. | |
| int | rmgui_chart_axis_draw (const rmgui_ui_t *ui, const rmgui_chart_view_t *view, rmgui_rect_t rect) |
| Draw the grid and time labels for a valid view. | |
chart_axis.h — the visible range of a chart, 1/2/5 tick selection for value and time axes, time labels, and the axis grid painter.
Values are raw int32 and never scaled; times are uint32 ms relative to an origin the caller owns, ordered with wrapping subtraction as in chart_series.h.
| #define RMGUI_CHART_VIEW_T_DEFINED |
| size_t rmgui_chart_ticks | ( | int32_t | v0, |
| int32_t | v1, | ||
| int | max_ticks, | ||
| int32_t * | out, | ||
| size_t | cap ) |
Ticks for the value range [v0, v1]: the step is the least of 1, 2, 5, 10, 20, 50, ... whose multiples in [v0, v1] number at most max_ticks, and the ticks are those multiples in ascending order (possibly none).
Writes at most cap of them to out and returns how many it wrote, never more than max_ticks. Returns 0 with out unchanged for NULL out, cap 0, max_ticks < 1 or v0 >= v1.
| size_t rmgui_chart_time_ticks | ( | uint32_t | t0, |
| uint32_t | t1, | ||
| int | max_ticks, | ||
| uint32_t * | out, | ||
| size_t | cap ) |
rmgui_chart_ticks for the time window [t0, t1] in ms: the step is the least of 1, 2, 5, 10, ... ms whose multiples in [t0, t0 + (t1 - t0)] (counted without wrapping) number at most max_ticks; each tick is written as that multiple reduced mod 2^32, ascending in wrapping order.
Returns 0 with out unchanged for NULL out, cap 0, max_ticks < 1 or a window not valid for rmgui_chart_view_t.
| size_t rmgui_chart_time_label | ( | uint32_t | t_ms, |
| char * | out, | ||
| size_t | cap ) |
Formats t_ms, floored to whole seconds, as "m:ss" below one hour and "h:mm:ss" from one hour on (0 -> "0:00", 59999 -> "0:59", 3600000 -> "1:00:00"; at most 10 characters).
Writes at most cap - 1 characters and a NUL, and returns the full label's length (excluding the NUL), so a return >= cap means out holds a truncated prefix. Returns 0 with out unchanged for NULL out or cap 0.
| void rmgui_chart_axis_paint | ( | rmgui_fb_t * | fb, |
| rmgui_rect_t | rect, | ||
| rmgui_rect_t | clip, | ||
| const rmgui_chart_view_t * | view, | ||
| const rmgui_style_resolved_t * | rs, | ||
| rmgui_font_t * | font, | ||
| int | font_px ) |
Paints the grid of view inside rect, with L = rmgui_font_line_height( font_px):
| void rmgui_chart_axis_paint_to | ( | rmgui_target_t * | , |
| rmgui_rect_t | , | ||
| rmgui_rect_t | , | ||
| const rmgui_chart_view_t * | , | ||
| const rmgui_style_resolved_t * | , | ||
| rmgui_font_t * | , | ||
| int | ) |
Explicit destination axis paint; prepared glyphs are required for RECORD.
Geometry and labels match the CPU painter; bounded failures latch.
| int rmgui_chart_axis_prepare | ( | const rmgui_ui_t * | ui | ) |
Prepare the time-label glyphs before recording.
CPU targets and contexts without a font need no preparation. Returns 0 or -1 on error.
| int rmgui_chart_axis_draw | ( | const rmgui_ui_t * | ui, |
| const rmgui_chart_view_t * | view, | ||
| rmgui_rect_t | rect ) |
Draw the grid and time labels for a valid view.
With no font the axis draws nothing. Returns 0 or -1 for invalid arguments or style; paint errors are reported by the target.