Add FillWidth and FillHeight enclosures.
This commit is contained in:
parent
cf56e8c47e
commit
dfc3f618c0
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@ cmd/cal/cal
|
||||||
cmd/scroll/scroll
|
cmd/scroll/scroll
|
||||||
cmd/grid/grid
|
cmd/grid/grid
|
||||||
*.apk
|
*.apk
|
||||||
|
memprofile*
|
||||||
|
|
|
@ -20,7 +20,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
sel int32
|
|
||||||
face text.Face
|
face text.Face
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
24
main.go
24
main.go
|
@ -204,6 +204,7 @@ type List = WidgetCombinator
|
||||||
type AxisOpt struct{ axis layout.Axis }
|
type AxisOpt struct{ axis layout.Axis }
|
||||||
|
|
||||||
func Axis(x layout.Axis) AxisOpt { return AxisOpt{x} }
|
func Axis(x layout.Axis) AxisOpt { return AxisOpt{x} }
|
||||||
|
|
||||||
var Horizontal = AxisOpt{layout.Horizontal}
|
var Horizontal = AxisOpt{layout.Horizontal}
|
||||||
var Vertical = AxisOpt{layout.Vertical}
|
var Vertical = AxisOpt{layout.Vertical}
|
||||||
|
|
||||||
|
@ -510,6 +511,29 @@ func Rrect(ops *ui.Ops, width, height, se, sw, nw, ne float32) {
|
||||||
Mallocs("Rrect() end")
|
Mallocs("Rrect() end")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type fillWidget struct {
|
||||||
|
axis layout.Axis
|
||||||
|
}
|
||||||
|
|
||||||
|
func FillWidth(ws ...Widget) Widget {
|
||||||
|
return Enclose(fillWidget{layout.Horizontal}, ws...)
|
||||||
|
}
|
||||||
|
func FillHeight(ws ...Widget) Widget {
|
||||||
|
return Enclose(fillWidget{layout.Vertical}, ws...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fw fillWidget) Begin(ctx *Context) {
|
||||||
|
switch fw.axis {
|
||||||
|
case layout.Horizontal:
|
||||||
|
ctx.cs.Width.Min = ctx.cs.Width.Max
|
||||||
|
case layout.Vertical:
|
||||||
|
ctx.cs.Height.Min = ctx.cs.Height.Max
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fw fillWidget) End(*Context) {
|
||||||
|
}
|
||||||
|
|
||||||
type Clickable interface {
|
type Clickable interface {
|
||||||
Widget
|
Widget
|
||||||
Clicked(*Context) bool
|
Clicked(*Context) bool
|
||||||
|
|
Loading…
Reference in New Issue
Block a user