Skip to content

Commit 92b3215

Browse files
committed
egui has StopLevel enum -- was using etime.Cycle but that is 2, not 0 -- now using NoTime as default (0) and it is settable -- probably should set to Trial for most sims.
1 parent f1a87d8 commit 92b3215

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

egui/gui.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"cogentcore.org/core/tree"
1818
_ "cogentcore.org/lab/gosl/slbool/slboolcore" // include to get gui views
1919
"cogentcore.org/lab/lab"
20+
"github.com/emer/emergent/v2/etime"
2021
"github.com/emer/emergent/v2/netview"
2122
)
2223

@@ -43,6 +44,9 @@ type GUI struct {
4344
// via the Stopped method. It should update the network view for example.
4445
OnStop func(mode, level enums.Enum)
4546

47+
// StopLevel is the enum to use when the stop button is pressed.
48+
StopLevel enums.Enum
49+
4650
// isRunning is true if sim is running.
4751
isRunning bool
4852

@@ -134,6 +138,7 @@ func NewGUIBody(b tree.Node, sim any, fsroot fs.FS, appname, title, about string
134138
// The first arg is an optional existing [core.Body] to make into: if nil then
135139
// a new body is made first.
136140
func (gui *GUI) MakeBody(b tree.Node, sim any, fsroot fs.FS, appname, title, about string) {
141+
gui.StopLevel = etime.NoTime // corresponds to the first level typically
137142
core.NoSentenceCaseFor = append(core.NoSentenceCaseFor, "github.com/emer")
138143
if b == nil {
139144
gui.Body = core.NewBody(appname).SetTitle(title)

egui/loopctrl.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"cogentcore.org/core/styles"
1717
"cogentcore.org/core/styles/abilities"
1818
"cogentcore.org/core/tree"
19-
"github.com/emer/emergent/v2/etime"
2019
"github.com/emer/emergent/v2/looper"
2120
)
2221

@@ -101,7 +100,7 @@ func (gui *GUI) AddLooperCtrl(p *tree.Plan, loops *looper.Stacks, prefix ...stri
101100
Tooltip: "Interrupts current running. Will pick back up where it left off.",
102101
Active: ActiveRunning,
103102
Func: func() {
104-
loops.Stop(etime.Cycle)
103+
loops.Stop(gui.StopLevel)
105104
// fmt.Println("Stop time!")
106105
gui.SetStopNow()
107106
},

0 commit comments

Comments
 (0)