-
Is there a layout that can be achieved? If not, what should I do? |
Beta Was this translation helpful? Give feedback.
Answered by
AllenDang
Jul 15, 2022
Replies: 2 comments 6 replies
-
You will have to use DummyWidget as the spacer, calcuate the width and height for it's size using |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
Seikaijyu
-
Totally Centered Button (leaving as a note to myself)package main
import "github.com/AllenDang/giu"
const buttonW, buttonH = 200, 80
func loop() {
giu.SingleWindow().Layout(
giu.Custom(func() {
availableW, availableH := giu.GetAvailableRegion()
itemSpacingX, itemSpacingY := giu.GetItemSpacing()
giu.Layout{
giu.Dummy(0, max(availableH/2-buttonH/2-itemSpacingY, 0)),
giu.Row(
giu.Dummy(max(availableW/2-buttonW/2-itemSpacingX, 0), 0),
giu.Button("I'm a totally centered button").Size(buttonW, buttonH),
),
// Center Horizontally (experimental!) alternative
//giu.Align(giu.AlignCenter).To(giu.Button("I'm a totally centered button").Size(buttonW, buttonH)),
}.Build()
}),
)
}
func main() {
wnd := giu.NewMasterWindow("Vertical+Horizontal align [discussion #529]", 640, 480, 0)
wnd.Run(loop)
} Also would be interesting to know - how safe is |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You will have to use DummyWidget as the spacer, calcuate the width and height for it's size using
g.GetAvailableRegion()
.Try set -1 to width and height and you will see what does it mean.