~pierrec/giox

ae28ab333001df8215da95e718b3cb49e41a8b9f — pierre 9 months ago 705a4bf
added wihtin function

Signed-off-by: pierre <pierre.curto@gmail.com>
1 files changed, 5 insertions(+), 2 deletions(-)

M widgetx/file.go
M widgetx/file.go => widgetx/file.go +5 -2
@@ 252,8 252,7 @@ func (a fileArea) Layout(gtx layout.Context, w, status layout.Widget) layout.Dim
				}
				// Scale the icon size based on the background size.
				sz := gtx.Constraints.Max.Y / 4
				sz = max(sz, 60)
				sz = min(sz, 120)
				sz = within(sz, 60, 120)
				// Min constraints used by Center, we want it centered on the whole available space
				// so set Min to Max.
				gtx.Constraints.Min = gtx.Constraints.Max


@@ 1635,3 1634,7 @@ func min(a, b int) int {
	}
	return b
}

func within(x, a, b int) int {
	return min(max(x, a), b)
}