From 7a1a6503e8d0bf18385b4bd5a14d65983311657b Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Tue, 3 May 2022 13:48:58 +0200 Subject: [PATCH] MarginView constructor with margin parameters --- tests/screen_test.go | 3 +-- views/view_margin.go | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/screen_test.go b/tests/screen_test.go index 2f25eb3..8c6099c 100644 --- a/tests/screen_test.go +++ b/tests/screen_test.go @@ -86,8 +86,7 @@ func TestFlowLayout(t *testing.T) { textView := views.NewTextView("hello world!") textView.SetStyle(tui.StyleDefault.Background(tcell.ColorRed).Foreground(tcell.ColorBlack)) - marginView := views.NewMarginView(textView) - marginView.SetMargin(3, 1, 1, 0) + marginView := views.NewMarginView(textView, 3, 1, 1, 0) //borderView := views.NewBorderView(textView) diff --git a/views/view_margin.go b/views/view_margin.go index a312bd9..015570d 100644 --- a/views/view_margin.go +++ b/views/view_margin.go @@ -10,10 +10,10 @@ type MarginView struct { 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.SetView(view) - v.SetMargin(0, 0, 0, 0) + v.SetMargin(top, right, bottom, left) return v }