# nodesnim/nodescontrol/box

Dark Mode

Search:
Group by:

Moves all child nodes at the center of the box.

# Imports

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

# Types

    BoxObj = object of ControlRef
      child_anchor*: AnchorRef

    BoxRef = ref BoxObj

# Procs

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

  Creates a new Box.

  Arguments:

  - `name` is a node name.

  Examples:

      var box1 = Box("My box")

# Methods

    method getChildSize(self: BoxRef): Vector2Ref {...}{.base, raises: [], tags: [].}

  Returns Vector2 of the minimal size of the box pointer.

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

  Adds new child in current node.

  Arguments:

  - `child`: other node.

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

  this method uses in the `window.nim`.

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

  Duplicates Box.

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

  Resizes Box node.

  Arguments:

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

    method setChildAnchor(self: BoxRef; anchor: AnchorRef) {...}{.base, raises: [], tags: [].}

  Changes child anchor.

  Arguments:

  - `anchor` - Anchor object.

    method setChildAnchor(self: BoxRef; x1, y1, x2, y2: float) {...}{.base, raises: [], tags: [].}

  Changes child anchor.

  Arguments:

  - `x1` and `y1` is an anchor relative to Box size.
  - `x2` and `y2` is an anchor relative to child size.