Beispiel #1
0
/*
Function: wz_update

Updates the widget tree, call this every frame
Doesn't update the disabled widgets

Parameters:
dt - Time that has passed since the last update
*/
void wz_update(WZ_WIDGET* wgt, double dt)
{
	ALLEGRO_EVENT event;
	wz_craft_event(&event, WZ_UPDATE, 0, 0);
	wz_broadcast_event(wgt, &event);
	wz_craft_event(&event, WZ_UPDATE_POSITION, 0, 0);
	wz_broadcast_event(wgt, &event);
}
Beispiel #2
0
/*
Function: wz_enable

Enables/disables the widget tree

Parameters:
enable - pass 1 to enable the widget tree, or 0 to disable it
*/
void wz_enable(WZ_WIDGET* wgt, int enable)
{
	ALLEGRO_EVENT event;
	wz_craft_event(&event, enable ? WZ_ENABLE : WZ_DISABLE, 0, 0);
	
	wz_broadcast_event(wgt, &event);
}
Beispiel #3
0
/*
Function: wz_show

Shows/hides the widget tree

Parameters:
show - pass 1 to show the widget tree, or 0 to hide it
*/
void wz_show(WZ_WIDGET* wgt, int show)
{
	ALLEGRO_EVENT event;
	wz_craft_event(&event, show ? WZ_SHOW : WZ_HIDE, 0, 0);
	
	wz_broadcast_event(wgt, &event);
}
Beispiel #4
0
/*
Function: wz_destroy

Destroys the widget tree. Call it to free all of the memory used by the widget tree.
*/
void wz_destroy(WZ_WIDGET* wgt)
{
	ALLEGRO_EVENT event;
	wz_detach(wgt);
	wz_craft_event(&event, WZ_DESTROY, 0, 0);
	wz_broadcast_event(wgt, &event);
}
Beispiel #5
0
/*
Function: wz_focus

Focuses/defocuses the widget tree. This function propagates the focus down the tree.

Parameters:
focus - pass 1 to focus the widget tree, or 0 to defocus it
*/
void wz_focus(WZ_WIDGET* wgt, int focus)
{
	if (focus)
	{
		wz_ask_parent_for_focus(wgt);
	}
	else
	{
		ALLEGRO_EVENT event;
		wz_craft_event(&event, WZ_LOSE_FOCUS, 0, 0);
		wz_broadcast_event(wgt, &event);
	}
}
Beispiel #6
0
/*
Function: wz_broadcast_event

Broadcasts an event to a widget, and to all of its children, propagating down the tree

Returns:
1 if the event was handled by some widget, 0 if it was not
*/
int wz_broadcast_event(WZ_WIDGET* wgt, ALLEGRO_EVENT* event)
{
	int ret = 0;
	WZ_WIDGET* child = wgt->first_child;
	ret |= wgt->proc(wgt, event);
	
	while (child)
	{
		WZ_WIDGET* next = child->next_sib;
		ret |= wz_broadcast_event(child, event);
		child = next;
	}
	return ret;
}
Beispiel #7
0
/*
Function: wz_draw

Draws the widget tree. Only affects the visible widgets
*/
void wz_draw(WZ_WIDGET* wgt)
{
	ALLEGRO_EVENT event;
	wz_craft_event(&event, WZ_DRAW, 0, 0);
	wz_broadcast_event(wgt, &event);
}
Beispiel #8
0
/*
 Function: wz_resize
 
 Resizes the widget tree. 
 
 Parameters:
 factor: scaling factor
 */
void wz_resize(WZ_WIDGET* wgt, float factor)
{
    ALLEGRO_EVENT event;
    wz_craft_event(&event, WZ_RESIZE, 0, *(intptr_t*)&factor);
    wz_broadcast_event(wgt, &event);
}