aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
blob: 08577a17077997ece30f5c98bb361c2561940f4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main

import (
	"fmt"
	g "github.com/AllenDang/giu"
	"os"
)

func check(err error) {
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}

var (
	manifoldPressure pressure

	// selectedPressureUnit is used to index pressureUnits
	selectedPressureUnit int32
)

func init() {
	manifoldPressure = pressure{100, defaultPressureUnit}

	// selectedPressureUnit is used to index pressureUnitStrings
	selectedPressureUnit = defaultPressureUnitIndex
}

func loop() {
	g.SingleWindow().Layout(
		g.Table().
			Rows(
				g.TableRow(
					g.Label("Manifold Absolute Pressure"),
					g.Combo(
						"",
						pressureUnitStrings()[selectedPressureUnit],
						pressureUnitStrings(),
						&selectedPressureUnit,
					).
						OnChange(func() {
							s := pressureUnitStrings()[selectedPressureUnit]
							u, err := pressureUnitFromString(s)
							check(err)

							manifoldPressure = pressure{
								manifoldPressure.asUnit(u),
								u,
							}
						}),
					g.InputFloat(&manifoldPressure.val).Format("%.2f"),
				),
			).
			Columns(
				g.TableColumn("Parameter"),
				g.TableColumn("Unit"),
				g.TableColumn("Point 1"),
			),
	)
}

func main() {
	wnd := g.NewMasterWindow("volute", 400, 200, 0)
	wnd.Run(loop)
}