Every canvas element has its own hide/show methods, see $FG_ROOT/Nasal/canvas/api.nas for details
You can then trigger those methods using a listener/timer as needed.
You could for example use a callback that is invoked whenever the property is changed, let's call that gearMonitor:
- Code: Select all
var gearMonitor = func(node) {
print("gear property updated\n");
}
var path = "your property path";
var myListener = setlistener(path, gearMonitor);
You can change the print statement to update the canvas text node instead, by accessing "myText" inside that callback (assuming that you set up the monitor/listener at the bottom of your code)
Once you have that working, the next step will be replacing the text node with a texture/image node, i.e. for all the different flags you want to show (unless you want to continue using text strings instead of images for the annunciator)
EDIT: As an aside, once you have this responding to your properties as needed, it really is trivial to switch to a different canvas drawing mode (say to replace the text node with a static image/texture instead, or use a texture lookup to use a shared texture as a texture map).
However, the most common way to do this is typically using Canvas.Path based drawing - which makes it easy to create your annunciators via an SVG editor like Inkscape. This is basically GiMP for vector graphics.
But again, it's best to continue "as is" - switching from text drawing to raster images or to vector images, really is very easy to do. And the underlying boilerplate will remain the same.
Suffice to say you WILL NOT need to texture your object - instead, the texture will be replaced/provided by the Canvas system.
The general workflow would be such that you set up an empty texture inside the cockpit/panel, which is to be replaced by a dynamic/canvas one.
Then, your canvas gets certain dimensions/background color and a top-level root group.
The root group can then be populated with a handful of drawing primitives.
Typically, you would prepare your artwork in inkscape, and assign different IDs to each element that you want to control (hide/show/update/animate) independently.
Then, in Nasal/Canvas space, you would load the SVG file and obtain a handle to each SVG ID.
Once you have a handle, you can independently control those elements as needed.
That's a rough overview, I may have missed/skipped some of the more obvious steps, but I am sure we can work out everything here