]> git.mxchange.org Git - flightgear.git/blob - docs-mini/README.gui
Mathias:
[flightgear.git] / docs-mini / README.gui
1 FlightGear GUI Mini-HOWTO
2
3 David Megginson
4 Started: 2003-01-20
5 Last revised: 2003-01-20
6
7
8 FlightGear creates its drop-down menubar and dialog boxes from XML
9 configuration files under $FG_ROOT/gui.  This document gives a quick
10 explanation of how to create or modify the menubar and dialogs.  The
11 toolkit for the FlightGear GUI is PUI, which is part of plib.
12
13 All of the XML files use the standard FlightGear PropertyList format.
14
15
16 MENUBAR
17 -------
18
19 FlightGear reads the configuration for its menubar from
20 $FG_ROOT/gui/menubar.xml.  The file consists of a series of top-level
21 elements named "menu", each of which defines on of the drop-down
22 menus, from left to right.  Each menu contains a series of items,
23 representing the actual items a user can select from the menu, and
24 each item has a series of bindings that FlightGear will activate when
25 the user selects the item.
26
27 Here's a simplified grammar:
28
29   [menubar] : menu*
30
31   menu : label, item*
32
33   item : label, binding*
34
35 The bindings are standard FlightGear bindings, the same as the ones
36 used for the keyboard, mouse, joysticks, and the instrument panel.
37 Any commands allowed in those bindings are allowed here as well.
38
39 Here's an example of a simple menubar with a "File" drop-down menu and
40 a single "Quit" item:
41
42   <PropertyList>
43
44    <menu>
45     <label>File</label>
46  
47     <item>
48      <label>Quit</label>
49      <binding>
50       <command>exit</command>
51      </binding>
52     </item>
53
54   </PropertyList>
55
56 PUI menus do not allow advanced features like submenus or checkmarks.
57 The most common command to include in a menu item binding is the
58 'dialog-show' command, which will open a user-defined dialog box as
59 described in the next section.
60
61
62 DIALOGS
63 -------
64
65 The configuration files for XML dialogs use a nested structure to set
66 up dialog boxes.  The top-level always describes a dialog box, and the
67 lower levels describe the groups and widgets that make it up.  Here is
68 a simple, "hello world" dialog:
69
70   <PropertyList>
71
72    <name>hello</name>
73
74    <width>150</width>
75    <height>100</height>
76    <modal>false</modal>
77
78    <text>
79     <x>10</x>
80     <y>50</y>
81     <label>Hello, world</label>
82    </text>
83
84    <button>
85     <x>40</x>
86     <y>10</y>
87     <legend>Close</legend>
88     <binding>
89      <command>dialog-close</command>
90     </binding>
91    </button>
92
93   </PropertyList>
94
95 The dialog contains two sub-objects: a text field and a button.  The
96 button contains one binding, which closes the active dialog when the
97 user clicks on the button.
98
99 Coordinates are pseudo-pixels.  The screen is always assumed to be
100 1024x768, no matter what the actual resolution is.  The origin is the
101 bottom left corner of the screen (or parent dialog or group); x goes
102 from left to right, and y goes from bottom to top.
103
104 All objects, including the top-level dialog, accept the following
105 properties, though they will ignore any that are not relevant:
106
107  x - the X position of the bottom left corner of the object, in
108    pseudo-pixels.  The default is to center the dialog.
109
110  y - the Y position of the bottom left corner of the object, in
111    pseudo-pixels.  The default is to center the dialog.
112
113  width - the width of the object, in pseudo-pixels.  The default is
114    the width of the parent container.
115
116  height - the height of the object, in pseudo-pixels.  The default is
117    the width of the parent container.
118
119  color - a subgroup to specify the dialogs color:
120   red   - specify the red color component of the color scheme.
121   green - specify the green color component of the color scheme.
122   blue  - specify the blue color component of the color scheme.
123   alpha - specify the alpha color component of the color scheme.
124
125  legend - the text legend to display in the object.
126
127  label - the text label to display near the object.
128
129  property - the name of the FlightGear property whose value will
130    be displayed in the object (and possibly modified through it).
131
132  binding - a FlightGear command binding that will be fired when the
133    user activates this object (more than one allowed).
134
135  default - true if this is the default object for when the user
136    presses the [RETURN] key.
137
138 Objects may appear nested within the top-level dialog or a "group"
139 object.  Here are all the object types allowed, with their special
140 properties:
141
142
143 dialog
144 ------
145
146 The top-level dialog box; the name does not actually appear in the
147 file, since the root element is named PropertyList.
148
149   name - (REQUIRED) the unique name of the dialog for use with the
150     "dialog-show" command.
151
152   modal - true if the dialog is modal (it blocks the rest of the
153     program), false otherwise.  The default is false.
154
155 Example:
156
157 <PropertyList>
158
159  <name>sample</name>
160  <width>500</width>
161  <height>210</height>
162  <modal>false</modal>
163
164  <text>
165   ...
166  </text>
167
168  <button>
169   ...
170  </button>
171
172 </PropertyList>
173
174
175 group
176 -----
177
178 A group of subobjects.  This object does not draw anything on the
179 screen, but all of its children specify their coordinates relative to
180 the group; using groups makes it easy to move parts of a dialog
181 around.
182
183 Example:
184
185   <group>
186    <x>0</x>
187    <y>50</y>
188
189    <text>
190     ...
191    </text>
192
193    <input>
194     ...
195    </input>
196
197    <button>
198     ...
199    </button>
200
201   </group>
202
203
204 input
205 -----
206
207 A simple editable text field.
208
209 Example:
210
211   <input>
212    <x>10</x>
213    <y>60</y>
214    <width>200</width>
215    <height>25</height>
216    <label>sea-level temperature (degC)</label>
217    <property>/environment/temperature-sea-level-degc</property>
218   </input>
219
220
221 text
222 ----
223
224 A non-editable text label.
225
226 Example:
227
228   <text>
229    <x>10</x>
230    <y>200</y>
231    <label>Heading</label>
232   </text>
233
234   <text>
235    <x>10</x>
236    <y>200</y>
237    <label>-9.9999</label> <!-- placeholder for width -->
238    <format>%-0.4f m</format>
239    <property>/foo/altitude</property>
240   </text>
241
242
243 checkbox
244 --------
245
246 A checkbox, useful for linking to boolean properties.
247
248 Example:
249
250   <checkbox>
251    <x>150</x>
252    <y>200</y>
253    <width>12</width>
254    <height>12</height>
255    <property>/autopilot/locks/heading</property>
256   </checkbox>
257
258
259
260 button
261 ------
262
263 A push button, useful for firing command bindings.
264
265   one-shot - true if the button should pop up again after it is
266     pushed, false otherwise.  The default is true.
267
268   <button>
269    <x>0</x>
270    <y>0</y>
271    <legend>OK</legend>
272    <binding>
273     <command>dialog-apply</command>
274    </binding>
275    <binding>
276     <command>dialog-close</command>
277    </binding>
278    <default>true</default>
279   </button>
280
281
282
283 combo
284 -----
285
286 A pop-up list of selections.
287
288   value - one of the selections available for the combo.  There may be
289   any number of "value" fields.
290
291 Example:
292
293   <combo>
294    <x>10</x>
295    <y>50</y>
296    <width>200</width>
297    <height>25</height>
298    <property>/environment/clouds/layer[0]/type</property>
299    <value>clear</value>
300    <value>mostly-sunny</value>
301    <value>mostly-cloudy</value>
302    <value>overcast</value>
303    <value>cirrus</value>
304   </combo>
305
306
307
308 select
309 ------
310
311 A scrollable list of selections.
312
313   selection - a path in the property tree which holds the selectable items.
314
315 Example:
316
317   <select>
318    <x>10</x>
319    <y>50</y>
320    <width>200</width>
321    <height>25</height>
322    <property>/sim/aircraft</property>
323    <selection>/sim/aircraft-types</selection>
324   </select>
325
326
327
328 slider
329 ------
330
331 A horizontal or vertical slider for setting a value.
332
333   vertical - true if the slider should be vertical, false if it should
334     be horizontal.  The default is false.
335
336   min - the minimum value for the slider.  The default is 0.0.
337
338   max - the maximum value for the slider.  The default is 1.0.
339
340 Example:
341
342   <slider>
343    <x>10</x>
344    <y>50</y>
345    <width>200</width>
346    <property>/environment/visibility-m</property>
347    <min>5</min>
348    <max>50000</max>
349   </slider>
350
351
352 dial
353 ----
354
355 A circular dial for choosing a direction.
356
357   wrap - true if the dial should wrap around, false otherwise.  The
358     default is true.
359
360   min - the minimum value for the dial.  The default is 0.0.
361
362   max - the maximum value for the dial.  The default is 1.0.
363
364 Example:
365
366   <dial>
367    <x>10</x>
368    <y>50</y>
369    <width>20</width>
370    <property>/environment/wind-from-direction-deg</property>
371    <min>0</min>
372    <max>360</max>
373   </dial>
374
375 textbox
376 -------
377
378 The text will be retrieved/buffered from/within a specified
379 property tree, like:
380
381 <textbox>
382     <!-- position -->
383     <x>100</x>
384     <y>100</y>
385
386     <!-- dimensions -->
387     <width>200</width> 
388     <height>400</height>
389
390     <property>/gui/path-to-text-node/contents</property>
391
392     <slider>15</slider> <!--width for slider -->
393     <wrap>false</wrap> <!-- don't wrap text; default: true -->
394
395     <editable>true</editable> <!-- whether the puLargeInput is supposed to be editable -->
396 </textbox>  
397
398 __end__