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 wrap: on
line diff
--- a/src/indyvon/async.clj	Fri Sep 18 04:06:43 2015 +0300
+++ b/src/indyvon/async.clj	Fri Sep 18 17:40:25 2015 +0300
@@ -81,7 +81,7 @@
   (when (-> (:buffers av)
             (swap! apply-flip update-in [:front-readers] dec)
             :flipped)
-    (update! av)))
+    (notify! av)))
 
 (defn- take-back! [av]
   (-> (:buffers av)
@@ -92,7 +92,7 @@
   (when (-> (:buffers av)
             (swap! apply-flip assoc :back-ready true)
             :flipped)
-    (update! av)))
+    (notify! av)))
 
 (defn- draw-offscreen! [async-view]
   ;;(Thread/sleep 1000)
--- a/src/indyvon/core.clj	Fri Sep 18 04:06:43 2015 +0300
+++ b/src/indyvon/core.clj	Fri Sep 18 17:40:25 2015 +0300
@@ -303,7 +303,7 @@
   referenced, all associated observers will be removed when the
   wathcer is removed by gc. The observer fn will be called with
   watcher and subject arguments and any additional arguments that was
-  passed to the update! function."
+  passed to the notify! function."
   [watcher subject f]
   (cm-swap! observers watcher assoc-cons subject f)
   nil)
@@ -320,7 +320,8 @@
     (.put observers new-watcher old))
   nil)
 
-(defn update!
+(defn notify!
+  "Notify the observers."
   [subject & args]
   (doseq [entry observers
           f (get (val entry) subject)]
@@ -333,23 +334,23 @@
   (add-observer! *scene* subject f))
 
 (defn repaint-on-update!
-  "Trigger repaint of the current scene when update! is
+  "Trigger repaint of the current scene when notify! is
   called with the subject."
   [subject]
   (let [scene *scene*]
     (if-not (identical? scene subject)
-      (add-observer! scene subject (fn [w _] (update! w))))))
+      (add-observer! scene subject (fn [w _] (notify! w))))))
 
 (defn repaint!
   "Requests repaint of the current scene. If handle and state are
   specified, the handle will be associated with the state in the
   *states* map for the next paint iteration."
   ([]
-     (update! *scene*))
+     (notify! *scene*))
   ([handle state]
      (let [scene *scene*]
        (swap! (:next-state scene) assoc handle state)
-       (update! scene))))
+       (notify! scene))))
 
 (defmacro binding-fast
   "Faster alternative to core/binding. Works only with vars that are
--- a/src/indyvon/viewport.clj	Fri Sep 18 04:06:43 2015 +0300
+++ b/src/indyvon/viewport.clj	Fri Sep 18 17:40:25 2015 +0300
@@ -109,7 +109,7 @@
                               (- (:y-on-screen e) (:fix-y s)))
                   :fix-x (:x-on-screen e)
                   :fix-y (:y-on-screen e))))
-       (update! view)]
+       (notify! view)]
       [:mouse-wheel e
        (scale-viewport!
         view
@@ -160,11 +160,11 @@
      (scale-viewport! viewport s relative? nil nil))
   ([viewport s relative? x y]
      (swap! (:state viewport) scale-viewport viewport s relative? x y)
-     (update! viewport)))
+     (notify! viewport)))
 
 (defn reset-viewport! [viewport]
   (reset! (:state viewport) viewport-initial-state)
-  (update! viewport))
+  (notify! viewport))
 
 (defn ^AffineTransform viewport-transform [viewport]
   (:transform @(:state viewport)))
@@ -223,7 +223,7 @@
                           :transform (pre-translate tr (- x) (- y)))))
             move-vp! (fn [x y]
                        (swap! (:state viewport) move-vp x y)
-                       (update! viewport))]
+                       (notify! viewport))]
         (with-color :alt-back-color
           (.fillRect *graphics* 0 0 *width* *height*))
         (with-transform transform
--- a/src/indyvon/views.clj	Fri Sep 18 04:06:43 2015 +0300
+++ b/src/indyvon/views.clj	Fri Sep 18 17:40:25 2015 +0300
@@ -272,7 +272,7 @@
   (reify
    ImageObserver
    (imageUpdate [this img infoflags x y width height]
-     (update! view)
+     (notify! view)
      (zero? (bit-and infoflags
                      (bit-or ImageObserver/ALLBITS
                              ImageObserver/ABORT))))))
@@ -313,7 +313,7 @@
                (if-let [view (view-fn @view-ref)]
                  (geometry view)
                  (->Size 1 1))))]
-     (add-watch view-ref v (fn [_ _ _ _] (update! v)))
+     (add-watch view-ref v (fn [_ _ _ _] (notify! v)))
      v)))
 
 ;;