;; See the file LICENSE for the full license governing this code.
;; Code for the dialog :coefficient-dialog

(in-package :cg-user)

; added in ch 5 step 8
;; modified in ch 5 step 17
(defclass coefficient-dialog (color-mixin dialog)
    ())

; added ch5 step 50
(defun coefficient-dialog-test-button-on-change (widget new-value old-value)
   (declare (ignore-if-unused widget new-value old-value))
   (when new-value
      (test-curve (parent widget)))
   (not new-value))

; initially added from ch5 step 52
(defmethod test-curve ((dialog coefficient-dialog))
   (let* ((curve (make-instance 'cycloidal-curve
                   :a-coefficient (value
                                    (find-component :a-coefficient-control 
                                      dialog))
                   :b-coefficient (value
                                    (find-component :b-coefficient-control 
                                      dialog))
                   :c-coefficient (value
                                    (find-component :c-coefficient-control 
                                      dialog))
                   ;; added ch6 step 24
                   :color (current-color dialog)))
          (curve-dialog (owner dialog))
          (doodler (owner curve-dialog)))
      (draw-curve (frame-child doodler) curve)))

;; added ch6 step 30
(defun coefficient-dialog-color-button-on-change (widget new-value old-value)
   (declare (ignore-if-unused widget new-value old-value))
   (when new-value
      (add-other-color (parent widget)))
   (not new-value))

