-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,554 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 1,13 @@ | ||
(defproject seesaw "1.0.4" | ||
:description "A Swing wrapper/DSL for Clojure" | ||
(defproject seesaw "1.0.5" | ||
:description "A Swing wrapper/DSL for Clojure. See http://seesaw-clj.org for more info." | ||
:url "http://seesaw-clj.org" | ||
:mailing-list {:name "seesaw-clj" | ||
:achive "https://groups.google.com/group/seesaw-clj" | ||
:post "[email protected]"} | ||
:license {:name "Eclipse Public License - v 1.0" | ||
:url "http://www.eclipse.org/legal/epl-v10.html" | ||
:distribution :repo | ||
:comments "same as Clojure"} | ||
:warn-on-reflection true | ||
:dependencies [[org.clojure/clojure "1.2.0"] | ||
[com.miglayout/miglayout "3.7.4"]] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,37 @@ | ||
; Copyright (c) Dave Ray, 2011. All rights reserved. | ||
|
||
; The use and distribution terms for this software are covered by the | ||
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) | ||
; which can be found in the file epl-v10.html at the root of this | ||
; distribution. | ||
; By using this software in any fashion, you are agreeing to be bound by | ||
; the terms of this license. | ||
; You must not remove this notice, or any other, from this software. | ||
|
||
(ns seesaw.bind | ||
(:use [seesaw.event])) | ||
|
||
(defn bind-atom-to-range-model | ||
"Connect a BoundedRangeModel to the value of an atom. When the atom is | ||
changed, the model's value is updated and vice versa. BoundedRangeModel | ||
is used by sliders, progress bars, spinners, scrollbars, etc. This is used | ||
by the :value option on these widget types. | ||
See: | ||
http://download.oracle.com/javase/6/docs/api/javax/swing/BoundedRangeModel.html | ||
" | ||
[^clojure.lang.Atom target-atom ^javax.swing.BoundedRangeModel model] | ||
(reset! target-atom (.getValue model)) | ||
(add-watch target-atom (keyword (gensym "bind-atom-to-range-model")) | ||
(fn [k r old-state new-state] | ||
(javax.swing.SwingUtilities/invokeAndWait | ||
(fn [] | ||
(when (not= new-state (.getValue model)) | ||
(.setValue model new-state)))))) | ||
(listen model :change | ||
(fn [e] | ||
(let [new-value (.getValue model)] | ||
(when (not= @target-atom new-value) | ||
(reset! target-atom new-value))))) | ||
target-atom) | ||
|
Oops, something went wrong.