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

Add a slider to a graph

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

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

Sliders honor the following list of options.

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

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

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

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

Link to this section Functions

Link to this function

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

View Source

Specs

add_to_graph(graph :: Scenic.Graph.t(), data :: any(), opts :: list()) ::
  Scenic.Graph.t()

Callback implementation for Scenic.Component.add_to_graph/3.