zilti / clojurefx

A Clojure JavaFX wrapper.
Eclipse Public License 1.0
58 stars 7 forks source link

I am rather new both to github and clojure #10

Closed JacobGood1 closed 6 years ago

JacobGood1 commented 11 years ago

I made some changes to your code(btw thanks for this) and I wondered what you thought about them.

First , extremely arbitrary change, I renamed fx to make(I think that the names should be more generic reflecting what they do).

I changed the construct node so that we could use a :cons key. :cons stands for constructor, I thought it might be nice to do things like this...

(make image :cons ["http://static.giantbomb.com/uploads/original/0/26/9780-itsahim.JPG" true] :height 100 :width 1000)

It can be passed a single argument or an array of args.

I would like to be able to contribute, I am a neophyte but I will be trying to use javafx a good bit...

zilti commented 10 years ago

First , extremely arbitrary change, I renamed fx to make(I think that the names should be more generic reflecting what they do).

Thanks for the input - for now, I'll leave it at fx and will consider creating make as an alias.

I changed the construct node so that we could use a :cons key. :cons stands for constructor, I thought it might be nice to do things like this...

(make image :cons ["http://static.giantbomb.com/uploads/original/0/26/9780-itsahim.JPG" true] :height 100 :width 1000)

It can be passed a single argument or an array of args.

Right now I don't really see any use for this except additional syntax. Arguments necessary for a constructor are extracted from the named-argument-list and used in the constructor. The keys for this arguments follow the same naming conventions as the keys for the other setters.

I would like to be able to contribute, I am a neophyte but I will be trying to use javafx a good bit...

Feel free to clone this repo and send me a pull request whenever you feel like a change is ready to get included. And welcome!

JacobGood1 commented 10 years ago

Thanks for the reply!

Well, the reason I made the cons thing is because i wanted to use fx like this...

(fx image :cons "url")

I did not know how to make it work without the constructor arguement, maybe I am missing something(which is def possible im a nublet)?

Here is the small change I made...

(defmethod construct-node :default [class args](if %28args :cons%29 %28let [temp %28args :cons%29] %28if %28coll? temp%29 %28run-now %28eval %28new ~class ~@temp%29%29%29 %28run-now %28eval%28new ~class ~temp%29%29%29%29%29 %28run-now %28eval `%28new ~class%29%29%29))

So both of these work...

(fx image :cons "url")

(fx image :cons ["url" true]) ;["url" true etc] as many args as the cons would take

zilti commented 10 years ago

Ok, so this is another class for which I've not yet written the construct-node helper. What you can do is this:

(fx image :url "url")

The fx macro will use one of the construct-node multimethods to find out if and what arguments the constructor needs to instantiate the class. I'll keep your idea in mind though.