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