开发者

StackLayoutPanel has no more place to show the children when there are too many headers ... how I can fix this?

StackLayoutPanel has no more place to show the children when there are too many headers ... how I can fix this?

My structure is of my program is

DockLayoutPanel: East, Wets, Center ----> ScrollPanel ----> StackLayoutPanel

In the middle I have a StackLayoutPanel, the issue is when i put headers in the stack Many 开发者_开发知识库Have No place to open and scroll Does Not updated their size to the son of the header That Opened if it has space and is out of range.

Would know how he could do for the center can always be with a scrollpanel even a son of stacklayoutpanel open? because as I said, if I put a lot in my StacklayoutPanel Headers has no place for you to open and as much as I wrap it in a scrollpanel to StackLayoutPanel does space to resize the scroll that contains it.

Greetings Jero.


You'll have to explicitly change the size of your StackLayoutPanel. You have to calculate this size yourself.

If each header is 40 pixels high, for example, and you want the displayed child (son) to have 200 pixels to display, you could call stackLayoutPanel.setHeight((40*numChildren + 200)+"px");

If you want it to take up all of the available space before scrolling, you'll have to get fancier in your calculations, but it's a flexible plan!


Luckily I could fix it .. the issue had to do the following.

1) The stay architectures as follows:

DockLayoutPanel -> ScrollPanel -> VerticalPanel ---> CustomStackLayoutPanel.

(Use Basic layout to be compatible with VerticalPanel ScrollPanel since LayoutPanel ScrollPanel and do not seem compatible.)

2) The method: Animated (int) was so.

private boolean isSetFirstHeight = false;
private double totalHeightHeader = 0;

private void animate(int duration) {

    if (layoutData.size() == 0) {
        return;
    }

    double top = 0, bottom = 0;
    int i = 0;

    for (; i < layoutData.size(); ++i) {

        if (top != 0)
            top += padingWidget;

        LayoutData data = layoutData.get(i);
        layoutPanel.setWidgetTopHeight(data.header, top, unit, data.headerSize, unit);

        top += data.headerSize;

        layoutPanel.setWidgetTopHeight(data.widget, top, unit, 0, unit);
        //Seteamos la altura con los combos cerrados por única vez
        if (i + 1 == layoutData.size() && !isSetFirstHeight) {
            isSetFirstHeight = true;
            layoutPanel.setHeight(top + "px");
            totalHeightHeader = top;
        }

        if (i == selectedIndex) {
            break;
        }
    }

    // TODO: JC Es para que cuando comienze no este abierto
    if (selectedIndex == -1 && openFirstDefault) {
        selectedIndex = 0;
    } else if (selectedIndex == -1 && !openFirstDefault) {
        return;
    }

    for (int j = layoutData.size() - 1; j > selectedIndex; --j) {
        bottom += padingWidget;
        LayoutData data = layoutData.get(j);
        layoutPanel.setWidgetBottomHeight(data.header, bottom, unit, data.headerSize, unit);
        layoutPanel.setWidgetBottomHeight(data.widget, bottom, unit, 0, unit); // aca achica al componente hijo que
                                                                                // es el la variable "widget"
        bottom += data.headerSize;
    }

    this.layoutDataSelected = layoutData.get(selectedIndex);

    //Setea la altura del panel de combo calculando la altura del hijo también, lo hace por única vez
    if (spacingButtonWorkAround && layoutDataSelected != null) {
        spacingButtonWorkAround = false;
        //TODO: esto de ver que sea compatible para otros widget y no reviente si no es un CheckListWidget
        double heightChild = ((CheckListWidget)layoutDataSelected.getWidget()).getCantidadDeFilasOcupadas() * hightRowChildWidget;  
        double heightWithChild = totalHeightHeader + heightChild;
        layoutPanel.setHeight(heightWithChild + "px");
    }


    layoutPanel.setWidgetTopBottom(layoutDataSelected.widget, top, unit, bottom, unit);

    layoutPanel.animate(duration);

}

Object-Child, I ask the number of columns, and from that height seteandole data I want from the StackLayoutPanel, calculate the height that can have. The truth is that it is the best way to implement it but for now that menera. It would be good to do it in a more flexible but well .. for now is what you get!

Greetings! Jero.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