54 lines
1.3 KiB
Plaintext
54 lines
1.3 KiB
Plaintext
--@include label.txt
|
|
--@include radius_mixin.txt
|
|
|
|
require("label.txt")
|
|
|
|
EButton = class("EButton", ELabel)
|
|
EButton:include(require("radius_mixin.txt"))
|
|
|
|
function EButton:initialize()
|
|
ELabel.initialize(self)
|
|
|
|
self:setText("Button")
|
|
self:setSize(100, 32)
|
|
self:setRoundedCorners(true)
|
|
self:setRadius(0)
|
|
self:setColorScheme({
|
|
bg = {
|
|
Color(46, 46, 46),
|
|
hover = Color(66, 66, 66),
|
|
disabled = Color(32, 32, 32)
|
|
},
|
|
text = {
|
|
Color(230, 230, 230),
|
|
disabled = Color(80, 80, 80)
|
|
}
|
|
})
|
|
end
|
|
|
|
function EButton:onMousePressed(x, y, key, keyName)
|
|
if keyName == "MOUSE1" then
|
|
self:onClick()
|
|
end
|
|
end
|
|
|
|
function EButton:paint(x, y, w, h)
|
|
local textW, textH = self:getTextSize()
|
|
local rTL, rTR, rBR, rBL = self:getRoundedCorners()
|
|
|
|
render.setColor(self:getColorFromScheme("bg"))
|
|
if self:getRadius() > 0 and (rTL or rTR or rBR or rBL) then
|
|
render.drawRoundedBoxEx(self:getRadius(), x, y, w, h, rTL, rTR, rBL, rBR)
|
|
else
|
|
render.drawRectFast(x, y, w, h)
|
|
end
|
|
|
|
render.setFont(self:getFont())
|
|
render.setColor(self:getColorFromScheme("text"))
|
|
render.drawSimpleText(x + w / 2 - textW / 2, y + h / 2 - textH / 2, self:getText())
|
|
end
|
|
|
|
-- STUB
|
|
|
|
function EButton:onClick()
|
|
end |