New elements; Fixes
This commit is contained in:
@@ -14,6 +14,7 @@ function Element:initialize()
|
||||
self._visible = true
|
||||
self._draggable = true
|
||||
self._hovered = false
|
||||
self._colorScheme = {}
|
||||
self._parent = nil
|
||||
self._firstChild = nil
|
||||
self._prevSibling = nil
|
||||
@@ -107,6 +108,35 @@ function Element:isHovered()
|
||||
return self._hovered
|
||||
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)
|
||||
checkVarClass(parent, Element)
|
||||
|
||||
@@ -238,14 +268,17 @@ function Element:_onThink()
|
||||
end
|
||||
|
||||
function Element:_onPaint()
|
||||
if self:isVisible() then
|
||||
if self:isVisible() then
|
||||
--[[
|
||||
if self:hasParent() then
|
||||
render.enableScissorRect(self:getParent():getBounds())
|
||||
end
|
||||
]]
|
||||
|
||||
self:paint()
|
||||
|
||||
local x, y = self:getAbsolutePos()
|
||||
local w, h = self:getSize()
|
||||
|
||||
self:paint(x, y, w, h)
|
||||
|
||||
if self._firstChild then
|
||||
self._firstChild:_postEventToAllReverse("PAINT")
|
||||
@@ -290,10 +323,10 @@ function Element:_onMouseReleased(x, y, key, keyName)
|
||||
end
|
||||
|
||||
function Element:_onMouseMoved(x, y)
|
||||
if self:cursorIntersect(x, y) and self:isEnabled() then
|
||||
local element = self:_postEventToAll("MOUSE_MOVED", x, y)
|
||||
|
||||
if not element then
|
||||
local element = self:_postEventToAll("MOUSE_MOVED", x, y)
|
||||
|
||||
if self:cursorIntersect(x, y) then
|
||||
if self:isEnabled() then
|
||||
if not self:isHovered() then
|
||||
self._hovered = true
|
||||
|
||||
@@ -302,17 +335,15 @@ function Element:_onMouseMoved(x, y)
|
||||
|
||||
self:onMouseMoved(x, y)
|
||||
end
|
||||
|
||||
return true
|
||||
else
|
||||
if self:isHovered() then
|
||||
self._hovered = false
|
||||
|
||||
self:onMouseLeave()
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function Element:_onButtonPressed(key, keyName)
|
||||
|
||||
Reference in New Issue
Block a user