CRESS-Surrey / eXtraWidgets

An extension for creating additional interface tabs in the NetLogo GUI and putting custom widgets on them.
MIT License
13 stars 4 forks source link

Dynamically create primitives for adding widget kinds? #47

Closed nicolaspayette closed 10 years ago

nicolaspayette commented 10 years ago

...and maybe even getting/setting properties?

45 gave me the idea.

Basically, the extension could look in plugins/eXtraWidgets/widgets and create xw:add-<kind> for everything that is there.

If we really want to get fancy, we could also do that for properties: adding xw:get-<property> and xw:set-<property> for each of them, with proper type validation. That's a bit trickier, though, because you have to actually load the class instead of just looking at the manifest. But it would be nice, and actually reduce the amount of code in the extension because we were planning on adding all that for known properties anyway (#36).

And loading the widget classes may have other benefits as well, e.g.: adding some other kinds of validation.

nicolaspayette commented 10 years ago

The first step towards that would be to make the WidgetLoader accessible from the extension.

Adding the xw:add-<kind> primitives should be fairly easy.

The properties getter/setters are trickier because the kind object doesn't currently know about them. I tried to put them there at first (in 242f0a2b3f60bdc335e9eaa7e3d47ad0b5c88f47) but had a hard time making all the types fit together. I resorted to putting the property defs directly in the widget classes but may give it another try. Having getters/setters would be oh so nice...

nicolaspayette commented 10 years ago

I have come to believe that this is an important feature. Basically, it will allow removing generic add, get and set primitives (or marking them as unsupported, i.e. xw:__add, etc.) and make the internal structure of the data model much more transparent/less in the way for the user.