Browse Source

rowheight now double, so scrolltable works smoother with subpixel rendering. Also fixed one index bug when requesting cache rows to the end of visible area. Hopefully fixes #3826

svn changeset:10573/svn branch:6.2
tags/6.7.0.beta1
Matti Tahvonen 14 years ago
parent
commit
59a4d0de75
1 changed files with 27 additions and 22 deletions
  1. 27
    22
      src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java

+ 27
- 22
src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java View File

@@ -209,8 +209,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
if (firstvisible != lastRequestedFirstvisible && scrollBody != null) {
// received 'surprising' firstvisible from server: scroll there
firstRowInViewPort = firstvisible;
bodyContainer.setScrollPosition(firstvisible
* scrollBody.getRowHeight());
bodyContainer.setScrollPosition((int) (firstvisible * scrollBody
.getRowHeight()));
}

showRowHeaders = uidl.getBooleanAttribute("rowheaders");
@@ -724,7 +724,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
// int bodyHeight = scrollBody.getOffsetHeight();
bodyHeight = scrollBody.getRequiredHeight();
} else {
bodyHeight = (scrollBody.getRowHeight(true) * pageLength);
bodyHeight = (int) Math.ceil(scrollBody.getRowHeight(true)
* pageLength);
}
boolean needsSpaceForHorizontalSrollbar = (total > availW);
if (needsSpaceForHorizontalSrollbar) {
@@ -741,8 +742,9 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
// without
DeferredCommand.addCommand(new Command() {
public void execute() {
bodyContainer.setScrollPosition(firstvisible
* scrollBody.getRowHeight());
bodyContainer
.setScrollPosition((int) (firstvisible * scrollBody
.getRowHeight()));
firstRowInViewPort = firstvisible;
}
});
@@ -781,7 +783,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
return true;
}
} else {
int fakeheight = scrollBody.getRowHeight() * totalRows;
int fakeheight = (int) Math.ceil(scrollBody.getRowHeight()
* totalRows);
int availableHeight = bodyContainer.getElement().getPropertyInt(
"clientHeight");
if (fakeheight > availableHeight) {
@@ -1766,7 +1769,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {

public static final int DEFAULT_ROW_HEIGHT = 24;

private int rowHeight = -1;
private double rowHeight = -1;

private final List<Widget> renderedRows = new ArrayList<Widget>();

@@ -1897,7 +1900,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
if (lastRendered < reactLastRow) {
// get some cache rows below visible area
rowRequestHandler.setReqFirstRow(lastRendered + 1);
rowRequestHandler.setReqRows(reactLastRow - lastRendered - 1);
rowRequestHandler.setReqRows(reactLastRow - lastRendered);
rowRequestHandler.deferRowFetch(1);
} else if (scrollBody.getFirstRendered() > reactFirstRow) {
/*
@@ -2032,23 +2035,23 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
}

private void fixSpacers() {
int prepx = getRowHeight() * firstRendered;
int prepx = (int) Math.round(getRowHeight() * firstRendered);
if (prepx < 0) {
prepx = 0;
}
DOM.setStyleAttribute(preSpacer, "height", prepx + "px");
int postpx = getRowHeight() * (totalRows - 1 - lastRendered);
preSpacer.getStyle().setPropertyPx("height", prepx);
int postpx = (int) (getRowHeight() * (totalRows - 1 - lastRendered));
if (postpx < 0) {
postpx = 0;
}
DOM.setStyleAttribute(postSpacer, "height", postpx + "px");
postSpacer.getStyle().setPropertyPx("height", postpx);
}

public int getRowHeight() {
public double getRowHeight() {
return getRowHeight(false);
}

public int getRowHeight(boolean forceUpdate) {
public double getRowHeight(boolean forceUpdate) {
if (tBodyMeasurementsDone && !forceUpdate) {
return rowHeight;
} else {
@@ -2056,7 +2059,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
if (tBodyElement.getRows().getLength() > 0) {
int tableHeight = getTableHeight();
int rowCount = tBodyElement.getRows().getLength();
rowHeight = tableHeight / rowCount;
rowHeight = tableHeight / (double) rowCount;
} else {
if (isAttached()) {
// measure row height by adding a dummy row
@@ -2611,7 +2614,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
return new RenderSpace(w, 0) {
@Override
public int getHeight() {
return getRowHeight();
return (int) getRowHeight();
}
};
}
@@ -2688,7 +2691,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
return;
}

int rowHeight = scrollBody.getRowHeight();
int rowHeight = (int) scrollBody.getRowHeight();
int bodyH = bodyContainer.getOffsetHeight();
int rowsAtOnce = bodyH / rowHeight;
boolean anotherPartlyVisible = ((bodyH % rowHeight) != 0);
@@ -2925,8 +2928,9 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
if (visible) {
DeferredCommand.addCommand(new Command() {
public void execute() {
bodyContainer.setScrollPosition(firstRowInViewPort
* scrollBody.getRowHeight());
bodyContainer
.setScrollPosition((int) (firstRowInViewPort * scrollBody
.getRowHeight()));
}
});
}
@@ -2963,8 +2967,9 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
return;
}
if (!enabled) {
bodyContainer.setScrollPosition(firstRowInViewPort
* scrollBody.getRowHeight());
bodyContainer
.setScrollPosition((int) (firstRowInViewPort * scrollBody
.getRowHeight()));
return;
}

@@ -2987,7 +2992,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler {
tHead.setHorizontalScrollPosition(scrollLeft);

firstRowInViewPort = (int) Math.ceil(scrollTop
/ (double) scrollBody.getRowHeight());
/ scrollBody.getRowHeight());
if (firstRowInViewPort > totalRows - pageLength) {
firstRowInViewPort = totalRows - pageLength;
}

Loading…
Cancel
Save