Browse Source

Add step forward and backward function.

(Internally: THE clock is now that of the progression-instance, not the scene.)
master
isoraqathedh 2 years ago
parent
commit
0751a2ca90
2 changed files with 28 additions and 16 deletions
  1. +14
    -5
      behaviour.lisp
  2. +14
    -11
      window.lisp

+ 14
- 5
behaviour.lisp View File

@ -80,7 +80,7 @@ and so on until the end of SLOTS is reached."
(let ((*width* (q+:width canvas-size))
(*height* (q+:height canvas-size)))
(flare:update (scene canvas)))
(signal! main-window (set-clock-time float) (clock (scene canvas)))
(signal! main-window (set-clock-time float) (clock (progression-of canvas)))
(q+:repaint canvas)))
(define-override (canvas paint-event) (ev)
@ -110,11 +110,20 @@ and so on until the end of SLOTS is reached."
(setf (q+:text (rslot-value main-window 'central-widget 'playback-input)) "1"
(flare:timescale (scene canvas)) 1))
(define-signal (canvas seek-by) (float))
(define-slot (canvas seek) ((delta float))
(let ((clock (clock (scene canvas))))
(unless (flare:running (scene canvas))
(flare:synchronize clock (- clock delta))
(q+:repaint canvas))))
(declare (connected canvas (seek-by float)))
(let* ((*width* (q+:width canvas))
(*height* (q+:height canvas))
(progrn (progression-of canvas))
(pclk (flare:clock progrn)))
;; Two clocks that need to be updated:
;; - The clock in the animation (progression, of progression-definition)
(flare:update (flare:clock progrn))
(flare:update (flare:synchronize progrn (+ pclk delta)))
;; - The clock in the scene
(flare:update (flare:synchronize (scene canvas) progrn))))
(defun load-presentation (presentation-symbol canvas)
(let* ((presentation (flare:progression-definition presentation-symbol))

+ 14
- 11
window.lisp View File

@ -19,6 +19,11 @@
(background :initform *background-colour* :accessor background)
(main-window :initarg :main-window :reader main-window)))
(defgeneric progression-of (canvas)
(:documentation "Get the progression (of the progression instance) of the canvas.")
(:method ((canvas canvas))
(first (flare:progressions (scene canvas)))))
(defmethod initialize-instance :after ((canvas canvas) &key width height)
(setf (q+:fixed-size canvas) (values width height)))
@ -136,23 +141,21 @@ to allow relative measurements to take place.")
;; Currently there is no need to do anything elaborate or serious,
;; just respond to the key presses to the canvas that correspond to some action.
;; we'll figure something more complex later if we actually need it.
(defparameter *step-interval* 1/30
"Interval for which the comma and full stop keys will jump the animation for.")
(define-override (main-window key-press-event) (event)
(let ((key (q+:key event))
(scene (rslot-value main-window 'central-widget 'stage 'scene))
(canvas (rslot-value main-window 'central-widget 'stage)))
(let* ((key (q+:key event))
(canvas (rslot-value main-window 'central-widget 'stage)))
(cond
((eql key (q+:qt.Key_Q))
(q+:quit *qapplication*))
((eql key (q+:qt.Key_Space))
(signal! main-window (play/pause)))
((and (not (flare:running scene))
(eql key (q+:qt.Key_Comma)))
(flare:update (flare:synchronize scene (- (print (flare:clock scene)) 1/10)))
(q+:repaint canvas))
((and (not (flare:running scene))
(eql key (q+:qt.Key_Period)))
(flare:update (flare:synchronize scene (+ (print (flare:clock scene)) 1/10)))
(q+:repaint canvas))
((eql key (q+:qt.Key_Comma))
(signal! canvas (seek-by float) (float (- *step-interval*) 0.0)))
((eql key (q+:qt.Key_Period))
(signal! canvas (seek-by float) (float (+ *step-interval*) 0.0)))
((eql key (q+:qt.Key_R))
(signal! main-window (restart)))
(t (stop-overriding)))))

Loading…
Cancel
Save