PDA

View Full Version : Sliding CardLayout



seb2nim
13 Oct 2009, 3:35 AM
Hi,

I'm trying to extend or clone card layout in order to swap ards with a sliding animation.

Multiple problems :

Cannot slideIn and slideOut the two cards simulteneously.

First item isn't well sized (margins issue).

Did anyone already did it or can figure out whats wrong?

Thanks in advance.

Here is my code :


public class SlidingCardLayout extends FitLayout {

/**
* Creates a new card layout instance.
*/
public SlidingCardLayout() {
monitorResize = true;
renderHidden = true;
}

/**
* Returns the active component.
*
* @return the top widget
*/
public Component getActiveItem() {
return activeItem;
}

/**
* Sets the active (visible) item in the layout.
*
* @param component
* the active component
*/
public void setActiveItem(Component component, boolean animate) {
if (activeItem == component) {
return;
}
int activeIdx = container.indexOf(activeItem);
int componentIdx = container.indexOf(component);

Direction dir = activeIdx<componentIdx?Direction.LEFT:Direction.RIGHT;

if (activeItem != null) {
//activeItem.el().slideOut(dir, FxConfig.NONE);
activeItem.hide();
}
activeItem = component;
if (activeItem != null) {
activeItem.show();
// deferred rendering
if (!activeItem.isRendered() || ((activeItem instanceof Container) && isLayoutNeeded((Container<?>) activeItem))) {
setLayoutNeeded(container, true);
}
layoutContainer();
if(animate){
activeItem.el().slideIn(dir, FxConfig.NONE);
}
}
}



}

seb2nim
15 Oct 2009, 8:01 AM
"Margin" problem is not : it's linked to an issue on effects not completing properly i saw elsewhere