Browse Source

Merged master and fixed a couple of issues in boxlayout

tags/7.0.0.beta1
Jouni Koivuviita 12 years ago
parent
commit
76a8403b7e

+ 20
- 17
src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java View File



@Override @Override
public void init() { public void init() {
super.init();
rpc = RpcProxy.create(AbstractOrderedLayoutServerRpc.class, this); rpc = RpcProxy.create(AbstractOrderedLayoutServerRpc.class, this);
getWidget().setLayoutManager(getLayoutManager()); getWidget().setLayoutManager(getLayoutManager());
} }
/** /**
* For bookkeeping. Used in extra calculations for horizontal layout. * For bookkeeping. Used in extra calculations for horizontal layout.
*/ */
private HashMap<Element, Integer> childElementHeight = new HashMap<Element, Integer>();
// private HashMap<Element, Integer> childElementHeight = new
// HashMap<Element, Integer>();


/** /**
* For bookkeeping. Used in extra calculations for horizontal layout. * For bookkeeping. Used in extra calculations for horizontal layout.
hasRelativeHeight.remove(child); hasRelativeHeight.remove(child);
hasExpandRatio.remove(child); hasExpandRatio.remove(child);
needsMeasure.remove(child.getWidget().getElement()); needsMeasure.remove(child.getWidget().getElement());
childElementHeight.remove(child.getWidget().getElement());
// childElementHeight.remove(child.getWidget().getElement());
childCaptionElementHeight childCaptionElementHeight
.remove(child.getWidget().getElement()); .remove(child.getWidget().getElement());
getLayoutManager().removeElementResizeListener( getLayoutManager().removeElementResizeListener(
hasExpandRatio.add(child); hasExpandRatio.add(child);
} }


if (child.getState().isRelativeHeight()) {
hasRelativeHeight.add(child);
} else {
needsMeasure.add(child.getWidget().getElement());
}
// if (child.getState().isRelativeHeight()) {
// hasRelativeHeight.add(child);
// } else {
// needsMeasure.add(child.getWidget().getElement());
// }
} }


updateAllSlotListeners(); updateAllSlotListeners();
// } // }


updateSlotListeners(child); updateSlotListeners(child);
// updateAllSlotListeners();

updateLayoutHeight();
} }
}; };




private ElementResizeListener childComponentResizeListener = new ElementResizeListener() { private ElementResizeListener childComponentResizeListener = new ElementResizeListener() {
public void onElementResize(ElementResizeEvent e) { public void onElementResize(ElementResizeEvent e) {
int h = getLayoutManager().getOuterHeight(e.getElement());
childElementHeight.put((Element) e.getElement().cast(), h);
// int h = getLayoutManager().getOuterHeight(e.getElement());
// childElementHeight.put((Element) e.getElement().cast(), h);
updateLayoutHeight(); updateLayoutHeight();


if (needsExpand()) { if (needsExpand()) {
}; };


private void updateLayoutHeight() { private void updateLayoutHeight() {
if (needsFixedHeight() && childElementHeight.size() > 0) {
if (needsFixedHeight()) {
int h = getMaxHeight(); int h = getMaxHeight();
h += getLayoutManager().getBorderHeight(getWidget().getElement()) h += getLayoutManager().getBorderHeight(getWidget().getElement())
+ getLayoutManager().getPaddingHeight( + getLayoutManager().getPaddingHeight(
} }


private int getMaxHeight() { private int getMaxHeight() {
// TODO should use layout manager instead of inner lists of element
// sizes
int highestNonRelative = -1; int highestNonRelative = -1;
int highestRelative = -1; int highestRelative = -1;
// System.out.println("Child sizes: "
// + childElementHeight.values().toString());
for (Element el : childElementHeight.keySet()) {

for (ComponentConnector child : getChildComponents()) {
// TODO would be more efficient to measure the slot element if both // TODO would be more efficient to measure the slot element if both
// caption and child widget elements need to be measured. Keeping // caption and child widget elements need to be measured. Keeping
// track of what to measure is the most difficult part of this // track of what to measure is the most difficult part of this
// layout. // layout.
Element el = child.getWidget().getElement();
CaptionPosition pos = getWidget().getCaptionPositionFromElement( CaptionPosition pos = getWidget().getCaptionPositionFromElement(
(Element) el.getParentElement().cast()); (Element) el.getParentElement().cast());
if (needsMeasure.contains(el)) { if (needsMeasure.contains(el)) {
int h = childElementHeight.get(el);
int h = getLayoutManager().getOuterHeight(el);
String sHeight = el.getStyle().getHeight(); String sHeight = el.getStyle().getHeight();
// Only add the caption size to the height of the slot if // Only add the caption size to the height of the slot if
// coption position is top or bottom // coption position is top or bottom
highestNonRelative = h; highestNonRelative = h;
} }
} else { } else {
int h = childElementHeight.get(el);
int h = getLayoutManager().getOuterHeight(el);
if (childCaptionElementHeight.containsKey(el) if (childCaptionElementHeight.containsKey(el)
&& (pos == CaptionPosition.TOP || pos == CaptionPosition.BOTTOM)) { && (pos == CaptionPosition.TOP || pos == CaptionPosition.BOTTOM)) {
h += childCaptionElementHeight.get(el); h += childCaptionElementHeight.get(el);

+ 2
- 2
src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java View File



getConnection().getVTooltip().connectHandlersToWidget(getWidget()); getConnection().getVTooltip().connectHandlersToWidget(getWidget());


// Set v-connector style names for the widget
getWidget().setStyleName("v-connector", true);
// Set the core 'v' style name for the widget
getWidget().setStyleName("v", true);
} }


/** /**

+ 3
- 1
src/com/vaadin/terminal/gwt/client/ui/VBoxLayout.java View File



public class VBoxLayout extends FlowPanel { public class VBoxLayout extends FlowPanel {


public static final String CLASSNAME = "v-boxlayout";

private static final String ALIGN_CLASS_PREFIX = "v-align-"; private static final String ALIGN_CLASS_PREFIX = "v-align-";


protected boolean spacing = false; protected boolean spacing = false;
private LayoutManager layoutManager; private LayoutManager layoutManager;


public VBoxLayout() { public VBoxLayout() {
setStylePrimaryName("v-boxlayout");
setStyleName(CLASSNAME);
setVertical(true); setVertical(true);
} }



+ 1
- 4
src/com/vaadin/terminal/gwt/client/ui/orderedlayout/HorizontalLayoutConnector.java View File

*/ */
package com.vaadin.terminal.gwt.client.ui.orderedlayout; package com.vaadin.terminal.gwt.client.ui.orderedlayout;


