module

Sketchbook::Element

Instance methods

adopted

Hook called when this element is added as a child to an element capable of holding children.

bounds

Returns the global bounding rect of this element.

bring_to_front

Brings this element to the top of Z axis of its parent. Does nothing if this element has no parent.

drag(stream = events) : Stream(Point)

Emits mouse position deltas when this element is being dragged, as per the given event stream.

NOTE: when this element is being dragged, transit events (and therefore enter and leave events) are all ignored (because you can drag faster than the element moves, and so go in/out of its bounds, leaving it but not finishing the drag).

enter(stream = events) : Stream(Point)

Pumps when cursor enters this element. Only true is pumped.

events

Pumps the event part of intake.

input(stream = events) : Stream(Char)

Pumps printable characters that the user types with the keyboard from stream.

intake

Central hub for events coming into this element.

The window (one that sent the event and the event itself are pumped.

keypress(stream = events) : Stream(SF::Event::KeyPressed)

Pumps key press events from stream.

keys(stream = events) : Stream(SF::Event::KeyEvent)

Pumps key events for keys that the user presses/releases from stream.

leave(stream = events) : Stream(Point)

Pumps when cursor leaves this element. Only false is pumped.

mouse_press(stream = events) : Stream(SF::Event::MouseButtonPressed)

Pumps mouse pressed events from stream.

offset

Holds the local position (offset from parent) of this frame.

offset=(offset)

Holds the local position (offset from parent) of this frame.

parent

Returns the parent element of this element. May be nil when this element is top-level.

parent=(parent : Group | Nil)

Returns the parent element of this element. May be nil when this element is top-level.

parent?

Returns the parent element of this element. May be nil when this element is top-level.

pos(accum = offset)

Returns the global position of this element.

NOTE: this method is recursive over parent and will fail at (very) deep element trees.

rejected

Hook called when this element is removed as a child from an element capable of holding children.

render(target)

Renders this element on the screen.

req

Returns the minimum required size for this element.

size

Holds the size of this frame. Sizes smaller than the required size will be ignored.

size=(size)

Holds the size of this frame. Sizes smaller than the required size will be ignored.

transit(stream = events) : Stream(Tuple(Point, Bool))

Pumps {point, in bounds} for whether the cursor entered or left this element (at a specific point).

Does not pump when dragging. See drag for the reason.