-
-
Notifications
You must be signed in to change notification settings - Fork 73
/
label.lua
37 lines (28 loc) · 908 Bytes
/
label.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--=========== Copyright © 2019, Planimeter, All rights reserved. ===========--
--
-- Purpose: Label class
--
--==========================================================================--
class "gui.label" ( "gui.box" )
local label = gui.label
function label:label( parent, name, text )
gui.box.box( self, parent, name )
self:setPosition( "absolute" )
self.font = self:getScheme( "font" )
self.width = 216
self.height = self.font:getHeight()
self.text = text or "Label"
end
function label:draw()
love.graphics.setColor( self:getScheme( "label.textColor" ) )
local font = self:getFont()
love.graphics.setFont( font )
local text = self:getText()
local limit = self:getWidth()
local align = self:getTextAlign()
love.graphics.printf( text, 0, 0, limit, align )
gui.box.draw( self )
end
gui.accessor( label, "font" )
gui.accessor( label, "text" )
gui.accessor( label, "textAlign" )