From 2b92ad71ed7bc6e8552ba4dc7e31eba63881bc56 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Mon, 10 Nov 2008 11:15:53 +0000 Subject: [PATCH] fixes some child component size change issues svn changeset:5840/svn branch:trunk --- .../terminal/gwt/client/ui/IGridLayout.java | 60 ++++++++----------- 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java index 180bc7e3f0..2d0238c9ee 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java @@ -547,6 +547,8 @@ public class IGridLayout extends SimplePanel implements Paintable, Container { public boolean requestLayout(final Set changedChildren) { ApplicationConnection.getConsole().log("IGridLayout.requestLayout()"); boolean needsLayout = false; + boolean reDistributeColSpanWidths = false; + boolean reDistributeRowSpanHeights = false; int offsetHeight = canvas.getOffsetHeight(); int offsetWidth = canvas.getOffsetWidth(); if ("".equals(width) || "".equals(height)) { @@ -574,24 +576,12 @@ public class IGridLayout extends SimplePanel implements Paintable, Container { } if (allocated < width) { needsLayout = true; - // columnWidths needs to be expanded due colspanned - // cell - int neededExtraSpace = width - allocated; - int spaceForColunms = neededExtraSpace / cell.colspan; - for (int i = 0; i < cell.colspan; i++) { - int col = cell.col + i; - columnWidths[col] += spaceForColunms; - neededExtraSpace -= spaceForColunms; - } - if (neededExtraSpace > 0) { - for (int i = 0; i < cell.colspan; i++) { - int col = cell.col + i; - columnWidths[col] += 1; - neededExtraSpace -= 1; - if (neededExtraSpace == 0) { - break; - } - } + if (cell.colspan == 1) { + // do simple column width expansion + columnWidths[cell.col] = minColumnWidths[cell.col] = width; + } else { + // mark that col span expansion is needed + reDistributeColSpanWidths = true; } } else if (allocated != width) { // size is smaller thant allocated, column might @@ -608,24 +598,12 @@ public class IGridLayout extends SimplePanel implements Paintable, Container { } if (allocated < height) { needsLayout = true; - // columnWidths needs to be expanded due colspanned - // cell - int neededExtraSpace = height - allocated; - int spaceForColunms = neededExtraSpace / cell.rowspan; - for (int i = 0; i < cell.rowspan; i++) { - int row = cell.row + i; - rowHeights[row] += spaceForColunms; - neededExtraSpace -= spaceForColunms; - } - if (neededExtraSpace > 0) { - for (int i = 0; i < cell.rowspan; i++) { - int row = cell.row + i; - rowHeights[row] += 1; - neededExtraSpace -= 1; - if (neededExtraSpace == 0) { - break; - } - } + if (cell.rowspan == 1) { + // do simple row expansion + rowHeights[cell.row] = minRowHeights[cell.row] = height; + } else { + // mark that row span expansion is needed + reDistributeRowSpanHeights = true; } } else if (allocated != height) { // size is smaller than allocated, row might shrink @@ -654,6 +632,11 @@ public class IGridLayout extends SimplePanel implements Paintable, Container { // ensure colspanned columns have enough space columnWidths = cloneArray(minColumnWidths); distributeColSpanWidths(); + reDistributeColSpanWidths = false; + } + + if (reDistributeColSpanWidths) { + distributeColSpanWidths(); } if (dirtyRows.size() > 0) { @@ -678,6 +661,11 @@ public class IGridLayout extends SimplePanel implements Paintable, Container { // TODO could check only some row spans rowHeights = cloneArray(minRowHeights); distributeRowSpanHeights(); + reDistributeRowSpanHeights = false; + } + + if (reDistributeRowSpanHeights) { + distributeRowSpanHeights(); } if (needsLayout) { -- 2.39.5