Design

MadSwatter have 4 main components. They are madswatter_editor, channel_wrap, word_box_wrap and elf_wrap. madswatter_editor, know as editor, initialize environment of GUI. It creates 3 channels, a start_word and event handlers for SVG objects in timeline panel. A channel is a line in timeline panel to hold words. A word is a set of actions they are performed and applied on elfs in a period of time, it is represented as a rectangle box in a channel in timeline panel. Periods of words in a channel is not overlaid in time. But, we have 3 channels. Periods of Words from different channel can be overlaid in time, that you can assign up to 3 words performing concurrently.

A word can only belong to exactly one channel, except start_word. start_word are created when a madswatter_editor object is initilaized and inserted into every channel. But, it does not showed on channel lines in timeline panel. A small red box, in timeline panel, at right side of second channel line represents it.

Internally, a madswatter_editor have 3 channel_wrap objects, one for each channel. channel_wrap objects are hold in madswatter_editor::channels. Every channel_wrap object has a list of word_box_wrap objects, they are internal representation of word. channel_wrap::words is the list of word_box_wrap objects.

channel_wrap::line is SVG DOM object of channel line in timeline panel. word_box_wrap::box is SVG DOM object of word box on the channel line in timeline panel. Objects other than madswatter_editor are not supposed to access these members.

To reduce couples and complexities, madswatter_editor responds to deal with logic among channels and words to keep consistency of states. Other objects trying to access channels and words should use interface provided by a madswatter_editor object if possible.

A word is a set of actions. word_box_wrap::activities is a list of action objects. A new action should be added to current word through madswatter_wrap::add_action() function.

A action is a object with 3 methods; start(), update™, and stop(). start() of an action object is called when a playing of a program starts to perform the word where the action object is in. And stop() is called when the word is stoped. The update™ of an action object are invoked periodically to update status of elfs during the period of the word.

An elf is a graphic imported from a SVG file. Elfs are targets that MadSwatter actions applied on.