Skip to content

Commit 110aba6

Browse files
author
p01
committed
Fix for DFL-3326, Allow cells in the composite view to have their own min-width and min-height
1 parent 499bfe8 commit 110aba6

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

src/ui-scripts/cells.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,17 @@
244244
rough_cell.height = stored_height;
245245
}
246246

247+
this.min_width = rough_cell.min_width != null?
248+
rough_cell.min_width : defaults.min_view_width;
249+
this.min_height = rough_cell.min_height != null ?
250+
rough_cell.min_height : defaults.min_view_height;
251+
247252
this.width =
248-
rough_cell.width && rough_cell.width > defaults.min_view_width ?
249-
rough_cell.width : defaults.min_view_width;
253+
rough_cell.width && rough_cell.width > this.min_width ?
254+
rough_cell.width : this.min_width;
250255
this.height =
251-
rough_cell.height && rough_cell.height > defaults.min_view_height ?
252-
rough_cell.height : defaults.min_view_height;
256+
rough_cell.height && rough_cell.height > this.min_height ?
257+
rough_cell.height : this.min_height;
253258
ids[ this.id = rough_cell.id || getId()] = this;
254259

255260
this.checked_height = 0;
@@ -500,7 +505,7 @@
500505
{
501506
var dim = this.dir == VER ? 'height' : 'width';
502507
var max = this[dim];
503-
var child = null, i = 0, sum = 0, length = this.children.length, temp = 0;
508+
var child = null, i = 0, min = 0, sum = 0, length = this.children.length, temp = 0;
504509
var auto_dim_count = 0, average_dim = 0;
505510
if (length)
506511
{
@@ -522,15 +527,16 @@
522527
// allocate space
523528
for (i = 0; child = this.children[i++]; )
524529
{
525-
if (child['has_explicit_' + dim] && child[dim] < defaults['min_view_' + dim])
530+
min = child['min_' + dim];
531+
if (child['has_explicit_' + dim] && child[dim] < min)
526532
{
527533
// if the dimension is below the minimum limit, set minimum value
528534
// and reduce the average to compensate for the distributed pixels
529-
average_dim -= (defaults['min_view_' + dim] - child[dim]) / auto_dim_count;
530-
child[dim] = defaults['min_view_' + dim];
535+
average_dim -= (min - child[dim]) / auto_dim_count;
536+
child[dim] = min;
531537
}
532538
else if (!child['has_explicit_' + dim])
533-
child[dim] = average_dim > defaults['min_view_' + dim] ? average_dim : defaults['min_view_' + dim];
539+
child[dim] = average_dim > min ? average_dim : min;
534540
}
535541
}
536542
}
@@ -539,15 +545,16 @@
539545
{
540546
sum = this.get_total_children_dimension(dim);
541547
temp = max - (sum - this.children[length][dim] - 2 * defaults.view_border_width);
542-
if (sum <= max || defaults['min_view_' + dim] < temp)
548+
min = this.children[length]['min_' + dim];
549+
if (sum <= max || min < temp)
543550
{
544551
this.children[length][dim] = temp;
545552
length = this.children.length;
546553
break;
547554
}
548555
else
549556
{
550-
this.children[length][dim] = defaults['min_view_' + dim];
557+
this.children[length][dim] = min;
551558
}
552559
}
553560

@@ -629,7 +636,7 @@
629636
{
630637
var delta_applied = 0;
631638
var child = null, i = 0;
632-
var deltas = [];
639+
var deltas = [], min = 0, max = 0;
633640
if( this.children.length )
634641
{
635642
if( ( dim == 'height' && this.dir == HOR ) || ( dim == 'width' && this.dir == VER ) )
@@ -640,8 +647,8 @@
640647
{
641648
deltas[deltas.length] = child.checkDelta(dim, delta, sibling);
642649
}
643-
var min = Math.min.apply(null, deltas);
644-
var max = Math.max.apply(null, deltas);
650+
min = Math.min.apply(null, deltas);
651+
max = Math.max.apply(null, deltas);
645652
delta_applied = delta > 0 ? max : min;
646653
if( max != min )
647654
{
@@ -673,16 +680,17 @@
673680
}
674681
else
675682
{
683+
min = this['min_' + dim];
676684
if( delta)
677685
{
678686
var newDim = this[dim] + delta;
679-
if( newDim >= defaults['min_view_' + dim] || newDim >= this[dim] )
687+
if( newDim >= min || newDim >= this[dim] )
680688
{
681689
this['checked_' + dim] = newDim;
682690
}
683691
else
684692
{
685-
this['checked_' + dim] = defaults['min_view_' + dim]
693+
this['checked_' + dim] = min;
686694
}
687695
delta_applied = delta - ( this['checked_' + dim] - this[dim] );
688696
}

0 commit comments

Comments
 (0)