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() {
|
button := widget.NewButton("X", func() {
|
||||||
fmt.Println("button clicked")
|
fmt.Println("button clicked")
|
||||||
layout.FloatingControlsLocation = layout.FloatingControlsLocation + 1
|
layout.FloatingControlsLocation = layout.FloatingControlsLocation + 1
|
||||||
if layout.FloatingControlsLocation > 4 {
|
if layout.FloatingControlsLocation > 8 {
|
||||||
layout.FloatingControlsLocation = 0
|
layout.FloatingControlsLocation = 0
|
||||||
}
|
}
|
||||||
w.SetContent(w.Content())
|
w.SetContent(w.Content())
|
||||||
|
|
|
@ -12,6 +12,10 @@ const (
|
||||||
FloatingControlsBottomLeft
|
FloatingControlsBottomLeft
|
||||||
FloatingControlsBottomRight
|
FloatingControlsBottomRight
|
||||||
FloatingControlsCenter
|
FloatingControlsCenter
|
||||||
|
FloatingControlsTopMiddle
|
||||||
|
FloatingControlsRightMiddle
|
||||||
|
FloatingControlsBottomMiddle
|
||||||
|
FloatingControlsLeftMiddle
|
||||||
)
|
)
|
||||||
|
|
||||||
type floatingControlsLayout struct {
|
type floatingControlsLayout struct {
|
||||||
|
@ -45,14 +49,22 @@ func (d *floatingControlsLayout) Layout(objects []fyne.CanvasObject, containerSi
|
||||||
switch d.FloatingControlsLocation {
|
switch d.FloatingControlsLocation {
|
||||||
case FloatingControlsTopLeft:
|
case FloatingControlsTopLeft:
|
||||||
o.Move(fyne.NewPos(0, 0))
|
o.Move(fyne.NewPos(0, 0))
|
||||||
|
case FloatingControlsTopMiddle:
|
||||||
|
o.Move(fyne.NewPos((containerSize.Width/2)-(size.Width/2), 0))
|
||||||
case FloatingControlsTopRight:
|
case FloatingControlsTopRight:
|
||||||
o.Move(fyne.NewPos(containerSize.Width-size.Width, 0))
|
o.Move(fyne.NewPos(containerSize.Width-size.Width, 0))
|
||||||
case FloatingControlsBottomLeft:
|
case FloatingControlsBottomLeft:
|
||||||
o.Move(fyne.NewPos(0, containerSize.Height-size.Height))
|
o.Move(fyne.NewPos(0, containerSize.Height-size.Height))
|
||||||
case FloatingControlsBottomRight:
|
case FloatingControlsBottomRight:
|
||||||
o.Move(fyne.NewPos(containerSize.Width-size.Width, containerSize.Height-size.Height))
|
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:
|
case FloatingControlsCenter:
|
||||||
o.Move(fyne.NewPos((containerSize.Width/2)-(size.Width/2), (containerSize.Height/2)-(size.Height/2)))
|
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