Commit 1aa4eb66 authored by Loïck Bonniot's avatar Loïck Bonniot

[d] Add step-by-step and remove auto replay

parent 075c808d
Pipeline #1812 passed with stage
......@@ -91,6 +91,7 @@ func (w *Window) initTimer() {
w.timer.OnTimeout(func() {
nbEvents := len(w.scene.Events)
if w.scene.currentEvent >= nbEvents {
w.stopButton.Click()
w.replayButton.Click()
return
}
......@@ -116,6 +117,7 @@ func (w *Window) initTimer() {
quantum := time.Duration(w.quantumField.Value()) * time.Microsecond
endOfQuantum := w.scene.currentTime.Add(quantum)
drawnEvents := 0
for i := w.scene.currentEvent; i < nbEvents; i++ {
e := w.scene.Events[i]
......@@ -125,10 +127,15 @@ func (w *Window) initTimer() {
w.DrawEvent(&e)
w.scene.currentEvent++
drawnEvents++
}
w.PrintQuantumInformation()
w.scene.currentTime = endOfQuantum
if w.speedSlider.Value() == 0 && drawnEvents > 0 {
w.stopButton.Click() // step-by-step
}
})
}
......
......@@ -187,7 +187,7 @@
<enum>Qt::TabFocus</enum>
</property>
<property name="minimum">
<number>1</number>
<number>0</number>
</property>
<property name="maximum">
<number>20</number>
......
......@@ -122,7 +122,11 @@ func (w *Window) addActions() {
w.playButton.OnClicked(func() {
w.playButton.SetDisabled(true)
w.stopButton.SetDisabled(false)
speed := 2000 / w.speedSlider.Value()
s := w.speedSlider.Value()
if s == 0 {
s = 100 // step-by-step arbitrary speed value
}
speed := 2000 / s
w.timer.StartWithMsec(speed)
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment