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 diff
1.1 --- a/src/net/kryshen/indyvon/core.clj Tue Apr 03 19:17:28 2012 +0400 1.2 +++ b/src/net/kryshen/indyvon/core.clj Fri Apr 06 18:59:04 2012 +0400 1.3 @@ -42,6 +42,10 @@ 1.4 1.5 (def ^:dynamic ^Shape *clip*) 1.6 1.7 +(def ^:dynamic *clipped* 1.8 + "True value indicates that *clip* is a subset of 1.9 + (Rectangle. 0 0 *width* *height*).") 1.10 + 1.11 (def ^:dynamic *time* 1.12 "Timestamp of the current frame (in nanoseconds).") 1.13 1.14 @@ -318,11 +322,11 @@ 1.15 coordinates (Shape or nil if empty)." 1.16 [x y w h] 1.17 (let [^Graphics2D clip-g (.create *graphics*)] 1.18 - (doto clip-g 1.19 - (.setClip x y w h) 1.20 - (.setTransform *initial-transform*) 1.21 - (.clip *clip*)) 1.22 (try 1.23 + (doto clip-g 1.24 + (.setClip x y w h) 1.25 + (.setTransform *initial-transform*) 1.26 + (.clip *clip*)) 1.27 (if (.isEmpty (.getClipBounds clip-g)) 1.28 nil 1.29 (.getClip clip-g)) 1.30 @@ -352,6 +356,7 @@ 1.31 (.translate graphics (int x) (int y)) 1.32 (binding [*width* w 1.33 *height* h 1.34 + *clipped* false 1.35 *graphics* graphics] 1.36 (apply f args)) 1.37 (finally 1.38 @@ -365,6 +370,7 @@ 1.39 (binding [*width* w 1.40 *height* h 1.41 *clip* clip 1.42 + *clipped* true 1.43 *graphics* graphics] 1.44 (apply f args)) 1.45 (finally 1.46 @@ -543,9 +549,12 @@ 1.47 (handle-hovered? parent handle))) 1.48 1.49 (defn- make-node [handle handlers] 1.50 - (DispatcherNode. handle handlers *event-dispatcher* *clip* 1.51 - (inverse-relative-transform) 1.52 - (get-thread-bindings))) 1.53 + (let [clip (if *clipped* 1.54 + *clip* 1.55 + (clip 0 0 *width* *height*))] 1.56 + (DispatcherNode. handle handlers *event-dispatcher* clip 1.57 + (inverse-relative-transform) 1.58 + (get-thread-bindings)))) 1.59 1.60 (defn- add-node [tree node] 1.61 (assoc-cons tree (:parent node) node)) 1.62 @@ -556,7 +565,8 @@ 1.63 (defn- under-cursor 1.64 "Returns a vector of child nodes under cursor." 1.65 [x y tree node] 1.66 - (some #(if (.contains ^Shape (:clip %) x y) 1.67 + (some #(if (and (:clip %) 1.68 + (.contains ^Shape (:clip %) x y)) 1.69 (conj (vec (under-cursor x y tree %)) %)) 1.70 (get tree node))) 1.71 1.72 @@ -726,7 +736,8 @@ 1.73 *event-dispatcher* (:event-dispatcher scene) 1.74 *width* width 1.75 *height* height 1.76 - *clip* (Rectangle2D$Double. 0 0 width height) 1.77 + *clip* (Rectangle2D$Double. 0.0 0.0 width height) 1.78 + *clipped* true 1.79 *time* (System/nanoTime)] 1.80 (apply-theme) 1.81 (let [tmp-watcher (Object.)]