Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolbar with widget.Label makes the ToolbarAction buttons higher #2257

Closed
marmiha opened this issue May 20, 2021 · 2 comments
Closed

Toolbar with widget.Label makes the ToolbarAction buttons higher #2257

marmiha opened this issue May 20, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@marmiha
Copy link

marmiha commented May 20, 2021

Describe the bug:

Adding a widget.NewLabel() inside a widget.NewToolbar() makes the widget.NewToolbarAction() a little bit higher.

To Reproduce:

Steps to reproduce the behaviour:

  1. Make a custom struct inheriting widget.ToolbarItem
type toolbarLabel struct {
	*widget.Label
}

func NewToolbarLabel(label string) widget.ToolbarItem {
	l := widget.NewLabelWithStyle(label, fyne.TextAlignCenter ,fyne.TextStyle{Bold: true})
	l.MinSize()
	return &toolbarLabel{l}
}

func (t *toolbarLabel) ToolbarObject() fyne.CanvasObject {
	return t.Label
}
  1. Compare the height of the buttons between the two toolbars. This can also be replicated if a Label is inside the HBox (acts the same as in Toolbar).
func MainScreen() fyne.CanvasObject {
	
	// Menu
	toolbar_hbox := container.NewHBox(
		widget.NewToolbarAction(theme.FolderIcon(), func() {
			fmt.Println("profile settings clicked in toolbar")
		}).ToolbarObject(),

		widget.NewToolbarSpacer().ToolbarObject(),
		widget.NewToolbarAction(theme.FolderIcon(), func() {
			fmt.Println("log out clicked in toolbar")
		}).ToolbarObject(),
	)

	toolbar_tb := widget.NewToolbar(
		widget.NewToolbarAction(theme.FolderIcon(), func() {
			fmt.Println("profile settings clicked in toolbar")
		}),
		element.NewToolbarLabel("marmiha"),
		widget.NewToolbarSpacer(),
		widget.NewToolbarAction(theme.FolderIcon(), func() {
			fmt.Println("log out clicked in toolbar")
		}),
	)


	return container.NewBorder(toolbar_tb, toolbar_hbox, nil, nil)
}

Screenshots:

image
image

Device (please complete the following information):

  • OS: Windows
  • Version: 10
  • Go version: go 1.16.3 windows/amd64
  • Fyne version: v2.0.3
@marmiha marmiha added the unverified A bug that has been reported but not verified label May 20, 2021
@andydotxyz andydotxyz added bug Something isn't working and removed unverified A bug that has been reported but not verified labels May 24, 2021
@andydotxyz andydotxyz added this to the Aberlour (2.1) milestone May 24, 2021
@andydotxyz andydotxyz self-assigned this May 24, 2021
@andydotxyz
Copy link
Member

I think we may have broken this with the 2.0 changes to how widgets are padded.

andydotxyz added a commit to andydotxyz/fyne that referenced this issue May 27, 2021
To do this right then low profile buttons are fixed as well.
This knocked on to accordion (header) and app/doc tabs.
All positive changes IMHO :)

Fixes fyne-io#2257
@andydotxyz
Copy link
Member

Fix is on develop branch now, will be in 2.1 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants