Justify settings entries
This commit is contained in:
@@ -161,12 +161,19 @@ func (p *Settings) Init(ctx *PageCtx) error {
|
|||||||
p.title.Y = p.ScreenHeight - p.title.H - p.verticalMargin*2
|
p.title.Y = p.ScreenHeight - p.title.H - p.verticalMargin*2
|
||||||
|
|
||||||
// Position prompt above title
|
// Position prompt above title
|
||||||
p.prompt.X = p.ScreenCenterX - p.prompt.W/2
|
p.prompt.X = p.ScreenCenterX - int32(float32(p.prompt.W)/2)
|
||||||
p.prompt.Y = p.title.Y - p.verticalMargin*2 - p.prompt.H
|
p.prompt.Y = p.title.Y - p.verticalMargin*2 - p.prompt.H
|
||||||
|
|
||||||
|
// If this value starts at 0, nothing is further left than that...
|
||||||
|
var furthestLeft int32 = p.ScreenWidth // < more to the left, > more to the right, = same
|
||||||
|
|
||||||
// Position options stacked upward from prompt
|
// Position options stacked upward from prompt
|
||||||
for i, option := range p.options {
|
for i, option := range p.options {
|
||||||
p.options[i].label.X = p.ScreenCenterX - option.label.W/2
|
p.options[i].label.X = p.ScreenCenterX - option.label.W/2 // Calculate horizontal center posision
|
||||||
|
if p.options[i].label.X < furthestLeft { // If the left most pixel is further left than furthestLeft, indicating a longer line:
|
||||||
|
// Then update furthestLeft
|
||||||
|
furthestLeft = p.options[i].label.X
|
||||||
|
}
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
p.options[i].label.Y = int32(float32(p.prompt.Y)-(float32(p.verticalMargin)*4)) - option.label.H
|
p.options[i].label.Y = int32(float32(p.prompt.Y)-(float32(p.verticalMargin)*4)) - option.label.H
|
||||||
} else {
|
} else {
|
||||||
@@ -174,6 +181,11 @@ func (p *Settings) Init(ctx *PageCtx) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now, re-iterate over the options and justify everything to furthestLeft
|
||||||
|
for i := range p.options {
|
||||||
|
p.options[i].label.X = furthestLeft
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user