changeset 102:fd8fb8a3ff5a

Fixed anchor point calculation, changes in demo/test scene.
author Mikhail Kryshen <mikhail@kryshen.net>
date Wed, 18 May 2011 21:28:24 +0400
parents 9874107e3e96
children 9b81174f0511
files src/net/kryshen/indyvon/core.clj src/net/kryshen/indyvon/demo.clj
diffstat 2 files changed, 12 insertions(+), 9 deletions(-) [+]
line diff
     1.1 --- a/src/net/kryshen/indyvon/core.clj	Wed May 18 20:50:49 2011 +0400
     1.2 +++ b/src/net/kryshen/indyvon/core.clj	Wed May 18 21:28:24 2011 +0400
     1.3 @@ -141,11 +141,11 @@
     1.4      (let [size (layer-size layer)]
     1.5        (Location.
     1.6         (case h-align
     1.7 -             :top 0
     1.8 +             :left 0
     1.9               :center (/ (:width size) 2)
    1.10               :right (:width size))
    1.11         (case v-align
    1.12 -             :left 0
    1.13 +             :top 0
    1.14               :center (/ (:height size) 2)
    1.15               :bottom (:height size))))))
    1.16  
     2.1 --- a/src/net/kryshen/indyvon/demo.clj	Wed May 18 20:50:49 2011 +0400
     2.2 +++ b/src/net/kryshen/indyvon/demo.clj	Wed May 18 21:28:24 2011 +0400
     2.3 @@ -40,7 +40,7 @@
     2.4            color (if (hovered? id) (.brighter color) color)
     2.5            width (- *width* shadow-offset)
     2.6            height (- *height* shadow-offset)]
     2.7 -      (with-color Color/BLACK
     2.8 +      (with-color (:shadow-color *theme*)
     2.9          (.fillRect *graphics* shadow-offset shadow-offset width height))
    2.10        (with-color color
    2.11          (.fillRect *graphics* offset offset width height))
    2.12 @@ -103,7 +103,7 @@
    2.13                         (animate highlight 0.0 1.0 @animation-speed))
    2.14                  width (- *width* shadow-offset)
    2.15                  height (- *height* shadow-offset)]
    2.16 -            (with-color Color/BLACK
    2.17 +            (with-color (:shadow-color *theme*)
    2.18                (.fillRect *graphics*
    2.19                           shadow-offset shadow-offset
    2.20                           width height))
    2.21 @@ -185,9 +185,9 @@
    2.22       (draw! test-layer3 100 100 80 50)
    2.23       (draw! button1 50 160)
    2.24       (with-rotate (/ Math/PI 6) 250 200
    2.25 -       (draw! button1 200 160))
    2.26 -     (draw! button2 50 250)
    2.27 -     (with-bounds 100 200 140 30
    2.28 +       (draw! button1 210 140))
    2.29 +     (draw! button2 100 200)
    2.30 +     (with-bounds 180 240 140 30
    2.31         (draw-button! :button
    2.32          (label "Immediate button" :center :center)
    2.33          #(println "Button clicked!"))))
    2.34 @@ -198,13 +198,17 @@
    2.35  (def vp (viewport root))
    2.36  
    2.37  ;; Miniature (rendered asynchronously)
    2.38 -(def vp-miniature (border (viewport-miniature vp 100 75)))
    2.39 +(def vp-miniature (-> vp (viewport-miniature 100 75) border shadow))
    2.40  
    2.41  ;; Main scene
    2.42  (def scene
    2.43    (fps-layer
    2.44     (decorate-layer vp [_]
    2.45       (draw! vp)
    2.46 +     (draw-anchored!
    2.47 +      (label (str "Drag mouse to pan," \newline
    2.48 +                  "use mouse wheel to zoom."))
    2.49 +      :left :bottom 5 (- *height* 5))
    2.50       (draw! vp-miniature (- *width* 105) 5))))
    2.51  
    2.52  (defn show-frame [layer]
    2.53 @@ -213,7 +217,6 @@
    2.54      (.setVisible true)))
    2.55  
    2.56  (defn -main []
    2.57 -  (println "Try to drag the viewport.")
    2.58    (show-frame scene))
    2.59  
    2.60  (comment