From 54954eb8de4c6afe919783559cb7dfdd76572986 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 12 May 2004 15:37:17 +0000 Subject: [PATCH] GUI layout management and a few visual/eye-candy modifications. See DOCS/README.layout in the base package for details, along with the modified dialog files. --- Docs/README.layout | 85 ++++ Nasal/autopilot.nas | 80 +++ Nasal/props.nas | 2 +- gui/dialogs/airports.xml | 104 ++-- gui/dialogs/autopilot.xml | 754 +++++++++++------------------ gui/dialogs/exit.xml | 66 +-- gui/dialogs/location-in-air.xml | 274 +++++------ gui/dialogs/location-on-ground.xml | 225 +++------ gui/dialogs/logging.xml | 640 +++++++++--------------- gui/dialogs/rendering.xml | 162 +++---- gui/dialogs/replay.xml | 190 +++----- gui/dialogs/static-lod.xml | 195 ++++---- 12 files changed, 1204 insertions(+), 1573 deletions(-) create mode 100644 Docs/README.layout create mode 100644 Nasal/autopilot.nas diff --git a/Docs/README.layout b/Docs/README.layout new file mode 100644 index 000000000..4ee75a248 --- /dev/null +++ b/Docs/README.layout @@ -0,0 +1,85 @@ +I just commited an implementation of GUI layout management, ported +over from my game project last year*. What this means is that you no +longer need to position your widgets manually in dialogs, and can +instead lay them out in tables and boxes like the pros do. :) I've +redone a few of the dialogs using the new scheme (I'm especially proud +of the autopilot dialog: http://plausible.org/andy/autopilot-new.png), +so you can see what the possibilities look like. + +* FWIW, this is almost the last of my useful code from last spring. + Nasal and the Plib vertex splitting code are two other bits that + were useful in isolation. I also had a terrain engine and stencil + shadow implementation, but those weren't really production quality. + +Basically, the implementation is a preprocessor on top of the existing +dialog properties, which sets x/y/width/height values based on +constraints. The objects, including the top-level one which +represents the whole dialog, can now have a property, which +can be "hbox", "vbox", or "table". + +The boxes simply lay out their children in order, either top-to-bottom +or left-to-right. The box name comes from Qt and Gtk, but this is +also the same thing that Java calls a "flow layout", or what the Tk +"packer" does. You can set "constraint" properties on the children, +to give the layout manager hints as to how to place the children. For +the boxes, these are: + + equal: The box manager makes sure that all the widgets with this + constraint set to true get equal sizes big enough to fit the + largest one. This is very useful for button boxes to make + the "OK" and "Cancel" buttons match, for example. + stretch: Cells with "stretch" set to true get all the extra space, + if any, the box has to allocate. These are useful for + alignment purposes, especially when combined with + "widgets" (which are ignored by the dialog creation code, + but honored by the layout engine). + +The table layout will be a little more familiar to anyone with HTML +experience. Children of tables get the following constraints: + + row: The row number containing the upper left corner of the widget. + Table rows are zero-indexed. + col: The column number containing the upper left corner of the widget. + Table columns are zero-indexed. + rowspan: The number of rows spanned by the widget. Defaults to one. + colspan: The number of columns spanned by the widget. Defaults to + one. + +Inside of each "cell", regardless of parent layout, there are some +constraints that are used to position the widget within the space +available: + + halign: The horizontal alignment. Can be "left", "right", + "center", or "fill" (i.e. stretch to available space). + valign: The vertical alignment. Can be "top", "bottom", + "center", or "fill". + padding: The number of pixels to leave between the edge of the + cell and the widget. + pref-height: + pref-width: Overrides the default preferred size of the widget. + Note that this is the size of the widget only, not the + cell (which includes padding). + +Also, the padding values for cells in a group can be set to a default +value with a property on the group widget. + +Some will ask why didn't I implement this as part of Pui. The problem +is the pui just isn't set up for it. Not only is there no notion of +"preferred" size for a widget, there isn't anything remote like a +"constraint" system for attaching arbitrary values to widgets. With +the property system, I have that for free (the original code was +written to work with Nasal objects, btw). I can do the layout with +the properties and on the properties, and our existing dialog code +hardly needs to change at all. + +Anyway, give it a try and see if I've broken anything. Also, note +that some of these changes *do* modify the visual appearance of the +GUI. I think it looks better, but opinions will no doubt vary. Shout +if you hate it. + +And finally, the text alignment doesn't quite look right with current +plib due to some minor rendering bugs. Bug Steve to apply the patch I +submitted a week or so ago. :) + +Andy + diff --git a/Nasal/autopilot.nas b/Nasal/autopilot.nas new file mode 100644 index 000000000..42b58d547 --- /dev/null +++ b/Nasal/autopilot.nas @@ -0,0 +1,80 @@ +## +## These are just GUI helper routines. The autopilot itself is not a +## Nasal module. +## + +tagSettings = + { + "hdg-wing" : ["/autopilot/locks/heading", "wing-leveler"], + "hdg-bug" : ["/autopilot/locks/heading", "dg-heading-hold"], + "hdg-true" : ["/autopilot/locks/heading", "true-heading-hold"], + "hdg-nav" : ["/autopilot/locks/heading", "nav1-hold"], + "vel-throttle" : ["/autopilot/locks/speed", "speed-with-throttle"], + "vel-pitch" : ["/autopilot/locks/speed", "speed-with-pitch-trim"], + "alt-vert" : ["/autopilot/locks/altitude", "vertical-speed-hold"], + "alt-pitch" : ["/autopilot/locks/altitude", "pitch-hold"], + "alt-aoa" : ["/autopilot/locks/altitude", "aoa-hold"], + "alt-alt" : ["/autopilot/locks/altitude", "altitude-hold"], + "alt-agl" : ["/autopilot/locks/altitude", "agl-hold"], + "alt-gs" : ["/autopilot/locks/altitude", "gs1-hold"] + }; + +radioGroups = [["hdg-wing", "hdg-bug", "hdg-true", "hdg-nav"], + ["vel-throttle", "vel-pitch"], + ["alt-vert", "alt-pitch", "alt-aoa", "alt-alt", + "alt-agl", "alt-gs"]]; + +# Initialize to get the types of the gui properties correct +INIT = func { + guinode = props.globals.getNode("/autopilot/gui", 1); + foreach(tag; keys(tagSettings)) { + guinode.getNode(tag, 1).setBoolValue(0); + } +} +settimer(INIT, 0); + +update = func { + # Suck out the values from the dialog + fgcommand("dialog-apply", props.Node.new()); + + # Sanitize the radio buttons such that only one is selected. We are + # passed a tag indicating the one that was pressed. + if(size(arg) > 0) { + tag = arg[0]; + foreach(group; radioGroups) { + for(i=0; i= 0 and typeof(arg[0]) == "hash") { + if(size(arg) > 0 and typeof(arg[0]) == "hash") { result.setValues(arg[0]); } return result; diff --git a/gui/dialogs/airports.xml b/gui/dialogs/airports.xml index 8196b3489..f9638e3de 100644 --- a/gui/dialogs/airports.xml +++ b/gui/dialogs/airports.xml @@ -1,60 +1,62 @@ - + airports + vbox - airports - 480 - 480 - true + + + - - 10 - 450 - - + + + 440 + 360 + /sim/presets/airport-id + - - 10 - 40 - 440 - 360 - /sim/presets/airport-id - + + hbox + 10 + true - + - + true + + + true + diff --git a/gui/dialogs/autopilot.xml b/gui/dialogs/autopilot.xml index 219022e2e..902e582e3 100644 --- a/gui/dialogs/autopilot.xml +++ b/gui/dialogs/autopilot.xml @@ -1,484 +1,316 @@ - + autopilot + vbox - autopilot - 500 - 580 - false + - - 10 - 550 - - + - + + hbox + + + vbox + + hbox + + true + + + /autopilot/gui/hdg-active + + nasal + + + + - - 10 - 510 - - + + table + + + right + 00 + + + 01 + /autopilot/gui/hdg-wing + + nasal + + + - + + + right + 10 + + + 11 + /autopilot/gui/hdg-bug + + nasal + + + + + 12 + hdg-bug + /autopilot/settings/heading-bug-deg + - + + + right + 20 + + + 21 + /autopilot/gui/hdg-true + + nasal + + + + + 22 + hdg-true + /autopilot/settings/true-heading-deg + - - 10 - 480 - - + + + right + 30 + + + 31 + /autopilot/gui/hdg-nav + + nasal + + + + - + + true + 28 + - - 10 - 450 - - + + hbox + + true + + + /autopilot/gui/vel-active + + nasal + + + + - - heading-bug - 150 - 450 - 150 - 25 - /autopilot/settings/heading-bug-deg - + + table + + + right + 00 + + + 01 + /autopilot/gui/vel-throttle + + nasal + + + + + 02 + vel-throttle + /autopilot/settings/target-speed-kt + - + + + right + 10 + + + 11 + /autopilot/gui/vel-pitch + + nasal + + + + + 12 + vel-pitch + /autopilot/settings/target-speed-kt + + + + + + + vbox + + hbox + + true + + + /autopilot/gui/alt-active + + nasal + + + + - - 10 - 420 - - + + table + + + right + 00 + + + 01 + /autopilot/gui/alt-vert + + nasal + + + + + 02 + alt-vert + /autopilot/settings/vertical-speed-fpm + - - true-heading - 150 - 420 - 150 - 25 - /autopilot/settings/true-heading-deg - + + + right + 10 + + + 11 + /autopilot/gui/alt-pitch + + nasal + + + + + 12 + alt-pitch + /autopilot/settings/target-pitch-deg + - + + + right + 20 + + + 21 + /autopilot/gui/alt-aoa + + nasal + + + + + 22 + alt-aoa + /autopilot/settings/target-aoa-deg + - - 10 - 390 - - + + + right + 30 + + + 31 + /autopilot/gui/alt-alt + + nasal + + + + + 32 + alt-alt + /autopilot/settings/target-altitude-ft + - + + + right + 40 + + + 41 + /autopilot/gui/alt-agl + + nasal + + + + + 42 + alt-agl + /autopilot/settings/target-agl-ft + - + + + right + 50 + + + 51 + /autopilot/gui/alt-gs + + nasal + + + + - - 10 - 350 - - + true - + + - + - - 10 - 320 - - - - - vertical-speed-fpm - 150 - 320 - 150 - 25 - /autopilot/settings/vertical-speed-fpm - - - - - - 10 - 290 - - - - - pitch-deg - 150 - 290 - 150 - 25 - /autopilot/settings/target-pitch-deg - - - - - - 10 - 260 - - - - - aoa-deg - 150 - 260 - 150 - 25 - /autopilot/settings/target-aoa-deg - - - - - - 10 - 230 - - - - - altitude - 150 - 230 - 150 - 25 - /autopilot/settings/target-altitude-ft - - - - - - 10 - 200 - - - - - agl - 150 - 200 - 150 - 25 - /autopilot/settings/target-agl-ft - - - - - - 10 - 170 - - - - - - - - - 10 - 130 - - - - - - - autospeed - 150 - 130 - 150 - 25 - /autopilot/settings/target-speed-kt - - - - - - 10 - 100 - - - - - - - 10 - 70 - - - - - - - - - - - - - - - - \ No newline at end of file + diff --git a/gui/dialogs/exit.xml b/gui/dialogs/exit.xml index ba3c79e0a..4e315229b 100644 --- a/gui/dialogs/exit.xml +++ b/gui/dialogs/exit.xml @@ -1,38 +1,42 @@ - + exit + true + vbox - exit - 180 - 100 - true + + + + + + hbox + fill + 10 + true - - 10 - 70 - - + - + true - + - \ No newline at end of file + true + + + diff --git a/gui/dialogs/location-in-air.xml b/gui/dialogs/location-in-air.xml index 357005ba3..ea9e0e703 100644 --- a/gui/dialogs/location-in-air.xml +++ b/gui/dialogs/location-in-air.xml @@ -1,168 +1,142 @@ - - location-in-air - 400 - 400 + location-in-air + vbox - - 10 - 360 - - + + + - - 10 - 300 - 200 - 25 - - /sim/presets/airport-id - + + table - - 10 - 270 - 200 - 25 - - /sim/presets/runway - + + 00 + right + + + + 01 + /sim/presets/airport-id + - - 10 - 240 - 200 - 25 - - /sim/presets/vor-id - + + 10 + right + + + + 11 + /sim/presets/runway + - - 10 - 210 - 200 - 25 - - /sim/presets/ndb-id - + + 20 + right + + + + 21 + /sim/presets/vor-id + - - 10 - 180 - 200 - 25 - - /sim/presets/fix - + + 30 + right + + + + 31 + /sim/presets/ndb-id + - - 10 - 150 - 200 - 25 - - /sim/presets/offset-distance - + + 40 + right + + + + 41 + /sim/presets/fix + - - 10 - 120 - 200 - 25 - - /sim/presets/altitude-ft - + + 02 + right + + + + 03 + /sim/presets/offset-distance + - - 10 - 90 - 200 - 25 - - /sim/presets/glidescope-deg - + + 12 + right + + + + 13 + /sim/presets/altitude-ft + - - 10 - 60 - 200 - 25 - - /sim/presets/airspeed-kt - + + 22 + right + + + + 23 + /sim/presets/glidescope-deg + - - - 10 - 10 + + 32 + right + + + + 33 + /sim/presets/airspeed-kt + - + - + + hbox + 10 - - - - - + + + diff --git a/gui/dialogs/location-on-ground.xml b/gui/dialogs/location-on-ground.xml index 834a5dcd9..49d4f59f0 100644 --- a/gui/dialogs/location-on-ground.xml +++ b/gui/dialogs/location-on-ground.xml @@ -1,165 +1,76 @@ - - location-on-ground - 400 - 400 + location-on-ground + vbox + + + + + + + table + center + + 00 + + + + 01 + /sim/presets/airport-id + + + 10 + + + + 11 + /sim/presets/runway + + - - 10 - 360 - - + + hbox + 10 + true - - 10 - 300 - 200 - 25 - - /sim/presets/airport-id - + - - 10 - 270 - 200 - 25 - - /sim/presets/runway - + true - - - 10 - 10 - - - - - - - - - - + + true + diff --git a/gui/dialogs/logging.xml b/gui/dialogs/logging.xml index 1869c1e3b..b44b30e1c 100644 --- a/gui/dialogs/logging.xml +++ b/gui/dialogs/logging.xml @@ -1,428 +1,234 @@ - logging - 600 - 420 - false - - - 10 - 390 - - + vbox - 0 - 360 + hbox - - 10 - 0 - 200 - 25 - /logging/log[0]/filename - - + + + fill + true + /logging/log[0]/filename + + + + + fill + /logging/log[0]/interval-ms + + - - 260 - 0 - 25 - 25 + + table + + + 02 + + + + 03 + + + + + 10 + + + + 11 + /logging/log[0]/entry[0]/enabled + + + 12 + fill + 120 + /logging/log[0]/entry[0]/title + + + 13 + fill + 240 + /logging/log[0]/entry[0]/property + + + + 20 + + + + 21 + /logging/log[0]/entry[1]/enabled + + + 22 + fill + /logging/log[0]/entry[1]/title + + + 23 + fill + /logging/log[0]/entry[1]/property + + + + 30 + + + + 31 + /logging/log[0]/entry[2]/enabled + + + 32 + fill + /logging/log[0]/entry[2]/title + + + 33 + fill + /logging/log[0]/entry[2]/property + + + + 40 + + + + 41 + /logging/log[0]/entry[3]/enabled + + + 42 + fill + /logging/log[0]/entry[3]/title + + + 43 + fill + /logging/log[0]/entry[3]/property + + + + 50 + + + + 51 + /logging/log[0]/entry[4]/enabled + + + 52 + fill + /logging/log[0]/entry[4]/title + + + 53 + fill + /logging/log[0]/entry[4]/property + + + + 60 + + + + 61 + /logging/log[0]/entry[5]/enabled + + + 62 + fill + /logging/log[0]/entry[5]/title + + + 63 + fill + /logging/log[0]/entry[5]/property + + + + 70 + + + + 71 + /logging/log[0]/entry[6]/enabled + + + 72 + fill + /logging/log[0]/entry[6]/title + + + 73 + fill + /logging/log[0]/entry[6]/property + + + + 80 + + + + 81 + /logging/log[0]/entry[7]/enabled + + + 82 + fill + /logging/log[0]/entry[7]/title + + + 83 + fill + /logging/log[0]/entry[7]/property + + + + 90 + + + + 91 + /logging/log[0]/entry[8]/enabled + + + 92 + fill + /logging/log[0]/entry[8]/title + + + 93 + fill + /logging/log[0]/entry[8]/property + + + + + /logging/log[0]/enabled - - - - - 380 - 0 - 100 - 25 - /logging/log[0]/interval-ms - - - - + + + - 0 - 330 - - - 10 - 0 - - - - - 80 - 0 - - - - - 160 - 0 - - - - - 300 - 0 - - - + hbox + true + + true + + true - - - - 0 - 300 - - - 10 - 0 - - - - - 80 - 0 - 25 - 25 - /logging/log[0]/entry[0]/enabled - - - - 160 - 0 - 120 - 25 - /logging/log[0]/entry[0]/title - - - - 300 - 0 - 200 - 25 - /logging/log[0]/entry[0]/property - - - - - - 0 - 270 - - - 10 - 0 - - - - - 80 - 0 - 25 - 25 - /logging/log[0]/entry[1]/enabled - - - - 160 - 0 - 120 - 25 - /logging/log[0]/entry[1]/title - - - - 300 - 0 - 200 - 25 - /logging/log[0]/entry[1]/property - - - - - - 0 - 240 - - - 10 - 0 - - - - - 80 - 0 - 25 - 25 - /logging/log[0]/entry[2]/enabled - - - - 160 - 0 - 120 - 25 - /logging/log[0]/entry[2]/title - - - - 300 - 0 - 200 - 25 - /logging/log[0]/entry[2]/property - - - - - - 0 - 210 - - - 10 - 0 - - - - - 80 - 0 - 25 - 25 - /logging/log[0]/entry[3]/enabled - - - - 160 - 0 - 120 - 25 - /logging/log[0]/entry[3]/title - - - - 300 - 0 - 200 - 25 - /logging/log[0]/entry[3]/property - - - - - - 0 - 180 - - - 10 - 0 - - - - - 80 - 0 - 25 - 25 - /logging/log[0]/entry[4]/enabled - - - - 160 - 0 - 120 - 25 - /logging/log[0]/entry[4]/title - - - - 300 - 0 - 200 - 25 - /logging/log[0]/entry[4]/property - - - - - - 0 - 150 - - - 10 - 0 - - - - - 80 - 0 - 25 - 25 - /logging/log[0]/entry[5]/enabled - - - - 160 - 0 - 120 - 25 - /logging/log[0]/entry[5]/title - - - - 300 - 0 - 200 - 25 - /logging/log[0]/entry[5]/property - - - - - - 0 - 120 - - - 10 - 0 - - - - - 80 - 0 - 25 - 25 - /logging/log[0]/entry[6]/enabled - - - - 160 - 0 - 120 - 25 - /logging/log[0]/entry[6]/title - - - - 300 - 0 - 200 - 25 - /logging/log[0]/entry[6]/property - - - - - - 0 - 90 - - - 10 - 0 - - - - - 80 - 0 - 25 - 25 - /logging/log[0]/entry[7]/enabled - - - - 160 - 0 - 120 - 25 - /logging/log[0]/entry[7]/title - - - - 300 - 0 - 200 - 25 - /logging/log[0]/entry[7]/property - - - - - - 0 - 60 - - - 10 - 0 - - - - - 80 - 0 - 25 - 25 - /logging/log[0]/entry[8]/enabled - - - - 160 - 0 - 120 - 25 - /logging/log[0]/entry[8]/title - - - - 300 - 0 - 200 - 25 - /logging/log[0]/entry[8]/property - - - - - - - - - \ No newline at end of file + diff --git a/gui/dialogs/rendering.xml b/gui/dialogs/rendering.xml index ee0337a94..53b6aaf6c 100644 --- a/gui/dialogs/rendering.xml +++ b/gui/dialogs/rendering.xml @@ -1,105 +1,89 @@ + rendering + false + vbox - + + + - rendering - 380 - 230 - false + + vbox + center - - 10 - 200 - - + + left + + /sim/rendering/horizon-effect + + + + left + + /sim/rendering/enhanced-lighting + + + + left + + /sim/rendering/distance-attenuation + + + + left + + /sim/rendering/specular-highlight + + - - 30 - 180 - - + + hbox + true - - 30 - 140 - 20 - 20 - - /sim/rendering/horizon-effect - + - - 30 - 110 - 20 - 20 - - /sim/rendering/enhanced-lighting - + true - - 30 - 80 - 20 - 20 - - /sim/rendering/distance-attenuation - + - - 30 - 50 - 20 - 20 - - /sim/rendering/specular-highlight - + true - - 10 + - + true - - - - - - - + + true + diff --git a/gui/dialogs/replay.xml b/gui/dialogs/replay.xml index cebc0fabc..7eba24439 100644 --- a/gui/dialogs/replay.xml +++ b/gui/dialogs/replay.xml @@ -1,120 +1,90 @@ - - - - - replay - 460 - 380 - false - - - 10 - 350 - - - - - 20 - 300 - 125 - 25 - /sim/replay/duration - - - - 10 - 270 - - - - - 10 - 250 - - - - - 20 - 200 - 200 - 25 - /sim/replay/view - 0 - 1 - 4 - - - - 10 - 170 - - - - - 10 - 145 - - - - - 10 - 125 - - - - - 10 - 105 - - - - - 10 - 80 - - + replay + false + vbox - 10 - 60 - + - - - + + table + + + 00 + right + + + + + 01 + left + /sim/replay/duration + + + + 10 + right + + + + + 11 + left + /sim/replay/view + 0 + 1 + 4 + + - - 20 - 10 + + + vbox + 0 + 6 + + + + + vbox + center + left + left + left + + + + + - - - - - + + hbox + true + + true + + true + diff --git a/gui/dialogs/static-lod.xml b/gui/dialogs/static-lod.xml index 181379f93..619b1cd43 100755 --- a/gui/dialogs/static-lod.xml +++ b/gui/dialogs/static-lod.xml @@ -1,122 +1,105 @@ + static-lod + vbox - + + + - static-lod - 380 - 260 - false + + table + center - - 10 - 230 - - + + 01 + + - - 30 - 190 - - + + 10 + right + + - - detailed - 200 - 190 - 100 - 25 - - /sim/rendering/static-lod/detailed - + + 11 + fill + /sim/rendering/static-lod/detailed + - - 30 - 150 - - + + 20 + right + + - - rough - 200 - 150 - 100 - 25 - - /sim/rendering/static-lod/rough - + + 21 + fill + /sim/rendering/static-lod/rough + - - 30 - 110 - - + + 30 + right + + - - bare - 200 - 110 - 100 - 25 - - /sim/rendering/static-lod/bare - + + 31 + fill + /sim/rendering/static-lod/bare + - - 20 - 70 - - - - 30 - 50 - - + - - 10 - - - - - - - - - - + + vbox + 0 + 6 + + + + + hbox + 10 + true + + true + + true + + true + +