Removed buttonbar (replaced by StackPanel).

This commit is contained in:
Sander Schobers 2020-05-23 09:13:33 +02:00
parent 6493b3165b
commit f065317c76
2 changed files with 6 additions and 65 deletions

View File

@ -1,60 +0,0 @@
package tins2020
import (
"opslag.de/schobers/zntg/ui"
)
// import "github.com/veandco/go-sdl2/sdl"
type ButtonBar struct {
ui.StackPanel
ButtonLength float32
}
const buttonBarWidth = 96
// func (b *ButtonBar) Init(ctx ui.Context) error {
// for i := range b.Buttons {
// b.AddChild(b.Buttons[i])
// }
// return b.Container.Init(ctx)
// }
// func (b *ButtonBar) Arrange(ctx ui.Context, bounds Rectangle) {
// b.Container.Arrange(ctx, bounds)
// length := b.ButtonLength
// switch b.Orientation {
// case OrientationHorizontal:
// if length == 0 {
// length = bounds.H
// }
// offset := bounds.X
// for i := range b.Buttons {
// b.Buttons[i].Arrange(ctx, Rect(offset, bounds.Y, length, bounds.H))
// offset += length
// }
// default:
// if length == 0 {
// length = bounds.W
// }
// offset := bounds.Y
// for i := range b.Buttons {
// b.Buttons[i].Arrange(ctx, Rect(bounds.X, offset, bounds.W, length))
// offset += length
// }
// }
// }
// func (b *ButtonBar) Render(ctx ui.Context) {
// SetDrawColor(ctx.Renderer, b.Background)
// ctx.Renderer.FillRect(b.Bounds.SDLPtr())
// b.Container.Render(ctx)
// }
// type Orientation int
// const (
// OrientationVertical Orientation = iota
// OrientationHorizontal
// )

View File

@ -15,10 +15,10 @@ type GameControls struct {
game *Game game *Game
dialogs *Dialogs dialogs *Dialogs
menu ButtonBar menu ui.StackPanel
top ButtonBar top ui.StackPanel
flowers ButtonBar flowers ui.StackPanel
otherTools ButtonBar otherTools ui.StackPanel
pause *IconButton pause *IconButton
run *IconButton run *IconButton
@ -43,7 +43,6 @@ func (c *GameControls) Init(ctx ui.Context) {
}) })
c.flowers.Background = zntg.MustHexColor("#356DAD") c.flowers.Background = zntg.MustHexColor("#356DAD")
c.flowers.ButtonLength = 64
for _, id := range c.game.Herbarium.Flowers() { for _, id := range c.game.Herbarium.Flowers() {
c.flowers.Children = append(c.flowers.Children, c.createBuyFlowerButton(id)) c.flowers.Children = append(c.flowers.Children, c.createBuyFlowerButton(id))
@ -165,6 +164,8 @@ func (c *GameControls) updateFlowerControls() {
} }
} }
const buttonBarWidth = 96
func (c *GameControls) Arrange(ctx ui.Context, bounds geom.RectangleF32, offset geom.PointF32, parent ui.Control) { func (c *GameControls) Arrange(ctx ui.Context, bounds geom.RectangleF32, offset geom.PointF32, parent ui.Control) {
c.ContainerBase.Arrange(ctx, bounds, offset, parent) c.ContainerBase.Arrange(ctx, bounds, offset, parent)