Added set_color and set_font to Element- fixes image elements unable to change their color when hovered, fixes hovered text changing its color incorrectly

This commit is contained in:
2021-11-18 13:11:02 -06:00
parent 63a51d9d2f
commit 5e5f8ba7ea

View File

@@ -51,6 +51,9 @@ module CyberarmEngine
def stylize
set_static_position
set_color
set_font
set_padding
set_margin
@@ -70,6 +73,15 @@ module CyberarmEngine
@y = @style.y if @style.y != 0
end
def set_color
@style.color = safe_style_fetch(:color)
@text&.color = @style.color
end
def set_font
@text&.swap_font(safe_style_fetch(:text_size), safe_style_fetch(:font))
end
def set_background
@style.background = safe_style_fetch(:background)
@@ -138,14 +150,8 @@ module CyberarmEngine
old_width = width
old_height = height
_style = @style.send(event)
@style_event = event
if @text.is_a?(CyberarmEngine::Text)
@text.color = _style&.dig(:color) || @style.default[:color]
@text.swap_font(_style&.dig(:text_size) || @style.default[:text_size], _style&.dig(:font) || @style.default[:font])
end
return if self.is_a?(ToolTip)
if old_width != width || old_height != height