2020-05-10 15:16:18 +00:00
|
|
|
package tins2020
|
|
|
|
|
2020-05-17 08:56:56 +00:00
|
|
|
import (
|
|
|
|
"opslag.de/schobers/zntg/ui"
|
|
|
|
)
|
|
|
|
|
|
|
|
// import "github.com/veandco/go-sdl2/sdl"
|
2020-05-10 15:16:18 +00:00
|
|
|
|
|
|
|
type ButtonBar struct {
|
2020-05-17 19:15:44 +00:00
|
|
|
ui.StackPanel
|
2020-05-10 15:16:18 +00:00
|
|
|
|
2020-05-17 08:56:56 +00:00
|
|
|
ButtonLength float32
|
2020-05-10 15:16:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const buttonBarWidth = 96
|
|
|
|
|
2020-05-17 08:56:56 +00:00
|
|
|
// func (b *ButtonBar) Init(ctx ui.Context) error {
|
|
|
|
// for i := range b.Buttons {
|
|
|
|
// b.AddChild(b.Buttons[i])
|
|
|
|
// }
|
|
|
|
// return b.Container.Init(ctx)
|
|
|
|
// }
|
2020-05-10 15:16:18 +00:00
|
|
|
|
2020-05-17 08:56:56 +00:00
|
|
|
// 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
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
2020-05-10 15:16:18 +00:00
|
|
|
|
2020-05-17 08:56:56 +00:00
|
|
|
// func (b *ButtonBar) Render(ctx ui.Context) {
|
|
|
|
// SetDrawColor(ctx.Renderer, b.Background)
|
|
|
|
// ctx.Renderer.FillRect(b.Bounds.SDLPtr())
|
|
|
|
// b.Container.Render(ctx)
|
|
|
|
// }
|
2020-05-10 15:16:18 +00:00
|
|
|
|
2020-05-17 08:56:56 +00:00
|
|
|
// type Orientation int
|
2020-05-10 15:16:18 +00:00
|
|
|
|
2020-05-17 08:56:56 +00:00
|
|
|
// const (
|
|
|
|
// OrientationVertical Orientation = iota
|
|
|
|
// OrientationHorizontal
|
|
|
|
// )
|