RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
scroll.h File Reference

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...

Enumerations

enum  rmgui_scroll_axes_t { RMGUI_SCROLL_AXES_X , RMGUI_SCROLL_AXES_Y , RMGUI_SCROLL_AXES_BOTH }
 Axes along which content may move. More...
enum  rmgui_scroll_visibility_t { RMGUI_SCROLL_VISIBILITY_AUTOMATIC , RMGUI_SCROLL_VISIBILITY_ALWAYS , RMGUI_SCROLL_VISIBILITY_HIDDEN }
 Visibility policy applied independently to both enabled axes. More...
enum  { RMGUI_SCROLL_BAR_WIDTH = 14 , RMGUI_SCROLL_MIN_THUMB = 18 , RMGUI_SCROLL_WHEEL_STEP = 30 }
enum  rmgui_scroll_part_t {
  RMGUI_SCROLL_PART_NONE , RMGUI_SCROLL_PART_TRACK_BEFORE , RMGUI_SCROLL_PART_TRACK_AFTER , RMGUI_SCROLL_PART_THUMB ,
  RMGUI_SCROLL_PART_DECREMENT , RMGUI_SCROLL_PART_INCREMENT
}
 Independent half-open scrollbar hit regions; NONE means no held part. More...
enum  rmgui_scroll_arrows_t { RMGUI_SCROLL_ARROWS_NONE , RMGUI_SCROLL_ARROWS_BOTH , RMGUI_SCROLL_ARROWS_START , RMGUI_SCROLL_ARROWS_END }
 Reserve both arrows at opposite ends, together at the start/end, or none. More...
enum  rmgui_scroll_track_action_t { RMGUI_SCROLL_TRACK_JUMP , RMGUI_SCROLL_TRACK_PAGE }
 Track press either jumps into a thumb drag or pages once without repeat. 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.

Detailed Description

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.

Enumeration Type Documentation

◆ rmgui_scroll_axes_t

Axes along which content may move.

Enumerator
RMGUI_SCROLL_AXES_X 
RMGUI_SCROLL_AXES_Y 
RMGUI_SCROLL_AXES_BOTH 

◆ rmgui_scroll_visibility_t

Visibility policy applied independently to both enabled axes.

Enumerator
RMGUI_SCROLL_VISIBILITY_AUTOMATIC 
RMGUI_SCROLL_VISIBILITY_ALWAYS 
RMGUI_SCROLL_VISIBILITY_HIDDEN 

◆ anonymous enum

anonymous enum
Enumerator
RMGUI_SCROLL_BAR_WIDTH 
RMGUI_SCROLL_MIN_THUMB 
RMGUI_SCROLL_WHEEL_STEP 

◆ rmgui_scroll_part_t

Independent half-open scrollbar hit regions; NONE means no held part.

Enumerator
RMGUI_SCROLL_PART_NONE 
RMGUI_SCROLL_PART_TRACK_BEFORE 
RMGUI_SCROLL_PART_TRACK_AFTER 
RMGUI_SCROLL_PART_THUMB 
RMGUI_SCROLL_PART_DECREMENT 
RMGUI_SCROLL_PART_INCREMENT 

◆ rmgui_scroll_arrows_t

Reserve both arrows at opposite ends, together at the start/end, or none.

Enumerator
RMGUI_SCROLL_ARROWS_NONE 
RMGUI_SCROLL_ARROWS_BOTH 
RMGUI_SCROLL_ARROWS_START 
RMGUI_SCROLL_ARROWS_END 

◆ rmgui_scroll_track_action_t

Track press either jumps into a thumb drag or pages once without repeat.

Enumerator
RMGUI_SCROLL_TRACK_JUMP 
RMGUI_SCROLL_TRACK_PAGE 

Function Documentation

◆ rmgui_scroll_layout()

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.

◆ rmgui_scroll_max_offset()

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.

◆ rmgui_scroll_set_offset()

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_scroll_input()

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.

◆ rmgui_scroll_paint()

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.

◆ rmgui_scroll_paint_styled()

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.

◆ rmgui_scroll_draw()

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.

◆ rmgui_scroll_step()

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.