Scenic Scrollable v0.1.0 Scenic.Scrollable.ScrollBars View Source

The scroll bars component can be used to add a horizontal, and a vertical scroll bar pair to the graph. This component is used internally by the Scenic.Scrollable component, and for most cases it is recommended to use the Scenic.Scrollable component instead.

Data

Scenic.Scrollable.ScrollBars.settings/0

The scroll bars require the following data for initialization:

With and height define the size of the frame, and thus correspond to the width of the horizontal, and the height of the vertical scroll bars.

Styles

Scenic.Scrollable.ScrollBars.styles/0

The scroll bars can be customized by using the following styles:

scroll_bar

Scenic.Scrollable.ScrollBar.styles/0

The styles to customize both scrollbars as defined in the corresponding module Scenic.Scrollable.Scrollbar. If different styles for the horizontal and vertical scroll bars are preffered, use the horizontal_scroll_bar and vertical_scroll_bar styles instead.

horizontal_scroll_bar

Scenic.Scrollable.ScrollBar.styles/0

The styles to customize the horizontal scroll bar.

vertical_scroll_bar

Scenic.Scrollable.ScrollBar.styles/0

The styles to customize the vertical scroll bar.

scroll_drag

t:Scenic.Scrollable.Drag/0

Settings to specify which mouse buttons can be used in order to drag the scroll bar sliders.

scroll_bar_thickness

number

Specify the height of the horizontal, and the width of the vertical scroll bars.

Examples

iex> graph = Scenic.Scrollable.Components.scroll_bars(
...>   Scenic.Graph.build(),
...>   %{
...>     width: 200,
...>     height: 200,
...>     content_size: {1000, 1000},
...>     scroll_position: {0, 0}
...>   },
...>   [
...>     scroll_bar: [
...>       scroll_buttons: true,
...>       scroll_bar_theme: Scenic.Primitive.Style.Theme.preset(:light),
...>       scroll_bar_radius: 2,
...>       scroll_bar_border: 2,
...>       scroll_drag: %{
...>         mouse_buttons: [:left, :right, :middle]
...>       }
...>     ],
...>     scroll_drag: %{
...>       mouse_buttons: [:left, :right, :middle]
...>     },
...>     id: :scroll_bars_component_1
...>   ]
...> )
...> graph.primitives[1].id
:scroll_bars_component_1

Link to this section Summary

Types

An atom describing the state the scroll bars are in.

  • idle: none of the scroll bars are currently being clicked or dragged.
  • dragging: one of the scroll bars is being dragged.
  • scrolling: one of the scroll bars is being scrolled using a scroll button

The required settings to initialize a scroll bars component. For more information see the top of this module

The optional styles to customize the scroll bars. For more information see the top of this module

A collection of optional styles to customize the scroll bars. For more information see Scenic.Scrollable.ScrollBars.style/0 and the top of this module

t()

The state with which the scrollable components GenServer is running

Data structure representing a vector 2, in the form of an {x, y} tuple

Functions

Find the direction the content should be scrolling in, depending on the scroll bar buttons pressed states

Find out if one of the scroll bars is currently being dragged

Find the latest position the scrollable content should be updated with. The position corresponds to the contents translation, rather than the scroll bars drag control translation

Link to this section Types

Link to this type

scroll_state() View Source
scroll_state() :: :idle | :dragging | :scrolling

An atom describing the state the scroll bars are in.

  • idle: none of the scroll bars are currently being clicked or dragged.
  • dragging: one of the scroll bars is being dragged.
  • scrolling: one of the scroll bars is being scrolled using a scroll button.
Link to this type

settings() View Source
settings() :: %{
  width: number(),
  height: number(),
  content_size: v2(),
  scroll_position: v2()
}

The required settings to initialize a scroll bars component. For more information see the top of this module.

Link to this type

style() View Source
style() ::
  {:scroll_bar, Scenic.Scrollable.ScrollBar.styles()}
  | {:horizontal_scroll_bar, Scenic.Scrollable.ScrollBar.styles()}
  | {:vertical_scroll_bar, Scenic.Scrollable.ScrollBar.styles()}
  | {:scroll_drag, Scenic.Scrollable.Drag.settings()}
  | {:scroll_bar_thickness, number()}

The optional styles to customize the scroll bars. For more information see the top of this module.

Link to this type

styles() View Source
styles() :: [style()]

A collection of optional styles to customize the scroll bars. For more information see Scenic.Scrollable.ScrollBars.style/0 and the top of this module.

Link to this type

t() View Source
t() :: %Scenic.Scrollable.ScrollBars{
  graph: Scenic.Graph.t(),
  horizontal_scroll_bar_pid: {:some, pid()} | :none,
  id: atom(),
  pid: pid(),
  scroll_position: v2(),
  scroll_state: scroll_state(),
  vertical_scroll_bar_pid: {:some, pid()} | :none
}

The state with which the scrollable components GenServer is running.

Data structure representing a vector 2, in the form of an {x, y} tuple.

Link to this section Functions

Link to this function

add_to_graph(graph, data \\ nil, opts \\ []) View Source
add_to_graph(graph :: Scenic.Graph.t(), data :: any(), opts :: list()) ::
  Scenic.Graph.t()

Callback implementation for Scenic.Component.add_to_graph/3.

Link to this function

direction(state) View Source
direction(t()) :: v2()

Find the direction the content should be scrolling in, depending on the scroll bar buttons pressed states.

Link to this function

dragging?(arg1) View Source
dragging?(t()) :: boolean()

Find out if one of the scroll bars is currently being dragged.

Link to this function

new_position(map) View Source
new_position(t()) :: {:some, v2()} | :none

Find the latest position the scrollable content should be updated with. The position corresponds to the contents translation, rather than the scroll bars drag control translation.