Skip to content

Commit c837737

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 a9d437c commit c837737

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;
@@ -499,7 +504,7 @@
499504
{
500505
var dim = this.dir == VER ? 'height' : 'width';
501506
var max = this[dim];
502-
var child = null, i = 0, sum = 0, length = this.children.length, temp = 0;
507+
var child = null, i = 0, sum = 0, length = this.children.length, temp = 0, min = 0;
503508
var auto_dim_count = 0, average_dim = 0;
504509
if (length)
505510
{
@@ -521,15 +526,16 @@
521526
// allocate space
522527
for (i = 0; child = this.children[i++]; )
523528
{
524-
if (child['has_explicit_' + dim] && child[dim] < defaults['min_view_' + dim])
529+
min = child['min_' + dim];
530+
if (child['has_explicit_' + dim] && child[dim] < min)
525531
{
526532
// if the dimension is below the minimum limit, set minimum value
527533
// and reduce the average to compensate for the distributed pixels
528-
average_dim -= (defaults['min_view_' + dim] - child[dim]) / auto_dim_count;
529-
child[dim] = defaults['min_view_' + dim];
534+
average_dim -= (min - child[dim]) / auto_dim_count;
535+
child[dim] = min;
530536
}
531537
else if (!child['has_explicit_' + dim])
532-
child[dim] = average_dim > defaults['min_view_' + dim] ? average_dim : defaults['min_view_' + dim];
538+
child[dim] = average_dim > min ? average_dim : min;
533539
}
534540
}
535541
}
@@ -538,15 +544,16 @@
538544
{
539545
sum = this.get_total_children_dimension(dim);
540546
temp = max - (sum - this.children[length][dim] - 2 * defaults.view_border_width);
541-
if (sum <= max || defaults['min_view_' + dim] < temp)
547+
min = this.children[length]['min_' + dim];
548+
if (sum <= max || min < temp)
542549
{
543550
this.children[length][dim] = temp;
544551
length = this.children.length;
545552
break;
546553
}
547554
else
548555
{
549-
this.children[length][dim] = defaults['min_view_' + dim];
556+
this.children[length][dim] = min;
550557
}
551558
}
552559

@@ -628,7 +635,7 @@
628635
{
629636
var delta_applied = 0;
630637
var child = null, i = 0;
631-
var deltas = [];
638+
var deltas = [], min = 0, max = 0;
632639
if( this.children.length )
633640
{
634641
if( ( dim == 'height' && this.dir == HOR ) || ( dim == 'width' && this.dir == VER ) )
@@ -639,8 +646,8 @@
639646
{
640647
deltas[deltas.length] = child.checkDelta(dim, delta, sibling);
641648
}
642-
var min = Math.min.apply(null, deltas);
643-
var max = Math.max.apply(null, deltas);
649+
min = Math.min.apply(null, deltas);
650+
max = Math.max.apply(null, deltas);
644651
delta_applied = delta > 0 ? max : min;
645652
if( max != min )
646653
{
@@ -672,16 +679,17 @@
672679
}
673680
else
674681
{
682+
min = this['min_' + dim];
675683
if( delta)
676684
{
677685
var newDim = this[dim] + delta;
678-
if( newDim >= defaults['min_view_' + dim] || newDim >= this[dim] )
686+
if( newDim >= min || newDim >= this[dim] )
679687
{
680688
this['checked_' + dim] = newDim;
681689
}
682690
else
683691
{
684-
this['checked_' + dim] = defaults['min_view_' + dim]
692+
this['checked_' + dim] = min;
685693
}
686694
delta_applied = delta - ( this['checked_' + dim] - this[dim] );
687695
}

0 commit comments

Comments
 (0)