diff options
author | John Ahlroos <john@vaadin.com> | 2013-01-21 15:02:56 +0200 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2013-01-22 13:19:28 +0200 |
commit | 308d75a1d7c3c5c975c90b579fb7d4622bac064a (patch) | |
tree | 381890540b494f557e155355c511bfc4a734e66d /client | |
parent | 84b0df6f6b731d055a5451be07bb76f73accdef9 (diff) | |
download | vaadin-framework-308d75a1d7c3c5c975c90b579fb7d4622bac064a.tar.gz vaadin-framework-308d75a1d7c3c5c975c90b579fb7d4622bac064a.zip |
Hide components if width 100% + expand ratio 0 #10783
Change-Id: I5ca5eac5fbfeec744078ebcb83f08192c1bf2af8
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java | 10 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java | 54 |
2 files changed, 44 insertions, 20 deletions
diff --git a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index 5653e1d1cf..afe81c79a0 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -251,9 +251,6 @@ public abstract class AbstractOrderedLayoutConnector extends slot.setCaption(caption, iconUrlString, styles, error, showError, required, enabled); - slot.setRelativeWidth(child.isRelativeWidth()); - slot.setRelativeHeight(child.isRelativeHeight()); - if (slot.hasCaption()) { CaptionPosition pos = slot.getCaptionPosition(); getLayoutManager().addElementResizeListener( @@ -360,12 +357,15 @@ public abstract class AbstractOrderedLayoutConnector extends // First update bookkeeping for all children for (ComponentConnector child : getChildComponents()) { + Slot slot = getWidget().getSlot(child.getWidget()); + + slot.setRelativeWidth(child.isRelativeWidth()); + slot.setRelativeHeight(child.isRelativeHeight()); + if (child.delegateCaptionHandling()) { updateCaptionInternal(child); } - Slot slot = getWidget().getSlot(child.getWidget()); - // Update slot style names List<String> childStyles = child.getState().styles; if (childStyles == null) { diff --git a/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java b/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java index c9f5b92c90..93176f67bb 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java @@ -21,6 +21,7 @@ import java.util.Map; import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.dom.client.Style.Visibility; import com.google.gwt.regexp.shared.MatchResult; import com.google.gwt.regexp.shared.RegExp; import com.google.gwt.user.client.DOM; @@ -367,34 +368,54 @@ public class VAbstractOrderedLayout extends FlowPanel { // Sum up expand ratios to get the denominator double total = 0; for (Slot slot : widgetToSlot.values()) { - if (slot.getExpandRatio() != 0) { - total += slot.getExpandRatio(); - } else { - if (vertical) { - slot.getElement().getStyle().clearHeight(); - } else { - slot.getElement().getStyle().clearWidth(); - } - } - slot.getElement().getStyle().clearMarginLeft(); - slot.getElement().getStyle().clearMarginTop(); + // FIXME expandRatio might be <0 + total += slot.getExpandRatio(); } - // Give each child its own share + // Give each expanded child its own share for (Slot slot : widgetToSlot.values()) { + + Element slotElement = slot.getElement(); + slotElement.removeAttribute("aria-hidden"); + + Style slotStyle = slotElement.getStyle(); + slotStyle.clearVisibility(); + slotStyle.clearMarginLeft(); + slotStyle.clearMarginTop(); + if (slot.getExpandRatio() != 0) { + // FIXME expandRatio might be <0 + double size = 100 * (slot.getExpandRatio() / total); + if (vertical) { - slot.setHeight((100 * (slot.getExpandRatio() / total)) - + "%"); + slot.setHeight(size + "%"); if (slot.hasRelativeHeight()) { Util.notifyParentOfSizeChange(this, true); } } else { - slot.setWidth((100 * (slot.getExpandRatio() / total)) + "%"); + slot.setWidth(size + "%"); if (slot.hasRelativeWidth()) { Util.notifyParentOfSizeChange(this, true); } } + + } else if (slot.isRelativeInDirection(vertical)) { + // Relative child without expansion gets no space at all + if (vertical) { + slot.setHeight("0"); + } else { + slot.setWidth("0"); + } + slotStyle.setVisibility(Visibility.HIDDEN); + slotElement.setAttribute("aria-hidden", "true"); + + } else { + // Non-relative child without expansion should be unconstrained + if (vertical) { + slotStyle.clearHeight(); + } else { + slotStyle.clearWidth(); + } } } } @@ -440,6 +461,7 @@ public class VAbstractOrderedLayout extends FlowPanel { public void updateExpandCompensation() { boolean isExpanding = false; for (Widget slot : getChildren()) { + // FIXME expandRatio might be <0 if (((Slot) slot).getExpandRatio() != 0) { isExpanding = true; break; @@ -501,6 +523,7 @@ public class VAbstractOrderedLayout extends FlowPanel { } } } else { + // FIXME expandRatio might be <0 totalSize += vertical ? slot.getOffsetHeight() : slot .getOffsetWidth(); } @@ -532,6 +555,7 @@ public class VAbstractOrderedLayout extends FlowPanel { lastExpandSize = totalSize; for (Widget w : getChildren()) { Slot slot = (Slot) w; + // FIXME expandRatio might be <0 if (slot.getExpandRatio() != 0) { if (layoutManager != null) { layoutManager.setNeedsMeasure(Util |