Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [A5] how to trigger expose event programmatically?

This thread is locked; no one can reply to it. rss feed Print
[A5] how to trigger expose event programmatically?
axilmar
Member #1,204
April 2001

Hi all. Is there a way in Allegro 5 to trigger an expose event programmatically? I need this for my GUI in order to avoid redrawing the whole widget tree each time there is a change in a widget.

I do not want to make a user expose event, because it is dumb to have two events doing the same thing.

It would be optional, of course. The default would be to redraw the whole GUI each time, as this is more appropriate for games.

Elias
Member #358
May 2000

#include <allegro5/internal/aintern_events.h> // for _al_event_source_emit_event
ALLEGRO_EVENT_DISPLAY_EXPOSE event;
event.display.x = x;
event.display.y = y;
event.display.w = w;
event.display.h = h;
_al_event_source_emit_event(al_get_display_event_source(display), &event);

--
"Either help out or stop whining" - Evert

axilmar
Member #1,204
April 2001

I cannot compile the code after inserting the internal events header. The error is that the symbol ALLEGRO_INTERNAL_THREAD_HEADER is not found.

Elias
Member #358
May 2000

You always need to include allegro5/allegro.h first. Possibly also allegro5/internal/alconfig.h.

--
"Either help out or stop whining" - Evert

axilmar
Member #1,204
April 2001

Now I have another error, after including allegro5/allegro.h first: the macro ASSERT is not found.

EDIT:

ALLEGRO_EVENT_DISPLAY_EXPOSE is also not found.

Elias
Member #358
May 2000

Guess you need some more internal headers in the right order then.
Since they aren't really supposed to be used that way they don't include dependencies it seems.

--
"Either help out or stop whining" - Evert

Evert
Member #794
November 2000
avatar

I think you can just create a general event, fill in the fields mentioned by Elias in the first post (and set the event type, I think you need to do that regardless) and emit the event. Shouldn't need too many internal headers for that.

axilmar
Member #1,204
April 2001

Evert said:

I think you can just create a general event, fill in the fields mentioned by Elias in the first post (and set the event type, I think you need to do that regardless) and emit the event. Shouldn't need too many internal headers for that.

So, can I do the following?

ALLEGRO_EVENT event;
event.display.type = ALLEGRO_EVENT_DISPLAY_EXPOSE;
event.display.x = update_x;
event.display.y = update_y;
event.display.width = update_width;
event.display.height = update_height;
al_emit_user_event(al_get_display_event_source(my_display), &ev, NULL);

Evert
Member #794
November 2000
avatar

I think so. It depends on whether al_emit_user_event sets the evernt type for you or not, but that should be easy to check.
Mind you, the only time I made my own "user events" predates the official user events in A5, so there may be a nuance I'm missing.

Elias
Member #358
May 2000

Hm, not sure you can emit anything but user events with al_emit_user_event. I don't see a reason why not though so even if it doesn't work right now we probably should make it work.

--
"Either help out or stop whining" - Evert

Go to: