ajstarks / fc

High-level canvas for the fyne package
Other
65 stars 4 forks source link

Combining fc with fyne (proper) #2

Open hippodribble opened 3 years ago

hippodribble commented 3 years ago

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

ajstarks commented 3 years ago

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

SteffenMahler commented 2 years ago

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
}
MatejMagat305 commented 2 years ago

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?