buggins / dlangui

Cross Platform GUI for D programming language
Boost Software License 1.0
805 stars 120 forks source link

How to align widget #637

Open FabArd opened 1 year ago

FabArd commented 1 year ago

Hi,

How to align the "send" button on the right side of the "MDI" groupbox ? All my attempts have been unsuccessful ! Thanks.

DmlEdit

GroupBox {
    text: "MDI"
    TextWidget {text: "Manual Command"}  
    EditLine {layoutWidth: 350}
    HorizontalLayout {
        Button {text: "Send"}
    }
}
GrimMaple commented 1 year ago

Hi! I would suggest creating an empty widget that takes all the extra space, eg:

GroupBox {
    maxWidth: 500px
    text: "MDI"
    TextWidget {text: "Manual Command"}
    EditLine {layoutWidth: 350}
    HorizontalLayout {
        VerticalLayout { layoutWidth: fill; minWidth: 10% }
        Button {text: "Send"}
    }
}

Note the extra "maxWidth" in the GroupBox. Without it, the widget becomes very long for some reason

FabArd commented 1 year ago

You have enabled me to find another solution :

GroupBox {
    text: "MDI"
    TextWidget {text: "Manual Command"}  
    EditLine {layoutWidth: 350}
    HorizontalLayout {
        HSpacer {layoutWidth: fill; minWidth: 350 }
        Button {text: "Send"}
    }
}
FabArd commented 1 year ago

I think the best solution is :

GroupBox {
    text: "MDI"
    TextWidget {text: "Manual Command"}  
    EditLine {layoutWidth: 350}
    HorizontalLayout {
        layoutWidth: fill
        HSpacer {layoutWidth: fill }
        Button {text: "Send"}
    }
}

This solution do not modify the "EditLine" dimension.