Graphics Reference
In-Depth Information
LMB Up
LMB Drag
LMB Drag
LMB Down
LMB Up
1
2
3
Service
Routines
LMBDownRoutine()
LMBDragRoutine()
LMBUpRoutine()
Define
HeroBall
Center
Define
HeroBall
Velocity &
Size
Done
Defining
HeroBall
Application
State
Figure 2.3.
State diagram for defining the HeroBall .
ing 1.7), we realize that we should also pay attention to the implicit mouse button
up event. Another example is the HeroBall selection action: right mouse button
down. In this case, right mouse button drag and up events are not serviced by our
application, and thus, they are undefined (to our application).
Consecutive user actions. When one user action (e.g., “drag out the HeroBall
is mapped to a group of consecutive events (e.g., mouse button down, then drag,
then up), a finite state diagram can usually be derived to help design the solution.
Figure 2.3 depicts the finite state diagram for defining the HeroBall .Theleft
mouse button down event puts the program into state 1 where, in our solution from
Listing 1.7, LMBDownRoutine() implements this state and defines the center of
the HeroBall , and so on. In this case, the transition between states is triggered
by the mouse events, and we see that it is physically impossible to move from
state 2 back to state 1. However, we do need to handle the case where the user
action causes a transition from State 1 to State 3 directly (mouse button down
and release without any dragging actions). This state diagram helps us analyze
possible combinations of state transitions and perform appropriate initializations.
Input/output functionality of GUI elements. An input GUI element (e.g., the
quit button) is an artifact (e.g., an icon) for the users to generate events to cause
changes in the application state, whereas an output GUI element (e.g., the status
bar) is an avenue for the application to present application state information to
the user as feedback. For both types of elements, information only flows in one
direction—either from the user to the application (input) or from the application
to the user (output). When working with GUI elements that serve both input and
Search WWH ::




Custom Search