From 72df06005933ee55a890176488de40a664c05293 Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Sun, 23 Jun 2019 11:27:13 -0500 Subject: [PATCH] Root Container width/height now always match window --- lib/cyberarm_engine/ui/container.rb | 9 +++++++-- lib/cyberarm_engine/ui/element.rb | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/cyberarm_engine/ui/container.rb b/lib/cyberarm_engine/ui/container.rb index 7854647..1fa43ab 100644 --- a/lib/cyberarm_engine/ui/container.rb +++ b/lib/cyberarm_engine/ui/container.rb @@ -60,8 +60,13 @@ module CyberarmEngine layout - @style.width = @max_width ? @max_width : (@children.map {|c| c.x + c.outer_width }.max || 0).round - @style.height = @max_height ? @max_height : (@children.map {|c| c.y + c.outer_height}.max || 0).round + if is_root? + @style.width = window.width + @style.height = window.height + else + @style.width = @max_width ? @max_width : (@children.map {|c| c.x + c.outer_width }.max || 0).round + @style.height = @max_height ? @max_height : (@children.map {|c| c.y + c.outer_height}.max || 0).round + end # Move child to parent after positioning @children.each do |child| diff --git a/lib/cyberarm_engine/ui/element.rb b/lib/cyberarm_engine/ui/element.rb index 4fe7f0f..8af35fd 100644 --- a/lib/cyberarm_engine/ui/element.rb +++ b/lib/cyberarm_engine/ui/element.rb @@ -214,6 +214,10 @@ module CyberarmEngine @root end + def is_root? + @gui_state != nil + end + def recalculate raise "#{self.class}#recalculate was not overridden!" end