fc icon indicating copy to clipboard operation
fc copied to clipboard

Combining fc with fyne (proper)

Open hippodribble opened this issue 2 years ago • 3 comments

AJ

Any way to make an app with a border layout with an fc Canvas as the central element?

The EndRun method may conflict with fyne.Window's ShowAndRun.

Congrats on a useful package!

glenn

hippodribble avatar Sep 20 '21 11:09 hippodribble

I think they will integrate as fc is built on fyne fundamental objects.

ajstarks avatar Sep 20 '21 17:09 ajstarks

Hi @hippodribble

The EndRun method may conflict with fyne.Window's ShowAndRun.

Then try this:

func main() {
    width := 500
    height := 500
    blue := color.RGBA{0, 0, 255, 255}
    white := color.RGBA{255, 255, 255, 255}

    canvas := fc.NewCanvas("hello", width, height)

    canvas.Circle(50, 0, 100, blue)
    canvas.Rect(20, 25, 20, 40, colornames.Green)
    canvas.CText(50, 25, 10, "hello, world", white)
    canvas.Image(50, 75, 200, 200, "earth.jpg")

    window := createWindow(canvas)
    window.ShowAndRun()
}

func createWindow(c fc.Canvas) fyne.Window {
    w := c.Window
    w.Resize(fyne.NewSize(float32(c.Width), float32(c.Height)))
    w.SetFixedSize(true)
    w.SetPadded(false)
    w.SetContent(c.Container)

    return w
}

SteffenMahler avatar Dec 14 '21 07:12 SteffenMahler

I would like to ask you like https://github.com/fyne-io/fyne/issues/2924, do you plan or would you allow me make some modifications to make "only" CanvasObject to integrate to fyne?

MatejMagat305 avatar Apr 18 '22 08:04 MatejMagat305