Class rtk.Spacer

Class Hierarchy

A simple "no-op" widget that can be used affect spacing in containers, or as a blank canvas for custom drawing via ondrawpre() and ondraw(), which can be convenient for simple drawing as opposed to creating a custom subclass of rtk.Widget.

-- Create a spacer that's half the width and height of its parent
local spacer = rtk.Spacer{w=0.5, h=0.5, bg='gainsboro'}
-- Add the spacer centered on the window (so now the spacer will be
-- half the width/height of the window)
window:add(spacer, {halign='center', valign='center'})
-- Create a custom draw handler that draws a circle centered in the
-- spacer's calculated box.
spacer.ondraw = function(self, offx, offy, alpha, event)
    self:setcolor('dodgerblue', alpha)
    -- Must draw relative to the supplied offx, offy.
        offx + self.calc.x + self.calc.w/2,
        offy + self.calc.y + self.calc.h/2,
        math.min(self.calc.w, self.calc.h)/2.5,
        1, -- fill
        1  -- antialias