class Layout::Block

Overview

A 2-dimensional region within the layout. You can constrain the different Primitives on a block in order to properly position it.

Example

The follow will create a 100x100 square that is offset from the top left corner of the screen by half it's width.

region = Block.new
region.height.eq 100
region.width.eq 100
region.top.eq region.width / 2
region.left.eq region.width / 2

Included Modules

Defined in:

block.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(label : String) #

Initialize with a label for easier debugging.


[View source]
def self.new #

[View source]

Instance Method Detail

def bottom : Layout::Primitive #

def center_x : Layout::Primitive #

def center_y : Layout::Primitive #

def children : Array(Layout::Block) #

You can encapsulate blocks inside of each other as children. This makes it easier to compose complex layout blocks.


[View source]
def children=(children : Array(Layout::Block)) #

You can encapsulate blocks inside of each other as children. This makes it easier to compose complex layout blocks.


[View source]
def each(&block : Block -> ) #

Enumerate over all blocks in this block's hierarchy.


[View source]
def each_constraint(&block : Kiwi::Constraint -> ) #

Enumerate over all constraints in this block's hierarchy


[View source]
def height : Layout::Primitive #

def label : String #

This is a unique or manually set identifier to help in debugging


[View source]
def label=(label : String) #

Re-assign the label of this block. Providing a label helps to provide context when debugging. You can also add a label in #initialize


[View source]
def left : Layout::Primitive #

def right : Layout::Primitive #

def top : Layout::Primitive #

def width : Layout::Primitive #

An alias to the #left primitive


[View source]

An alias to the #top primitive


[View source]