Fixed minor layout weirdness with GroupLayout- if stretching, the size

of the stretchy components was computed as the maximum size of all
the components, even the fixed ones, and they already have their size
accounted for.
Changed to also track the maximum size of the free components and use that
instead.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1549 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray
2004-12-15 03:28:08 +00:00
parent 28d4dd8be3
commit 2d1e549454
4 changed files with 27 additions and 11 deletions
@@ -40,6 +40,9 @@ public class DimenInfo
public int fixwid;
public int fixhei;
public int maxfreewid;
public int maxfreehei;
public int totweight;
public Dimension[] dimens;
@@ -55,6 +58,8 @@ public class DimenInfo
buf.append(", numfix=").append(numfix);
buf.append(", fixwid=").append(fixwid);
buf.append(", fixhei=").append(fixhei);
buf.append(", maxfreewid=").append(maxfreewid);
buf.append(", maxfreehei=").append(maxfreehei);
buf.append(", totweight=").append(totweight);
return buf.append("]").toString();
}
@@ -333,6 +333,13 @@ public abstract class GroupLayout
} else {
info.totweight += getWeight(child);
if (csize.width > info.maxfreewid) {
info.maxfreewid = csize.width;
}
if (csize.height > info.maxfreehei) {
info.maxfreehei = csize.height;
}
}
info.dimens[i] = csize;
@@ -60,14 +60,16 @@ public class HGroupLayout extends GroupLayout
DimenInfo info = computeDimens(parent, type);
Dimension dims = new Dimension();
if (_policy == STRETCH || _policy == EQUALIZE) {
dims.width = info.maxwid * (info.count - info.numfix) +
info.fixwid + _gap * info.count;
if (_policy == STRETCH) {
dims.width = info.maxfreewid * (info.count - info.numfix) +
info.fixwid;
} else if (_policy == EQUALIZE) {
dims.width = info.maxwid * info.count;
} else { // NONE or CONSTRAIN
dims.width = info.totwid + _gap * info.count;
dims.width = info.totwid;
}
dims.width -= _gap;
dims.width += (info.count - 1) * _gap;
dims.height = info.maxhei;
// account for the insets
@@ -60,14 +60,16 @@ public class VGroupLayout extends GroupLayout
DimenInfo info = computeDimens(parent, type);
Dimension dims = new Dimension();
if (_policy == STRETCH || _policy == EQUALIZE) {
dims.height = info.maxhei * (info.count - info.numfix) +
info.fixhei + _gap * info.count;
} else {
dims.height = info.tothei + _gap * info.count;
if (_policy == STRETCH) {
dims.height = info.maxfreehei * (info.count - info.numfix) +
info.fixhei;
} else if (_policy == EQUALIZE) {
dims.height = info.maxhei * info.count;
} else { // NONE or CONSTRAIN
dims.height = info.tothei;
}
dims.height -= _gap;
dims.height += (info.count - 1) * _gap;
dims.width = info.maxwid;
// account for the insets