Skip to content
coding_jackalope edited this page Sep 11, 2020 · 2 revisions
Table of Contents

Overview

Integrating Slab into an existing project is designed to be very simple. Below is an example of a simple window rendering a "Hello World" text field. The only functions that are necessary to be called are Slab.Initialize, Slab.Update, and Slab.Draw. Other functions such as wheelmoved and textinput are handled by Slab and will re-route those calls to the Love defined version of the function.

local Slab = require 'Slab'

function love.load(args)
    love.graphics.setBackgroundColor(0.4, 0.88, 1.0)
    Slab.Initialize(args)
end

function love.update(dt)
    Slab.Update(dt)
  
    Slab.BeginWindow('MyFirstWindow', {Title = "My First Window"})
    Slab.Text("Hello World")
    Slab.EndWindow()
end

function love.draw()
    Slab.Draw()
end

API

Below is a list of functions associated with setting up Slab.

Initialize

Initializes Slab and hooks into the required events. This function should be called in love.load.

Parameter Type Description
args Table The list of parameters passed in by the user on the command-line. This should be passed in from love.load function.
Option Type Description
NoMessages String Disables the messaging system that warns developers of any changes in the API.
NoDocks String Disables all docks.

GetVersion

Retrieves the current version of Slab being used as a string.

Return Description
String String of the current Slab version.

GetLoveVersion

Retrieves the current version of Love being used as a string.

Return Description
String String of the current Love version.

Update

Updates the input state and states of various widgets. This function must be called every frame. This should be called before any Slab calls are made to ensure proper responses to Input are made.

Parameter Type Description
dt Number The delta time for the frame. This should be passed in from love.update.

Draw

This function will execute all buffered draw calls from the various Slab calls made prior. This function should be called from love.draw and should be called at the very to ensure Slab is rendered above the user's workspace.

Clone this wiki locally