summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Koivuviita <jouni@jounikoivuviita.com>2012-04-09 22:38:49 +0300
committerJouni Koivuviita <jouni@jounikoivuviita.com>2012-04-09 22:38:49 +0300
commitc22e33364d4c3427f85ea4d6cb940c2cb71ebc5b (patch)
tree3e3c36276caf7429cdf7d183dd9023215813c9f3
parentf64a5927e92791c0b1a03899bb7b2487bc08896c (diff)
downloadvaadin-framework-c22e33364d4c3427f85ea4d6cb940c2cb71ebc5b.tar.gz
vaadin-framework-c22e33364d4c3427f85ea4d6cb940c2cb71ebc5b.zip
Small fixes to VBoxLayout, moved styles to separate stylesheet
-rw-r--r--WebContent/VAADIN/themes/base/boxlayout/boxlayout.css143
-rw-r--r--WebContent/VAADIN/themes/base/paintable/paintable.css4
-rw-r--r--WebContent/VAADIN/themes/tests-components/styles.css144
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java5
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VBoxLayout.java32
5 files changed, 178 insertions, 150 deletions
diff --git a/WebContent/VAADIN/themes/base/boxlayout/boxlayout.css b/WebContent/VAADIN/themes/base/boxlayout/boxlayout.css
new file mode 100644
index 0000000000..b2514d2382
--- /dev/null
+++ b/WebContent/VAADIN/themes/base/boxlayout/boxlayout.css
@@ -0,0 +1,143 @@
+.v-boxlayout.v-margin-top {padding-top: 18px;}
+.v-boxlayout.v-margin-right {padding-right: 18px;}
+.v-boxlayout.v-margin-bottom {padding-bottom: 18px;}
+.v-boxlayout.v-margin-left {padding-left: 18px;}
+
+.v-spacing {
+ width: 7px;
+ height: 7px;
+}
+
+.v-boxlayout {
+ display: inline-block;
+}
+
+.v-boxlayout.v-horizontal {
+ white-space: nowrap;
+}
+
+.v-boxlayout > .v-expand {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ width: 100%;
+ height: 100%;
+}
+
+.v-slot,
+.v-spacing {
+ display: inline-block;
+ white-space: normal;
+ vertical-align: top;
+}
+
+.v-vertical > .v-slot,
+.v-vertical > .v-expand > .v-slot {
+ display: block;
+}
+
+.v-horizontal > .v-slot,
+.v-horizontal > .v-expand > .v-slot {
+ height: 100%;
+}
+
+.v-vertical > .v-spacing,
+.v-vertical > .v-expand > .v-spacing {
+ width: 0;
+}
+
+.v-horizontal > .v-spacing,
+.v-horizontal > .v-expand > .v-spacing {
+ height: 0;
+}
+
+.v-align-middle:before,
+.v-align-bottom:before,
+.v-expand > .v-align-middle:before,
+.v-expand > .v-align-bottom:before {
+ content: "";
+ display: inline-block;
+ height: 100%;
+ vertical-align: middle;
+ width: 0;
+}
+
+.v-align-middle,
+.v-align-bottom {
+ white-space: nowrap;;
+}
+
+.v-align-middle > .v-paintable,
+.v-align-bottom > .v-paintable {
+ display: inline-block;
+ /* TODO this is a bit tricky, since it will override component defaults in some cases */
+ white-space: normal;
+}
+
+.v-align-middle > .v-paintable {
+ vertical-align: middle;
+}
+
+.v-align-bottom > .v-paintable {
+ vertical-align: bottom;
+}
+
+.v-align-center {
+ text-align: center;
+}
+
+.v-align-center > .v-paintable {
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.v-align-right {
+ text-align: right;
+}
+
+.v-align-right > .v-paintable {
+ margin-left: auto;
+}
+
+.v-has-caption {
+ display: inline-block;
+}
+
+.v-caption {
+ overflow: visible;
+ vertical-align: middle;
+}
+
+.v-caption-on-left,
+.v-caption-on-right {
+ white-space: nowrap;
+}
+
+.v-caption-on-left > .v-caption,
+.v-caption-on-right > .v-caption {
+ display: inline-block;
+}
+
+.v-caption-on-left > .v-caption {
+ padding-right: .5em;
+}
+
+.v-caption-on-right > .v-caption {
+ padding-left: .5em;
+}
+
+.v-caption-on-left > .v-paintable,
+.v-caption-on-right > .v-paintable {
+ display: inline-block;
+ vertical-align: middle;
+ /* TODO this is a bit tricky, since it will override component defaults in some cases */
+ white-space: normal;
+}
+
+.v-has-caption.v-has-width > .v-paintable {
+ width: 100% !important;
+}
+
+.v-has-caption.v-has-height > .v-paintable {
+ height: 100% !important;
+} \ No newline at end of file
diff --git a/WebContent/VAADIN/themes/base/paintable/paintable.css b/WebContent/VAADIN/themes/base/paintable/paintable.css
index 1de0b70c38..c42da19e4f 100644
--- a/WebContent/VAADIN/themes/base/paintable/paintable.css
+++ b/WebContent/VAADIN/themes/base/paintable/paintable.css
@@ -1,4 +1,6 @@
.v-paintable {
- box-sizing: border-box;
+ -webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
+ box-sizing: border-box;
+ text-align: left;
} \ No newline at end of file
diff --git a/WebContent/VAADIN/themes/tests-components/styles.css b/WebContent/VAADIN/themes/tests-components/styles.css
index 8ab31f511d..4a62696e1b 100644
--- a/WebContent/VAADIN/themes/tests-components/styles.css
+++ b/WebContent/VAADIN/themes/tests-components/styles.css
@@ -38,146 +38,10 @@
background: #f00;
}
-
-
-
-
-
-/* BoxLayout styles */
-.v-layout.v-margin-top {padding-top: 1.5em;}
-.v-layout.v-margin-right {padding-right: 1.5em;}
-.v-layout.v-margin-bottom {padding-bottom: 1.5em;}
-.v-layout.v-margin-left {padding-left: 1.5em;}
-
-.v-layout.v-box {
- display: inline-block;
-}
-
-.v-paintable {
- text-align: left;
-}
-
-.v-layout.v-box.v-horizontal {
- white-space: nowrap;
-}
-
-.v-box-expand {
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
- width: 100%;
- height: 100%;
-}
-
-.v-slot,
-.v-spacing {
- display: inline-block;
- white-space: normal;
- vertical-align: top;
-}
-
-.v-vertical > .v-slot,
-.v-vertical > .v-box-expand > .v-slot {
- display: block;
-}
-
-.v-horizontal > .v-slot,
-.v-horizontal > .v-box-expand > .v-slot {
- height: 100%;
-}
-
-.v-spacing {
- width: 1em;
- height: 1em;
-}
-
-.v-box > .v-align-middle:before,
-.v-box > .v-align-bottom:before,
-.v-box-expand > .v-align-middle:before,
-.v-box-expand > .v-align-bottom:before {
- content: "";
- display: inline-block;
- height: 100%;
- vertical-align: middle;
- width: 0;
-}
-
-.v-align-middle,
-.v-align-bottom {
- white-space: nowrap;;
-}
-
-.v-align-middle > .v-paintable,
-.v-align-bottom > .v-paintable {
- display: inline-block;
- /* TODO this is a bit tricky, since it will override component defaults in some cases */
- white-space: normal;
-}
-
-.v-align-middle > .v-paintable {
- vertical-align: middle;
-}
-
-.v-align-bottom > .v-paintable {
- vertical-align: bottom;
-}
-
-.v-align-center {
- text-align: center;
-}
-
-.v-align-center > .v-paintable {
- margin-left: auto;
- margin-right: auto;
-}
-
-.v-align-right {
- text-align: right;
-}
-
-.v-align-right > .v-paintable {
- margin-left: auto;
-}
-
-.v-has-caption {
- display: inline-block;
-}
-
-.v-caption {
- overflow: visible;
- vertical-align: middle;
-}
-
-.v-caption-on-left,
-.v-caption-on-right {
- white-space: nowrap;
-}
-
-.v-caption-on-left > .v-caption,
-.v-caption-on-right > .v-caption {
- display: inline-block;
-}
-
-.v-caption-on-left > .v-caption {
- padding-right: .5em;
-}
-
-.v-caption-on-right > .v-caption {
- padding-left: .5em;
-}
-
-.v-caption-on-left > .v-paintable,
-.v-caption-on-right > .v-paintable {
- display: inline-block;
- vertical-align: middle;
- /* TODO this is a bit tricky, since it will override component defaults in some cases */
- white-space: normal;
-}
-
-.v-has-caption.v-has-width > .v-paintable {
- width: 100% !important;
+.v-boxlayout.test {
+ border: 1px solid #ddd;
}
-.v-has-caption.v-has-height > .v-paintable {
- height: 100% !important;
+.v-boxlayout.test .target {
+ outline: 2px dashed blue;
} \ No newline at end of file
diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java
index 0cebb72da7..b9b6798240 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java
@@ -111,6 +111,7 @@ public abstract class AbstractBoxLayoutConnector extends
icon != null ? icon.getURL() : null, connector.getState()
.getStyles());
// Description is handled from somewhere else?
+ // TODO handle error indication
}
@Override
@@ -163,6 +164,8 @@ public abstract class AbstractBoxLayoutConnector extends
super.onStateChanged(stateChangeEvent);
getWidget().setMargin(new VMarginInfo(getState().getMarginsBitmask()));
getWidget().setSpacing(getState().isSpacing());
+
+ // If height is set to undefined we need to run this
getWidget().recalculateLayoutHeight();
}
@@ -177,6 +180,8 @@ public abstract class AbstractBoxLayoutConnector extends
}
public void onElementResize(ElementResizeEvent e) {
+ // The following needs to be run every time a child components size
+ // changes
getWidget().recalculateUsedSpace();
getWidget().recalculateLayoutHeight();
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VBoxLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VBoxLayout.java
index 1413c1c8bd..266cc6e87e 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VBoxLayout.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VBoxLayout.java
@@ -13,10 +13,10 @@ import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.terminal.gwt.client.VConsole;
public class VBoxLayout extends FlowPanel {
@@ -27,13 +27,12 @@ public class VBoxLayout extends FlowPanel {
private Map<Widget, Slot> widgetToSlot = new HashMap<Widget, Slot>();
public VBoxLayout() {
- setStylePrimaryName("v-layout");
+ setStylePrimaryName("v-boxlayout");
setVertical(true);
}
public void setVertical(boolean isVertical) {
vertical = isVertical;
- addStyleName("v-box");
if (vertical) {
addStyleName("v-vertical");
removeStyleName("v-horizontal");
@@ -172,6 +171,8 @@ public class VBoxLayout extends FlowPanel {
if (spacer == null) {
return 0;
}
+ // TODO place for optimization (in expense of theme flexibility):
+ // only measure one of the elements and cache the value
if (vertical) {
return spacer.getOffsetHeight();
} else {
@@ -245,9 +246,14 @@ public class VBoxLayout extends FlowPanel {
}
// Styles
- caption.setClassName("v-caption");
- for (String style : styles) {
- caption.addClassName("v-caption-" + style);
+ if (caption != null) {
+ caption.setClassName("v-caption");
+
+ if (styles != null) {
+ for (String style : styles) {
+ caption.addClassName("v-caption-" + style);
+ }
+ }
}
// TODO add extra styles to captionWrap as well?
@@ -256,13 +262,20 @@ public class VBoxLayout extends FlowPanel {
}
+ @Override
+ public void onBrowserEvent(Event event) {
+ super.onBrowserEvent(event);
+ if (DOM.eventGetType(event) == Event.ONLOAD
+ && icon == DOM.eventGetTarget(event)) {
+ updateSize();
+ }
+ }
+
public void updateSize() {
if (caption == null) {
return;
}
- VConsole.log("####################### updateSize");
-
Style style = captionWrap.getStyle();
style.clearWidth();
@@ -413,7 +426,7 @@ public class VBoxLayout extends FlowPanel {
if (isExpanding) {
if (expandWrapper == null) {
expandWrapper = DOM.createDiv();
- expandWrapper.setClassName("v-box-expand");
+ expandWrapper.setClassName("v-expand");
for (; getElement().getChildCount() > 0;) {
Node el = getElement().getChild(0);
expandWrapper.appendChild(el);
@@ -428,6 +441,7 @@ public class VBoxLayout extends FlowPanel {
totalSize += vertical ? slot.getOffsetHeight() : slot
.getOffsetWidth();
}
+ // TODO fails in Opera, always returns 0
totalSize += slot.getSpacingSize(vertical);
}