mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-16 13:12:34 +00:00
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:
@@ -51,6 +51,9 @@ module CyberarmEngine
|
|||||||
def stylize
|
def stylize
|
||||||
set_static_position
|
set_static_position
|
||||||
|
|
||||||
|
set_color
|
||||||
|
set_font
|
||||||
|
|
||||||
set_padding
|
set_padding
|
||||||
set_margin
|
set_margin
|
||||||
|
|
||||||
@@ -70,6 +73,15 @@ module CyberarmEngine
|
|||||||
@y = @style.y if @style.y != 0
|
@y = @style.y if @style.y != 0
|
||||||
end
|
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
|
def set_background
|
||||||
@style.background = safe_style_fetch(:background)
|
@style.background = safe_style_fetch(:background)
|
||||||
|
|
||||||
@@ -138,14 +150,8 @@ module CyberarmEngine
|
|||||||
old_width = width
|
old_width = width
|
||||||
old_height = height
|
old_height = height
|
||||||
|
|
||||||
_style = @style.send(event)
|
|
||||||
@style_event = 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)
|
return if self.is_a?(ToolTip)
|
||||||
|
|
||||||
if old_width != width || old_height != height
|
if old_width != width || old_height != height
|
||||||
|
|||||||
Reference in New Issue
Block a user