Initial commit. The start of something big...
This commit is contained in:
parent
d915593d1a
commit
17ea235279
10 changed files with 202 additions and 188 deletions
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -1,9 +0,0 @@
|
|||
pom.xml
|
||||
*jar
|
||||
/lib/
|
||||
/classes/
|
||||
/target/
|
||||
.lein-deps-sum
|
||||
*~
|
||||
*class
|
||||
/docs/
|
31
.hgignore
Normal file
31
.hgignore
Normal file
|
@ -0,0 +1,31 @@
|
|||
syntax: glob
|
||||
init-script/
|
||||
target/
|
||||
*.orig
|
||||
*.html
|
||||
*.dot
|
||||
*.iml
|
||||
lib/
|
||||
classes/
|
||||
checkouts/
|
||||
/resources/public/js/frontend.js
|
||||
frontend.min.js
|
||||
tests.js
|
||||
.generated/
|
||||
repl/
|
||||
out/
|
||||
.pom.xml
|
||||
.pom.xml.asc
|
||||
.macrolog.txt
|
||||
*.jar
|
||||
*.class
|
||||
.DS_Store
|
||||
.lein-env
|
||||
.lein-deps-sum
|
||||
.lein-failures
|
||||
.lein-plugins
|
||||
.lein-repl-history
|
||||
.nrepl-history
|
||||
.nrepl-port
|
||||
*~
|
||||
.idea/
|
|
@ -1,12 +0,0 @@
|
|||
(def blahref '{a 1 b 2})
|
||||
(get blahref 'a)
|
||||
(def x (symbol "abc"))
|
||||
(def y (symbol "abc"))
|
||||
(= x y)
|
||||
(split "abc-def" #"-")
|
||||
(use 'clojure.string)
|
||||
(split "abc-def" #"-")
|
||||
(first "bvc")
|
||||
(apply str (list "abc" "Def"))
|
||||
(cons (list 1 2 3) 4)
|
||||
(quit)
|
180
LICENSE
180
LICENSE
|
@ -1,23 +1,165 @@
|
|||
Copyright (c) 2013, Daniel Ziltener
|
||||
All rights reserved.
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
|
|
13
README.md
13
README.md
|
@ -1,4 +1,11 @@
|
|||
clojurefx
|
||||
=========
|
||||
# ClojureFX
|
||||
|
||||
A Clojure JavaFX wrapper. [Documentation can be found here](http://zilti.github.io/clojurefx).
|
||||
A Clojure wrapper to make working with [JavaFX](http://download.java.net/jdk8/jfxdocs/index.html) simpler and more idiomatic.
|
||||
|
||||
## Features
|
||||
|
||||
Nothing yet, but if you give me some time... :)
|
||||
|
||||
## TODO
|
||||
|
||||
Everything.
|
||||
|
|
0
build.boot
Normal file
0
build.boot
Normal file
|
@ -1,3 +0,0 @@
|
|||
# Introduction to clojurefx
|
||||
|
||||
TODO: write [great documentation](http://jacobian.org/writing/great-documentation/what-to-write/)
|
12
project.clj
12
project.clj
|
@ -1,12 +0,0 @@
|
|||
(defproject clojurefx "0.0.3"
|
||||
:description "Helper functions and probably a wrapper to simplify usage of JavaFX in Clojure.
|
||||
|
||||
You'll need to have jfxrt.jar in your local maven repository. See [this coderwall protip](https://coderwall.com/p/4yjy1a) for how to make this happen.
|
||||
|
||||
**Installation: `[clojurefx \"0.0.3\"]`**"
|
||||
:url "https://www.github.com/zilti/clojurefx"
|
||||
:license {:name "Eclipse Public License"
|
||||
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
||||
:dependencies [[org.clojure/clojure "1.5.1"]
|
||||
[com.oracle/javafx-runtime "2.2.0"]]
|
||||
:plugins [[lein-marginalia "0.7.1"]])
|
|
@ -1,121 +0,0 @@
|
|||
(ns clojurefx.core
|
||||
(:require [clojure.string :as str]))
|
||||
|
||||
(defonce force-toolkit-init (javafx.embed.swing.JFXPanel.))
|
||||
|
||||
(defn run-later*"
|
||||
Simple wrapper for Platform/runLater. You should use run-later.
|
||||
" [f]
|
||||
(javafx.application.Platform/runLater f))
|
||||
|
||||
(defmacro run-later [& body]
|
||||
`(run-later* (fn [] ~@body)))
|
||||
|
||||
(defn run-now*"
|
||||
A modification of run-later waiting for the running method to return. You should use run-now.
|
||||
" [f]
|
||||
(if (= "JavaFX Application Thread" (.. Thread currentThread getName))
|
||||
(apply f [])
|
||||
(let [result (promise)]
|
||||
(run-later
|
||||
(deliver result (try (f) (catch Throwable e e))))
|
||||
@result)))
|
||||
|
||||
(defmacro run-now [& body]
|
||||
`(run-now* (fn [] ~@body)))
|
||||
|
||||
(defn- camel [in]
|
||||
(let [in (name in)
|
||||
in (str/split in #"-")
|
||||
in (map #(if (= (str (first %)) (str/upper-case (first %)))
|
||||
% (str/capitalize %)) in)
|
||||
in (conj (into [] in) "Builder")]
|
||||
(apply str in)))
|
||||
|
||||
(defn- get-qualified "
|
||||
An exhaustive list of [everything implementing the builder pattern](http://docs.oracle.com/javafx/2/api/javafx/util/Builder.html). In the future it will be possible to add entries yourself.<br/>
|
||||
Don't use this yourself; See the macros \"build\" and \"deffx\" below.
|
||||
" [builder]
|
||||
(let [pkgs {"javafx.scene.control" '[accordion button cell check-box check-box-tree-item check-menu-item choice-box
|
||||
color-picker combo-box context-menu custom-menu-item hyperlink
|
||||
indexed-cell index-range label list-cell list-view menu-bar menu menu-button menu-item
|
||||
pagination password-field popup-control progress-bar progress-indicator
|
||||
radio-button radio-button-menu-item scroll-bar scroll-pane separator
|
||||
separator-menu-item slider split-menu-button split-pane tab table-cell table-column
|
||||
table-position table-row table-view tab-pane text-area text-field tree-cell
|
||||
titled-pane toggle-button toggle-group tool-bar tooltip tree-item tree-view]
|
||||
"javafx.scene.control.cell" '[check-box-list-cell check-box-table-cell check-box-tree-cell
|
||||
choice-box-list-cell choice-box-table-cell choice-box-tree-cell
|
||||
combo-box-list-cell combo-box-table-cell combo-box-tree-cell
|
||||
text-field-list-cell text-field-table-cell text-field-tree-cell
|
||||
property-value-factory]
|
||||
"javafx.scene.layout" '[anchor border-pane column-constraints flow-pane grid-pane h-box pane region
|
||||
row-constraints stack-pane tile-pane v-box]
|
||||
"javafx.scene.text" '[text font]
|
||||
"javafx.scene.shape" '[arc arc-to circle close-path cubic-curve cubic-curve-to ellipse
|
||||
h-line-to line line-to move-to path polygon polyline quad-curve quad-curve-to
|
||||
rectangle SVG-path b-line-to]
|
||||
"javafx.scene.canvas" '[canvas]
|
||||
"javafx.scene.image" '[image-view]
|
||||
"javafx.scene.input" '[clipboard-content key-character-combination key-code-combination mnemonic]
|
||||
"javafx.scene.effect" '[blend bloom box-blur color-adjust color-input displacement-map dropshadow float-map
|
||||
gaussian-blur glow image-input inner-shadow lighting motion-blur perspective-transform
|
||||
reflection sepia-tone shadow]
|
||||
"javafx.scene.paint" '[color image-pattern linear-gradient radial-gradient stop]
|
||||
"javafx.scene.chart" '[chart area-chart bar-chart line-chart bubble-chart pie-chart scatter-chart
|
||||
stacked-area-chart stacked-bar-chart x-y-chart
|
||||
axis category-axis number-axis value-axis]
|
||||
"javafx.scene.media" '[audio-clip media media-player media-view]
|
||||
"javafx.scene.transform" '[affine rotate scale shear translate]
|
||||
"javafx.scene.web" '[HTML-editor prompt-data web-engine web-view]
|
||||
"javafx.scene" '[scene group image-cursor perspective-camera snapshot-parameters]
|
||||
"javafx.animation" '[fade-transition fill-transition parallel-transition path-transition pause-transition
|
||||
rotate-transition scale-transition sequential-transition stroke-transition timeline
|
||||
translate-transition]
|
||||
"javafx.stage" '[stage directory-chooser file-chooser popup]
|
||||
"javafx.geometry" '[bounding-box dimension-2D insets point-2D point-3D rectangle-2D]
|
||||
"javafx.embed.swt" '[custom-transfer]
|
||||
"javafx.embed.swing" '[JFX-panel-builder]}
|
||||
builder (symbol builder)]
|
||||
(first (filter (comp not nil?) (for [k (keys pkgs)]
|
||||
(if (not (empty? (filter #(= % builder) (get pkgs k))))
|
||||
(symbol (str k "." (camel (name builder))))))))))
|
||||
|
||||
(defmacro build "This helper macro makes it easier to use the [JavaFX builder classes](http://docs.oracle.com/javafx/2/api/javafx/util/Builder.html). You can also use a map, so it is possible to compose the arguments for the builder over time.
|
||||
|
||||
**Examples:**
|
||||
|
||||
* `(build button (text \"Close me.\") (cancelButton true))`
|
||||
* `(build button {:text \"Close me.\" :cancelButton true})`
|
||||
"[what & args]
|
||||
(if (and (= 1 (count args))
|
||||
(map? (first args)))
|
||||
`(build ~what ~@(for [entry# (keys (first args))]
|
||||
`(~(symbol (name entry#)) ~((first args) entry#))))
|
||||
`(run-now (.. ~(get-qualified what) ~(symbol "create")
|
||||
~@args
|
||||
~(symbol "build")))))
|
||||
|
||||
(defmacro deffx "
|
||||
Uses build and assigns the result to a symbol.
|
||||
"[name what & args]
|
||||
`(def ~name
|
||||
(build ~what ~@args)))
|
||||
|
||||
;; ### Event handling
|
||||
(defmacro add-listener "
|
||||
Adds a listener to prop (\"Property\" gets added automatically) of obj, gets the value and passes it to fun.<br/>
|
||||
Example: `(add-listener inputfield focused #(println \"Focus change!\"))`
|
||||
"[obj prop fun]
|
||||
`(.. ~obj
|
||||
~(symbol (str (name prop) "Property"))
|
||||
(addListener (reify javafx.beans.value.ChangeListener
|
||||
(changed [c#]
|
||||
(~fun (.getValue c#)))))))
|
||||
|
||||
(defn event-handler* [f]
|
||||
(reify javafx.event.EventHandler
|
||||
(handle [this e] (f e))))
|
||||
|
||||
(defmacro event-handler [arg & body]
|
||||
`(event-handler* (fn ~arg ~@body)))
|
|
@ -1,9 +0,0 @@
|
|||
(ns clojurefx.core-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[clojurefx.core :refer :all]))
|
||||
|
||||
(deftest runnow
|
||||
(testing "Uses correct thread"
|
||||
(is (= javafx.scene.Scene (type (build scene {})))))
|
||||
(testing "Nested run-nows"
|
||||
(is (= javafx.scene.Scene (type (build scene {:root (build v-box {})}))))))
|
Loading…
Reference in a new issue