aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go66
1 files changed, 66 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..08577a1
--- /dev/null
+++ b/main.go
@@ -0,0 +1,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)
+}