Previous Next Up Title Contents Index Top Library

7.3. ANIMATION

The problem is carrying out graphic actions (editing the CSS and redisplaying) and maintaining event management in the main loop without blocking user interaction during animation. This problem is solved by calling the function GPHIGS_ANIM_CB for the required user interaction.

Upon validation of a pushbutton, e.g., we may begin graphic animation. Just enter a call to the function GPHIGS_ANIM_CB via the pushbutton callback, entering the name of the animation function, and the problem is solved.

XtAddCallback(pushbutton,XmNactivateCallback,GPHIGS_ANIM_CB,fctAnim);

where fctAnim is the name of the animation function.

The user program will therefore have the following form:

1. Initialization

user

toolkit

PHIGS

4. Widget creation (GPHIGS widgets in particular)

5. Event management

add callback XmNredrawCallback for the construction of the CSS

add callback to start the animation

user handler

other callbacks

6. Create widgets

7. Event loop (Main loop)

Two functions are to be studied:

1. Redraw callback

creation of CSS

display

2. fctAnim

structure editing

redisplay

Note: This function is used as follows:

The GPHIGS_ANIM_CB function manages the infinite loop for this function. It is not necessary to put the loop inside this function (no for(;;) or while(...)). This means that GPHIGS_ANIM_CB loops on the call to fctAnim, taking the exterior events into account. The main body of the function is to be designed in a similar way:

	fctAnim()
	{
		static int count = 0;
		....
		calculation as a function of count
		structure editing, view editing, ...
		redisplay for screen updating
		...
		count += step;
	}


Previous Next Up Title Contents Index Top Library