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

Incorrect row header width in widget.Table #4370

Closed
2 tasks done
vinser opened this issue Nov 5, 2023 · 3 comments
Closed
2 tasks done

Incorrect row header width in widget.Table #4370

vinser opened this issue Nov 5, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@vinser
Copy link

vinser commented Nov 5, 2023

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

Neither SetColumnWidth nor template in CreateHeader do not set row header width up.
See the first fixed column on screenshot below

How to reproduce

Run the code below

Screenshots

image

Example code

import (
	"fmt"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
)

func main() {
	myApp := app.New()
	w := myApp.NewWindow("Table with Borders")

	t := widget.NewTableWithHeaders(
		func() (int, int) { return 5, 5 },
		func() fyne.CanvasObject {
			return widget.NewLabel("Cell 000, 000")
		},
		func(id widget.TableCellID, o fyne.CanvasObject) {
			label := o.(*widget.Label)
			label.SetText(fmt.Sprintf("Cell %d, %d", id.Row, id.Col))
		})

	t.SetColumnWidth(-1, 100)

	t.CreateHeader = func() fyne.CanvasObject {
		return widget.NewLabel("Row 000")
	}

	t.UpdateHeader = func(id widget.TableCellID, o fyne.CanvasObject) {
		l := o.(*widget.Label)
		if id.Col == -1 {
			l.SetText(fmt.Sprintf("Row %d", id.Row))
		} else {
			l.SetText(fmt.Sprintf("Column %d", id.Col))
		}
	}

	content := container.NewBorder(nil, nil, nil, nil, t)

	w.Resize(fyne.NewSize(400, 300))
	w.CenterOnScreen()
	w.SetContent(content)
	w.ShowAndRun()
}

Fyne version

2.4.1

Go compiler version

1.21.3

Operating system and version

Ubuntu 22.04 arm64, Windows 10 amd64

Additional Information

No response

@vinser vinser added the unverified A bug that has been reported but not verified label Nov 5, 2023
@Ju-B
Copy link
Contributor

Ju-B commented Nov 24, 2023

i encounter the same issue.

The code to handle header sizing do not use t.columnWidths nor t.rowHeights.
The size is always the one from the template's Minsize cached in t.headerSize.

Exposing t.headerSize or have a setter could help set the row header's width and column header's height
Or handle -1 case in SetColumnWidth and SetRowHeight to affect t.headerSize in stead of changing the maps

@andydotxyz
Copy link
Member

Maybe I should have asked this before, but in what case does the header size need to very from the header template minimum size?

@andydotxyz
Copy link
Member

Understood the use-case and now the patch is landed too. Marking for next feature release

@andydotxyz andydotxyz added this to the "Elgin" release, late 2023 milestone Dec 6, 2023
@andydotxyz andydotxyz added enhancement New feature or request and removed unverified A bug that has been reported but not verified labels Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants