Updownquark / Quick

Quark's User Interface Creation Kit
0 stars 0 forks source link

Rewrite eventing architecture #46

Closed Updownquark closed 10 years ago

Updownquark commented 10 years ago

I thought through the current eventing architecture for a long time during my initial design of what is now MUIS many years ago, but since I've actually been using it, it kind of just sucks. You have to know where the event type objects are located and then to get full utility out of the events, you have to know what subtype an event is (e.g. the mouse event's strong type is Void, so you just have to know that all events propagated for the mouse type are of type MouseEvent, but this is not type-enforced and must be filtered by a responsible listener).

Also, the events being propagated through the tree by the elements themselves hasn't worked out as well as I'd thought back then and I believe that functionality is no longer used. This feature is what the local flag on the listeners is for, but it's not well documented or intuitive. This feature probably just needs to be removed and verified that it's not used anywhere.

In addition, I'd like to move listeners out of the MuisElement class itself and into a separate attribute, like all the other managers. The more I think about it, the more I like the standard addXXXListener approach, but this needs to be extensible by subtypes.

Updownquark commented 10 years ago

The one big problem I've encountered so far is that the child list on an element natively supported adding listeners to all children on the list, dynamically. This more difficult when the events are not propagated through the elements themselves. Need to think of a clever solution to this.

Updownquark commented 10 years ago

I have just noticed that the child list is not really thread safe. The list is not locked while events are firing (by design), so the list's contents could change while the event is firing. I think the solution to this is to put more information in the event itself, e.g. the elements in the child list before and after the call. This way listeners can inspect the event itself and not be dependent upon the list for information during event firing.

Updownquark commented 10 years ago

Thinking over things again, having the (mostly) unified eventing architecture was kind of nice. It would be even nicer if it did things more than just fire events piecewise. I've been thinking of some things the event architecture should have that would justify the unification: Some of these may be pipe dreams.

I think I'm flip-flopping. Maybe the unified eventing could be a good thing if it can be made feature-full.

Updownquark commented 10 years ago

My flip-flopping is complete. I think having a central eventing service on the element is better than a bunch of fractured eventing services on each thing that does eventing. I will move the eventing out of the element itself into a new manager though. Regarding the previous ideas, I've done some thinking...

Updownquark commented 10 years ago

As mentioned in the commit, it works!! Mostly. Most of the tests work fine. A couple things I've noticed that are wrong:

Also, I need to think about firing state events through the new architecture instead of through the state engine itself. I might think of a few more things, but I think this can be closed out pretty soon.

Updownquark commented 10 years ago

I think just bugfixes now. As soon as all the tests function just like they should, this can be closed.

Updownquark commented 10 years ago

This is done now. I need to reset the feature-BaseWidgets branch to this head and drop the two feature-EventRefactor branches and then I'll close this.