From 08d068f1566158179f48b27d4ff99b66f82e8561 Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Mon, 4 Apr 2022 10:08:39 -0500 Subject: [PATCH] Fixed weirdness for Container dynamic fill mode --- lib/cyberarm_engine/ui/elements/container.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/cyberarm_engine/ui/elements/container.rb b/lib/cyberarm_engine/ui/elements/container.rb index 60bd3a5..a45e01b 100644 --- a/lib/cyberarm_engine/ui/elements/container.rb +++ b/lib/cyberarm_engine/ui/elements/container.rb @@ -133,17 +133,16 @@ module CyberarmEngine @width = @style.max_width if @style.max_width && @width > @style.max_width @height = @style.max_height if @style.max_height && @height > @style.max_height - # FIXME: Detect if other siblings (parents children) also want to fill and share space with them if @parent && @style.fill fill_siblings = @parent.children.select { |c| c.style.fill }.count.to_f # include self since we're dividing - space_available_width = ((@parent.content_width - (@parent.children.map(&:outer_width).sum - outer_width)) / fill_siblings).floor - space_available_height = ((@parent.content_height - (@parent.children.map(&:outer_height).sum - outer_height)) / fill_siblings).floor + space_available_width = ((@parent.content_width - (@parent.children.reject { |c| c.style.fill }).map(&:outer_width).sum) / fill_siblings).round + space_available_height = ((@parent.content_height - (@parent.children.reject { |c| c.style.fill }).map(&:outer_height).sum) / fill_siblings).round @width = space_available_width - inner_width if @parent.is_a?(Flow) @height = space_available_height - inner_height if @parent.is_a?(Stack) - # pp ["siblings: #{fill_siblings}", "parent is flow: #{@parent.is_a?(Flow)}", "parent is stack: #{@parent.is_a?(Stack)}", [@parent.content_width, space_available_width, @width, outer_width], [@parent.content_height, space_available_height, @height, outer_height]] + # pp ["siblings: #{fill_siblings}", "parent is #{@parent.inspect}", [@parent.content_width, space_available_width, @width, outer_width], [@parent.content_height, space_available_height, @height, outer_height]] end end