From 1ac5e0695e7f1af7771d57c2839dc73313a58825 Mon Sep 17 00:00:00 2001 From: cyberarm Date: Tue, 5 Jan 2021 23:15:22 -0600 Subject: [PATCH] Fixed Image element background and border not working, made button use Style as sole source of background and color colors --- lib/cyberarm_engine/ui/elements/button.rb | 38 +++++++++++------------ lib/cyberarm_engine/ui/elements/image.rb | 2 ++ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/lib/cyberarm_engine/ui/elements/button.rb b/lib/cyberarm_engine/ui/elements/button.rb index a039325..9629f6a 100644 --- a/lib/cyberarm_engine/ui/elements/button.rb +++ b/lib/cyberarm_engine/ui/elements/button.rb @@ -10,7 +10,7 @@ module CyberarmEngine super(text_or_image, options, block) - @style.background_canvas.background = default(:background) + @style.background_canvas.background = @style.background end def render @@ -38,14 +38,14 @@ module CyberarmEngine @focus = false unless window.button_down?(Gosu::MsLeft) if !@enabled - @style.background_canvas.background = default(:disabled, :background) - @text.color = default(:disabled, :color) + @style.background_canvas.background = @style.disabled[:background] + @text.color = @style.disabled[:color] elsif @focus - @style.background_canvas.background = default(:active, :background) - @text.color = default(:active, :color) + @style.background_canvas.background = @style.active[:background] + @text.color = @style.active[:color] else - @style.background_canvas.background = default(:hover, :background) - @text.color = default(:hover, :color) + @style.background_canvas.background = @style.hover[:background] + @text.color = @style.hover[:color] end :handled @@ -55,11 +55,11 @@ module CyberarmEngine @focus = true unless @enabled - @style.background_canvas.background = default(:disabled, :background) - @text.color = default(:disabled, :color) + @style.background_canvas.background = @style.disabled[:background] + @text.color = @style.disabled[:color] else - @style.background_canvas.background = default(:active, :background) - @text.color = default(:active, :color) + @style.background_canvas.background = @style.active[:background] + @text.color = @style.active[:color] end window.current_state.focus = self @@ -81,11 +81,11 @@ module CyberarmEngine def leave(_sender) unless @enabled - @style.background_canvas.background = default(:disabled, :background) - @text.color = default(:disabled, :color) + @style.background_canvas.background = @style.disabled[:background] + @text.color = @style.disabled[:color] else - @style.background_canvas.background = default(:background) - @text.color = default(:color) + @style.background_canvas.background = @style.background + @text.color = @style.color end :handled @@ -99,11 +99,11 @@ module CyberarmEngine def recalculate unless @enabled - @style.background_canvas.background = default(:disabled, :background) - @text.color = default(:disabled, :color) + @style.background_canvas.background = @style.disabled[:background] + @text.color = @style.disabled[:color] else - @style.background_canvas.background = default(:background) - @text.color = default(:color) + @style.background_canvas.background = @style.background + @text.color = @style.color end if @image diff --git a/lib/cyberarm_engine/ui/elements/image.rb b/lib/cyberarm_engine/ui/elements/image.rb index 24a9ffd..2c569b2 100644 --- a/lib/cyberarm_engine/ui/elements/image.rb +++ b/lib/cyberarm_engine/ui/elements/image.rb @@ -47,6 +47,8 @@ module CyberarmEngine @width = _width || @image.width.round * @scale_x @height = _height || @image.height.round * @scale_y + + update_background end def value