shamansir / tron-gui / Tron.Control.Value

The helper type to represent any value flowing through the GUI.

Used for converting values from controls to JSON;

Use Tron.proxify or Tree.proxify function to make any GUI store its current values as the subjects. Since in case of Tron.proxify it is a function (Just is stored inside), proxify is safe in that sense, but keep in mind that for Tree.proxify => Tree Control.Value those values don't change, if one changes the inner control value after that.


type Value
    = FromSlider Basics.Float
    | FromXY (( Basics.Float, Basics.Float ))
    | FromInput String
    | FromChoice (( Tron.Control.Impl.Nest.ItemId, Maybe Tron.Path.Label ))
    | FromColor Color
    | FromToggle Basics.Bool
    | FromButton
    | FromGroup
    | None

Encode and convert

encode : Value -> Json.Encode.Value

Encode value to JSON.

toString : Value -> String

Encode value to string (regardless of the type).

getTypeString : Value -> String

Get type of the value as string.

Extract value

fromNumber : Value -> Maybe Basics.Float

fromXY : Value -> Maybe ( Basics.Float, Basics.Float )

fromText : Value -> Maybe String

fromChoice : Value -> Maybe ( Tron.Control.Impl.Nest.ItemId, Maybe Tron.Path.Label )

fromChoiceOf : List a -> Value -> Maybe a

fromColor : Value -> Maybe Color

fromToggle : Value -> Maybe Basics.Bool

fromAction : Value -> Maybe ()