## box

API reference for the fucking bread and butter of canvas elements.

#### Some Properties

##### `_interactionEnabled`
If true all mouse and key events are disabled on the box.

#### Some Methods

##### `set scrollpoint`
ARGS: scrollpoint:(NUMBER)  
DESCRIPTION: Sets the scrollpoint for all children and calls private `_handleScrollpoint` method.

##### `unselect`
Unselects it duh.

##### `handleMouseDown`
ARGS: --void-  
RETURN: BOOLEAN or instance:(BOX)  
DESCRIPTION: If the object is selectable and it is not already selects it, it will set the `_selected` property to true and return a call to the `_handleMouseDown` method. Likely does not need to be overwritten, to control behavior define `_selectable` and `__handleMouseDown`.

##### `isWithinBounds`
ARGS: coordinate:({ x:NUMBER, y: NUMBER })  
RETURN: BOOLEAN  
DESCRIPTION: Returns true if the provided coordinate is within the box's bounds.

##### `tryMouseDown`
ARGS: coordinate:({ x:NUMBER, y: NUMBER })  
RETURN: BOOLEAN or instance:(BOX)  
DESCRIPTION: This method attempts to find a handler for a mousedown event in this order:
1. It first tries `_tryMouseDown` -- if this returns truthy, the method returns `handleMouseDown` here.
2. Otherwise, it will iterate through the box's children and attempt to find a handler there. If it finds a handler, it returns the response.
3. Otherwise returns a call to `handleMouseDown`.

##### `addChild`
ARGS: constructor:(CLASS), params:(OBJECT)  
RETURN: new instance of CLASS in ARGS[0]  
DESCRIPTION: Instance is added to array of children in the property `_children`.

##### `draw`
ARGS: --void--  
RETURN: --void--  
DESCRIPTION: Uses the context it is given to draw the box in this order:
1. If `_selected` is true it will draw a border. This is just a filled rectangle that is slightly larger than the box's content.
2. A call to `_myDraw` is made. The default is to draw another rectangle using `fillRect` -- however, this function is meant to be overwritten with whatever functionality you need (e.g. replace with a `drawImage` or some shit with text).
3. Then we call the draw methods for all the children.

##### `mousemove` and `mouseup`
ARGS: object:({ startCoord, offset }) <-- both properties are coordinates  
RETURN: --void--  
DESCRIPTION: Super important methods that get called after a trySelect has returned the box object to the `CanvasManager`.


### draggable

Useful subclass of box.

#### Constructor notes
Stay tuned.

#### Some Properties

##### `_limitRect`
TYPE: { x:NUMBER, y:NUMBER, width:NUMBER, height:NUMBER }  
Sets bounds that the box cannot leave. Required.

##### `dragHandle`
TYPE: instance of BUTTON  
Defaults to the whole box, but otherwise is used as the handle that must be clicked to initiate dragging.

##### `_dragging`
TYPE: BOOLEAN  
Tells the box how to interpret mousemove events.

#### Some Methods

##### `reposition`
ARGS: coordinate:({ x:NUMBER, y: NUMBER })  
RETURN: --void--  
DESCRIPTION: This is the $$$$. Basically just sets the box's new position based on the offset values passed in from a mousevent.

### scalable

Subclass of draggable - this is because if you scale something, the position MUST also change. So we subclass draggable because of its handy `reposition` method.

#### Constructor notes
Stay tuned.

#### Some Properties

##### `_resizeHandle`
TYPE: STRING  
Sets a key that is used to determine how the box will be resized (e.g. resizing from bottom-right corner is different from resizing from left-middle).

##### `_lastHandlePostions`
TYPE: object that is annoyingly long to define.  
Big list of box positions representing the handles.

#### Some Methods

##### `handlePostions`
ARGS: --void--  
RETURN: Big list of handle positions.  
DESCRIPTION: Re-calculates the resize handle positions. Actually just a getter.

##### `_trySetHandle`
ARGS: coordinate:({ x:NUMBER, y: NUMBER })  
RETURN: FALSE or handle-key:(STRING)  
DESCRIPTION: Basically a `tryMouseDown` just for handles - sets the corresponding handle if it finds one.

##### `_drawHandles`
ARGS: --void--  
RETURN: --void--  
DESCRIPTION: Draws the resize handles.

##### `resize`
ARGS: coordinate:({ x:NUMBER, y: NUMBER })
RETURN: --void--
DESCRIPTION: Resizes the box using the offset and the appropriate resize handle function.
