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

View file

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

View file

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