diff --git a/ui/ctx.go b/ui/ctx.go index 4de8ed5..95bcba8 100644 --- a/ui/ctx.go +++ b/ui/ctx.go @@ -21,12 +21,13 @@ func NewContextMenu() *ContextMenu { return c } -func (c *ContextMenu) Size(mw, mh, ch int) (int, int, int, int) { +func (c *ContextMenu) Size(mw, mh int) (int, int, int, int) { + cslice := c.ContentHandler() + cheight := len(cslice) + 3 cwidth := 30 epx := 4 - ch += 3 - return mw/2 - (cwidth/2 + epx), (mh/2 - (ch/2 + epx)), cwidth, ch + return mw/2 - (cwidth/2 + epx), (mh/2 - (cheight/2 + epx)), cwidth, cheight } func (c *ContextMenu) ContentHandler() []string { diff --git a/ui/root.go b/ui/root.go index 0d00bf0..b8e0e21 100644 --- a/ui/root.go +++ b/ui/root.go @@ -27,7 +27,7 @@ type CenteredWidget interface { ContentHandler() []string SelectionHandler(s string) Title() string - Size(mw, mh, ch int) (int, int, int, int) + Size(mw, mh int) (int, int, int, int) } func (m *Main) addCenteredWidget(t CenteredWidget) { @@ -42,7 +42,7 @@ func (m *Main) addCenteredWidget(t CenteredWidget) { } drawCtx := func() { m.Root.AddPage(currentTime, t.Primitive(), false, true) - p.SetRect(t.Size(w, h, len(cslice))) + p.SetRect(t.Size(w, h)) } redraw := func() { closeCtx()