Removed core.typed.

This commit is contained in:
Daniel Ziltener 2016-12-17 14:12:45 +00:00
parent e36d84bfb6
commit bf030f500e
4 changed files with 245 additions and 281 deletions

8
project.clj Normal file
View file

@ -0,0 +1,8 @@
(defproject clojurefx "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.8.0"]
[com.taoensso/timbre "4.7.4" :exclusions [com.taoensso/carmine]]
[org.clojure/core.typed "0.3.26"]
[clojure-jsr-223 "0.1.0"]]
:injections [(require 'clojure.core.typed)
(clojure.core.typed/install)]
:profiles {:uberjar {:aot :all}})

View file

@ -1,8 +1,5 @@
1(ns clojurefx.clojurefx 1(ns clojurefx.clojurefx
(:refer-clojure :exclude [atom doseq let fn defn ref dotimes defprotocol loop for send meta with-meta]) (:require [taoensso.timbre :as timbre]
(:require [clojure.core.typed :refer :all]
[clojure.core.typed.unsafe :refer [ignore-with-unchecked-cast]]
[taoensso.timbre :as timbre]
[clojure.java.io :as io] [clojure.java.io :as io]
[clojure.zip :as zip] [clojure.zip :as zip]
[clojurefx.protocols :as p] [clojurefx.protocols :as p]
@ -12,41 +9,39 @@
;; ## Threading helpers ;; ## Threading helpers
(ann run-later* [(Fn [-> Any]) -> nil]) (defn run-later*"
(defn run-later*"
Simple wrapper for Platform/runLater. You should use run-later. Simple wrapper for Platform/runLater. You should use run-later.
" [f] " [f]
(tc-ignore (assert (instance? Runnable f)) (assert (instance? Runnable f))
(javafx.application.Platform/runLater f)) (javafx.application.Platform/runLater f)
nil) nil)
(defmacro run-later [& body] (defmacro run-later [& body]
`(run-later* (fn [] ~@body))) `(run-later* (fn [] ~@body)))
(ann run-now* (All [x] [[-> x] -> x])) (defn run-now* "
(defn run-now* "
A modification of run-later waiting for the running method to return. You should use run-now. A modification of run-later waiting for the running method to return. You should use run-now.
" [f] " [f]
(if (javafx.application.Platform/isFxApplicationThread) (if (javafx.application.Platform/isFxApplicationThread)
(apply f []) (apply f [])
(let [result (promise)] (let [result (promise)]
(run-later (run-later
(deliver result (try (f) (catch Throwable e e)))) (deliver result (try (f) (catch Throwable e e))))
@result))) @result)))
(defmacro run-now " (defmacro run-now "
Runs the code on the FX application thread and waits until the return value is delivered. Runs the code on the FX application thread and waits until the return value is delivered.
" [& body] " [& body]
`(run-now* (fn [] ~@body))) `(run-now* (fn [] ~@body)))
(defn collize " (defn collize "
Turns the input into a collection, if it isn't already. Turns the input into a collection, if it isn't already.
" [input] " [input]
(if (coll? input) (if (coll? input)
input input
(list input))) (list input)))
(tc-ignore (timbre/refer-timbre)) (timbre/refer-timbre)
(import (javafx.scene.control Labeled Label TextField TextArea CheckBox ComboBox Menu MenuItem MenuBar (import (javafx.scene.control Labeled Label TextField TextArea CheckBox ComboBox Menu MenuItem MenuBar
MenuButton ContextMenu ToolBar SplitPane ScrollPane Accordion MenuButton ContextMenu ToolBar SplitPane ScrollPane Accordion
@ -59,217 +54,196 @@ nil)
(javafx.event Event ActionEvent EventTarget) (javafx.event Event ActionEvent EventTarget)
(java.util Collection)) (java.util Collection))
(defn tc-assert [clazz :- Class value :- Any & [message :- String]] (defn pred-protocol [proto check]
(try (assert (instance? clazz value))
(catch AssertionError e (tc-ignore (error (if message message "") e)
(error "Expected:" clazz "Actual:" (type value))
(throw e)))))
(defn pred-protocol [proto :- (HMap :mandatory {:impls (Map Keyword Class)}) check :- Any] :- Boolean
(let [impls (keys (proto :impls)) (let [impls (keys (proto :impls))
check (type check)] check (type check)]
(reduce #(or %1 (isa? check %2)) false impls))) (reduce #(or %1 (isa? check %2)) false impls)))
;;## Shadows ;;## Shadows
(tc-ignore (extend-protocol p/FXMeta
(extend-protocol p/FXMeta clojure.lang.IObj
clojure.lang.IObj (meta [this] (clojure.core/meta this))
(meta [this] (clojure.core/meta this)) (with-meta [this metadata] (clojure.core/with-meta this metadata))
(with-meta [this metadata] (clojure.core/with-meta this metadata)) Node
Node (meta [this] (.getUserData ^Node this))
(meta [this] (.getUserData ^Node this)) (with-meta [this metadata] (.setUserData ^Node this metadata) this)
(with-meta [this metadata] (.setUserData ^Node this metadata) this) MenuItem
MenuItem (meta [this] (.getUserData ^MenuItem this))
(meta [this] (.getUserData ^MenuItem this)) (with-meta [this metadata] (.setUserData ^MenuItem this metadata) this))
(with-meta [this metadata] (.setUserData ^MenuItem this metadata) this)))
;;## Standard ;;## Standard
(tc-ignore (extend-protocol p/FXValue
(extend-protocol p/FXValue Labeled
Labeled (value [this] (.getText ^Label this))
(value [this] (.getText ^Label this)) (set-value! [this value] (.setText ^Label this ^String value) this)
(set-value! [this value] (tc-assert String value) (.setText ^Label this ^String value) this) TextField
TextField (value [this] (.getText ^TextField this))
(value [this] (.getText ^TextField this)) (set-value! [this value] (.setText ^TextField this ^String value) this)
(set-value! [this value] (tc-assert String value) (.setText ^TextField this ^String value) this) TextArea
TextArea (value [this] (.getText ^TextArea this))
(value [this] (.getText ^TextArea this)) (set-value! [this value] (.setText ^TextArea this ^String value) this)
(set-value! [this value] (tc-assert String value) (.setText ^TextArea this ^String value) this) CheckBox
CheckBox (value [this] (.isSelected ^CheckBox this))
(value [this] (.isSelected ^CheckBox this)) (set-value! [this value] (.setSelected ^CheckBox this ^Boolean value) this)
(set-value! [this value] (tc-assert Boolean value) (.setSelected ^CheckBox this ^Boolean value) this) ComboBox
ComboBox (value [this] (let [selection-model (.getSelectionModel ^ComboBox this)
(value [this] (let [selection-model (.getSelectionModel ^ComboBox this) _ (assert (not (nil? selection-model)))
_ (assert (not (nil? selection-model))) index (.getSelectedIndex ^javafx.scene.control.SingleSelectionModel selection-model)]
index (.getSelectedIndex ^javafx.scene.control.SingleSelectionModel selection-model)] (if (>= index 0)
(if (>= index 0) (nth (.getItems ^ComboBox this) index)
(nth (.getItems ^ComboBox this) index) (.getSelectedItem ^javafx.scene.control.SingleSelectionModel selection-model))))
(.getSelectedItem ^javafx.scene.control.SingleSelectionModel selection-model)))) (set-value! [this value] (let [sel-model (.getSelectionModel ^ComboBox this)
(set-value! [this value] (let [sel-model (.getSelectionModel ^ComboBox this) item (first (filter #(= value %) (.getItems ^ComboBox this)))]
item (first (filter #(= value %) (.getItems ^ComboBox this)))] (if-not (nil? item)
(if-not (nil? item) (.select ^javafx.scene.control.SingleSelectionModel sel-model item))) this)
(tc-ignore (.select ^javafx.scene.control.SingleSelectionModel sel-model item)))) this) Menu
Menu (value [this] (.getText ^Menu this))
(value [this] (.getText ^Menu this)) (set-value! [this value] (.setText ^Menu this ^String value) this)
(set-value! [this value] (tc-assert String value) (.setText ^Menu this ^String value) this) MenuItem
MenuItem (value [this] (.getText ^MenuItem this))
(value [this] (.getText ^MenuItem this)) (set-value! [this value] (.setText ^MenuItem this ^String value) this))
(set-value! [this value] (tc-assert String value) (.setText ^MenuItem this ^String value) this)))
(tc-ignore (extend-protocol p/FXId
(extend-protocol p/FXId Styleable
Styleable (id [this] (.getId ^Styleable this))
(id [this] (.getId ^Styleable this)) (set-id! [this id] (.setId ^Styleable this ^String id) this))
(set-id! [this id] (tc-assert String id) (.setId ^Styleable this ^String id) this)))
(tc-ignore (extend-protocol p/FXParent
(extend-protocol p/FXParent Pane
Pane (subnodes [this] (.getChildren ^Pane this))
(subnodes [this] (.getChildren ^Pane this)) (set-subnodes! [this nodes] (.setAll ^ObservableList (.getChildren ^Pane this) (collize nodes)) this)
(set-subnodes! [this nodes] (.setAll ^ObservableList (.getChildren ^Pane this) (collize nodes)) this) TabPane
TabPane (subnodes [this] (.getTabs ^TabPane this))
(subnodes [this] (.getTabs ^TabPane this)) (set-subnodes! [this nodes] (.setAll ^ObservableList (.getTabs ^TabPane this) (collize nodes)) this)
(set-subnodes! [this nodes] (.setAll ^ObservableList (.getTabs ^TabPane this) (collize nodes)) this) MenuBar
MenuBar (subnodes [this] (.getMenus ^MenuBar this))
(subnodes [this] (.getMenus ^MenuBar this)) (set-subnodes! [this nodes] (.setAll ^ObservableList (.getMenus ^MenuBar this) (collize nodes)) this)
(set-subnodes! [this nodes] (.setAll ^ObservableList (.getMenus ^MenuBar this) (collize nodes)) this) Menu
Menu (subnodes [this] (.getItems ^Menu this))
(subnodes [this] (.getItems ^Menu this)) (set-subnodes! [this nodes] (.setAll ^ObservableList (.getItems ^Menu this) nodes) (collize this))
(set-subnodes! [this nodes] (.setAll ^ObservableList (.getItems ^Menu this) nodes) (collize this)) MenuButton
MenuButton (subnodes [this] (.getItems ^MenuButton this))
(subnodes [this] (.getItems ^MenuButton this)) (set-subnodes! [this nodes] (.setAll ^ObservableList (.getItems ^MenuButton this) (collize nodes)) this)
(set-subnodes! [this nodes] (.setAll ^ObservableList (.getItems ^MenuButton this) (collize nodes)) this) ContextMenu
ContextMenu (subnodes [this] (.getItems ^ContextMenu this))
(subnodes [this] (.getItems ^ContextMenu this)) (set-subnodes! [this nodes] (.setAll ^ObservableList (.getItems ^ContextMenu this) (collize nodes)) this)
(set-subnodes! [this nodes] (.setAll ^ObservableList (.getItems ^ContextMenu this) (collize nodes)) this) ToolBar
ToolBar (subnodes [this] (.getItems ^ToolBar this))
(subnodes [this] (.getItems ^ToolBar this)) (set-subnodes! [this nodes] (.setAll ^ObservableList (.getItems ^ToolBar this) (collize nodes)) this)
(set-subnodes! [this nodes] (.setAll ^ObservableList (.getItems ^ToolBar this) (collize nodes)) this) SplitPane
SplitPane (subnodes [this] (.getItems ^SplitPane this))
(subnodes [this] (.getItems ^SplitPane this)) (set-subnodes! [this nodes] (.setAll ^ObservableList (.getItems ^SplitPane this) (collize nodes)) this)
(set-subnodes! [this nodes] (.setAll ^ObservableList (.getItems ^SplitPane this) (collize nodes)) this) Accordion
Accordion (subnodes [this] (.getPanes ^Accordion this))
(subnodes [this] (.getPanes ^Accordion this)) (set-subnodes! [this nodes] (.setAll ^ObservableList (.getPanes ^Accordion this) (collize nodes)) this))
(set-subnodes! [this nodes] (.setAll ^ObservableList (.getPanes ^Accordion this) (collize nodes)) this)))
(tc-ignore (extend-protocol p/FXContainer
(extend-protocol p/FXContainer Tab
Tab (content [this] (.getContent ^Tab this))
(content [this] (.getContent ^Tab this)) (set-content! [this node] (.setContent ^Tab this ^Node node) this)
(set-content! [this node] (.setContent ^Tab this ^Node node) this) TitledPane
TitledPane (content [this] (.getContent ^TitledPane this))
(content [this] (.getContent ^TitledPane this)) (set-content! [this node] (.setContent ^TitledPane this ^Node node) this)
(set-content! [this node] (.setContent ^TitledPane this ^Node node) this) ScrollPane
ScrollPane (content [this] (.getContent ^ScrollPane this))
(content [this] (.getContent ^ScrollPane this)) (set-content! [this node] (.setContent ^ScrollPane this ^Node node) this))
(set-content! [this node] (.setContent ^ScrollPane this ^Node node) this)))
(tc-ignore (extend-protocol p/FXGraphic
(extend-protocol p/FXGraphic Labeled
Labeled (graphic [this] (.getGraphic ^Labeled this))
(graphic [this] (.getGraphic ^Labeled this)) (set-graphic! [this graphic] (.setGraphic ^Labeled this ^Node graphic))
(set-graphic! [this graphic] (.setGraphic ^Labeled this ^Node graphic)) MenuItem
MenuItem (graphic [this] (.getGraphic ^Menu this))
(graphic [this] (.getGraphic ^Menu this)) (set-graphic! [this graphic] (.setGraphic ^Menu this ^Node graphic)))
(set-graphic! [this graphic] (.setGraphic ^Menu this ^Node graphic))))
(tc-ignore (extend-protocol p/FXStyleSetter
(extend-protocol p/FXStyleSetter Node
Node (set-style! [this style] (.setStyle ^Node this ^String style) this)
(set-style! [this style] (.setStyle ^Node this ^String style) this) MenuItem
MenuItem (set-style! [this style] (.setStyle ^MenuItem this ^String style) this))
(set-style! [this style] (.setStyle ^MenuItem this ^String style) this)))
(tc-ignore (extend-type Styleable
(extend-type Styleable p/FXStyleable
p/FXStyleable (css-meta [this] (.getCssMetaData ^Styleable this))
(css-meta [this] (.getCssMetaData ^Styleable this)) (pseudo-class-styles [this] (.getPseudoClassStyles ^Styleable this))
(pseudo-class-styles [this] (.getPseudoClassStyles ^Styleable this)) (style [this] (.getStyle ^Styleable this))
(style [this] (.getStyle ^Styleable this)) (style-classes [this] (.getStyleClass ^Styleable this))
(style-classes [this] (.getStyleClass ^Styleable this)) (set-style-classes! [this classes] (.setAll ^ObservableList (.getStyleClass ^Styleable this) classes) this)
(set-style-classes! [this classes] (.setAll ^ObservableList (.getStyleClass ^Styleable this) classes) this) (styleable-parent [this] (.getStyleableParent ^Styleable this))
(styleable-parent [this] (.getStyleableParent ^Styleable this)) (type-selector [this] (.getTypeSelector ^Styleable this)))
(type-selector [this] (.getTypeSelector ^Styleable this))))
(declare bind-event) (declare bind-event)
(tc-ignore (extend-protocol p/FXOnAction
(extend-protocol p/FXOnAction ButtonBase
ButtonBase (action [this] (.getOnAction ^ButtonBase this))
(action [this] (.getOnAction ^ButtonBase this)) (set-action! [this action] (.setOnAction ^ButtonBase this (bind-event action)) this)
(set-action! [this action] (.setOnAction ^ButtonBase this (bind-event action)) this) (fire! [this] (.fire this))
(fire! [this] (.fire this)) MenuItem
MenuItem (action [this] (.getOnAction ^MenuItem this))
(action [this] (.getOnAction ^MenuItem this)) (set-action! [this action] (.setOnAction ^ButtonBase this (bind-event action)) this)
(set-action! [this action] (.setOnAction ^ButtonBase this (bind-event action)) this) (fire! [this] (.fire this)))
(fire! [this] (.fire this))))
;;## Special Types ;;## Special Types
;;### javafx.event ;;### javafx.event
(tc-ignore (extend-type Event
(extend-type Event p/FXEvent
p/FXEvent (source [this] (.getSource ^Event this))
(source [this] (.getSource ^Event this)) (consume! [this] (.consume ^Event this) this)
(consume! [this] (.consume ^Event this) this) (copy [this new-src new-target] (.copy ^Event this new-src new-target))
(copy [this new-src new-target] (.copy ^Event this new-src new-target)) (event-type [this] (.getEventType this))
(event-type [this] (.getEventType this)) (target [this] (.getTarget this))
(target [this] (.getTarget this)) (consumed? [this] (.isConsumed this)))
(consumed? [this] (.isConsumed this))))
;;### javafx.stage ;;### javafx.stage
(tc-ignore (extend-type Stage
(extend-type Stage p/FXStage
p/FXStage (title [this] (.getTitle ^Stage this))
(title [this] (.getTitle ^Stage this)) (set-title! [this title] (.setTitle ^Stage this ^String title))
(set-title! [this title] (.setTitle ^Stage this ^String title)) (scene [this] (.getScene ^Stage this))
(scene [this] (.getScene ^Stage this)) (set-scene! [this scene] (.setScene ^Stage this ^Scene scene)))
(set-scene! [this scene] (.setScene ^Stage this ^Scene scene))))
;;### javafx.scene ;;### javafx.scene
(tc-ignore (extend-type Scene
(extend-type Scene p/FXScene
p/FXScene (root [this] (.getRoot ^Scene this))
(root [this] (.getRoot ^Scene this)) (set-root! [this root] (.setRoot ^Scene this ^Parent root) this))
(set-root! [this root] (.setRoot ^Scene this ^Parent root) this)))
;;## Event handling helper ;;## Event handling helper
(tc-ignore (defn bind-event
(defn bind-event [handler]
[handler :- (All [[A :variance :covariant :< Event]] (Fn [A -> Any]))] :- javafx.event.EventHandler (reify javafx.event.EventHandler
(reify javafx.event.EventHandler (handle [_ event] (handler event))))
(handle [_ event] (handler event)))))
;;## IdMapper ;;## IdMapper
(defn fxzipper [root] (defn fxzipper [root]
(zip/zipper (fn branch? [node :- Any] :- Boolean (zip/zipper (fn branch? [node]
(or (pred-protocol p/FXParent node) (pred-protocol p/FXContainer node))) (or (pred-protocol p/FXParent node) (pred-protocol p/FXContainer node)))
(fn children [node :- (U p/FXParent p/FXContainer)] :- java.util.List (fn children [node]
(if (pred-protocol p/FXParent node) (if (pred-protocol p/FXParent node)
(into [] (p/subnodes node)) (into [] (p/subnodes node))
[(p/content node)])) [(p/content node)]))
(fn make-node [node :- (U p/FXParent p/FXContainer) children :- Any] :- (U p/FXParent p/FXContainer) (fn make-node [node children]
(if (pred-protocol p/FXParent node) (if (pred-protocol p/FXParent node)
(p/set-subnodes! node children) (p/set-subnodes! node children)
(p/set-content! node children))) (p/set-content! node children)))
root)) root))
(tc-ignore (defn get-node-by-id [graph id]
(defn get-node-by-id [graph id] (loop [zipper (fxzipper graph)]
(loop [zipper (fxzipper graph)] (cond (zip/end? zipper) nil
(cond (zip/end? zipper) nil (= (p/id (zip/node zipper)) (name id)) (zip/node zipper)
(= (p/id (zip/node zipper)) (name id)) (zip/node zipper) :else (recur (zip/next zipper)))))
:else (recur (zip/next zipper))))))
(tc-ignore (defn get-id-map [graph]
(defn get-id-map [graph] (loop [zipper (fxzipper graph)
(loop [zipper (fxzipper graph) ids {}]
ids {}] (if (zip/end? zipper)
(if (zip/end? zipper) ids
ids (recur (zip/next zipper)
(recur (zip/next zipper) (assoc ids (keyword (p/id (zip/node zipper))) (zip/node zipper))))))
(assoc ids (keyword (p/id (zip/node zipper))) (zip/node zipper)))))))

View file

@ -1,18 +1,15 @@
(ns clojurefx.factory (ns clojurefx.factory
(:refer-clojure :exclude [atom doseq let fn defn ref dotimes defprotocol loop for send compile meta with-meta]) (:require [taoensso.timbre :as timbre]
(:require [clojure.core.typed :refer :all]
[clojure.core.typed.unsafe :refer [ignore-with-unchecked-cast]]
[taoensso.timbre :as timbre]
[clojure.java.io :as io] [clojure.java.io :as io]
[clojurefx.clojurefx :as fx] [clojurefx.clojurefx :as fx]
[clojurefx.protocols :refer :all]) [clojurefx.protocols :refer :all])
(:import (javafx.scene Scene Node Parent))) (:import (javafx.scene Scene Node Parent)))
(tc-ignore (timbre/refer-timbre)) (timbre/refer-timbre)
;;## FXMLLoader ;;## FXMLLoader
(defn load-fxml [filename :- String] :- javafx.scene.Node (defn load-fxml [filename]
(let [loader (new javafx.fxml.FXMLLoader)] (let [loader (new javafx.fxml.FXMLLoader)]
(.setLocation loader (io/resource "")) (.setLocation loader (io/resource ""))
(.load loader (-> filename io/resource io/input-stream)))) (.load loader (-> filename io/resource io/input-stream))))
@ -22,7 +19,6 @@
(def getter first) (def getter first)
(def setter second) (def setter second)
(ann translation-map (Atom1 (Map Keyword (Vec clojure.lang.Var))))
(def translation-map (def translation-map
(atom {;;; FXValue (atom {;;; FXValue
:text (with-meta [#'value #'set-value!] {:argument String :parent FXValue}) :text (with-meta [#'value #'set-value!] {:argument String :parent FXValue})
@ -49,7 +45,6 @@
(atom {javafx.scene.Scene [:root]})) (atom {javafx.scene.Scene [:root]}))
(declare compile-o-matic) (declare compile-o-matic)
(ann apply-props-to-node [Any (Map Keyword Any) -> Any])
(defn apply-props-to-node [node props] (defn apply-props-to-node [node props]
(doseq [[k v] props] (doseq [[k v] props]
(let [translation (get @translation-map k) (let [translation (get @translation-map k)
@ -65,7 +60,6 @@
((setter translation) node v))) ((setter translation) node v)))
node) node)
(ann build-node [Any (Map Keyword Any) -> Any])
(defn build-node [object props] (defn build-node [object props]
(debug "build-node:" object props) (debug "build-node:" object props)
(let [mandatory (get mandatory-constructor-args object) (let [mandatory (get mandatory-constructor-args object)
@ -87,7 +81,6 @@
;; (string? thing) (recur (symbol thing)) ;; (string? thing) (recur (symbol thing))
;; :else thing)) ;; :else thing))
(ann compile [(Vec Any) -> Any])
(defn compile (defn compile
([args] (compile args [])) ([args] (compile args []))
([[obj & other] accu] ([[obj & other] accu]
@ -98,7 +91,6 @@
(class? obj) (recur (rest other) (conj accu (build-node obj (first other)))) (class? obj) (recur (rest other) (conj accu (build-node obj (first other))))
:else (recur other (conj accu obj))))) :else (recur other (conj accu obj)))))
(ann compile-o-matic [Any -> Any])
(defn compile-o-matic [thing] (defn compile-o-matic [thing]
(if (instance? java.util.List thing) (if (instance? java.util.List thing)
(if (and (not (coll? (first thing))) (map? (second thing))) (if (and (not (coll? (first thing))) (map? (second thing)))

View file

@ -1,101 +1,91 @@
(ns clojurefx.protocols (ns clojurefx.protocols)
(:refer-clojure :exclude [atom doseq let fn defn ref dotimes defprotocol loop for send meta with-meta])
(:require [clojure.core.typed :refer :all]))
;;## Shadows ;;## Shadows
(defprotocol [[A :variance :covariant]] (defprotocol
FXMeta FXMeta
(meta [this :- A] :- (Map Any Any)) (meta [this])
(with-meta [this :- A metadata :- (Map Any Any)] :- A)) (with-meta [this metadata]))
;;## Standard ;;## Standard
(declare-protocols FXValue FXId FXParent) ;; (declare-protocols FXValue FXId FXParent)
(defprotocol [[A :variance :covariant] (defprotocol
[B :variance :covariant]] FXValue
FXValue (value [this])
(value [this :- A] :- B) (set-value! [this value]))
(set-value! [this :- A value :- B] :- A))
(defprotocol [[A :variance :covariant] (defprotocol
[x :variance :covariant]] FXId
FXId (id [this])
(id [this :- A] :- (U nil String)) (set-id! [this id]))
(set-id! [this :- A id :- String] :- A))
(defalias FXElement (U FXValue FXId)) ;; (defalias FXElement (U FXValue FXId))
(defprotocol [[A :variance :covariant] (defprotocol
[B :variance :covariant :< Seqable]] FXParent
FXParent
"The ClojureFX extension to javafx.scene.Parent." "The ClojureFX extension to javafx.scene.Parent."
(subnodes [this :- A] :- B) (subnodes [this])
(set-subnodes! [this :- A nodes :- B] :- A)) (set-subnodes! [this nodes]))
(defprotocol [[A :variance :covariant] (defprotocol
[B :variance :covariant]] FXContainer
FXContainer (content [this])
(content [this :- A] :- B) (set-content! [this node]))
(set-content! [this :- A node :- B] :- A))
(defprotocol [[A :variance :covariant] (defprotocol
[B :variance :covariant :< javafx.scene.Node]] FXGraphic
FXGraphic (graphic [this])
(graphic [this :- A] :- B) (set-graphic! [this graphic]))
(set-graphic! [this :- A graphic :- B] :- A))
(defprotocol [[A :variance :covariant :< javafx.css.Styleable] (defprotocol
[B :variance :covariant :< javafx.css.Styleable]] FXStyleable
FXStyleable
"http://download.java.net/jdk8/jfxdocs/javafx/css/Styleable.html" "http://download.java.net/jdk8/jfxdocs/javafx/css/Styleable.html"
(css-meta [this :- A] :- (java.util.List javafx.css.CssMetaData)) ;; TODO (css-meta [this]) ;; TODO
(pseudo-class-styles [this :- A] :- (javafx.collections.ObservableSet javafx.css.PseudoClass)) (pseudo-class-styles [this])
(style [this :- A] :- String) (style [this])
(style-classes [this :- A] :- (javafx.collections.ObservableList String)) (style-classes [this])
(set-style-classes! [this :- A classes :- java.util.Collection] :- A) (set-style-classes! [this classes])
(styleable-parent [this :- A] :- (U nil B)) (styleable-parent [this])
(type-selector [this :- A] :- String)) (type-selector [this]))
(defprotocol [[A :variance :covariant]] (defprotocol
FXStyleSetter FXStyleSetter
(set-style! [this :- A style :- String] :- A)) (set-style! [this style]))
(defalias FXStyled (U FXStyleable FXStyleSetter)) ;; (defalias FXStyled (U FXStyleable FXStyleSetter))
(defprotocol [[A :variance :covariant]] (defprotocol
FXOnAction FXOnAction
(action [this :- A] :- [javafx.event.EventHandler -> Any]) (action [this])
(set-action! [this :- A action :- [javafx.event.EventHandler -> Any]] :- A) (set-action! [this action])
(fire! [this :- A] :- nil)) (fire! [this]))
;;## Special Types ;;## Special Types
;;### javafx.event ;;### javafx.event
(defprotocol [[A :variance :covariant :< javafx.event.Event]] (defprotocol
FXEvent FXEvent
(source [this :- A] :- Any) (source [this])
(consume! [this :- A] :- A) (consume! [this])
(copy [this :- A newSource :- Object newTarget :- javafx.event.EventTarget] :- A) (copy [this newSource newTarget])
(event-type [this :- A] :- javafx.event.EventType) (event-type [this])
(target [this :- A] :- javafx.event.EventTarget) (target [this])
(consumed? [this :- A] :- Boolean)) (consumed? [this]))
;;### javafx.stage ;;### javafx.stage
(defprotocol [[A :variance :covariant :< javafx.stage.Stage] (defprotocol
[B :variance :covariant :< javafx.scene.Scene]] FXStage
FXStage (title [this])
(title [this :- A] :- String) (set-title! [this title])
(set-title! [this :- A title :- String] :- A) (scene [this])
(scene [this :- A] :- B) (set-scene! [this scene]))
(set-scene! [this :- A scene :- B] :- A))
;;### javafx.scene ;;### javafx.scene
(defprotocol [[A :variance :covariant :< javafx.scene.Scene] (defprotocol
[B :variance :covariant :< javafx.scene.Parent]] FXScene
FXScene (root [this])
(root [this :- A] :- B) (set-root! [this root]))
(set-root! [this :- A root :- B] :- A))