Skip to content

Commit

Permalink
Merge branch 'release/1.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
daveray committed Jun 3, 2011
2 parents 95c3eb0 3043363 commit 3c35433
Show file tree
Hide file tree
Showing 19 changed files with 1,554 additions and 244 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 28,9 @@ Add Seesaw to `project.clj`
:description "FIXME: write"
:dependencies [[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]
[seesaw "1.0.1"]])
[seesaw "x.y.z"]])

_Replace the Seesaw version with whatever the latest version tag is in case I forget to update this. See below!_
_Replace the Seesaw version with whatever the latest version tag is. See below!_

Now edit the generated `src/hello_seesaw/core.clj` file:

Expand All @@ -57,13 57,8 @@ Now run it:

## TODO

* A non-trivial example app to see if this stuff holds up
* GridBagLayout needs more work
* Graphics - I'd rather not wrap the entire Java2D API if there's already something out there (maybe processing?) that does that.
* Structural manip - add/remove widgets to containers.
* Selectors - select widgets by class, data, etc.
* Styling
* Some kind of ToModel protocol for auto-converting Clojure data-structures to Swing models.
* Investigate how a framework like [cljque] (https://github.com/stuartsierra/cljque) might fit in with Seesaw

## License
Expand Down
12 changes: 10 additions & 2 deletions project.clj
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"]]
Expand Down
28 changes: 27 additions & 1 deletion src/seesaw/action.clj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 28,33 @@
:handler #(put-meta! %1 action-handler-property %2)
})

(defn action [& opts]
(defn action
"Construct a new Action object. Supports the following properties:
:enabled? Whether the action is enabled
:selected? Whether the action is selected (for use with radio buttons,
toggle buttons, etc.
:name The name of the action, i.e. the text that will be displayed
in whatever widget it's associated with
:command The action command key. An arbitrary string identifier associated
with the action.
:tip The action's tooltip
:icon The action's icon. See (seesaw.core/icon)
:key A keystroke associated with the action. See (seesaw.keystroke/keystroke).
:handler A single-argument function that performs whatever operations are
associated with the action. The argument is a ActionEvent instance.
Instances of action can be passed to the :action option of most buttons, menu items,
etc.
Actions can be later configured with the same properties above with (seesaw.core/config!).
Returns an instance of javax.swing.Action.
See:
http://download.oracle.com/javase/6/docs/api/javax/swing/Action.html
"
[& opts]
(let [a (proxy [AbstractAction] []
(actionPerformed [e]
(if-let [f (get-meta this action-handler-property)] (f e))))]
Expand Down
37 changes: 37 additions & 0 deletions src/seesaw/bind.clj
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)

Loading

0 comments on commit 3c35433

Please sign in to comment.