package layouts

import (
	"image"

	"gioui.org/layout"
)

// FixedMinSize returns a wrapper widget around the provided widget with a fixed minimum constraint.
func FixedMinSize(w layout.Widget, width, height int) layout.Widget {
	return func(gtx layout.Context) layout.Dimensions {
		gtx.Constraints.Min = image.Pt(width, height)
		return w(gtx)
	}
}

// FixedMaxSize returns a wrapper widget around the provided widget with a fixed maximum constraint.
func FixedMaxSize(w layout.Widget, width, height int) layout.Widget {
	return func(gtx layout.Context) layout.Dimensions {
		gtx.Constraints.Max = image.Pt(width, height)
		return w(gtx)
	}
}

// FixedSize returns a wrapper widget around the provided widget with a fixed constraint.
func FixedSize(w layout.Widget, width, height int) layout.Widget {
	return func(gtx layout.Context) layout.Dimensions {
		gtx.Constraints.Min = image.Pt(width, height)
		gtx.Constraints.Min = image.Pt(width, height)
		return w(gtx)
	}
}
