Add Empty method to widgets
This commit is contained in:
parent
ffdef73ac8
commit
cba07aae64
4 changed files with 25 additions and 6 deletions
8
box.go
8
box.go
|
@ -115,4 +115,12 @@ func (b *Box) AddChild(w ...Widget) {
|
|||
b.children = append(b.children, w...)
|
||||
}
|
||||
|
||||
// Empty removes all children from the widget.
|
||||
func (b *Box) Empty() {
|
||||
b.Lock()
|
||||
defer b.Unlock()
|
||||
|
||||
b.children = b.children[:0]
|
||||
}
|
||||
|
||||
var _ Widget = &Box{}
|
||||
|
|
4
go.mod
4
go.mod
|
@ -3,7 +3,7 @@ module code.rocket9labs.com/tslocum/etk
|
|||
go 1.18
|
||||
|
||||
require (
|
||||
code.rocketnine.space/tslocum/messeji v1.0.6-0.20231108225635-7a691903039e
|
||||
code.rocketnine.space/tslocum/messeji v1.0.6-0.20231118073151-fee1357e1e9b
|
||||
github.com/hajimehoshi/ebiten/v2 v2.6.2
|
||||
github.com/llgcode/draw2d v0.0.0-20231022063514-1acb54133d2a
|
||||
golang.org/x/image v0.14.0
|
||||
|
@ -13,7 +13,7 @@ require (
|
|||
github.com/ebitengine/purego v0.5.0 // indirect
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
||||
github.com/jezek/xgb v1.1.0 // indirect
|
||||
golang.org/x/exp/shiny v0.0.0-20231108232855-2478ac86f678 // indirect
|
||||
golang.org/x/exp/shiny v0.0.0-20231110203233-9a3e6036ecaa // indirect
|
||||
golang.org/x/mobile v0.0.0-20231108233038-35478a0c49da // indirect
|
||||
golang.org/x/sync v0.5.0 // indirect
|
||||
golang.org/x/sys v0.14.0 // indirect
|
||||
|
|
8
go.sum
8
go.sum
|
@ -1,5 +1,5 @@
|
|||
code.rocketnine.space/tslocum/messeji v1.0.6-0.20231108225635-7a691903039e h1:8NByMX1dSs69cmfzHbudEfU9qmcMNl3V2+/RnyLaxm4=
|
||||
code.rocketnine.space/tslocum/messeji v1.0.6-0.20231108225635-7a691903039e/go.mod h1:DVSVJUFs9QkKxnGOhk6RSM1q6XcYsMOHqdsLVA7sotQ=
|
||||
code.rocketnine.space/tslocum/messeji v1.0.6-0.20231118073151-fee1357e1e9b h1:NyI5ZC016QW3k4itXcsBvpkO6b55+PrwOazq2vzOaVM=
|
||||
code.rocketnine.space/tslocum/messeji v1.0.6-0.20231118073151-fee1357e1e9b/go.mod h1:9hzkp+tOkEjCWqOwS1FfAwbbyZtndk6H1ZvhGq4aD6Q=
|
||||
github.com/ebitengine/purego v0.5.0 h1:JrMGKfRIAM4/QVKaesIIT7m/UVjTj5GYhRSQYwfVdpo=
|
||||
github.com/ebitengine/purego v0.5.0/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||
|
@ -12,8 +12,8 @@ github.com/jezek/xgb v1.1.0/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFl
|
|||
github.com/llgcode/draw2d v0.0.0-20231022063514-1acb54133d2a h1:aP1ySrs3EYBaKOF+1hEUbIMNjT8FZlGGbB73cRAukZw=
|
||||
github.com/llgcode/draw2d v0.0.0-20231022063514-1acb54133d2a/go.mod h1:zNlGqkQNLxAN7D2uihSJsrEzrkWrSIK5kmSZU/dN5NY=
|
||||
github.com/llgcode/ps v0.0.0-20150911083025-f1443b32eedb h1:61ndUreYSlWFeCY44JxDDkngVoI7/1MVhEl98Nm0KOk=
|
||||
golang.org/x/exp/shiny v0.0.0-20231108232855-2478ac86f678 h1:nDuntdpRJsxpHuFwQ/TTrOkfIwx+TEDnolEyUNVL/60=
|
||||
golang.org/x/exp/shiny v0.0.0-20231108232855-2478ac86f678/go.mod h1:UH99kUObWAZkDnWqppdQe5ZhPYESUw8I0zVV1uWBR+0=
|
||||
golang.org/x/exp/shiny v0.0.0-20231110203233-9a3e6036ecaa h1:9AiXA/XkU9MpMQpJQ71TkQDEnWbOdpZfbQkqR+GsseU=
|
||||
golang.org/x/exp/shiny v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:UH99kUObWAZkDnWqppdQe5ZhPYESUw8I0zVV1uWBR+0=
|
||||
golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4=
|
||||
golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
|
||||
golang.org/x/mobile v0.0.0-20231108233038-35478a0c49da h1:gS9sVMAeHM+gVBmM9bTM6vUi/NHv58O3QzJ3vjjN84M=
|
||||
|
|
11
grid.go
11
grid.go
|
@ -101,6 +101,17 @@ func (g *Grid) AddChildAt(wgt Widget, x int, y int, columns int, rows int) {
|
|||
g.updated = true
|
||||
}
|
||||
|
||||
// Empty removes all children from the Grid.
|
||||
func (g *Grid) Empty() {
|
||||
g.Lock()
|
||||
defer g.Unlock()
|
||||
|
||||
g.children = g.children[:0]
|
||||
g.cellPositions = g.cellPositions[:0]
|
||||
g.cellSpans = g.cellSpans[:0]
|
||||
g.updated = true
|
||||
}
|
||||
|
||||
// HandleKeyboard is called when a keyboard event occurs.
|
||||
func (g *Grid) HandleKeyboard(ebiten.Key, rune) (handled bool, err error) {
|
||||
if g.updated {
|
||||
|
|
Loading…
Reference in a new issue