Board index FlightGear Development Canvas

777 EFB: initial feedback

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

Re: 777 EFB: initial feedback

Postby Hooray » Tue Jun 24, 2014 9:40 am

no, event listeners are canvas specific - they're for anything that should be clickable that IS a Canvas.
The GPSMap196 only happens to use those because it supports a "native" Canvas Window to render the whole instrument, i.e. without any cockpit at all.
This works by creating a background image and rendering another image with buttons on top of it, each button is associated with a SVG element ID.
That way, the whole thing works even without a cockpit (and even without an aircraft!).
I kind of prefer this generic approach - because it simplifies prototyping and testing significantly. Imagine being able to load & test your EFB with simple aircraft like the ufo/ogel etc - just by opening a dialog from the menu. That's what the GPSMap196 supports. So, the Nasal/Canvas code will basically open a few images and render them on top, and then associate the buttons with event listeners so that it can respond to events (the red screen is an embedded canvas created/managed elsewhere, so that the cockpit and the dialog can share the same "screen" output):
http://wiki.flightgear.org/Canvas_Glass_Cockpit_Efforts
Image

Then again, for cockpit hot spots it uses actually a fairly inflexible and inelegant method through setting properties, so this is fairly low-level and not really needed IMO.
Unless you are planning to also create a skin with buttons, you won't need to use the Event Listener stuff, but it's documented here: http://wiki.flightgear.org/Canvas_-_Event_Handling

Personally, I'd directly associate Nasal callbacks with each button - but properties will work, too. Use what works best for you, and what you understand.
Canvas Event Listeners are really only useful in the context of a Canvas-based element.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11376
Joined: Tue Mar 25, 2008 8:40 am

Previous

Return to Canvas

Who is online

Users browsing this forum: No registered users and 1 guest