diff options
author | Henri Sara <hesara@vaadin.com> | 2013-01-04 15:24:43 +0000 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-01-04 15:24:43 +0000 |
commit | ddcd8d06f154c73136ab3f19477abb5c6fce73fd (patch) | |
tree | fde1999ac497ec2f9625a770ea498d25c2d1088c | |
parent | 32204117f8b0c18cce3b88732f2bc636bf01c532 (diff) | |
parent | c322474415ed2fc546e763a2329fdd82a62b06ec (diff) | |
download | vaadin-framework-ddcd8d06f154c73136ab3f19477abb5c6fce73fd.tar.gz vaadin-framework-ddcd8d06f154c73136ab3f19477abb5c6fce73fd.zip |
Merge "Don't include relative sizes in expand compensation (#10222)"
4 files changed, 151 insertions, 1 deletions
diff --git a/client/src/com/vaadin/client/ui/orderedlayout/Slot.java b/client/src/com/vaadin/client/ui/orderedlayout/Slot.java index 8b6ad14669..b59c3664c7 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/Slot.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/Slot.java @@ -661,4 +661,12 @@ public final class Slot extends SimplePanel { getElement().getParentElement().insertBefore(spacer, getElement()); } } + + public boolean isRelativeInDirection(boolean vertical) { + if (vertical) { + return hasRelativeHeight(); + } else { + return hasRelativeWidth(); + } + } }
\ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java b/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java index a11251f0b0..84f946dec4 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java @@ -426,10 +426,25 @@ public class VAbstractOrderedLayout extends FlowPanel { } if (isExpanding) { + /* + * Expanded slots have relative sizes that together add up to 100%. + * To make room for slots without expand, we will add padding that + * is not considered for relative sizes and a corresponding negative + * margin for the unexpanded slots. We calculate the size by summing + * the size of all non-expanded non-relative slots. + * + * Relatively sized slots without expansion are considered to get + * 0px, but we still keep them visible (causing overflows) to help + * the developer see what's happening. Forcing them to only get 0px + * would make them disappear which would avoid overflows but would + * instead cause confusion as they would then just disappear without + * any obvious reason. + */ int totalSize = 0; for (Widget w : getChildren()) { Slot slot = (Slot) w; - if (slot.getExpandRatio() == 0) { + if (slot.getExpandRatio() == 0 + && !slot.isRelativeInDirection(vertical)) { if (layoutManager != null) { // TODO check caption position diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/RelativeChildrenWithoutExpand.html b/uitest/src/com/vaadin/tests/components/orderedlayout/RelativeChildrenWithoutExpand.html new file mode 100644 index 0000000000..46252bc447 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/RelativeChildrenWithoutExpand.html @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.orderedlayout.RelativeChildrenWithoutExpand?restartApplication</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutRelativeChildrenWithoutExpand::/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutRelativeChildrenWithoutExpand::Root/VNotification[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutRelativeChildrenWithoutExpand::/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutRelativeChildrenWithoutExpand::Root/VNotification[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutRelativeChildrenWithoutExpand::/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutRelativeChildrenWithoutExpand::Root/VNotification[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutRelativeChildrenWithoutExpand::/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutRelativeChildrenWithoutExpand::Root/VNotification[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutRelativeChildrenWithoutExpand::/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutRelativeChildrenWithoutExpand::Root/VNotification[0]</td> + <td></td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/RelativeChildrenWithoutExpand.java b/uitest/src/com/vaadin/tests/components/orderedlayout/RelativeChildrenWithoutExpand.java new file mode 100644 index 0000000000..a1ac1df307 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/RelativeChildrenWithoutExpand.java @@ -0,0 +1,55 @@ +package com.vaadin.tests.components.orderedlayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.VerticalLayout; + +public class RelativeChildrenWithoutExpand extends AbstractTestUI { + + private final String loremIpsum = "This is a label without expand but with relative width that shouldn't get any space at all. "; + + @Override + protected void setup(VaadinRequest request) { + final HorizontalLayout horizontalExpand = new HorizontalLayout(); + + VerticalLayout vl = new VerticalLayout(); + vl.addComponent(new Label(getTestDescription())); + vl.setSizeFull(); + + // Replacing default AbstractTestUI content to get the right expansions + setContent(vl); + + HorizontalLayout verticalExpand = new HorizontalLayout(); + verticalExpand.addComponent(new Button("Add relative child", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + horizontalExpand.addComponent(new Label(loremIpsum), 0); + } + })); + vl.addComponent(verticalExpand); + vl.setExpandRatio(verticalExpand, 1); + + horizontalExpand.setWidth("100%"); + vl.addComponent(horizontalExpand); + + Label lblExpandRatio1 = new Label( + "This is an expanding label that will get all of the normal space in the component."); + horizontalExpand.addComponent(lblExpandRatio1); + horizontalExpand.setExpandRatio(lblExpandRatio1, 1); + } + + @Override + protected String getTestDescription() { + return "HorizontalLayout containing relatively sized components that are not expanded should not cause infinite layout loops when scrollbars appear. Add children until the entire space is filled up."; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(10222); + } +}
\ No newline at end of file |