Skip to content

Commit

Permalink
Fixed cyclic dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
stathissideris committed Feb 18, 2012
1 parent c968be1 commit 445a60d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/clarity/component.clj
Expand Up @@ -3,8 +3,8 @@
are make and do-component."
:author "Stathis Sideris"}
clarity.component
(:require [clarity.event :as event]
[clarity.util :as util]))
(:require [clarity.util :as util]
[clarity.event :as event]))

(cond (util/clojure-1-2?) (require '[clojure.contrib.str-utils2 :as str])
(util/clojure-1-3?) (require '[clojure.string :as str]))
Expand Down
6 changes: 1 addition & 5 deletions src/clarity/component_make.clj
@@ -1,9 +1,5 @@
(in-ns 'clarity.component)

(ns clarity.style)
(defn apply-stylesheet [_ _])
(in-ns 'clarity.component)

;;; this part of the namespace implements the construction and
;;; manipulation of components

Expand All @@ -27,7 +23,7 @@
(defn event-form? [form]
(if (sequential? form)
(let [[k v] form]
(contains? (into #{} (keys clarity.event/event-map)) k))))
(contains? (into #{} (keys event/event-map)) k))))
;;TODO optimize?

(defn event-form-listener [[k v]]
Expand Down
13 changes: 13 additions & 0 deletions src/clarity/event.clj
Expand Up @@ -197,3 +197,16 @@
;; (:on-mouse-over (.setText button "on"))
;; (:on-mouse-out (.setText button "out"))))
;; (show-comp)))

(defmacro timer
"Creates a javax.swing.Timer with the specified delay, which
executes the code in body at the specified intervals. Delay is in
milliseconds. The timer waits the specified amount of time before
executing the code for the first time, and after that, it continues
executing the code every time the delay time has elapsed."
[delay & body]
`(javax.swing.Timer.
~delay
(event/listener
:action
(:on-action-performed ~@body))))
14 changes: 0 additions & 14 deletions src/clarity/util.clj
@@ -1,5 +1,4 @@
(ns clarity.util
(:require [clarity.event :as event])
(:import [javax.swing SwingUtilities]
[javax.imageio ImageIO]))

Expand Down Expand Up @@ -47,19 +46,6 @@
[& body]
`(do-swing* :now (fn [] ~@body)))

(defmacro timer
"Creates a javax.swing.Timer with the specified delay, which
executes the code in body at the specified intervals. Delay is in
milliseconds. The timer waits the specified amount of time before
executing the code for the first time, and after that, it continues
executing the code every time the delay time has elapsed."
[delay & body]
`(javax.swing.Timer.
~delay
(event/listener
:action
(:on-action-performed ~@body))))

(defn clojure-1-2? []
(and (= 1 (:major *clojure-version*))
(= 2 (:minor *clojure-version*))))
Expand Down

0 comments on commit 445a60d

Please sign in to comment.