MarginView constructor with margin parameters

This commit is contained in:
Timon Ringwald 2022-05-03 13:48:58 +02:00
parent 01dd57a665
commit 7a1a6503e8
2 changed files with 3 additions and 4 deletions

View File

@ -86,8 +86,7 @@ func TestFlowLayout(t *testing.T) {
textView := views.NewTextView("hello world!") textView := views.NewTextView("hello world!")
textView.SetStyle(tui.StyleDefault.Background(tcell.ColorRed).Foreground(tcell.ColorBlack)) textView.SetStyle(tui.StyleDefault.Background(tcell.ColorRed).Foreground(tcell.ColorBlack))
marginView := views.NewMarginView(textView) marginView := views.NewMarginView(textView, 3, 1, 1, 0)
marginView.SetMargin(3, 1, 1, 0)
//borderView := views.NewBorderView(textView) //borderView := views.NewBorderView(textView)

View File

@ -10,10 +10,10 @@ type MarginView struct {
var _ tui.Wrapper = &MarginView{} var _ tui.Wrapper = &MarginView{}
func NewMarginView(view tui.View) *MarginView { func NewMarginView(view tui.View, top, right, bottom, left int) *MarginView {
v := new(MarginView) v := new(MarginView)
v.SetView(view) v.SetView(view)
v.SetMargin(0, 0, 0, 0) v.SetMargin(top, right, bottom, left)
return v return v
} }