Skip to content
Snippets Groups Projects
Commit 42e6e853 authored by Andrew E. Torda's avatar Andrew E. Torda
Browse files

Incomplete, but working version.

parent 27c8e3bb
No related branches found
No related tags found
No related merge requests found
// 17 Feb 2022
// Handle the output tab stuff
// There should be three states.
// 1. initial, nothing happened yet
// 2. thinking
// 3. show results
package ui
import (
"bytes"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
type status uint8
const (
initial status = iota
calculating
resultsReady
)
type workstatus struct {
fdata, xdata []byte
status status
}
func showIniTab(cntr *fyne.Container) {
cntr.Add(widget.NewCard("No results yet", "go back to the input", nil))
}
func showCalcTab(cntr *fyne.Container) {
for _, c := range cntr.Objects {
cntr.Remove(c)
}
cntr.Add(widget.NewCard("calculating", "busy", nil))
cntr.Refresh()
}
// showResultsTab show the two plots
func showResultsTab(cntr *fyne.Container, fdata, xdata []byte) {
for _, c := range cntr.Objects {
cntr.Remove(c)
}
fImage := canvas.NewImageFromReader(bytes.NewReader(fdata), "func.png")
fImage.FillMode = canvas.ImageFillContain
fImage.SetMinSize( fyne.Size{500, 300})
xImage := canvas.NewImageFromReader(bytes.NewReader(xdata), "xdata.png")
xImage.FillMode = canvas.ImageFillContain
xImage.SetMinSize( fyne.Size{500, 300})
content := container.NewGridWithRows(2, fImage, xImage)
cntr.Add(content)
}
func outputTab(chn chan workstatus, cntr *fyne.Container) {
showIniTab(cntr)
for s := range chn {
switch s.status {
case calculating:
showCalcTab(cntr)
case resultsReady:
showResultsTab(cntr, s.fdata, s.xdata)
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment