mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-15 20:52:35 +00:00
Container child elements that are not visible are no longer drawn
This commit is contained in:
@@ -4,7 +4,7 @@ module CyberarmEngine
|
|||||||
include Event
|
include Event
|
||||||
include Common
|
include Common
|
||||||
|
|
||||||
attr_accessor :x, :y, :z, :tip
|
attr_accessor :x, :y, :z, :tip, :element_visible
|
||||||
attr_reader :parent, :options, :style, :event_handler, :background_canvas, :border_canvas
|
attr_reader :parent, :options, :style, :event_handler, :background_canvas, :border_canvas
|
||||||
|
|
||||||
def initialize(options = {}, block = nil)
|
def initialize(options = {}, block = nil)
|
||||||
@@ -24,6 +24,7 @@ module CyberarmEngine
|
|||||||
|
|
||||||
@root ||= nil
|
@root ||= nil
|
||||||
@gui_state ||= nil
|
@gui_state ||= nil
|
||||||
|
@element_visible = true
|
||||||
|
|
||||||
@x = @style.x
|
@x = @style.x
|
||||||
@y = @style.y
|
@y = @style.y
|
||||||
@@ -260,6 +261,10 @@ module CyberarmEngine
|
|||||||
@visible
|
@visible
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def element_visible?
|
||||||
|
@element_visible
|
||||||
|
end
|
||||||
|
|
||||||
def toggle
|
def toggle
|
||||||
@visible = !@visible
|
@visible = !@visible
|
||||||
root.gui_state.request_recalculate
|
root.gui_state.request_recalculate
|
||||||
@@ -279,6 +284,7 @@ module CyberarmEngine
|
|||||||
|
|
||||||
def draw
|
def draw
|
||||||
return unless visible?
|
return unless visible?
|
||||||
|
return unless element_visible?
|
||||||
|
|
||||||
@style.background_canvas.draw
|
@style.background_canvas.draw
|
||||||
@style.background_nine_slice_canvas.draw
|
@style.background_nine_slice_canvas.draw
|
||||||
|
|||||||
@@ -129,6 +129,9 @@ module CyberarmEngine
|
|||||||
child.reposition # TODO: Implement top,bottom,left,center, and right positioning
|
child.reposition # TODO: Implement top,bottom,left,center, and right positioning
|
||||||
|
|
||||||
Stats.increment(:gui_recalculations_last_frame, 1)
|
Stats.increment(:gui_recalculations_last_frame, 1)
|
||||||
|
|
||||||
|
child.element_visible = child.x >= @x - child.width && child.x <= @x + width &&
|
||||||
|
child.y >= @y - child.height && child.y <= @y + height
|
||||||
end
|
end
|
||||||
|
|
||||||
update_background
|
update_background
|
||||||
|
|||||||
Reference in New Issue
Block a user