This code places an Elementary mapbuf widget on a window, to exemplify part of the widget's API.
First we'll add an window with a background and a vertical box to pack our interface elements:
Next we'll simply add the mapbuf widget to the box:
But mapbuf is a container widget, it won't do anything alone. So let's create a table full of icons. For that we'll loop to fill each line of each column. See tutorial_table_01 if you don't know how to use tables:
Finally, setting mapbuf content:
Also, would be good a horizontal box with some controls to change mapbuf behavior:
By default map is disabled. So just setting content isn't enough. Alpha and smooth settings will be applied when map is enabled. So we'll add a check for that. Everytime the map properties are changed, map will need to be enabled again. So if you want to play a bit with our example, remember to always enable map again after concluding your changes.
We have added a callback function to this check, so it will enable or disable map:
Let's add check boxes for alpha blending and smooth rendering:
By default, mapbuf would enable alpha blending and smooth rendering, so we need to check boxes to be consistent with its behavior.
Callback functions look like the one added to the check. This way we could enable or disable the both properties:
You'll see that disabling alpha blending will set a black rectangle below the icons. That's the reason you only should enable that when you're sure the mapbuf content is 100% solid.
See mapbuf_example.c, whose window should look like this picture: