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

random render #4668

Closed
2 tasks done
MatejMagat305 opened this issue Feb 23, 2024 · 1 comment
Closed
2 tasks done

random render #4668

MatejMagat305 opened this issue Feb 23, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@MatejMagat305
Copy link
Contributor

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

I create symple gui (inspirate with defyne editor) and sometime it render good and sometime bad ..., when render bad, buttons still register mouse at ridht place ...

How to reproduce

  1. go to https://github.com/MatejMagat305/fyneCL
  2. download it
  3. run multiple go run .
  4. see

Screenshots

good:

goodshow

bad

show

Example code

package main

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

func main() {
	a := app.NewWithID("m.m.fyneCL")
	w := a.NewWindow("fyneCL")
	w.Resize(fyne.NewSize(1024, 768))
	ed := &editor{...}
	entry := widget.NewEntry()
	list := makeList(ed)
	label := widget.NewLabel("select file")
	codeSpace := container.NewHSplit(list, label)
	codeSpace.Offset = 0.01
	menu := makeMenu(ed)
	spaceNormal := container.NewVBox(menu, codeSpace)
	space := container.NewWithoutLayout(spaceNormal)
	w.SetContent(space)
        ...
	w.SetMainMenu(makeMainMenu(ed))
	w.ShowAndRun()
}

func makeMainMenu(d *editor) *fyne.MainMenu {
	menu := fyne.NewMainMenu(
		fyne.NewMenu("File",
			fyne.NewMenuItem("New File...", d.menuActionNew),
			fyne.NewMenuItemSeparator(),
			fyne.NewMenuItem("Save", d.menuActionSave),
			fyne.NewMenuItemSeparator(),
			fyne.NewMenuItem("Run", d.menuActionRun),
		))
	return menu
}

func makeMenu(ed *editor) *widget.Toolbar {
	return widget.NewToolbar(
		widget.NewToolbarAction(theme.FileIcon(), ed.menuActionNew),
		widget.NewToolbarAction(theme.DocumentSaveIcon(), ed.menuActionSave),
		widget.NewToolbarSeparator(),
		widget.NewToolbarAction(theme.MediaPlayIcon(), ed.menuActionRun),
	)
}

...

func (e *editor) menuActionNew() {
	entry := widget.NewEntry()
	menu := container.NewVBox(
		widget.NewLabel("zadajte meno:"),
		container.NewHBox(entry, widget.NewLabel(".cl")),
		container.NewHBox(widget.NewButton("cancel", func() {
			e.stackSpace.Objects = e.stackSpace.Objects[1:]
		}), widget.NewButton("ok", func() {
			if len(entry.Text) == 0 {
				return
			}
			create, err := e.app.Storage().Create(filepath.Join(e.app.Storage().RootURI().Path(),
				strings.Join([]string{entry.Text, ".cl"}, "")))
			if err != nil {
				return
			}
			defer create.Close()
			shouldW := len([]byte(kernelImg))
			for shouldW != 0 {
				w, err := create.Write([]byte(kernelImg))
				if err != nil {
					return
				}
				shouldW -= w
			}
			e.stackSpace.Objects = e.stackSpace.Objects[1:]
			e.fileTree.Refresh()
		})))
	e.stackSpace.Objects = append([]fyne.CanvasObject{menu}, e.stackSpace.Objects...)
	menu.Move(fyne.NewPos(e.window.Canvas().Size().Width/2, e.window.Canvas().Size().Height/2))
}
...

Fyne version

fyne.io/fyne/v2 v2.4.4

Go compiler version

1.22.0

Operating system and version

Pop!_OS 22.04 LTS x86_64

Additional Information

CPU: AMD Ryzen 9 5950X (32) @ 3.400GHz
GPU: NVIDIA GeForce RTX 3060 Ti Lite Hash Rate
Kernel: 6.6.10-76060610-generic
+
do not worry folder blackCL is not embedded .... until error with fyne will be during

@MatejMagat305 MatejMagat305 added the unverified A bug that has been reported but not verified label Feb 23, 2024
@andydotxyz
Copy link
Member

You have put your entire UI into a container without a layout, and have not added any layout code.
This is not a good idea, you should consider using a standard layout or actually putting layout code in your app.

	space := container.NewWithoutLayout(spaceNormal)

However, I think the bug you are describing is a duplicate of #4431

@andydotxyz andydotxyz added the duplicate This issue or pull request already exists label Feb 23, 2024
@Jacalz Jacalz closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2024
@Jacalz Jacalz removed the unverified A bug that has been reported but not verified label Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants