View Source Scenic.Component.Input.Slider (Scenic v0.11.2)

Add a slider to a graph

data

Data

{ extents, initial_value}

  • extents gives the range of values. It can take several forms...
    • {min, max} If min and max are integers, then the slider value will be an integer.
    • {min, max} If min and max are floats, then the slider value will be an float.
    • [a, b, c] A list of terms. The value will be one of the terms
  • initial_value Sets the initial value (and position) of the slider. It must make sense with the extents you passed in.

messages

Messages

When the state of the slider changes, it sends an event message to the host scene in the form of:

{:value_changed, id, value}

options

Options

Sliders honor the following list of options.

styles

Styles

Sliders honor the following styles

  • :hidden - If false the component is rendered. If true, it is skipped. The default is false.
  • :theme - The color set used to draw. See below. The default is :dark

theme

Theme

Sliders work well with the following predefined themes: :light, :dark

To pass in a custom theme, supply a map with at least the following entries:

  • :border - the color of the slider line
  • :thumb - the color of slider thumb

usage

Usage

You should add/modify components via the helper functions in Scenic.Components

examples

Examples

The following example creates a numeric slider and positions it on the screen.

graph
|> slider({{0,100}, 0}, id: :num_slider, translate: {20,20})

The following example creates a list slider and positions it on the screen.

graph
|> slider({[
    :white,
    :cornflower_blue,
    :green,
    :chartreuse
  ], :cornflower_blue}, id: :slider_id, translate: {20,20})

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Link to this section Functions

Link to this function

add_to_graph(graph, data, opts \\ [])

View Source

Callback implementation for Scenic.Component.add_to_graph/3.

Returns a specification to start this module under a supervisor.

See Supervisor.