Begin adding widget constraints
This commit is contained in:
parent
c5339a9ae4
commit
4291bfb210
@ -95,8 +95,10 @@ func (l *ListWidget) Render() [][]Cell {
|
||||
}
|
||||
}
|
||||
|
||||
l.lastSize.X = sx
|
||||
l.lastSize.Y = sy
|
||||
l.size.X = sx
|
||||
l.size.Y = sy
|
||||
l.lastSize = l.size
|
||||
|
||||
return append([][]Cell(nil), l.cells...)
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ type Scene struct {
|
||||
}
|
||||
|
||||
func (s *Scene) Render() {
|
||||
s.Window.SetSize(s.Terminal.Size())
|
||||
// s.Window.SetSize(s.Terminal.Size())
|
||||
|
||||
c := make([]Cell, 0)
|
||||
|
||||
|
@ -41,11 +41,21 @@ func (w *WindowWidget) SetSize(s Size) {
|
||||
}
|
||||
|
||||
func (w *WindowWidget) Render() [][]Cell {
|
||||
if w.size.X == 0 || w.size.Y == 0 {
|
||||
return w.renderContent()
|
||||
} else {
|
||||
return w.renderSize()
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WindowWidget) renderContent() [][]Cell {
|
||||
c := make([][]Cell, 0)
|
||||
|
||||
var y int
|
||||
|
||||
for _, w := range w.widgets {
|
||||
for _, row := range w.Render() {
|
||||
|
||||
t := make([]Cell, len(row))
|
||||
c = append(c, t)
|
||||
|
||||
@ -60,3 +70,15 @@ func (w *WindowWidget) Render() [][]Cell {
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (w *WindowWidget) renderSize() [][]Cell {
|
||||
c := make([][]Cell, w.size.Y)
|
||||
|
||||
for y := 0; y < w.size.Y; y++ {
|
||||
for x := 0; x < w.size.X; x++ {
|
||||
c[y][x] = Cell{Pos: Position{X: x, Y: y}}
|
||||
}
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
15
spectator.go
15
spectator.go
@ -169,19 +169,26 @@ func main() {
|
||||
aIt := asks.Iterator()
|
||||
|
||||
var low, high decimal.Decimal
|
||||
for i := num - 1; i >= 0; i-- {
|
||||
asks := make([]ListEntry, num)
|
||||
for i := 0; i < num; i++ {
|
||||
aIt.Next()
|
||||
|
||||
entries := aIt.Value().(Entries)
|
||||
price, size := flatten(entries)
|
||||
|
||||
topAsks.AddEntry(ListEntry{Value: size.StringFixed(8),
|
||||
Attrs: exhibit.Attributes{ForegroundColor: exhibit.FGBlue}})
|
||||
asks[i] = ListEntry{Value: size.StringFixed(8),
|
||||
Attrs: exhibit.Attributes{ForegroundColor:
|
||||
exhibit.FGBlue}}
|
||||
|
||||
if i == num-1 {
|
||||
if i == 0 {
|
||||
low = price
|
||||
}
|
||||
}
|
||||
|
||||
for i := num - 1; i >= 0; i-- {
|
||||
topAsks.AddEntry(asks[i])
|
||||
}
|
||||
|
||||
topAsks.Commit()
|
||||
|
||||
bIt := bids.Iterator()
|
||||
|
Reference in New Issue
Block a user