FlightGear Newsletter June 2014: Difference between revisions

Jump to navigation Jump to search
Canvas GUI/MessageBox
No edit summary
(Canvas GUI/MessageBox)
Line 32: Line 32:


{{Template:Newsletter-article-start|{{{1|Canvas GUI: Layouting, Widgets and MessageBoxes}}}|By [[User:TheTom|TheTom]]}}
{{Template:Newsletter-article-start|{{{1|Canvas GUI: Layouting, Widgets and MessageBoxes}}}|By [[User:TheTom|TheTom]]}}
Thanks to Tom's and James' recent work on the upcoming [[Aircraft Center]] for downloading and switching between aircraft without having to exit FlightGear, beginning with FlightGear 3.2, FlightGear's [[Canvas]]-based GUI will contain support for so called [[Canvas MessageBox|Message Boxes]]:
 
{|
=== Widgets and Layouting ===
|- style="vertical-align:top;"
 
| [[File:Canvas-MessageBox-demo information.png|link=]] ||
[[File:Canvas GUI Demo Dialog.png|300px|thumb|Screen shot showing a simple [[Canvas GUI]] dialog with a handful of [[Canvas Widgets|Button Widgets]].]]
 
Thanks to the recent work of Tom, the [[Canvas]] system now supports basic widgets and layouting, similar to the Qt [http://qt-project.org/doc/qt-5/layout.html Layouting System]. Using vertical and horizontal box layouts widgets can be placed and sized automatically within the available space. Together with standard widgets like buttons, checkboxes, labels and scroll areas, this is a large step forward in creating a modern, new GUI for FlightGear.
 
For an example on how to use the new system see [[Howto:Creating a Canvas GUI dialog file]].
 
=== MessageBoxes ===
 
Based on the new widgets and layouts, [[Canvas MessageBox|Message Boxes]] provide a simple way to report information to the user or ask him simple questions with a standardized appearance. Selecting from a predefined set of icons and buttons showing a message can be as simple as:
 
<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
canvas.MessageBox.information("Success", "The operation has successfully completed.");
canvas.MessageBox.information("Success", "The operation has successfully completed.");
</syntaxhighlight>
</syntaxhighlight>
|- style="vertical-align:top;"
| [[File:Canvas-MessageBox-demo question.png|link=]] ||
<syntaxhighlight lang="nasal">
canvas.MessageBox.question(
  "Do you want it?",
  "The question is: Do you want to get a real question?.",
  func(sel)
  {
    if( sel == canvas.MessageBox.Yes )
      print("I only know that the answer is 42.");
    else
      print("Ok, I will not give you a real question.");
  }
);
</syntaxhighlight>
|- style="vertical-align:top;"
| [[File:Canvas-MessageBox-demo warning dont-show-again.png|link=]] ||
<syntaxhighlight lang="nasal">
canvas.MessageBox.warning(
  "Warning...",
  "Have you read this warning? If you want it will not be shown again.",
  func(sel)
  {
    if( sel != canvas.MessageBox.Ok )
      return;
    print("You have been warned. Let the games begin...");
  },
    canvas.MessageBox.Ok
  | canvas.MessageBox.Cancel
  | canvas.MessageBox.DontShowAgain
);
</syntaxhighlight>
|}
[[File:Canvas GUI Demo Dialog.png|300px|thumb|Screen shot showing a simple [[Canvas GUI]] dialog with a handful of [[Canvas Widgets|Button Widgets]].]]


For an example see [[Howto:Creating a Canvas GUI dialog file]].
Get more information on how to [[Canvas MessageBox|create Message Boxes on your own...]]


<div style="clear:both;"></div>
<gallery mode=packed>
Canvas-MessageBox-demo information.png|Reporting information
Canvas-MessageBox-demo warning dont-show-again.png|Showing a warning (allowing the user to not get it reported the next time)
</gallery>


{{Template:Newsletter-article-start|{{{1|Preview: Aircraft Center - get it on the fly}}}|By [[User:TheTom|TheTom]] and [[User:Zakalawe|Zakalawe]]}}
{{Template:Newsletter-article-start|{{{1|Preview: Aircraft Center - get it on the fly}}}|By [[User:TheTom|TheTom]] and [[User:Zakalawe|Zakalawe]]}}
166

edits

Navigation menu