Add middle of sides to complete the pool of options
This commit is contained in:
parent
1964b0202b
commit
899918e85d
|
@ -23,7 +23,7 @@ func main() {
|
|||
button := widget.NewButton("X", func() {
|
||||
fmt.Println("button clicked")
|
||||
layout.FloatingControlsLocation = layout.FloatingControlsLocation + 1
|
||||
if layout.FloatingControlsLocation > 4 {
|
||||
if layout.FloatingControlsLocation > 8 {
|
||||
layout.FloatingControlsLocation = 0
|
||||
}
|
||||
w.SetContent(w.Content())
|
||||
|
|
|
@ -12,6 +12,10 @@ const (
|
|||
FloatingControlsBottomLeft
|
||||
FloatingControlsBottomRight
|
||||
FloatingControlsCenter
|
||||
FloatingControlsTopMiddle
|
||||
FloatingControlsRightMiddle
|
||||
FloatingControlsBottomMiddle
|
||||
FloatingControlsLeftMiddle
|
||||
)
|
||||
|
||||
type floatingControlsLayout struct {
|
||||
|
@ -45,14 +49,22 @@ func (d *floatingControlsLayout) Layout(objects []fyne.CanvasObject, containerSi
|
|||
switch d.FloatingControlsLocation {
|
||||
case FloatingControlsTopLeft:
|
||||
o.Move(fyne.NewPos(0, 0))
|
||||
case FloatingControlsTopMiddle:
|
||||
o.Move(fyne.NewPos((containerSize.Width/2)-(size.Width/2), 0))
|
||||
case FloatingControlsTopRight:
|
||||
o.Move(fyne.NewPos(containerSize.Width-size.Width, 0))
|
||||
case FloatingControlsBottomLeft:
|
||||
o.Move(fyne.NewPos(0, containerSize.Height-size.Height))
|
||||
case FloatingControlsBottomRight:
|
||||
o.Move(fyne.NewPos(containerSize.Width-size.Width, containerSize.Height-size.Height))
|
||||
case FloatingControlsBottomMiddle:
|
||||
o.Move(fyne.NewPos((containerSize.Width/2)-(size.Width/2), containerSize.Height-size.Height))
|
||||
case FloatingControlsCenter:
|
||||
o.Move(fyne.NewPos((containerSize.Width/2)-(size.Width/2), (containerSize.Height/2)-(size.Height/2)))
|
||||
case FloatingControlsLeftMiddle:
|
||||
o.Move(fyne.NewPos(0, (containerSize.Height/2)-(size.Height/2)))
|
||||
case FloatingControlsRightMiddle:
|
||||
o.Move(fyne.NewPos(containerSize.Width-size.Width, (containerSize.Height/2)-(size.Height/2)))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue