diff --git a/tests/screen_test.go b/tests/screen_test.go index 45820da..6c8ec77 100644 --- a/tests/screen_test.go +++ b/tests/screen_test.go @@ -62,8 +62,8 @@ func TestScrollView(t *testing.T) { } screen.MouseClicked = func(event *tui.MouseEvent) (consumed bool) { - //textViews[0].(*views.TextView).Text = fmt.Sprintf("mouse position: %d | %d", event.X, event.Y) - //textViews[1].(*views.TextView).Text = fmt.Sprintf("mouse button: %d", event.Button) + textViews[0].(*views.TextView).Text = fmt.Sprintf("mouse position: %d | %d", event.X, event.Y) + textViews[1].(*views.TextView).Text = fmt.Sprintf("mouse button: %d", event.Button) if event.Button == tui.MouseWheelUp { scrollView.Scroll(-1, 0) diff --git a/views/layout_coord.go b/views/layout_coord.go index 181654e..e744f8f 100644 --- a/views/layout_coord.go +++ b/views/layout_coord.go @@ -29,6 +29,7 @@ func (g *CoordLayout) Views() []tui.View { func (g *CoordLayout) SetView(v tui.View, x, y, width, height int) { g.views[v] = tui.Dimension{Point: tui.Point{X: x, Y: y}, Size: tui.Size{Width: width, Height: height}} } + func (g *CoordLayout) Draw(buf *tui.ViewBuffer) { for v, d := range g.views { v.Draw(buf.Sub(d.X, d.Y, d.Width, d.Height)) diff --git a/views/layout_flow.go b/views/layout_flow.go index 9f71b5b..7058f13 100644 --- a/views/layout_flow.go +++ b/views/layout_flow.go @@ -39,15 +39,21 @@ func (g *FlowLayout) InsertView(v tui.View, index int) { g.views = append(g.views[:index], append([]tui.View{v}, g.views[index:]...)...) } -func (g *FlowLayout) RemoveView(v tui.View) { +func (g *FlowLayout) removeView(v tui.View) { for index, view := range g.Views() { - if view == v { - g.views = append(g.views[:index], g.views[index:]...) + if v == view { + g.views = append(g.views[:index], g.views[index+1:]...) return } } } +func (g *FlowLayout) RemoveViews(v ...tui.View) { + for _, view := range v { + g.removeView(view) + } +} + func (g *FlowLayout) Draw(buf *tui.ViewBuffer) { g.ViewTmpl.Draw(buf) diff --git a/views/view_scroll.go b/views/view_scroll.go index 8cd0dcb..77dd8fe 100644 --- a/views/view_scroll.go +++ b/views/view_scroll.go @@ -29,6 +29,8 @@ func NewScrollView(view tui.View) *ScrollView { } func (v *ScrollView) Draw(buf *tui.ViewBuffer) { + v.ViewTmpl.Draw(buf) + w, h := v.View().Layout() if v.buf == nil || v.buf.Width() != w || v.buf.Height() != h {