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

后端 未结 2 794
刺人心
刺人心 2021-01-28 10:41

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:

2条回答
  •  逝去的感伤
    2021-01-28 11:09

    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.

提交回复
热议问题