Monday, September 20, 2010

Re: DockLayoutPanel and LazyPanel

Thank you, Thomas.

I finally had a chance to attempt your solution, but it did not
resolve the issue for me. :( Here's the class I created:


public abstract class ResizingLazyPanel extends LazyPanel implements
RequiresResize, ProvidesResize {

@Override
abstract protected Widget createWidget();

public void onResize() {
Widget widget = getWidget();
if (widget instanceof RequiresResize) {
((RequiresResize) widget).onResize();
}
}

}


But when I attempt to create an instance of DocLayoutPanel in the
CreateWidget method, I still don't see the center and south widgets.

I also had to get rid of the DeckPanel and implement my own deck
functionality using a LayoutPanel, which seems to work fine. Except...

When I attempt to implement the sliding animation similar to the
Bikeshed Expenses sample, the panels slide too far to the left every
time. I've tried a variety of ways to compensate, but none seem to
work. If I just do an add/remove to flip between panels, they appear
in the correct locations.

Any ideas on this one?

Here's my sliding animation method:


private void showWidget(final Widget widget, boolean fromLeft) {
// Early out if the widget is already in the layout panel.
final Widget current = layoutPanel.getWidget(0);
if (current == widget) {
return;
}

// Initialize the layout.
layoutPanel.add(widget);

layoutPanel.setWidgetLeftWidth(current, 0, Unit.PCT, 100,
Unit.PCT);
if (fromLeft) {
layoutPanel.setWidgetLeftWidth(widget, -100, Unit.PCT, 100,
Unit.PCT);
} else {
layoutPanel.setWidgetLeftWidth(widget, 100, Unit.PCT, 100,
Unit.PCT);
}
layoutPanel.forceLayout();

// Slide into view.
if (fromLeft) {
layoutPanel.setWidgetLeftWidth(current, 100, Unit.PCT, 100,
Unit.PCT);
} else {
layoutPanel.setWidgetLeftWidth(current, -100, Unit.PCT, 100,
Unit.PCT);
}
layoutPanel.setWidgetLeftWidth(widget, 0, Unit.PCT, 100,
Unit.PCT);

layoutPanel.animate(1000, new Layout.AnimationCallback() {
public void onAnimationComplete() {
// Remove the old widget when the animation completes.
layoutPanel.remove(current);
}
public void onLayout(Layer layer, double progress) { }
});
}

This is a method on a class that extends Composite and the top element
in the ui.xml is a DockLayoutPanel and the layoutPanel variable in the
method above refers to the center of the DocLayoutPanel:


<g:center>
<g:LayoutPanel ui:field='layoutPanel'>
<g:layer>
<cust:CustomerList ui:field='customerList' />
</g:layer>
</g:LayoutPanel>
</g:center>


Any ideas? It's really confounding me.

Thanks
~Jason

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment