module Sketchbook::Element

Direct including types

Defined in:

tree/element.cr

Instance Method Summary

Instance Method Detail

def adopted #

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


[View source]
def bounds : Rect #

Returns the global bounding rect of this element.


[View source]
def bring_to_front #

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


[View source]
def 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).


[View source]
def enter(stream = events) : Stream(Point) #

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


[View source]
def events : Stream(SF::Event) #

Pumps the event part of #intake.


[View source]
def input(stream = events) : Stream(Char) #

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


[View source]
def intake #

Central hub for events coming into this element.

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


[View source]
def keypress(stream = events) : Stream(SF::Event::KeyPressed) #

Pumps key press events from stream.


[View source]
def keys(stream = events) : Stream(SF::Event::KeyEvent) #

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


[View source]
def leave(stream = events) : Stream(Point) #

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


[View source]
def mouse_press(stream = events) : Stream(SF::Event::MouseButtonPressed) #

Pumps mouse pressed events from stream.


[View source]
def offset #

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


[View source]
def offset=(offset) #

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


[View source]
def parent : Group | Nil #

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


def parent=(parent : Group | Nil) #

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


[View source]
def parent? : Group | Nil | Nil #

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


def 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.


[View source]
def rejected #

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


[View source]
def render(target) #

Renders this element on the screen.


[View source]
abstract def req #

Returns the minimum required size for this element.


[View source]
def size #

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


[View source]
def size=(size) #

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


[View source]
def 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.


[View source]