mirror of
https://codeberg.org/scip/golsky.git
synced 2025-12-17 04:30:57 +01:00
added toolbar icon widget
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/ebitenui/ebitenui/image"
|
"github.com/ebitenui/ebitenui/image"
|
||||||
"github.com/ebitenui/ebitenui/widget"
|
"github.com/ebitenui/ebitenui/widget"
|
||||||
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewMenuButton(
|
func NewMenuButton(
|
||||||
@@ -40,6 +41,32 @@ func NewMenuButton(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewToolbarButton(
|
||||||
|
icon *ebiten.Image,
|
||||||
|
action func(args *widget.ButtonClickedEventArgs)) *widget.Container {
|
||||||
|
|
||||||
|
buttonImage, _ := LoadButtonImage()
|
||||||
|
|
||||||
|
iconContainer := widget.NewContainer(
|
||||||
|
widget.ContainerOpts.Layout(widget.NewStackedLayout()),
|
||||||
|
widget.ContainerOpts.WidgetOpts(widget.WidgetOpts.LayoutData(widget.AnchorLayoutData{
|
||||||
|
HorizontalPosition: widget.AnchorLayoutPositionCenter,
|
||||||
|
VerticalPosition: widget.AnchorLayoutPositionCenter,
|
||||||
|
})),
|
||||||
|
)
|
||||||
|
|
||||||
|
button := widget.NewButton(
|
||||||
|
widget.ButtonOpts.Image(buttonImage),
|
||||||
|
widget.ButtonOpts.ClickedHandler(action),
|
||||||
|
)
|
||||||
|
|
||||||
|
iconContainer.AddChild(button)
|
||||||
|
|
||||||
|
iconContainer.AddChild(widget.NewGraphic(widget.GraphicOpts.Image(icon)))
|
||||||
|
|
||||||
|
return iconContainer
|
||||||
|
}
|
||||||
|
|
||||||
func NewCheckbox(
|
func NewCheckbox(
|
||||||
text string,
|
text string,
|
||||||
initialvalue bool,
|
initialvalue bool,
|
||||||
|
|||||||
Reference in New Issue
Block a user