|
RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
|
scroll.h — scroll state shared by kernel nodes and independently painted host panes. More...
#include <stdint.h>#include "fb.h"#include "geom.h"#include "input.h"#include "style.h"#include "ui_context.h"Data Structures | |
| struct | rmgui_scroll_bar_t |
| A bar's half-open thumb lane, thumb and separate arrow rectangles. More... | |
| struct | rmgui_scroll_t |
| The owner supplies key (0 for host panes), axes, visibility and a scale in 1..400 before layout. More... | |
Functions | |
| void | rmgui_scroll_layout (rmgui_scroll_t *self, int content_w, int content_h, rmgui_rect_t outer) |
| Lay out both bars against the full outer rectangle and the natural content extent. | |
| int | rmgui_scroll_max_offset (const rmgui_scroll_t *self, rmgui_scroll_axes_t axis) |
| Maximum displacement for axis X or Y; zero for NULL, a disabled or invalid axis. | |
| int | rmgui_scroll_set_offset (rmgui_scroll_t *self, rmgui_scroll_axes_t axis, int offset) |
| Clamp and set one axis' displacement, updating its thumb. | |
| rmgui_input_result_t | rmgui_scroll_input (rmgui_scroll_t *self, const rmgui_input_t *in) |
| Apply one wheel or pointer event. | |
| void | rmgui_scroll_paint (rmgui_fb_t *fb, const rmgui_scroll_t *self, rmgui_rect_t clip) |
| Paint both visible tracks and thumbs, clipped to the framebuffer and clip; their shared corner remains untouched. | |
| void | rmgui_scroll_paint_styled (rmgui_fb_t *fb, const rmgui_scroll_t *self, rmgui_rect_t clip, const rmgui_style_resolved_t *rs) |
| Paint current parts without re-layout using a SCROLLBAR record resolved at self.scale_percent from the same snapshot as self.style (NULL=builtin). | |
| int | rmgui_scroll_draw (const rmgui_ui_t *ui, const rmgui_scroll_t *scroll) |
| Draw the arranged scrollbar(s) with the context's theme and skins. | |
| int | rmgui_scroll_step (rmgui_scroll_t *self, uint16_t dt_ms) |
| Advance a held arrow's repeat countdown by dt_ms, with arithmetic catch-up and saturated offsets. | |
scroll.h — scroll state shared by kernel nodes and independently painted host panes.
All coordinates and dimensions are framebuffer pixels.
Constants
Bar thickness, minimum thumb length and wheel travel at 100% UI scale.
| enum rmgui_scroll_axes_t |
| enum rmgui_scroll_part_t |
| void rmgui_scroll_layout | ( | rmgui_scroll_t * | self, |
| int | content_w, | ||
| int | content_h, | ||
| rmgui_rect_t | outer ) |
Lay out both bars against the full outer rectangle and the natural content extent.
Invalid scale, NULL or empty outer clears bar geometry and drag; offsets remain clamped to their axis' resulting viewport. AUTO resolves coupled gutters, ALWAYS shows enabled bars with nonempty content, HIDDEN reserves no gutter but still allows scrolling.
| int rmgui_scroll_max_offset | ( | const rmgui_scroll_t * | self, |
| rmgui_scroll_axes_t | axis ) |
Maximum displacement for axis X or Y; zero for NULL, a disabled or invalid axis.
| int rmgui_scroll_set_offset | ( | rmgui_scroll_t * | self, |
| rmgui_scroll_axes_t | axis, | ||
| int | offset ) |
Clamp and set one axis' displacement, updating its thumb.
Return 1 if it changed; zero for NULL, an invalid axis or an unchanged displacement.
| rmgui_input_result_t rmgui_scroll_input | ( | rmgui_scroll_t * | self, |
| const rmgui_input_t * | in ) |
Apply one wheel or pointer event.
Wheel detents move both enabled axes independently, with positive detents increasing offsets. A changed result reports Y's offset if Y moved, otherwise X's; clients needing both read the state. A pointer may capture one bar, either a thumb or a pressed part. Arrow presses step immediately and start a host-driven repeat countdown. Moving outside the held arrow pauses repeat and resets its initial delay. Release/leave/disabled or disappearing geometry cancel capture. An endpoint arrow or disabled inside press is consumed as REFUSED without capture. A press or move that leaves a captured thumb on the same pixel leaves the offset unchanged; the original drag anchor is retained. NULL inputs and unrelated events return an all-zero result.
| void rmgui_scroll_paint | ( | rmgui_fb_t * | fb, |
| const rmgui_scroll_t * | self, | ||
| rmgui_rect_t | clip ) |
Paint both visible tracks and thumbs, clipped to the framebuffer and clip; their shared corner remains untouched.
NULL pointers paint nothing.
| void rmgui_scroll_paint_styled | ( | rmgui_fb_t * | fb, |
| const rmgui_scroll_t * | self, | ||
| rmgui_rect_t | clip, | ||
| const rmgui_style_resolved_t * | rs ) |
Paint current parts without re-layout using a SCROLLBAR record resolved at self.scale_percent from the same snapshot as self.style (NULL=builtin).
Local colour overrides are permitted. Hover/pressed/endpoint-disabled states are selected per part. DECREMENT/INCREMENT skins replace the full arrow, including its glyph. ARROW_UP/DOWN/LEFT/RIGHT optionally overlay direction glyphs, selected by axis and decrement/increment. Procedural ink is drawn only when neither the full-arrow nor glyph skin is present. Lion, Experience, and Remix use centered, anti-aliased directional glyphs in each generated tier, including the endpoint-disabled state. Horizontal tracks/thumbs prefer TRACK_HORIZONTAL/THUMB_HORIZONTAL at the exact normalized state and nearest tier; absent art falls back to TRACK/ THUMB. Directional declarations contain native horizontal source art: sampling, physical insets and record/replay semantics remain unchanged. NULL required pointers paint nothing.
| int rmgui_scroll_draw | ( | const rmgui_ui_t * | ui, |
| const rmgui_scroll_t * | scroll ) |
Draw the arranged scrollbar(s) with the context's theme and skins.
Use the same theme and scale during layout. Returns -1 for a missing context, target, scroll state or invalid style; paint errors latch on the target. No font is required.
| int rmgui_scroll_step | ( | rmgui_scroll_t * | self, |
| uint16_t | dt_ms ) |
Advance a held arrow's repeat countdown by dt_ms, with arithmetic catch-up and saturated offsets.
Returns 1 if countdown or offset changes, otherwise 0 (including NULL, dt=0 or no eligible arrow). At an endpoint repeat stops but capture remains until release. Fixed-state time partitions are equal; no timer, allocation or loop per elapsed interval is performed.