Fix layout issue where content area was pinned to the right-hand side in hosted mode Linux and Mac/Tiger.
To fix this, we make sure that the styleTesterTimer always runs, regardless of whether or not a stylesheet was swapped out. We need to ensure that the resizing code in onWindowResize is invoked AFTER the stylesheet has been applied, so we add a call to onWindowResize when the styleTesterTimer fires.
Patch by: jamieyap, rdayal (pair prog)
Review by: knorton.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2925 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/samples/showcase/src/com/google/gwt/sample/showcase/client/Application.java b/samples/showcase/src/com/google/gwt/sample/showcase/client/Application.java
index 96e98d3..443bd40 100644
--- a/samples/showcase/src/com/google/gwt/sample/showcase/client/Application.java
+++ b/samples/showcase/src/com/google/gwt/sample/showcase/client/Application.java
@@ -226,13 +226,7 @@
return;
}
windowWidth = width;
- int menuWidth = mainMenu.getOffsetWidth();
- int contentWidth = width - menuWidth - 30;
- int contentWidthInner = contentWidth - 10;
- bottomPanel.setCellWidth(mainMenu, menuWidth + "px");
- bottomPanel.setCellWidth(contentLayout, contentWidth + "px");
- contentLayout.getCellFormatter().setWidth(0, 0, contentWidthInner + "px");
- contentLayout.getCellFormatter().setWidth(1, 0, contentWidthInner + "px");
+ onWindowResizedImpl(width);
}
/**
@@ -299,6 +293,16 @@
windowWidth = -1;
}
+ protected void onWindowResizedImpl(int width) {
+ int menuWidth = mainMenu.getOffsetWidth();
+ int contentWidth = width - menuWidth - 30;
+ int contentWidthInner = contentWidth - 10;
+ bottomPanel.setCellWidth(mainMenu, menuWidth + "px");
+ bottomPanel.setCellWidth(contentLayout, contentWidth + "px");
+ contentLayout.getCellFormatter().setWidth(0, 0, contentWidthInner + "px");
+ contentLayout.getCellFormatter().setWidth(1, 0, contentWidthInner + "px");
+ }
+
/**
* Create the main menu.
*/
diff --git a/samples/showcase/src/com/google/gwt/sample/showcase/client/Showcase.java b/samples/showcase/src/com/google/gwt/sample/showcase/client/Showcase.java
index ab0a75e..280fb2d 100644
--- a/samples/showcase/src/com/google/gwt/sample/showcase/client/Showcase.java
+++ b/samples/showcase/src/com/google/gwt/sample/showcase/client/Showcase.java
@@ -215,6 +215,7 @@
if (styleTester.getOffsetWidth() > 0) {
RootPanel.getBodyElement().getStyle().setProperty("display", "none");
RootPanel.getBodyElement().getStyle().setProperty("display", "");
+ app.onWindowResizedImpl(Window.getClientWidth());
} else {
schedule(25);
}
@@ -581,10 +582,15 @@
}
}
+ // Kick off the timer that checks to see when the stylesheet has been applied, so that
+ // we can force a re-layout of the application. We even do this in the case where
+ // no stylesheets are swapped out, because this could be on the first load of the application,
+ // and the stylesheet may not have been applied to the DOM elements as yet.
+ styleTesterTimer.schedule(25);
+
// Add the new style sheets
String modulePath = GWT.getModuleBaseURL();
if (gwtStyleSheet != null) {
- styleTesterTimer.schedule(25);
loadStyleSheet(modulePath + gwtStyleSheet);
}
if (showcaseStyleSheet != null) {