New elements; Fixes
This commit is contained in:
parent
eaf0a90173
commit
d4dd889bb5
@ -8,37 +8,40 @@ require("/koptilnya/libs/utils.txt")
|
|||||||
EButton = class("EButton", ELabel)
|
EButton = class("EButton", ELabel)
|
||||||
EButton:include(require("radius_mixin.txt"))
|
EButton:include(require("radius_mixin.txt"))
|
||||||
|
|
||||||
accessorFunc(EButton, "_textColor", "TextColor", Color(230, 230, 230))
|
|
||||||
accessorFunc(EButton, "_hoveredColor", "HoveredColor", Color(66, 66, 66))
|
|
||||||
accessorFunc(EButton, "_hoveredTextColor", "HoveredTextColor", Color(230, 230, 230))
|
|
||||||
accessorFunc(EButton, "_disabledColor", "DisabledColor", Color(32, 32, 32))
|
|
||||||
accessorFunc(EButton, "_disabledTextColor", "DisabledTextColor", Color(80, 80, 80))
|
|
||||||
|
|
||||||
function EButton:initialize()
|
function EButton:initialize()
|
||||||
ELabel.initialize(self)
|
ELabel.initialize(self)
|
||||||
|
|
||||||
self:setText("Button")
|
self:setText("Button")
|
||||||
self:setColor(Color(46, 46, 46))
|
|
||||||
self:setSize(100, 32)
|
self:setSize(100, 32)
|
||||||
self:setRoundedCorners(true)
|
self:setRoundedCorners(true)
|
||||||
self:setRadius(5)
|
self:setRadius(5)
|
||||||
|
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
|
end
|
||||||
|
|
||||||
function EButton:paint()
|
function EButton:onClick()
|
||||||
local x, y = self:getAbsolutePos()
|
end
|
||||||
local w, h = self:getSize()
|
|
||||||
|
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 textW, textH = self:getTextSize()
|
||||||
local rTL, rTR, rBR, rBL = self:getRoundedCorners()
|
local rTL, rTR, rBR, rBL = self:getRoundedCorners()
|
||||||
local bgColor, textColor
|
|
||||||
if self:isEnabled() then
|
|
||||||
bgColor = self:isHovered() and self:getHoveredColor() or self:getColor()
|
|
||||||
textColor = self:isHovered() and self:getHoveredTextColor() or self:getTextColor()
|
|
||||||
else
|
|
||||||
bgColor = self:getDisabledColor()
|
|
||||||
textColor = self:getDisabledTextColor()
|
|
||||||
end
|
|
||||||
|
|
||||||
render.setColor(bgColor)
|
render.setColor(self:getColorFromScheme("bg"))
|
||||||
if self:getRadius() > 0 and (rTL or rTR or rBR or rBL) then
|
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)
|
render.drawRoundedBoxEx(self:getRadius(), x, y, w, h, rTL, rTR, rBL, rBR)
|
||||||
else
|
else
|
||||||
@ -46,6 +49,6 @@ function EButton:paint()
|
|||||||
end
|
end
|
||||||
|
|
||||||
render.setFont(self:getFont())
|
render.setFont(self:getFont())
|
||||||
render.setColor(textColor)
|
render.setColor(self:getColorFromScheme("text"))
|
||||||
render.drawSimpleText(x + w / 2 - textW / 2, y + h / 2 - textH / 2, self:getText())
|
render.drawSimpleText(x + w / 2 - textW / 2, y + h / 2 - textH / 2, self:getText())
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,62 +1,58 @@
|
|||||||
--@include element.txt
|
--@include element.txt
|
||||||
--@include label.txt
|
|
||||||
--@include /koptilnya/libs/utils.txt
|
--@include /koptilnya/libs/utils.txt
|
||||||
|
|
||||||
require("element.txt")
|
require("element.txt")
|
||||||
require("label.txt")
|
|
||||||
require("/koptilnya/libs/utils.txt")
|
require("/koptilnya/libs/utils.txt")
|
||||||
|
|
||||||
ECheckbox = class("ECheckbox", ELabel)
|
ECheckbox = class("ECheckbox", Element)
|
||||||
|
|
||||||
accessorFunc(ECheckbox, "_textColor", "TextColor", Color(255, 255, 255))
|
|
||||||
accessorFunc(ECheckbox, "_hoveredColor", "HoveredColor", Color(66, 66, 66))
|
|
||||||
accessorFunc(ECheckbox, "_hoveredTextColor", "HoveredTextColor", Color(255, 255, 255))
|
|
||||||
accessorFunc(ECheckbox, "_disabledColor", "DisabledColor", Color(32, 32, 32))
|
|
||||||
accessorFunc(ECheckbox, "_disabledTextColor", "DisabledTextColor", Color(80, 80, 80))
|
|
||||||
accessorFunc(ECheckbox, "_indent", "Indent", 8)
|
|
||||||
|
|
||||||
function ECheckbox:initialize()
|
function ECheckbox:initialize()
|
||||||
ELabel.initialize(self)
|
Element.initialize(self)
|
||||||
|
|
||||||
self._checked = false
|
self._checked = false
|
||||||
|
|
||||||
self:setText("Checkbox")
|
self:setSize(16, 16)
|
||||||
self:setSize(200, 16)
|
self:setColorScheme({
|
||||||
|
border = {
|
||||||
|
Color(209, 209, 209),
|
||||||
|
hover = Color(255, 255, 255),
|
||||||
|
disabled = Color(130, 130, 130)
|
||||||
|
},
|
||||||
|
mark = {
|
||||||
|
Color(81, 92, 107),
|
||||||
|
disabled = Color(40, 46, 53)
|
||||||
|
}
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function ECheckbox:setChecked(state)
|
function ECheckbox:setChecked(state)
|
||||||
self._checked = state
|
self._checked = state
|
||||||
|
|
||||||
self:onChange()
|
self:onChange(state)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ECheckbox:isChecked()
|
function ECheckbox:isChecked()
|
||||||
return self._checked
|
return self._checked
|
||||||
end
|
end
|
||||||
|
|
||||||
function ECheckbox:paint()
|
function ECheckbox:toggle()
|
||||||
local x, y = self:getAbsolutePos()
|
self:setChecked(!self:isChecked())
|
||||||
local w, h = self:getSize()
|
end
|
||||||
local textW, textH = self:getTextSize()
|
|
||||||
--[[
|
function ECheckbox:onMousePressed(x, y, key, keyName)
|
||||||
local bgColor, textColor
|
if keyName == "MOUSE1" then
|
||||||
if self:isEnabled() then
|
self:toggle()
|
||||||
bgColor = self:isHovered() and self:getHoveredColor() or self:getColor()
|
end
|
||||||
textColor = self:isHovered() and self:getHoveredTextColor() or self:getTextColor()
|
end
|
||||||
else
|
|
||||||
bgColor = self:getDisabledColor()
|
function ECheckbox:paint(x, y, w, h)
|
||||||
textColor = self:getDisabledTextColor()
|
render.setColor(self:isChecked() and self:getColorFromScheme("mark") or Color(0, 0, 0, 0))
|
||||||
end
|
render.drawRectFast(x, y, h, h)
|
||||||
]]
|
|
||||||
|
render.setColor(self:getColorFromScheme("border"))
|
||||||
render.setColor(Color(209, 209, 209))
|
render.drawRectOutline(x, y, h, h, 1)
|
||||||
render.drawCircle(x, y, h / 2)
|
render.drawRectOutline(x + 1, y + 1, h - 2, h - 2, 1)
|
||||||
--render.drawRectOutline(x, y, h, h, -8)
|
end
|
||||||
|
|
||||||
--render.setColor(Color(209, 209, 209, 0))
|
function ECheckbox:onChange(state)
|
||||||
--render.drawRectFast(x, y, h - 2, h - 2)
|
|
||||||
|
|
||||||
render.setFont(self:getFont())
|
|
||||||
render.setColor(Color(255, 255, 255))
|
|
||||||
render.drawSimpleText(x + h + self:getIndent(), y + h / 2 - textH / 2, self:getText())
|
|
||||||
end
|
end
|
||||||
@ -14,6 +14,7 @@ function Element:initialize()
|
|||||||
self._visible = true
|
self._visible = true
|
||||||
self._draggable = true
|
self._draggable = true
|
||||||
self._hovered = false
|
self._hovered = false
|
||||||
|
self._colorScheme = {}
|
||||||
self._parent = nil
|
self._parent = nil
|
||||||
self._firstChild = nil
|
self._firstChild = nil
|
||||||
self._prevSibling = nil
|
self._prevSibling = nil
|
||||||
@ -107,6 +108,35 @@ function Element:isHovered()
|
|||||||
return self._hovered
|
return self._hovered
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Element:setColorScheme(scheme, overwrite)
|
||||||
|
if overwrite then
|
||||||
|
self._colorScheme = scheme
|
||||||
|
else
|
||||||
|
self._colorScheme = table.merge(self._colorScheme, scheme)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Element:getColorScheme()
|
||||||
|
return self._colorScheme
|
||||||
|
end
|
||||||
|
|
||||||
|
function Element:getColorFromScheme(key)
|
||||||
|
local scheme = self:getColorScheme()[key]
|
||||||
|
local color
|
||||||
|
|
||||||
|
if scheme then
|
||||||
|
if not self:isEnabled() then
|
||||||
|
color = scheme["disabled"] or scheme[1]
|
||||||
|
elseif self:isHovered() then
|
||||||
|
color = scheme["hover"] or scheme[1]
|
||||||
|
else
|
||||||
|
color = scheme[1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return color or Color(255, 255, 255)
|
||||||
|
end
|
||||||
|
|
||||||
function Element:setParent(parent)
|
function Element:setParent(parent)
|
||||||
checkVarClass(parent, Element)
|
checkVarClass(parent, Element)
|
||||||
|
|
||||||
@ -245,7 +275,10 @@ function Element:_onPaint()
|
|||||||
end
|
end
|
||||||
]]
|
]]
|
||||||
|
|
||||||
self:paint()
|
local x, y = self:getAbsolutePos()
|
||||||
|
local w, h = self:getSize()
|
||||||
|
|
||||||
|
self:paint(x, y, w, h)
|
||||||
|
|
||||||
if self._firstChild then
|
if self._firstChild then
|
||||||
self._firstChild:_postEventToAllReverse("PAINT")
|
self._firstChild:_postEventToAllReverse("PAINT")
|
||||||
@ -290,10 +323,10 @@ function Element:_onMouseReleased(x, y, key, keyName)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Element:_onMouseMoved(x, y)
|
function Element:_onMouseMoved(x, y)
|
||||||
if self:cursorIntersect(x, y) and self:isEnabled() then
|
|
||||||
local element = self:_postEventToAll("MOUSE_MOVED", x, y)
|
local element = self:_postEventToAll("MOUSE_MOVED", x, y)
|
||||||
|
|
||||||
if not element then
|
if self:cursorIntersect(x, y) then
|
||||||
|
if self:isEnabled() then
|
||||||
if not self:isHovered() then
|
if not self:isHovered() then
|
||||||
self._hovered = true
|
self._hovered = true
|
||||||
|
|
||||||
@ -302,17 +335,15 @@ function Element:_onMouseMoved(x, y)
|
|||||||
|
|
||||||
self:onMouseMoved(x, y)
|
self:onMouseMoved(x, y)
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
|
||||||
else
|
else
|
||||||
if self:isHovered() then
|
if self:isHovered() then
|
||||||
self._hovered = false
|
self._hovered = false
|
||||||
|
|
||||||
self:onMouseLeave()
|
self:onMouseLeave()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Element:_onButtonPressed(key, keyName)
|
function Element:_onButtonPressed(key, keyName)
|
||||||
|
|||||||
@ -1,5 +0,0 @@
|
|||||||
--@include element.txt
|
|
||||||
|
|
||||||
require("element.txt")
|
|
||||||
|
|
||||||
EEmpty = class("EEmpty", Element)
|
|
||||||
@ -6,17 +6,20 @@ require("/koptilnya/libs/utils.txt")
|
|||||||
|
|
||||||
ELabel = class("ELabel", Element)
|
ELabel = class("ELabel", Element)
|
||||||
|
|
||||||
accessorFunc(ELabel, "_color", "Color", Color(255, 255, 255))
|
|
||||||
accessorFunc(ELabel, "_disabledColor", "DisabledColor", Color(200, 200, 200))
|
|
||||||
|
|
||||||
function ELabel:initialize()
|
function ELabel:initialize()
|
||||||
Element.initialize(self)
|
Element.initialize(self)
|
||||||
self._text = ""
|
self._text = ""
|
||||||
self._textWidth = 0
|
self._textWidth = 0
|
||||||
self._textHeight = 0
|
self._textHeight = 0
|
||||||
|
|
||||||
self:setFont("Trebuchet18")
|
self:setFont(GUI.fonts["main"])
|
||||||
self:setText("Label")
|
self:setText("Label")
|
||||||
|
self:setColorScheme({
|
||||||
|
text = {
|
||||||
|
Color(255, 255, 255),
|
||||||
|
disabled = Color(200, 200, 200)
|
||||||
|
}
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function ELabel:setText(text)
|
function ELabel:setText(text)
|
||||||
@ -25,7 +28,7 @@ function ELabel:setText(text)
|
|||||||
if self:getFont() then
|
if self:getFont() then
|
||||||
render.setFont(self:getFont())
|
render.setFont(self:getFont())
|
||||||
|
|
||||||
self._textWidth, self._textHeight = render.getTextSize(self:getText())
|
self._textWidth, self._textHeight = render.getTextSize(text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -36,7 +39,7 @@ end
|
|||||||
function ELabel:setFont(font)
|
function ELabel:setFont(font)
|
||||||
self._font = font
|
self._font = font
|
||||||
|
|
||||||
render.setFont(self:getFont())
|
render.setFont(font)
|
||||||
|
|
||||||
self._textWidth, self._textHeight = render.getTextSize(self:getText())
|
self._textWidth, self._textHeight = render.getTextSize(self:getText())
|
||||||
end
|
end
|
||||||
@ -49,10 +52,12 @@ function ELabel:getTextSize()
|
|||||||
return self._textWidth, self._textHeight
|
return self._textWidth, self._textHeight
|
||||||
end
|
end
|
||||||
|
|
||||||
function ELabel:paint()
|
function ELabel:sizeToContents()
|
||||||
local x, y = self:getAbsolutePos()
|
self:setSize(self:getTextSize())
|
||||||
|
end
|
||||||
|
|
||||||
|
function ELabel:paint(x, y, w, h)
|
||||||
render.setFont(self:getFont())
|
render.setFont(self:getFont())
|
||||||
render.setColor(self:isEnabled() and self:getColor() or self:getDisabledColor())
|
render.setColor(self:getColorFromScheme("text"))
|
||||||
render.drawSimpleText(x, y, self:getText())
|
render.drawSimpleText(x, y, self:getText())
|
||||||
end
|
end
|
||||||
69
koptilnya/gui/elements/labeled_checkbox.txt
Normal file
69
koptilnya/gui/elements/labeled_checkbox.txt
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
--@include element.txt
|
||||||
|
--@include checkbox.txt
|
||||||
|
--@include label.txt
|
||||||
|
--@include /koptilnya/libs/utils.txt
|
||||||
|
|
||||||
|
require("element.txt")
|
||||||
|
require("checkbox.txt")
|
||||||
|
require("label.txt")
|
||||||
|
require("/koptilnya/libs/utils.txt")
|
||||||
|
|
||||||
|
ELabeledCheckbox = class("ELabeledCheckbox", Element)
|
||||||
|
|
||||||
|
accessorFunc(ELabeledCheckbox, "_indent", "Indent", 8)
|
||||||
|
|
||||||
|
function ELabeledCheckbox:initialize()
|
||||||
|
Element.initialize(self)
|
||||||
|
|
||||||
|
self._checked = false
|
||||||
|
|
||||||
|
self.checkbox = ECheckbox:new()
|
||||||
|
self.checkbox.onChange = function(_, state) self:onChange(state) end
|
||||||
|
self:addChild(self.checkbox)
|
||||||
|
|
||||||
|
self.label = ELabel:new()
|
||||||
|
self.label.onMousePressed = function(_, x, y, key, keyName)
|
||||||
|
if keyName == "MOUSE1" then
|
||||||
|
self:toggle()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:addChild(self.label)
|
||||||
|
|
||||||
|
self:setText("Checkbox")
|
||||||
|
end
|
||||||
|
|
||||||
|
function ELabeledCheckbox:setChecked(state)
|
||||||
|
self.checkbox:setChecked(state)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ELabeledCheckbox:isChecked()
|
||||||
|
return self.checkbox:isChecked()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ELabeledCheckbox:toggle()
|
||||||
|
self.checkbox:toggle()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ELabeledCheckbox:setText(text)
|
||||||
|
self.label:setText(text)
|
||||||
|
self:sizeToContents()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ELabeledCheckbox:setFont(font)
|
||||||
|
self.label:setFont(font)
|
||||||
|
self:sizeToContents()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ELabeledCheckbox:sizeToContents()
|
||||||
|
self:performLayout(self:getSize())
|
||||||
|
self:setWidth(self.label:getX() + self.label:getWidth())
|
||||||
|
self:setHeight(math.max(self.checkbox:getHeight(), self.label:getHeight()))
|
||||||
|
end
|
||||||
|
|
||||||
|
function ELabeledCheckbox:performLayout(w, h)
|
||||||
|
self.label:sizeToContents()
|
||||||
|
self.label:setX(self.checkbox:getWidth() + self:getIndent())
|
||||||
|
end
|
||||||
|
|
||||||
|
function ELabeledCheckbox:onChange(state)
|
||||||
|
end
|
||||||
@ -10,7 +10,6 @@ require("/koptilnya/libs/utils.txt")
|
|||||||
|
|
||||||
EPanel = class("EPanel", Element)
|
EPanel = class("EPanel", Element)
|
||||||
|
|
||||||
accessorFunc(EPanel, "_backgroundColor", "BackgroundColor", Color(23, 23, 23))
|
|
||||||
accessorFunc(EPanel, "_parentLock", "ParentLock", false)
|
accessorFunc(EPanel, "_parentLock", "ParentLock", false)
|
||||||
|
|
||||||
function EPanel:initialize()
|
function EPanel:initialize()
|
||||||
@ -22,23 +21,46 @@ function EPanel:initialize()
|
|||||||
self.title:setPos(12, 8)
|
self.title:setPos(12, 8)
|
||||||
self:addChild(self.title)
|
self:addChild(self.title)
|
||||||
|
|
||||||
|
local colorScheme = {
|
||||||
|
bg = {
|
||||||
|
Color(0, 0, 0),
|
||||||
|
hover = Color(25, 25, 25),
|
||||||
|
disabled = Color(0, 0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.minimizeButton = EButton:new()
|
self.minimizeButton = EButton:new()
|
||||||
|
self.minimizeButton:setFont(GUI.fonts["icons"])
|
||||||
self.minimizeButton:setText("_")
|
self.minimizeButton:setText("_")
|
||||||
self.minimizeButton:setSize(32, 32)
|
self.minimizeButton:setSize(32, 32)
|
||||||
self.minimizeButton:setRadius(0)
|
self.minimizeButton:setRadius(0)
|
||||||
self.minimizeButton:setColor(Color(0, 0, 0))
|
self.minimizeButton:setColorScheme(colorScheme)
|
||||||
self.minimizeButton:setHoveredColor(Color(25, 25, 25))
|
self.minimizeButton:setEnabled(false)
|
||||||
self:addChild(self.minimizeButton)
|
self:addChild(self.minimizeButton)
|
||||||
|
|
||||||
self.closeButton = EButton:new()
|
self.closeButton = EButton:new()
|
||||||
|
self.closeButton:setFont(GUI.fonts["icons"])
|
||||||
self.closeButton:setText("X")
|
self.closeButton:setText("X")
|
||||||
self.closeButton:setSize(32, 32)
|
self.closeButton:setSize(32, 32)
|
||||||
self.closeButton:setRadius(0)
|
self.closeButton:setRadius(0)
|
||||||
self.closeButton:setColor(Color(0, 0, 0))
|
self.closeButton:setColorScheme(colorScheme)
|
||||||
self.closeButton:setHoveredColor(Color(25, 25, 25))
|
self.closeButton.onClick = function()
|
||||||
|
self:close()
|
||||||
|
end
|
||||||
self:addChild(self.closeButton)
|
self:addChild(self.closeButton)
|
||||||
|
|
||||||
self:setTitle("Panel")
|
self:setTitle("Panel")
|
||||||
|
self:setColorScheme({
|
||||||
|
border = {
|
||||||
|
Color(255, 255, 255, 10)
|
||||||
|
},
|
||||||
|
header = {
|
||||||
|
Color(0, 0, 0)
|
||||||
|
},
|
||||||
|
bg = {
|
||||||
|
Color(23, 23, 23)
|
||||||
|
}
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function EPanel:setTitle(title)
|
function EPanel:setTitle(title)
|
||||||
@ -57,6 +79,16 @@ function EPanel:isMinimized()
|
|||||||
return self._minimized
|
return self._minimized
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function EPanel:close()
|
||||||
|
self:setVisible(false)
|
||||||
|
self:setEnabled(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
function EPanel:open()
|
||||||
|
self:setVisible(false)
|
||||||
|
self:setEnabled(false)
|
||||||
|
end
|
||||||
|
|
||||||
function EPanel:onMousePressed(x, y, key, keyName)
|
function EPanel:onMousePressed(x, y, key, keyName)
|
||||||
if keyName == "MOUSE1" then
|
if keyName == "MOUSE1" then
|
||||||
local aX, aY = self:getAbsolutePos()
|
local aX, aY = self:getAbsolutePos()
|
||||||
@ -97,16 +129,13 @@ function EPanel:performLayout(w, h)
|
|||||||
self.minimizeButton:setPos(w - 65, 1)
|
self.minimizeButton:setPos(w - 65, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
function EPanel:paint()
|
function EPanel:paint(x, y, w, h)
|
||||||
local x, y = self:getAbsolutePos()
|
render.setColor(self:getColorFromScheme("border"))
|
||||||
local w, h = self:getSize()
|
|
||||||
|
|
||||||
render.setColor(Color(255, 255, 255, 10))
|
|
||||||
render.drawRectFast(x, y, w, h)
|
render.drawRectFast(x, y, w, h)
|
||||||
|
|
||||||
render.setColor(Color(0, 0, 0))
|
render.setColor(self:getColorFromScheme("header"))
|
||||||
render.drawRectFast(x + 1, y + 1, w - 2, 32)
|
render.drawRectFast(x + 1, y + 1, w - 2, 32)
|
||||||
|
|
||||||
render.setColor(self:getBackgroundColor())
|
render.setColor(self:getColorFromScheme("bg"))
|
||||||
render.drawRectFast(x + 1, y + 33, w - 2, h - 34)
|
render.drawRectFast(x + 1, y + 33, w - 2, h - 34)
|
||||||
end
|
end
|
||||||
@ -7,11 +7,9 @@ require("/koptilnya/libs/utils.txt")
|
|||||||
EShape = class("EShape", Element)
|
EShape = class("EShape", Element)
|
||||||
|
|
||||||
accessorFunc(EShape, "_color", "Color", Color(255, 255, 255))
|
accessorFunc(EShape, "_color", "Color", Color(255, 255, 255))
|
||||||
|
accessorFunc(EShape, "_hoveredColor", "HoveredColor", Color(150, 150, 150))
|
||||||
|
|
||||||
function EShape:paint()
|
function EShape:paint(x, y, w, h)
|
||||||
local x, y = self:getAbsolutePos()
|
render.setColor(self:isHovered() and self:getHoveredColor() or self:getColor())
|
||||||
local w, h = self:getSize()
|
|
||||||
|
|
||||||
render.setColor(self:getColor())
|
|
||||||
render.drawRectFast(x, y, w, h)
|
render.drawRectFast(x, y, w, h)
|
||||||
end
|
end
|
||||||
@ -6,6 +6,11 @@ require("elements/root.txt")
|
|||||||
|
|
||||||
GUI = class("GUI")
|
GUI = class("GUI")
|
||||||
|
|
||||||
|
GUI.static.fonts = {
|
||||||
|
main = render.createFont("Roboto", 16, 700, true),
|
||||||
|
icons = render.createFont("Roboto Mono", 16, 700, true)
|
||||||
|
}
|
||||||
|
|
||||||
function GUI:initialize(renderDevice)
|
function GUI:initialize(renderDevice)
|
||||||
checkVarClass(renderDevice, RenderDevice)
|
checkVarClass(renderDevice, RenderDevice)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user