Canvas wrappers: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
No edit summary
Line 17: Line 17:


The Canvas/GUI integration is implemented such that none of the existing code is touched, i.e. the old behavior remains fully supported. In addition, new widgets can be shared and reused by adding them to the $FG_ROOT/Nasal directory.
The Canvas/GUI integration is implemented such that none of the existing code is touched, i.e. the old behavior remains fully supported. In addition, new widgets can be shared and reused by adding them to the $FG_ROOT/Nasal directory.
Also, we also don't need to duplicate the existing C++ code and the dialog XML parsing.
Everything keeps as working as it is, adding new widgets (and USING them) can be purely done by modifying stuff in the base package, without touching the C++ code again.


In order to start using any custom Canvas-widgets, you only need to change the widget type to "canvas" and specify the name of the widget to be instantiated. For example:
In order to start using any custom Canvas-widgets, you only need to change the widget type to "canvas" and specify the name of the widget to be instantiated. For example:
Line 26: Line 31:


This is fully supported by Nasal code, as well as XML files.
This is fully supported by Nasal code, as well as XML files.
For example, if someone creates a new Canvas-based widget, say a "button" - all that is needed to start using it in FG, would be modifying the corresponding GUI XML files, and replacing the
<type>button</type>
with this instead:
<type>canvas</type>
<widget>button</widget>
(i.e. rename type and add a new "widget" node)
This can be done automatically within seconds using XSLT for XML files in $FG_ROOT - and all of a sudden, the PUI button class would no longer be used - no need to touch any C++.


== MFD ==
== MFD ==

Revision as of 02:48, 7 July 2012


The canvas subsystem is entirely implemented on top of the property tree, so it does not depend on Nasal scripting. However, it is Nasal scripting which makes the Canvas system really flexible and powerful.

Currently, there are a number of efforts being discussed to unify the 2D rendering backends in FlightGear (2D panel, HUD, GUI etc) to ensure that the Canvas system is the common backend for all these needs, which will reduce the amount of legacy C++ code that we have in FlightGear for these things, while also paving the way towards better overall OpenGL compatibility, better maintainability and more optimization opportunities.

Directly working with the canvas via the property tree is possible but tedious, that's why there is a special generic Nasal wrapper to simplify working with canvases. However, to cater for more specific 2D drawing needs, there are going to be additional wrappers provided on top of the main canvas.nas module.

The purpose of this page is to determine the requirements for each wrapper.

HUDs

The HUD module will be specifically targeted at developing HUDs.

GUI Widgets

The widget module will allow implementing custom GUI widgets using the Canvas system and Nasal, this will make it possible to re-implement existing PUI widgets as fully interactive "Nasal canvases", so that usage of PUI is increasingly reduced, facilitating phasing out of PUI eventually.

The Canvas/GUI integration is implemented such that none of the existing code is touched, i.e. the old behavior remains fully supported. In addition, new widgets can be shared and reused by adding them to the $FG_ROOT/Nasal directory.


Also, we also don't need to duplicate the existing C++ code and the dialog XML parsing.

Everything keeps as working as it is, adding new widgets (and USING them) can be purely done by modifying stuff in the base package, without touching the C++ code again.

In order to start using any custom Canvas-widgets, you only need to change the widget type to "canvas" and specify the name of the widget to be instantiated. For example:

 <type>canvas</type>
 <name>button</name>

This is fully supported by Nasal code, as well as XML files.


For example, if someone creates a new Canvas-based widget, say a "button" - all that is needed to start using it in FG, would be modifying the corresponding GUI XML files, and replacing the

<type>button</type>

with this instead:

<type>canvas</type> <widget>button</widget>

(i.e. rename type and add a new "widget" node)

This can be done automatically within seconds using XSLT for XML files in $FG_ROOT - and all of a sudden, the PUI button class would no longer be used - no need to touch any C++.

MFD

The MFD module will provide a wrapper on top of the canvas system specifically designed for building MFD-type displays (PFD, ND, EICAS etc). The MFD module will be largely inspired on the hard coded displays currently available in FlightGear, in particular the NavDisplay: Navigation display. What about CDUs, shall these be also covered by this module, or separately?

2D Panels

The 2D panel module will reimplement the existing 2D panel functionality in Canvas/Nasal space, so that the legacy C++ code can be slowly phased out.