import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.Connect.LoadStyle;
import com.vaadin.ui.HorizontalLayout;


@Connect(value = HorizontalLayout.class, loadStyle = LoadStyle.EAGER)
//@Connect(value = HorizontalLayout.class, loadStyle = LoadStyle.EAGER)
public class HorizontalLayoutConnector extends AbstractOrderedLayoutConnector { public class HorizontalLayoutConnector extends AbstractOrderedLayoutConnector {


@Override @Override

+ 1
- 4
src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VerticalLayoutConnector.java View File

*/ */
package com.vaadin.terminal.gwt.client.ui.orderedlayout; package com.vaadin.terminal.gwt.client.ui.orderedlayout;


import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.Connect.LoadStyle;
import com.vaadin.ui.VerticalLayout;


@Connect(value = VerticalLayout.class, loadStyle = LoadStyle.EAGER)
//@Connect(value = VerticalLayout.class, loadStyle = LoadStyle.EAGER)
public class VerticalLayoutConnector extends AbstractOrderedLayoutConnector { public class VerticalLayoutConnector extends AbstractOrderedLayoutConnector {


@Override @Override

+ 1
- 1
tests/testbench/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java View File

// view.addComponent(createTestLayout(false)); // view.addComponent(createTestLayout(false));
// view.setExpandRatio(view.getComponent(1), 1); // view.setExpandRatio(view.getComponent(1), 1);


for (int i = 0; i < 200; i++) {
for (int i = 0; i < 20; i++) {
view.addComponent(createHorizontalTest()); view.addComponent(createHorizontalTest());
} }



Loading…
Cancel
Save