From dd37b99c2e32b3357edcd64f0f11aba0d6e2e5d0 Mon Sep 17 00:00:00 2001 From: Maarten Vanraes Date: Sun, 7 Aug 2016 21:26:00 +0200 Subject: manadisk buttonbox: calculate size from children if parent doesn't have a size property --- lib/ManaTools/Module/Disk.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/ManaTools/Module/Disk.pm b/lib/ManaTools/Module/Disk.pm index 83ed4d65..8fd1232b 100644 --- a/lib/ManaTools/Module/Disk.pm +++ b/lib/ManaTools/Module/Disk.pm @@ -364,8 +364,18 @@ sub _rebuildButtonBox { my $totalWeight = $maxparts * $minsize; # TODO: dependant upon disk types, etc... $offset = $alignment; - $self->W("$self: parent $parent does not have a size property") if !defined($parent->prop('size')); - my $totalWidth = $parent->prop('size') - $boundary - $offset; # offset at beginning, boundary at end + my $size = 0; + if (!defined($parent->prop('size')) || !$parent->hasProp('size')) { + $self->W("$self: parent $parent does not have a size property, calculation from children"); + for my $i (@items) { + $size = $i->prop('start') + $i->prop('sectors') if ($i->prop('start') + $i->prop('sectors')) > $size; + } + $size = $size + $boundary; + } + else { + $size = $parent->prop('size'); + } + my $totalWidth = $size - $boundary - $offset; # offset at beginning, boundary at end my $start = $offset; my $buttonWidths = []; my $count = 0; -- cgit v1.2.1