Mercurial > hg > indyvon
changeset 86:069ea63803a2
Correctly highlight visible area in viewport miniature.
author | Mikhail Kryshen <mikhail@kryshen.net> |
---|---|
date | Wed, 06 Oct 2010 18:08:21 +0400 |
parents | e718a69f7d99 |
children | beb89bd18839 |
files | src/net/kryshen/indyvon/layers.clj |
diffstat | 1 files changed, 13 insertions(+), 8 deletions(-) [+] |
line diff
1.1 --- a/src/net/kryshen/indyvon/layers.clj Fri Oct 01 18:45:17 2010 +0400 1.2 +++ b/src/net/kryshen/indyvon/layers.clj Wed Oct 06 18:08:21 2010 +0400 1.3 @@ -220,8 +220,10 @@ 1.4 width height)) 1.5 1.6 (defrecord Viewport [content h-align v-align 1.7 - ;; state (refs) 1.8 - x y fix-x fix-y last-width last-height] 1.9 + ;; State (refs) 1.10 + ;; TODO: group into data structures. 1.11 + x y fix-x fix-y last-width last-height 1.12 + vp-x vp-y] 1.13 Layer 1.14 (render! [layer] 1.15 (repaint-on-update layer) 1.16 @@ -231,9 +233,11 @@ 1.17 (alter x + (align-x *width* @last-width h-align)) 1.18 (alter y + (align-y *height* @last-height v-align)) 1.19 (ref-set last-width *width*) 1.20 - (ref-set last-height *height*)) 1.21 + (ref-set last-height *height*) 1.22 + (ref-set vp-x (+ @x (:x anchor))) 1.23 + (ref-set vp-y (+ @y (:y anchor)))) 1.24 ;; TODO: notify observers when size changes. 1.25 - (draw! content (- 0 @x (:x anchor)) (- 0 @y (:y anchor)))) 1.26 + (draw! content (- @vp-x) (- @vp-y))) 1.27 (:mouse-pressed e 1.28 (dosync 1.29 (ref-set fix-x (:x-on-screen e)) 1.30 @@ -260,13 +264,14 @@ 1.31 (Viewport. content h-align v-align 1.32 (ref 0) (ref 0) ; x y 1.33 (ref 0) (ref 0) ; fix-x fix-y 1.34 - (ref 0) (ref 0)))) ; last-width last-height 1.35 + (ref 0) (ref 0) ; last-width last-height 1.36 + (ref 0) (ref 0)))) ; vp-x vp-y 1.37 1.38 (defn- viewport-visible-bounds 1.39 - [viewport] 1.40 + [vp] 1.41 (dosync 1.42 - [@(:x viewport) @(:y viewport) 1.43 - @(:last-width viewport) @(:last-height viewport)])) 1.44 + [@(:vp-x vp) @(:vp-y vp) 1.45 + @(:last-width vp) @(:last-height vp)])) 1.46 1.47 (defn viewport-miniature 1.48 "Creates miniature view of the viewport's contents."