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

Cells are not getting draw in correct location after column resize. #1951

Closed
zdima opened this issue Feb 12, 2021 · 1 comment
Closed

Cells are not getting draw in correct location after column resize. #1951

zdima opened this issue Feb 12, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@zdima
Copy link
Contributor

zdima commented Feb 12, 2021

Describe the bug:

After calling SetColumnWidth the cells are not getting draw in correct location.
The table.Refresh() doesn't help.
The column's border is properly displayed and selection highlight correct.
This is tested with development branch due to Apple M1 (github.com/sirkon/fyne/v2 v2.0.1-0.20210209074931-f93d4e04b627).

To Reproduce:

Steps to reproduce the behaviour:
Run provided test program.
After 5 second delay the columns border is changed.
The Cells widgets are not moved to correct location.
Try select individual cells, the selection marks are displayed properly.

Screenshots:

Screen Shot 2021-02-12 at 1 14 59 PM

Screen Shot 2021-02-12 at 1 15 05 PM

Example code:

package main

import (
	"fmt"
	"time"

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

func main() {
	a := app.New()
	w := a.NewWindow("Examples")
	w.SetContent(newTable())
	w.Resize(fyne.Size{Width: 800, Height: 300})
	w.ShowAndRun()
}

func newTable() fyne.CanvasObject {
	var data map[int][]string = make(map[int][]string, 1)
	var colWidth []float32 = make([]float32, 3)
	data[0] = []string{"Header 1", "Header 2", "Header 3"}
	var table *widget.Table
	table = widget.NewTable(func() (int, int) {
		return len(data), 3
	}, func() fyne.CanvasObject {
		l := widget.NewLabel("")
		l.Resize(fyne.Size{Width: 200, Height: 20})
		return l
	}, func(tci widget.TableCellID, co fyne.CanvasObject) {
		if label, ok := co.(*widget.Label); ok {
			col := tci.Col
			label.Text = data[tci.Row][col]
			label.Refresh()
			width := label.MinSize().Width
			if colWidth[col] < width {
				colWidth[col] = width
				// Options A
				// go func() {
				// 	table.SetColumnWidth(col, colWidth[col])
				// 	table.Refresh()
				// }()
			}
		}
	})

	table.SetColumnWidth(0, 200)
	table.SetColumnWidth(1, 200)
	table.SetColumnWidth(2, 200)

	table.OnSelected = func(id widget.TableCellID) {
		fmt.Printf("Select col %d row %d\n", id.Col, id.Row)
	}

	// Options B
	go func() {
		time.Sleep(time.Second * 5)
		table.SetColumnWidth(0, 100)
		table.SetColumnWidth(1, 100)
		table.SetColumnWidth(2, 100)
		table.Refresh()
	}()

	return table
}

go.mod for Apple M1:

module table-test

go 1.16

replace fyne.io/fyne/v2 => github.com/sirkon/fyne/v2 v2.0.1-0.20210209074931-f93d4e04b627

require fyne.io/fyne/v2 v2.0.0-00010101000000-000000000000

Device (please complete the following information):

  • MacOS:
  • 11.2:
  • go1.16rc1:
  • 2.0 (dev):
@zdima zdima added the bug Something isn't working label Feb 12, 2021
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Feb 15, 2021
Also fix the minsize for the scroller which was ignoring the value
Fixes fyne-io#1951
@andydotxyz
Copy link
Member

On develop for testing

andydotxyz added a commit that referenced this issue Feb 21, 2021
Also fix the minsize for the scroller which was ignoring the value
Fixes #1951
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