package mosaic
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/mosaic.ui/Mosaic_ui/Scroll_box/index.html
Module Mosaic_ui.Scroll_box
Scrollable container with optional scrollbars and sticky scroll.
Scrollable container with viewport clipping and scroll bars.
A scroll box manages a content area larger than its visible viewport. Internally it builds a multi-node hierarchy:
- root -- flex-row container holding wrapper and the vertical bar.
- wrapper -- flex-column holding viewport and the horizontal bar.
- viewport -- overflow-hidden node that clips content.
- content -- translated node holding user children.
Children are routed to the content node via Renderable.set_child_target. Scrolling translates content without triggering relayout.
Scroll acceleration
module Scroll_accel : sig ... endProps
module Props : sig ... endTypes
The type for scroll box widgets backed by a Renderable.t.
Constructors
val create :
parent:Renderable.t ->
?index:int ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?scroll_x:bool ->
?scroll_y:bool ->
?sticky_scroll:bool ->
?sticky_start:[ `Top | `Bottom | `Left | `Right ] ->
?background:Ansi.Color.t ->
?scroll_accel:Scroll_accel.t ->
?scrollbar_props:Scroll_bar.Props.t ->
?vertical_bar_props:Scroll_bar.Props.t ->
?horizontal_bar_props:Scroll_bar.Props.t ->
?on_scroll:(x:int -> y:int -> unit) ->
unit ->
tcreate ~parent () is a new scroll box attached to parent with:
indexinsertion index amongparent's children.idnode identifier for debugging.stylelayout style. Defaults to theToffee.Style.tdefault.visibleinitial visibility. Defaults totrue.z_indexstacking order. Defaults to0.opacitynode opacity. Defaults to1.0.scroll_xenables horizontal scrolling. Defaults tofalse.scroll_yenables vertical scrolling. Defaults totrue.sticky_scrollenables sticky edge tracking. Defaults tofalse.sticky_startselects the sticky edge. Defaults to`Bottom.backgroundfills the container background.scroll_accelacceleration strategy. Defaults toScroll_accel.linear.scrollbar_propsvisual properties applied to both scroll bars.vertical_bar_propsoverridesscrollbar_propsfor the vertical bar.horizontal_bar_propsoverridesscrollbar_propsfor the horizontal bar.on_scrollcallback invoked with the new scroll position whenever it changes.
Accessors
val node : t -> Renderable.tnode t is the root Renderable.t of t.
val content : t -> Renderable.tcontent t is the internal content node of t that holds user children.
val viewport : t -> Renderable.tviewport t is the internal viewport node of t that clips content.
val vertical_bar : t -> Scroll_bar.tvertical_bar t is the vertical Scroll_bar.t of t.
val horizontal_bar : t -> Scroll_bar.thorizontal_bar t is the horizontal Scroll_bar.t of t.
Scroll state
val scroll_top : t -> intscroll_top t is the vertical scroll offset of t in cells.
See also set_scroll_top.
val scroll_left : t -> intscroll_left t is the horizontal scroll offset of t in cells.
See also set_scroll_left.
val set_scroll_top : t -> int -> unitset_scroll_top t v sets the vertical scroll offset of t to v, clamped to the valid range. Fires the on_scroll callback.
See also scroll_top.
val set_scroll_left : t -> int -> unitset_scroll_left t v sets the horizontal scroll offset of t to v, clamped to the valid range. Fires the on_scroll callback.
See also scroll_left.
val scroll_to : t -> ?x:int -> ?y:int -> unit -> unitscroll_to t ~x ~y () sets the absolute scroll position of t. Each axis is clamped to its valid range.
See also scroll_by.
val scroll_by : t -> ?x:int -> ?y:int -> unit -> unitscroll_by t ~x ~y () adjusts the scroll position of t by a relative offset.
See also scroll_to.
val scroll_by_unit :
t ->
?x:float ->
?y:float ->
unit:Scroll_bar.scroll_unit ->
unit ->
unitscroll_by_unit t ~x ~y ~unit () adjusts the scroll position of t by x and y expressed in unit. Delegates to Scroll_bar.scroll_by which handles unit conversion and clamping.
See also scroll_by and Scroll_bar.scroll_unit.
val scroll_width : t -> intscroll_width t is the total content width of t in cells.
val scroll_height : t -> intscroll_height t is the total content height of t in cells.
val viewport_width : t -> intviewport_width t is the visible area width of t in cells.
val viewport_height : t -> intviewport_height t is the visible area height of t in cells.
Sticky scroll
val set_sticky_scroll : t -> bool -> unitset_sticky_scroll t v enables (true) or disables (false) sticky scrolling on t.
See also reset_sticky.
val set_sticky_start : t -> [ `Top | `Bottom | `Left | `Right ] option -> unitset_sticky_start t edge sets the sticky edge of t to edge. None removes the sticky edge.
val reset_sticky : t -> unitreset_sticky t clears the manual scroll flag of t and reapplies sticky positioning.
See also set_sticky_scroll.
Appearance
val set_background : t -> Ansi.Color.t option -> unitset_background t color sets the container background color of t to color. None removes the background.
Callbacks
val set_on_scroll : t -> (x:int -> y:int -> unit) option -> unitset_on_scroll t f replaces the scroll callback of t with f. None removes the callback.
val set_scroll_accel : t -> Scroll_accel.t -> unitset_scroll_accel t accel replaces the scroll acceleration strategy of t with accel.
See also Scroll_accel.
Keyboard
handle_key t event is true iff event was consumed by t. Delegates to the internal scroll bars for directional arrows, Page Up/Down, and Home/End.
Reconciler
apply_props t props replaces the visual properties of t with props. Creation-time fields (create's scroll_x, scroll_y) remain unchanged.
See also Props.make.
Formatting
val pp : Format.formatter -> t -> unitpp formats a scroll box value for debugging.