class Opal::UI::Layer

Overview

Represents an isolated 2D drawing surface with position, z-index, visibility, and clipping rectangle. Layers allow complex UIs, floating windows, dropdowns, and overlays to be rendered independently and composited in depth order.

Defined in:

opal/ui/layer.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(width : Int32, height : Int32, x : Int32 = 0, y : Int32 = 0, z_index : Int32 = 0, visible : Bool = true, transparent_bg : Bool = true, clip_rect : Rect | Nil = nil) #

[View source]

Instance Method Detail

def blit_to(target : Buffer) : Nil #

Blits this layer onto a target buffer at (@x, @y), respecting visibility, transparent_bg, and any layer clipping rectangle.


[View source]
def buffer : Buffer #

[View source]
def clear : Nil #

Clears the layer's internal buffer.


[View source]
def clip_rect : Rect | Nil #

[View source]
def clip_rect=(clip_rect : Rect | Nil) #

[View source]
def height : Int32 #

[View source]
def opacity : Float64 #

[View source]
def opacity=(opacity : Float64) #

[View source]
def render_element(element : Element, rel_x : Int32 = 0, rel_y : Int32 = 0, render_w : Int32 | Nil = nil, render_h : Int32 | Nil = nil) : Nil #

Renders a declarative UI element onto this layer.


[View source]
def resize(new_width : Int32, new_height : Int32) : self #

Resizes the layer's internal buffer, preserving existing content if possible.


[View source]
def transparent_bg=(transparent_bg : Bool) #

[View source]
def transparent_bg? : Bool #

[View source]
def visible=(visible : Bool) #

[View source]
def visible? : Bool #

[View source]
def width : Int32 #

[View source]
def x : Int32 #

[View source]
def x=(x : Int32) #

[View source]
def y : Int32 #

[View source]
def y=(y : Int32) #

[View source]
def z_index : Int32 #

[View source]
def z_index=(z_index : Int32) #

[View source]