SetFont/GetFont on Button and ImageButton. Closes #9

This commit is contained in:
João Lopes 2021-02-04 21:01:56 +00:00
parent 72886439e7
commit eae3c6edbe
4 changed files with 46 additions and 4 deletions

View File

@ -196,6 +196,27 @@ function newobject:GetText()
end
--[[---------------------------------------------------------
- func: SetFont(font)
- desc: sets the object's font, nil uses the skin's default
--]]---------------------------------------------------------
function newobject:SetFont(font)
self.font = font
return self
end
--[[---------------------------------------------------------
- func: GetFont()
- desc: gets the object's font
--]]---------------------------------------------------------
function newobject:GetFont()
return self.font
end
--[[---------------------------------------------------------
- func: SetImage(image)
- desc: adds an image to the object

View File

@ -190,6 +190,27 @@ function newobject:GetText()
end
--[[---------------------------------------------------------
- func: SetFont(font)
- desc: sets the object's font, nil uses the skin's default
--]]---------------------------------------------------------
function newobject:SetFont(font)
self.font = font
return self
end
--[[---------------------------------------------------------
- func: GetFont()
- desc: gets the object's font
--]]---------------------------------------------------------
function newobject:GetFont()
return self.font
end
--[[---------------------------------------------------------
- func: SetClickable(bool)
- desc: sets whether the object can be clicked or not

View File

@ -313,7 +313,7 @@ function skin.button(object)
local height = object:GetHeight()
local hover = object:GetHover()
local text = object:GetText()
local font = skin.controls.button_text_font
local font = object:GetFont() or skin.controls.button_text_font
local twidth = font:getWidth(object.text)
local theight = font:getHeight(object.text)
local down = object:GetDown()
@ -558,7 +558,7 @@ function skin.imagebutton(object)
local image = object:GetImage()
local imagecolor = object.imagecolor or {1, 1, 1, 1}
local down = object.down
local font = skin.controls.imagebutton_text_font
local font = object:GetFont() or skin.controls.imagebutton_text_font
local twidth = font:getWidth(object.text)
local theight = font:getHeight(object.text)
local textdowncolor = skin.controls.imagebutton_text_down_color

View File

@ -172,7 +172,7 @@ function skin.button(object)
local height = object:GetHeight()
local hover = object:GetHover()
local text = object:GetText()
local font = skin.controls.smallfont
local font = object:GetFont() or skin.controls.smallfont
local twidth = font:getWidth(object.text)
local theight = font:getHeight(object.text)
local down = object:GetDown()
@ -344,7 +344,7 @@ function skin.imagebutton(object)
local image = object:GetImage()
local imagecolor = object.imagecolor or skin.controls.color_image
local down = object.down
local font = skin.controls.imagebuttonfont
local font = object:GetFont() or skin.controls.imagebuttonfont
local twidth = font:getWidth(object.text)
local theight = font:getHeight(object.text)
local checked = object.checked