package mosaic
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/mosaic.ui/Mosaic_ui/Slider/index.html
Module Mosaic_ui.Slider
Interactive horizontal or vertical slider.
Slider with sub-cell precision thumb.
A slider maps a float value in [min;max] to a visual thumb position along a horizontal or vertical track. The thumb size is proportional to viewport_size relative to the total range, giving scrollbar-style display where the thumb represents the visible portion of content.
The slider handles left-button mouse events: clicking on the track jumps the thumb, clicking on the thumb initiates a drag, and releasing ends it.
The type for sliders. A slider owns a Renderable.t and manages its own rendering and mouse interaction.
Construction
val create :
parent:Renderable.t ->
?index:int ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?orientation:orientation ->
?value:float ->
?min:float ->
?max:float ->
?viewport_size:float ->
?track_color:Ansi.Color.t ->
?thumb_color:Ansi.Color.t ->
?on_change:(float -> unit) ->
unit ->
tcreate ~parent () is a slider attached to parent with:
orientationdefaults to`Horizontal.mindefaults to0.0.maxdefaults to100.0.valuedefaults tomin. Clamped to [min;max].viewport_sizecontrols thumb size relative to the range. Defaults tomax (max -. min) *. 0.1, minimum1.0.track_colordefaults to dark gray (RGB 37 37 39).thumb_colordefaults to medium gray (RGB 154 158 163).on_changeis called when the clamped value changes, whether from mouse interaction orset_value.
val node : t -> Renderable.tnode t is t's underlying renderable.
Props
module Props : sig ... endapply_props t props replaces all properties at once and clamps the value to the new range. Always triggers a re-render. Does not fire on_change.
Value
val value : t -> floatvalue t is the current value, always in [min;max].
val set_value : t -> float -> unitset_value t v sets the value to v clamped to [min;max]. Fires on_change if the clamped result differs from the current value.
val min : t -> floatmin t is the lower bound of the range.
val set_min : t -> float -> unitset_min t v sets the lower bound. If the current value is below v, it is clamped up, which may fire on_change. No effect if v equals the current minimum.
val max : t -> floatmax t is the upper bound of the range.
val set_max : t -> float -> unitset_max t v sets the upper bound. If the current value is above v, it is clamped down, which may fire on_change. No effect if v equals the current maximum.
Appearance
val set_orientation : t -> orientation -> unitset_orientation t o sets the track direction. No effect if o equals the current orientation.
val set_viewport_size : t -> float -> unitset_viewport_size t v sets the visible portion size, clamped to [0.01;max -. min]. Controls thumb size relative to the range. No effect if the clamped result equals the current viewport size.
val set_track_color : t -> Ansi.Color.t -> unitset_track_color t c sets the track background color. No effect if c equals the current track color.
val set_thumb_color : t -> Ansi.Color.t -> unitset_thumb_color t c sets the thumb foreground color. No effect if c equals the current thumb color.
Callback
val set_on_change : t -> (float -> unit) option -> unitset_on_change t f replaces the change callback. None removes it.
Formatting
val pp : Format.formatter -> t -> unitpp formats a slider for debugging.