Canvas widgets: Difference between revisions

Jump to navigation Jump to search
m
Line 216: Line 216:
{{Feedback}}
{{Feedback}}


* We also need a function which parses existing dialog xml files (reimplementing http://gitorious.org/fg/flightgear/blobs/next/src/GUI/FGPUIDialog.cxx#line708 FGPUIDialog.cxx/FGPUIDialog::makeObject]) and maps them to the new canvas widgets. Each widgets sits in is own Nasal file (eg. inside $FG_DATA/gui/widgets) and has to be implemented using a hash with several required functions, implementing the abstract interface of a widget:
* We also need a function which parses existing dialog xml files (reimplementing http://gitorious.org/fg/flightgear/blobs/next/src/GUI/FGPUIDialog.cxx#line708 FGPUIDialog.cxx/FGPUIDialog::makeObject]) and maps them to the new canvas widgets. Each widgets sits in is own Nasal file (eg. inside $FG_DATA/Nasal/canvas/gui/widgets) and has to be implemented using a hash with several required functions, implementing the abstract interface of a widget: [[Howto:Creating a Canvas GUI Widget]].
 
<syntaxhighlight lang="nasal">
var SampleWidget = {
  # Add the widget to the parent
  #
  # @param config A hash containing all parameters for this widget.
  new: func(parent, config),
  # Get the minimal required size. Used for positioning following elements
  # if no absolute coordinates are given and to calculated available space
  # for widgets with vertical or horizontal stretch enabled.
  getMinSize: func(),
};
</syntaxhighlight>
 
In addition, the interface should probably contain methods to:
 
* show/hide widget
* destroy widget
* enable/disable propagation of events (mouse/keyboard)
 


Also, we are currently able to reload the GUI in FlightGear, we will want to retain this feature. But once we start implementing widgets in Nasal, we won't just want to reload the GUI XML files, but also the widget modules from [[$FG_ROOT]]/Nasal/widgets, so that widgets can be easily developed and tested, without having to restart FG.
Also, we are currently able to reload the GUI in FlightGear, we will want to retain this feature. But once we start implementing widgets in Nasal, we won't just want to reload the GUI XML files, but also the widget modules from [[$FG_ROOT]]/Nasal/widgets, so that widgets can be easily developed and tested, without having to restart FG.


This can be implemented in Nasal space, there's no need to modify the Nasal sub modules code for this - however, we also need to ensure that there's a sane way to terminate all active widgets, i.e. by stopping all running instances. This will also be important to handle simulator reinit/reset.
This can be implemented in Nasal space, there's no need to modify the Nasal sub modules code for this - however, we also need to ensure that there's a sane way to terminate all active widgets, i.e. by stopping all running instances. This will also be important to handle simulator reinit/reset.
Thus, during instantiation, all widgets would need to register a listener, so that they can be terminated properly using a signal property.


=== Dialog Parser  ===
=== Dialog Parser  ===

Navigation menu