changeset 177:f0f11db714f8

Renamed update! to notify!
author Mikhail Kryshen <mikhail@kryshen.net>
date Fri, 18 Sep 2015 17:40:25 +0300
parents 6a29fcb6fe9a
children 8ba774291bac
files src/indyvon/async.clj src/indyvon/core.clj src/indyvon/viewport.clj src/indyvon/views.clj
diffstat 4 files changed, 15 insertions(+), 14 deletions(-) [+]
line diff
     1.1 --- a/src/indyvon/async.clj	Fri Sep 18 04:06:43 2015 +0300
     1.2 +++ b/src/indyvon/async.clj	Fri Sep 18 17:40:25 2015 +0300
     1.3 @@ -81,7 +81,7 @@
     1.4    (when (-> (:buffers av)
     1.5              (swap! apply-flip update-in [:front-readers] dec)
     1.6              :flipped)
     1.7 -    (update! av)))
     1.8 +    (notify! av)))
     1.9  
    1.10  (defn- take-back! [av]
    1.11    (-> (:buffers av)
    1.12 @@ -92,7 +92,7 @@
    1.13    (when (-> (:buffers av)
    1.14              (swap! apply-flip assoc :back-ready true)
    1.15              :flipped)
    1.16 -    (update! av)))
    1.17 +    (notify! av)))
    1.18  
    1.19  (defn- draw-offscreen! [async-view]
    1.20    ;;(Thread/sleep 1000)
     2.1 --- a/src/indyvon/core.clj	Fri Sep 18 04:06:43 2015 +0300
     2.2 +++ b/src/indyvon/core.clj	Fri Sep 18 17:40:25 2015 +0300
     2.3 @@ -303,7 +303,7 @@
     2.4    referenced, all associated observers will be removed when the
     2.5    wathcer is removed by gc. The observer fn will be called with
     2.6    watcher and subject arguments and any additional arguments that was
     2.7 -  passed to the update! function."
     2.8 +  passed to the notify! function."
     2.9    [watcher subject f]
    2.10    (cm-swap! observers watcher assoc-cons subject f)
    2.11    nil)
    2.12 @@ -320,7 +320,8 @@
    2.13      (.put observers new-watcher old))
    2.14    nil)
    2.15  
    2.16 -(defn update!
    2.17 +(defn notify!
    2.18 +  "Notify the observers."
    2.19    [subject & args]
    2.20    (doseq [entry observers
    2.21            f (get (val entry) subject)]
    2.22 @@ -333,23 +334,23 @@
    2.23    (add-observer! *scene* subject f))
    2.24  
    2.25  (defn repaint-on-update!
    2.26 -  "Trigger repaint of the current scene when update! is
    2.27 +  "Trigger repaint of the current scene when notify! is
    2.28    called with the subject."
    2.29    [subject]
    2.30    (let [scene *scene*]
    2.31      (if-not (identical? scene subject)
    2.32 -      (add-observer! scene subject (fn [w _] (update! w))))))
    2.33 +      (add-observer! scene subject (fn [w _] (notify! w))))))
    2.34  
    2.35  (defn repaint!
    2.36    "Requests repaint of the current scene. If handle and state are
    2.37    specified, the handle will be associated with the state in the
    2.38    *states* map for the next paint iteration."
    2.39    ([]
    2.40 -     (update! *scene*))
    2.41 +     (notify! *scene*))
    2.42    ([handle state]
    2.43       (let [scene *scene*]
    2.44         (swap! (:next-state scene) assoc handle state)
    2.45 -       (update! scene))))
    2.46 +       (notify! scene))))
    2.47  
    2.48  (defmacro binding-fast
    2.49    "Faster alternative to core/binding. Works only with vars that are
     3.1 --- a/src/indyvon/viewport.clj	Fri Sep 18 04:06:43 2015 +0300
     3.2 +++ b/src/indyvon/viewport.clj	Fri Sep 18 17:40:25 2015 +0300
     3.3 @@ -109,7 +109,7 @@
     3.4                                (- (:y-on-screen e) (:fix-y s)))
     3.5                    :fix-x (:x-on-screen e)
     3.6                    :fix-y (:y-on-screen e))))
     3.7 -       (update! view)]
     3.8 +       (notify! view)]
     3.9        [:mouse-wheel e
    3.10         (scale-viewport!
    3.11          view
    3.12 @@ -160,11 +160,11 @@
    3.13       (scale-viewport! viewport s relative? nil nil))
    3.14    ([viewport s relative? x y]
    3.15       (swap! (:state viewport) scale-viewport viewport s relative? x y)
    3.16 -     (update! viewport)))
    3.17 +     (notify! viewport)))
    3.18  
    3.19  (defn reset-viewport! [viewport]
    3.20    (reset! (:state viewport) viewport-initial-state)
    3.21 -  (update! viewport))
    3.22 +  (notify! viewport))
    3.23  
    3.24  (defn ^AffineTransform viewport-transform [viewport]
    3.25    (:transform @(:state viewport)))
    3.26 @@ -223,7 +223,7 @@
    3.27                            :transform (pre-translate tr (- x) (- y)))))
    3.28              move-vp! (fn [x y]
    3.29                         (swap! (:state viewport) move-vp x y)
    3.30 -                       (update! viewport))]
    3.31 +                       (notify! viewport))]
    3.32          (with-color :alt-back-color
    3.33            (.fillRect *graphics* 0 0 *width* *height*))
    3.34          (with-transform transform
     4.1 --- a/src/indyvon/views.clj	Fri Sep 18 04:06:43 2015 +0300
     4.2 +++ b/src/indyvon/views.clj	Fri Sep 18 17:40:25 2015 +0300
     4.3 @@ -272,7 +272,7 @@
     4.4    (reify
     4.5     ImageObserver
     4.6     (imageUpdate [this img infoflags x y width height]
     4.7 -     (update! view)
     4.8 +     (notify! view)
     4.9       (zero? (bit-and infoflags
    4.10                       (bit-or ImageObserver/ALLBITS
    4.11                               ImageObserver/ABORT))))))
    4.12 @@ -313,7 +313,7 @@
    4.13                 (if-let [view (view-fn @view-ref)]
    4.14                   (geometry view)
    4.15                   (->Size 1 1))))]
    4.16 -     (add-watch view-ref v (fn [_ _ _ _] (update! v)))
    4.17 +     (add-watch view-ref v (fn [_ _ _ _] (notify! v)))
    4.18       v)))
    4.19  
    4.20  ;;