]> git.mxchange.org Git - flightgear.git/blob - docs-mini/README.gui
1cc27b937049b8b194bb1c9f16275a564f415f32
[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 compnent of the color scheme.
121   green - specify the green color compnent of the color scheme.
122   blue  - specify the blue color compnent of the color scheme.
123   alpha - specify the alpha color compnent 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
235 checkbox
236 --------
237
238 A checkbox, useful for linking to boolean properties.
239
240 Example:
241
242   <checkbox>
243    <x>150</x>
244    <y>200</y>
245    <width>12</width>
246    <height>12</height>
247    <property>/autopilot/locks/heading</property>
248   </checkbox>
249
250
251
252 button
253 ------
254
255 A push button, useful for firing command bindings.
256
257   one-shot - true if the button should pop up again after it is
258     pushed, false otherwise.  The default is true.
259
260   <button>
261    <x>0</x>
262    <y>0</y>
263    <legend>OK</legend>
264    <binding>
265     <command>dialog-apply</command>
266    </binding>
267    <binding>
268     <command>dialog-close</command>
269    </binding>
270    <default>true</default>
271   </button>
272
273
274
275 combo
276 -----
277
278 A pop-up list of selections.
279
280   value - one of the selections available for the combo.  There may be
281   any number of "value" fields.
282
283 Example:
284
285   <combo>
286    <x>10</x>
287    <y>50</y>
288    <width>200</width>
289    <height>25</height>
290    <property>/environment/clouds/layer[0]/type</property>
291    <value>clear</value>
292    <value>mostly-sunny</value>
293    <value>mostly-cloudy</value>
294    <value>overcast</value>
295    <value>cirrus</value>
296   </combo>
297
298
299
300 select
301 ------
302
303 A scrollable list of selections.
304
305   selection - a path in the property tree which holds the selectable items.
306
307 Example:
308
309   <select>
310    <x>10</x>
311    <y>50</y>
312    <width>200</width>
313    <height>25</height>
314    <property>/sim/aircraft</property>
315    <selection>/sim/aircraft-types</selection>
316   </select>
317
318
319
320 slider
321 ------
322
323 A horizontal or vertical slider for setting a value.
324
325   vertical - true if the slider should be vertical, false if it should
326     be horizontal.  The default is false.
327
328   min - the minimum value for the slider.  The default is 0.0.
329
330   max - the maximum value for the slider.  The default is 1.0.
331
332 Example:
333
334   <slider>
335    <x>10</x>
336    <y>50</y>
337    <width>200</width>
338    <property>/environment/visibility-m</property>
339    <min>5</min>
340    <max>50000</max>
341   </slider>
342
343
344 dial
345 ----
346
347 A circular dial for choosing a direction.
348
349   wrap - true if the dial should wrap around, false otherwise.  The
350     default is true.
351
352   min - the minimum value for the dial.  The default is 0.0.
353
354   max - the maximum value for the dial.  The default is 1.0.
355
356 Example:
357
358   <dial>
359    <x>10</x>
360    <y>50</y>
361    <width>20</width>
362    <property>/environment/wind-from-direction-deg</property>
363    <min>0</min>
364    <max>360</max>
365   </dial>
366
367 textbox
368 -------
369
370 The text will be retrieved/buffered from/within a specified
371 property tree, like:
372
373 <textbox>
374     <!-- position -->
375     <x>100</x>
376     <y>100</y>
377
378     <!-- dimensions -->
379     <width>200</width> 
380     <height>400</height>
381
382     <property>/gui/path-to-text-node/contents</property>
383
384     <slider>15</slider> <!--width for slider -->
385
386     <editable>true</editable> <!-- whether the puLargeInput is supposed to be editable -->
387 </textbox>  
388
389 __end__