Mercurial > hg > indyvon
changeset 121:b5ac04d5fc8a
Drawing a layer without clipping still sets clip for pointer events.
author | Mikhail Kryshen <mikhail@kryshen.net> |
---|---|
date | Fri, 06 Apr 2012 18:59:04 +0400 |
parents | 87ebc46cc66d |
children | 17aa55059b07 |
files | src/net/kryshen/indyvon/core.clj |
diffstat | 1 files changed, 20 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/net/kryshen/indyvon/core.clj Tue Apr 03 19:17:28 2012 +0400 +++ b/src/net/kryshen/indyvon/core.clj Fri Apr 06 18:59:04 2012 +0400 @@ -42,6 +42,10 @@ (def ^:dynamic ^Shape *clip*) +(def ^:dynamic *clipped* + "True value indicates that *clip* is a subset of + (Rectangle. 0 0 *width* *height*).") + (def ^:dynamic *time* "Timestamp of the current frame (in nanoseconds).") @@ -318,11 +322,11 @@ coordinates (Shape or nil if empty)." [x y w h] (let [^Graphics2D clip-g (.create *graphics*)] - (doto clip-g - (.setClip x y w h) - (.setTransform *initial-transform*) - (.clip *clip*)) (try + (doto clip-g + (.setClip x y w h) + (.setTransform *initial-transform*) + (.clip *clip*)) (if (.isEmpty (.getClipBounds clip-g)) nil (.getClip clip-g)) @@ -352,6 +356,7 @@ (.translate graphics (int x) (int y)) (binding [*width* w *height* h + *clipped* false *graphics* graphics] (apply f args)) (finally @@ -365,6 +370,7 @@ (binding [*width* w *height* h *clip* clip + *clipped* true *graphics* graphics] (apply f args)) (finally @@ -543,9 +549,12 @@ (handle-hovered? parent handle))) (defn- make-node [handle handlers] - (DispatcherNode. handle handlers *event-dispatcher* *clip* - (inverse-relative-transform) - (get-thread-bindings))) + (let [clip (if *clipped* + *clip* + (clip 0 0 *width* *height*))] + (DispatcherNode. handle handlers *event-dispatcher* clip + (inverse-relative-transform) + (get-thread-bindings)))) (defn- add-node [tree node] (assoc-cons tree (:parent node) node)) @@ -556,7 +565,8 @@ (defn- under-cursor "Returns a vector of child nodes under cursor." [x y tree node] - (some #(if (.contains ^Shape (:clip %) x y) + (some #(if (and (:clip %) + (.contains ^Shape (:clip %) x y)) (conj (vec (under-cursor x y tree %)) %)) (get tree node))) @@ -726,7 +736,8 @@ *event-dispatcher* (:event-dispatcher scene) *width* width *height* height - *clip* (Rectangle2D$Double. 0 0 width height) + *clip* (Rectangle2D$Double. 0.0 0.0 width height) + *clipped* true *time* (System/nanoTime)] (apply-theme) (let [tmp-watcher (Object.)]