boolean dynamicHeight = !uidl.hasAttribute("height");
boolean widthHasBeenFixed = false;
- String layoutWidth = childUidl.getStringAttribute("width");
- boolean layoutRelativeWidth = (layoutWidth != null && layoutWidth
- .endsWith("%"));
+ boolean layoutRelativeWidth = uidl.hasAttribute("layoutRelativeWidth");
+ boolean layoutRelativeHeight = uidl
+ .hasAttribute("layoutRelativeHeight");
if (dynamicWidth && layoutRelativeWidth) {
/*
* be able to take scrollbars into account (layout gets narrower
* space if it is higher than the window) -> only vertical scrollbar
*/
- client.handleComponentRelativeSize((Widget) layout);
+ client.runDescendentsLayout(this);
}
/*
widthHasBeenFixed = true;
}
+ if (dynamicHeight && layoutRelativeHeight) {
+ /*
+ * Window height is undefined, layout is 100% high so the layout
+ * should define the initial window height but on resize the layout
+ * should be as high as the window. We fix the height immediately to
+ * deal with this.
+ */
+
+ int h = contents.getOffsetHeight() + getExtraHeight();
+ int w = contents.getOffsetWidth();
+
+ // Prevent resizing until height has been fixed
+ resizable = false;
+
+ client.updateVariable(id, "height", h, false);
+ client.updateVariable(id, "width", w, true);
+ // ApplicationConnection.getConsole().log("Fixing window size to " +
+ // w + "x" + h);
+ }
+
// we may have actions and notifications
if (uidl.getChildCount() > 1) {
final int cnt = uidl.getChildCount();
--- /dev/null
+package com.itmill.toolkit.tests.tickets;
+
+import com.itmill.toolkit.Application;
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.VerticalLayout;
+import com.itmill.toolkit.ui.Window;
+import com.itmill.toolkit.ui.Button.ClickEvent;
+import com.itmill.toolkit.ui.Button.ClickListener;
+
+public class Ticket2406 extends Application {
+
+ private Window w;
+
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ // setTheme("tests-tickets");
+ createUI((VerticalLayout) w.getLayout());
+ }
+
+ private void createUI(VerticalLayout layout) {
+ w = new Window("A sub window");
+ w.setSizeUndefined();
+ getMainWindow().addWindow(w);
+
+ VerticalLayout l = new VerticalLayout();
+ l.setSizeFull();
+ w.setLayout(l);
+
+ Button b = new Button("Button 1");
+ b.setSizeFull();
+ b.addListener(new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ w.setHeight("200px");
+ }
+
+ });
+ l.addComponent(b);
+
+ for (int i = 0; i < 5; i++) {
+ b = new Button("Button number "+(i+2));
+ b.setSizeFull();
+ l.addComponent(b);
+ }
+ }
+}
import com.itmill.toolkit.terminal.PaintTarget;
import com.itmill.toolkit.terminal.ParameterHandler;
import com.itmill.toolkit.terminal.Resource;
+import com.itmill.toolkit.terminal.Sizeable;
import com.itmill.toolkit.terminal.Terminal;
import com.itmill.toolkit.terminal.URIHandler;
target.addAttribute("main", true);
}
+ if (getLayout() != null) {
+ if (getLayout().getHeightUnits() == Sizeable.UNITS_PERCENTAGE) {
+ target.addAttribute("layoutRelativeHeight", true);
+ }
+ if (getLayout().getWidthUnits() == Sizeable.UNITS_PERCENTAGE) {
+ target.addAttribute("layoutRelativeWidth", true);
+ }
+ }
+
// Open requested resource
synchronized (openList) {
if (!openList.isEmpty()) {