]> git.mxchange.org Git - flightgear.git/blob - docs-mini/README.gui
- implement progress information (enabled by default; can be turned off via
[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    <draggable>true</draggable>
78
79    <text>
80     <x>10</x>
81     <y>50</y>
82     <label>Hello, world</label>
83    </text>
84
85    <button>
86     <x>40</x>
87     <y>10</y>
88     <legend>Close</legend>
89     <binding>
90      <command>dialog-close</command>
91     </binding>
92    </button>
93
94   </PropertyList>
95
96 The dialog contains two sub-objects: a text field and a button.  The
97 button contains one binding, which closes the active dialog when the
98 user clicks on the button.
99
100 Coordinates are pseudo-pixels.  The screen is always assumed to be
101 1024x768, no matter what the actual resolution is.  The origin is the
102 bottom left corner of the screen (or parent dialog or group); x goes
103 from left to right, and y goes from bottom to top.
104
105 All objects, including the top-level dialog, accept the following
106 properties, though they will ignore any that are not relevant:
107
108  x - the X position of the bottom left corner of the object, in
109    pseudo-pixels.  The default is to center the dialog.
110
111  y - the Y position of the bottom left corner of the object, in
112    pseudo-pixels.  The default is to center the dialog.
113
114  width - the width of the object, in pseudo-pixels.  The default is
115    the width of the parent container.
116
117  height - the height of the object, in pseudo-pixels.  The default is
118    the width of the parent container.
119
120  color - a subgroup to specify the dialogs color:
121   red   - specify the red color component of the color scheme.
122   green - specify the green color component of the color scheme.
123   blue  - specify the blue color component of the color scheme.
124   alpha - specify the alpha color component of the color scheme.
125
126  font - a subgroup to specify a specific font type
127   name - the name of the font (excluding it's .txf extension)
128   size - size of the font
129   slant -  the slant of the font (in pixels)
130
131  legend - the text legend to display in the object.
132
133  label - the text label to display near the object.
134
135  property - the name of the FlightGear property whose value will
136    be displayed in the object (and possibly modified through it).
137
138  binding - a FlightGear command binding that will be fired when the
139    user activates this object (more than one allowed).
140
141  default - true if this is the default object for when the user
142    presses the [RETURN] key.
143
144 Objects may appear nested within the top-level dialog or a "group"
145 object.  Here are all the object types allowed, with their special
146 properties:
147
148
149 dialog
150 ------
151
152 The top-level dialog box; the name does not actually appear in the
153 file, since the root element is named PropertyList.
154
155   name - (REQUIRED) the unique name of the dialog for use with the
156     "dialog-show" command.
157
158   modal - true if the dialog is modal (it blocks the rest of the
159     program), false otherwise.  The default is false.
160
161   draggable - false if the dialog is not draggable. The default is true.
162
163 Example:
164
165 <PropertyList>
166
167  <name>sample</name>
168  <width>500</width>
169  <height>210</height>
170  <modal>false</modal>
171
172  <text>
173   ...
174  </text>
175
176  <button>
177   ...
178  </button>
179
180 </PropertyList>
181
182
183 group
184 -----
185
186 A group of subobjects.  This object does not draw anything on the
187 screen, but all of its children specify their coordinates relative to
188 the group; using groups makes it easy to move parts of a dialog
189 around.
190
191 Example:
192
193   <group>
194    <x>0</x>
195    <y>50</y>
196
197    <text>
198     ...
199    </text>
200
201    <input>
202     ...
203    </input>
204
205    <button>
206     ...
207    </button>
208
209   </group>
210
211
212 input
213 -----
214
215 A simple editable text field.
216
217 Example:
218
219   <input>
220    <x>10</x>
221    <y>60</y>
222    <width>200</width>
223    <height>25</height>
224    <label>sea-level temperature (degC)</label>
225    <property>/environment/temperature-sea-level-degc</property>
226   </input>
227
228
229 text
230 ----
231
232 A non-editable text label.
233
234 Example:
235
236   <text>
237    <x>10</x>
238    <y>200</y>
239    <label>Heading</label>
240   </text>
241
242   <text>
243    <x>10</x>
244    <y>200</y>
245    <label>-9.9999</label> <!-- placeholder for width -->
246    <format>%-0.4f m</format>
247    <property>/foo/altitude</property>
248   </text>
249
250
251 checkbox
252 --------
253
254 A checkbox, useful for linking to boolean properties.
255
256 Example:
257
258   <checkbox>
259    <x>150</x>
260    <y>200</y>
261    <width>12</width>
262    <height>12</height>
263    <property>/autopilot/locks/heading</property>
264   </checkbox>
265
266
267
268 button
269 ------
270
271 A push button, useful for firing command bindings.
272
273   one-shot - true if the button should pop up again after it is
274     pushed, false otherwise.  The default is true.
275
276   <button>
277    <x>0</x>
278    <y>0</y>
279    <legend>OK</legend>
280    <binding>
281     <command>dialog-apply</command>
282    </binding>
283    <binding>
284     <command>dialog-close</command>
285    </binding>
286    <default>true</default>
287   </button>
288
289
290
291 combo
292 -----
293
294 A pop-up list of selections.
295
296   value - one of the selections available for the combo.  There may be
297   any number of "value" fields.
298
299 Example:
300
301   <combo>
302    <x>10</x>
303    <y>50</y>
304    <width>200</width>
305    <height>25</height>
306    <property>/environment/clouds/layer[0]/type</property>
307    <value>clear</value>
308    <value>mostly-sunny</value>
309    <value>mostly-cloudy</value>
310    <value>overcast</value>
311    <value>cirrus</value>
312   </combo>
313
314
315
316 select
317 ------
318
319 A scrollable list of selections.
320
321   selection - a path in the property tree which holds the selectable items.
322
323 Example:
324
325   <select>
326    <x>10</x>
327    <y>50</y>
328    <width>200</width>
329    <height>25</height>
330    <property>/sim/aircraft</property>
331    <selection>/sim/aircraft-types</selection>
332   </select>
333
334
335
336 slider
337 ------
338
339 A horizontal or vertical slider for setting a value.
340
341   vertical - true if the slider should be vertical, false if it should
342     be horizontal.  The default is false.
343
344   min - the minimum value for the slider.  The default is 0.0.
345
346   max - the maximum value for the slider.  The default is 1.0.
347
348 Example:
349
350   <slider>
351    <x>10</x>
352    <y>50</y>
353    <width>200</width>
354    <property>/environment/visibility-m</property>
355    <min>5</min>
356    <max>50000</max>
357   </slider>
358
359
360 dial
361 ----
362
363 A circular dial for choosing a direction.
364
365   wrap - true if the dial should wrap around, false otherwise.  The
366     default is true.
367
368   min - the minimum value for the dial.  The default is 0.0.
369
370   max - the maximum value for the dial.  The default is 1.0.
371
372 Example:
373
374   <dial>
375    <x>10</x>
376    <y>50</y>
377    <width>20</width>
378    <property>/environment/wind-from-direction-deg</property>
379    <min>0</min>
380    <max>360</max>
381   </dial>
382
383 textbox
384 -------
385
386 The text will be retrieved/buffered from/within a specified
387 property tree, like:
388
389 <textbox>
390     <!-- position -->
391     <x>100</x>
392     <y>100</y>
393
394     <!-- dimensions -->
395     <width>200</width> 
396     <height>400</height>
397
398     <property>/gui/path-to-text-node/contents</property>
399
400     <slider>15</slider> <!--width for slider -->
401     <wrap>false</wrap> <!-- don't wrap text; default: true -->
402
403     <editable>true</editable> <!-- whether the puLargeInput is supposed to be editable -->
404 </textbox>  
405
406 __end__