Canvas GUI: Difference between revisions

Jump to navigation Jump to search
1,719 bytes added ,  24 May 2013
m
No edit summary
Line 28: Line 28:


In order to re-implement these using the Canvas system, we need to identify Nasal APIs that are currently missing, and which need to be provided via the cppbind framework.
In order to re-implement these using the Canvas system, we need to identify Nasal APIs that are currently missing, and which need to be provided via the cppbind framework.
== Replacing native PUI widgets with Canvas widgets ==
* provide a PropertyList-XML file that specifies the canvas to be put into $FG_ROOT/gui/widgets
* provide a Nasal implementation to be put into $FG_ROOT/Nasal/canvas/widgets
* modify all existing uses of the hardcoded widget
For example, to replace the loglist widget:
Provide an PropertyList-XML that declares the canvas and its default settings, including a Nasal section that implements the logic:
<syntaxhighlight lang="php">
<?xml version="1.0"?>
<PropertyList>
              <name></name>
              <valign>fill</valign>
              <halign>fill</halign>
              <stretch>true</stretch>
              <pref-width>400</pref-width>
              <pref-height>200</pref-height>
                <nasal><load><![CDATA[
                print("canvas loglist running!");
                ]]></load></nasal>
</PropertyList>
</syntaxhighlight>
Next, replace the original <loglist>
<syntaxhighlight lang="php">
<loglist>
                <halign>fill</halign>
                <valign>fill</valign>
                <stretch>true</stretch>
                <pref-width>450</pref-width>
                <pref-height>200</pref-height>
                <padding>6</padding>
</loglist>
</syntaxhighlight>
And include the corresponding canvas file:
<syntaxhighlight lang="php">
<canvas include="gui/widgets/loglist.xml"> <!-- see $FG_ROOT/Docs/README.gui for details -->
                <halign>fill</halign>
                <valign>fill</valign>
                <stretch>true</stretch>
                <pref-width>450</pref-width>
                <pref-height>200</pref-height>
                <padding>6</padding>
        </canvas>
</syntaxhighlight>

Navigation menu