wanadev / PhotonUI

A javascript framework to create user interfaces
http://wanadev.github.io/PhotonUI/
BSD 3-Clause "New" or "Revised" License
63 stars 20 forks source link

Expander strange behavior when inside a Window #82

Closed MangelMaxime closed 2 months ago

MangelMaxime commented 7 years ago

I took the same code as from Photonui expander's doc and put it inside a window.

The behavior is strange because the expander are not stacked together and split the space at 33% each.

screenshot from 2016-11-20 21-53-58

Here is my code:

JavaScript:

var photonui = require('photonui');

var win = new photonui.Window({
    visible: true,
    fullscreen: true,
    closeButtonVisible: false,
    child: new photonui.BoxLayout({
        orientation: "horizontal",
        children: [
            new photonui.BoxLayout({
                horizontalPadding: 10,
                verticalPadding: 10,
                spacing: 10,

                children: [
                    new photonui.Expander({
                        title: "Expander 1",
                        child: new photonui.Label({
                            text: "Never gonna..."
                        })
                    }),
                    new photonui.Expander({
                        title: "Expander 2",
                        folded: true,
                        child: new photonui.Label({
                            text: "... give you..."
                        })

                    }),
                    new photonui.Expander({
                        title: "Expander 3",
                        folded: true,
                        child: new photonui.Label({
                            text: "... up!"
                        })
                    })
                ]
            })
        ]
    })
});

My CSS: (should not interfere)

html, body {
    margin: 0;
    width: 100%;
    height: 100%;
}

Possible solutions:

Here are the css rules that I find controlling this behavior:

I just give this possible solutions like that but I didn't think about their usage.

Breush commented 7 years ago

Can you try adding stretchToParentHeight: false to the BoxLayout's options that is holding the expanders?

I'm pretty sure the behavior you are experimenting is related to BoxLayout and not Expanders.

MangelMaxime commented 7 years ago

Adding stretchToParentHeight: false does nothing.

And you are probably reason about the behavior being related to BoxLayout because I tried to use BoxLayout to structure my app and I gave the same behavior whenever the BoxLayout is going taller.

MangelMaxime commented 7 years ago

Just to complete, if we replace the Expander by Menu + SubMenuItem the behavior is correct.

Breush commented 7 years ago

Well, I just noticed that you have two BoxLayouts. Set stretchToParentHeight: false to both (or just the outermost one), and it should fix the issue.

You also might not need the horizontal box, or should use a GridLayout if you have a complex UI to design.

MangelMaxime commented 7 years ago

Ok so I needed to put stretchToParentHeight: false on the outermost BoxLayout.

And yes, should probably try to use the GridLayout but I am not sure if this would make cleaner or not the GUI. Nevermind, thanks for your help @Breush

I let you close this issue if you think that the current behavior is OK.