What's the "Movieclip" object in MadButterfly
Posted by wycc on 2008-11-15 00:16
In most GUI framework, there is something called "widget", "GUI object" or "Movieclip" in flash. These data structure is used to identify an object that need to be operated. In the MadButterfly, what's the object? It looks like coord_t is the object since we attach event handler to it by using the coord_get_mouse_event. However, the name "coord_t" does not reflect this feature. Why don't we put something like rdman_object_t to collect all information about one single "object" in the screen? In this way, we can use
rdman_object_t *object = rdman_object_get_by_id("gun");
subject_t *subject = rdman_object_get_mouse_event(object);
subject_add_observer(rdman_get_ob_factory(rdman), subject, handler, NULL);
Does this looks more natural than use coord_t here? The coord_t should be internal structure of the rdman_object_t.
In addition, I suggest to make the API looks like
object_add_observer(object, rdman_object_get_mouse_event(object), handler, NULL);
Instead of using subject as the first argument, we should use rdman_object_t as the first argument. The factory of an pbject can be determined by using
rdman_get_ob_factory(object->rdman)
In this way, we can hide the factory and subject from the users. In my point of view, these are internal implementation which most users are not insteresting in it.
Home / Developer API / Tour / Get a Project - Solutions for Bug & Issue Tracking, Collaboration Tools, Subversion Hosting, Git Hosting
Madbutterfly is powered by Assembla.
0 Comments