ui/uiwidget/widgetborder.go
2024-04-03 16:07:24 +02:00

23 lines
606 B
Go

package uiwidget
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
)
// NewWidgetBorder creates a new widget border for the given fyne.CanvasObject.
// It does so by wrapping the object in a Stack layout with a border drawn
// above the widget.
func NewWidgetBorder(widget fyne.CanvasObject) fyne.CanvasObject {
b := canvas.NewRectangle(color.Transparent)
b.StrokeColor = theme.InputBorderColor()
b.StrokeWidth = theme.InputBorderSize()
b.CornerRadius = theme.InputRadiusSize()
l := container.NewStack(widget, b)
return l
}