# nodesnim/nodescontrol/scroll

Dark Mode

Search:
Group by:

It provides primitive scroll box.

# Imports

../thirdparty/opengl, ../core/vector2, ../core/rect2, ../core/anchor, ../core/input, ../core/enums, ../core/color, ../nodes/node, control

# Types

    ScrollObj = object of ControlObj
      thumb_y_has_mouse*, thumb_x_has_mouse*: bool
      thumb_width*, thumb_height*: float
      viewport_w*, viewport_h*: float
      viewport_x*, viewport_y*: float
      thumb_color*: ColorRef
      back_color*: ColorRef

    ScrollRef = ref ScrollObj

# Procs

    proc Scroll(name: string = "Scroll"): ScrollRef {...}{.raises: [], tags: [].}

  Creates a new Scroll.

  Arguments:

  - `name` is a node name.

  Examples:

      var sc = Scroll("Scroll")

# Methods

    method addChild(self: ScrollRef; other: NodeRef) {...}{.raises: [], tags: [].}

  Adds a new node in Scroll.

  Arguments:

  - `other` is other Node.

    method duplicate(self: ScrollRef): ScrollRef {...}{.base, raises: [], tags: [].}

  Duplicates Scroll object and create a new Scroll.

    method resize(canvas: ScrollRef; w, h: GLfloat) {...}{.raises: [], tags: [].}

  Resizes scroll.

  Arguments:

  - `w` is a new width.
  - `h` is a new height.

    method draw(self: ScrollRef; w, h: GLfloat) {...}{.raises: [GLerror, Exception],
                                            tags: [RootEffect].}

  This uses in the `window.nim`.

    method draw2stage(self: ScrollRef; w, h: GLfloat) {...}{.raises: [GLerror], tags: [].}

  This uses in the `window.nim`.

    method scrollBy(self: ScrollRef; x, y: float) {...}{.base, raises: [], tags: [].}

  Scrolls by `x` and `y`, if available.

    method scrollTo(self: ScrollRef; x, y: float) {...}{.base, raises: [], tags: [].}

  Scrolls to `x` and `y` position.

    method handle(self: ScrollRef; event: InputEvent; mouse_on: var NodeRef) {...}{.
        raises: [Exception], tags: [RootEffect].}

  handles user input. This uses in the `window.nim`.