2
0

toolbar.go 885 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package components
  2. import (
  3. "image/color"
  4. "fyne.io/fyne/v2"
  5. "fyne.io/fyne/v2/container"
  6. "fyne.io/fyne/v2/widget"
  7. )
  8. // NewToolbarLabelButton - makes a toolbar button cell with label
  9. func NewToolbarLabelButton(label string, icon fyne.Resource, onclick func(), colour color.Color) widget.ToolbarItem {
  10. l := ColoredIconButton(label, icon, onclick, colour)
  11. l.MinSize()
  12. return &toolbarLabelButton{l}
  13. }
  14. // NewToolbarLabel - makes a toolbar text cell
  15. func NewToolbarLabel(label string) widget.ToolbarItem {
  16. l := widget.NewLabel(label)
  17. l.MinSize()
  18. return &toolbarLabel{l}
  19. }
  20. type toolbarLabelButton struct {
  21. *fyne.Container
  22. }
  23. type toolbarLabel struct {
  24. *widget.Label
  25. }
  26. func (t *toolbarLabelButton) ToolbarObject() fyne.CanvasObject {
  27. return container.NewCenter(t.Container)
  28. }
  29. func (t *toolbarLabel) ToolbarObject() fyne.CanvasObject {
  30. return container.NewCenter(t.Label)
  31. }