Vision2 Widget Documentation

PreviousNext

EiffelMedia Vision2 Widget Handling

Here you will find a short description how to handle a EiffelMedia Vision2 Widget properly. The main goal of this Widget is to port a native SDL application in no time to a Vision2 application. The main Advantage of a EiffelMedia Vision2 Widget is the possibility to create a good Editor for levels, scripting, or whatever and to preview the result with the original graphic engine.

The performance is nearly the same as on a native EiffelMedia application. There is no significant performance impact except in debug mode, there it is slightly slower. But after finalized it is as fast as it can be.

Setting up an Vision2 Application

There is only one good way to setup a Vision2 Application with EiffelMedia support. You have to copy the example Vision2 project and modify it the way you want it. Everything from EiffelMedia is already included. This example is located in {EM}/example/vision2.

Vision2 Widget Overview

There are two Vision2 Widgets, which are EM_EV_WIDGET and EM_EV_WIDGET_SCROLLABLE.

Basically you have to inherit one of these two classes and integrate this new class into you GUI. Then you need to redefine make_em_application and in this redefined feature you put the code you normally would put in your creation procedure of a native EiffelMedia application.


Here is a short description of these two classes:


EM_EV_WIDGET_SCROLLABLE is a Vision2 Widget that behaves like the standard Vision2 EV_SCROLLABLE_AREA Widget. It will display a SDL Scene in the widget and take care of scene size and displayed area. It will also provide two scrollbars (if needed) to scroll around the scene. The scene will start immediately after creation in make_em_application in a separated SDL thread. If you want to start later, then you have to define manually a starting procedure by calling set_initialization_procedure and then launch it by calling launch_threaded.


EM_EV_WIDGET is the more basic widget and nothing is automated. You have to call launch_threaded manually, after project startup (otherwise it will have unpredictable results), to start a EiffelMedia Scene. This feature will call your redefinition of make_em_application and from here on, everything is like a normal EiffelMedia application.

Note: As said above, this widget is a basic widget for vision2. It has to be handled with care. EM_EV_WIDGET simply displays a SDL scene in the widget and does not take care of window size or clipping area. You should use the more advanced EM_EV_WIDGET_SCROLLABLE in your application.

Special things to be good to know

If you want to change the scene from a vision2 event (Button click, ...) you have to call set_next_scene_and_start otherwise you will deadlock your application.

When you have to communicate between to threads, use SEMAPHORE or MUTEX (provided by the ise_thread cluster) to synchronize those two threads, otherwise it can cause some serious unpredictable behavior.