Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

first 8 rows in the table have large line-height #71

Open
taylorchu opened this issue Nov 23, 2017 · 6 comments
Open

first 8 rows in the table have large line-height #71

taylorchu opened this issue Nov 23, 2017 · 6 comments
Labels

Comments

@taylorchu
Copy link
Contributor

screen shot 2017-11-23 at 9 40 31 am

@taylorchu
Copy link
Contributor Author

││ │ ││....││

I wonder if this is intended.

@marcusolsson
Copy link
Owner

It is a consequence of the layout algorithm used in tui-go (which is the same as in the Qt project). Widgets in a Box fight for the space, and unless one of the widgets have the Expanding size policy, they will share the space equally. In a graphical application (with Qt) this isn't as big of an issue since pixels are smaller units of space.

The solution is probably to make the top or bottom widget expand:

widget.SetSizePolicy(tui.Preferred, tui.Expanding)

... or, to add a Spacer widget.

Let me know if it works for you!

@taylorchu
Copy link
Contributor Author

I added a bottom spacer widget to the vbox that has the table. Strangely this does not shrink the table height. And setting size policy also does not work too.

@marcusolsson
Copy link
Owner

That should work though, so it might be a bug after all :) Do you think you could post an example with the problem? Thanks!

@taylorchu
Copy link
Contributor Author

Here is a minimum example. It turns out that I have a no-break space in my text 🍰 .

package main

import (
	tui "github.com/marcusolsson/tui-go"
)

func main() {
	table := tui.NewTable(0, 0)
	for i := 0; i < 3; i++ {
		table.AppendRow(
			tui.NewLabel("test\u00a0test"),
		)
	}

	container := tui.NewVBox(table, tui.NewSpacer())
	container.SetBorder(true)
	container.SetSizePolicy(tui.Expanding, tui.Expanding)

	ui := tui.New(container)
	ui.SetKeybinding("Esc", func() { ui.Quit() })
	ui.Run()
}

@marcusolsson
Copy link
Owner

Confirming this as a bug. The spacer should claim the extra space from the table rows.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants