Raxol. UI. Layout. SplitPane. Resize
(Raxol v2.6.0)
View Source
Helpers for interactive split pane resize in TEA applications.
Resize is handled at the app level via TEA update/2 -- the SplitPane element is stateless (takes ratio from app model). This module provides the math.
Summary
Functions
Calculates a new ratio tuple from a drag position.
Checks if a mouse position hits a divider.
Computes divider positions for hit testing.
Handles keyboard-based resize.
Functions
Calculates a new ratio tuple from a drag position.
Parameters
drag_pos- Current mouse{x, y}positiondirection-:horizontalor:verticalorigin-{x, y}of the split pane's top-left cornertotal_size- Total width (horizontal) or height (vertical)pane_count- Number of panesmin_size- Minimum pane size in characters
Returns a ratio tuple with integer parts proportional to the drag position.
Checks if a mouse position hits a divider.
Returns {:hit, pane_index} if the position is on a divider, or :miss.
Parameters
mouse_pos-{x, y}mouse coordinatesdividers- List of divider rects fromdivider_positions/3direction-:horizontalor:vertical
Computes divider positions for hit testing.
Returns a list of {x, y, width, height, pane_index} tuples.
Parameters
direction-:horizontalor:verticalratio- Ratio tuplespace- Available space map with:x,:y,:width,:height
Handles keyboard-based resize.
Returns {:ok, new_ratio} if the key event triggers a resize, or :ignore.
Parameters
key_event- A key event map with:key,:char, and:ctrlfieldsdirection-:horizontalor:verticalcurrent_ratio- Current ratio tuplestep- Adjustment step as float proportion (default 0.05)