From 16b7ffba052b66a7b78c12e65dc029b86e9d5cc8 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Tue, 28 Dec 2010 19:51:34 +0000 Subject: [PATCH] Consistent Close and title bars for Fuel & Payload, Wildfire and Route Manager dialogs. --- Nasal/gui.nas | 31 ++++--- Nasal/wildfire.nas | 34 +++++--- gui/dialogs/route-manager.xml | 157 +++++++++++++++++++++------------- 3 files changed, 142 insertions(+), 80 deletions(-) diff --git a/Nasal/gui.nas b/Nasal/gui.nas index ea098f99a..2d2d9c52b 100644 --- a/Nasal/gui.nas +++ b/Nasal/gui.nas @@ -155,7 +155,7 @@ _setlistener("/sim/signals/nasal-dir-initialized", func { menubarAutoVisibilityListener = setlistener( "/devices/status/mice/mouse/y", func(n) { if( n.getValue() == nil ) return; if( mouseMode.getValue() != 0 ) return; - + if( n.getValue() <= menubarAutoVisibilityEdge.getValue() ) menubarVisibility.setBoolValue( 1 ); @@ -372,10 +372,10 @@ var OverlaySelector = { var m = Dialog.new(data.getNode("dialog", 1), "gui/dialogs/overlay-select.xml", name); m.parents = [OverlaySelector, Dialog]; - + # resolve the path in FG_ROOT, and --fg-aircraft dir, etc m.dir = resolvepath(dir) ~ "/"; - + var relpath = func(p) substr(p, p[0] == `/`); m.nameprop = relpath(nameprop); m.sortprop = relpath(sortprop or nameprop); @@ -724,8 +724,17 @@ var showWeightDialog = func { dialog[name].set("name", name); dialog[name].set("layout", "vbox"); - var header = dialog[name].addChild("text"); - header.set("label", title); + var header = dialog[name].addChild("group"); + header.set("layout", "hbox"); + header.addChild("empty").set("stretch", "1"); + header.addChild("text").set("label", title); + header.addChild("empty").set("stretch", "1"); + var w = header.addChild("button"); + w.set("pref-width", 16); + w.set("pref-height", 16); + w.set("legend", ""); + w.set("default", 0); + w.setBinding("dialog-close"); dialog[name].addChild("hrule"); @@ -801,15 +810,17 @@ var showWeightDialog = func { weightitem = nil; } + dialog[name].addChild("hrule"); + var buttonBar = dialog[name].addChild("group"); buttonBar.set("layout", "hbox"); buttonBar.set("default-padding", 10); - var ok = buttonBar.addChild("button"); - ok.set("legend", "OK"); - ok.set("key", "esc"); - ok.setBinding("dialog-apply"); - ok.setBinding("dialog-close"); + var close = buttonBar.addChild("button"); + close.set("legend", "Close"); + close.set("default", "true"); + close.set("key", "Enter"); + close.setBinding("dialog-close"); # Temporary helper function var tcell = func(parent, type, row, col) { diff --git a/Nasal/wildfire.nas b/Nasal/wildfire.nas index 0e1188d26..cdde00c41 100644 --- a/Nasal/wildfire.nas +++ b/Nasal/wildfire.nas @@ -216,12 +216,12 @@ var parse_msg = func (source, msg) { var pos = Binary.decodeCoord(substr(msg, 6)); var radius = Binary.decodeDouble(substr(msg, 36)); resolve_retardant_drop(pos, radius, 0, 0); - } + } if (type == 4) { var pos = Binary.decodeCoord(substr(msg, 6)); var radius = Binary.decodeDouble(substr(msg, 36)); resolve_foam_drop(pos, radius, 0, 0); - } + } } ############################################################################### @@ -356,7 +356,7 @@ var FireCell = { CAFire.set_cell(me.x + d[0], me.y + d[1], FireCell.new(me.x + d[0], me.y + d[1])); - } + } } } foreach (var d; CAFire.NEIGHBOURS[1]) { @@ -385,7 +385,7 @@ var CellModel = { ############################################################ new : func (x, y, alt) { var m = { parents: [CellModel] }; - m.type = "none"; + m.type = "none"; m.model = nil; m.lat = y * CAFire.CELL_SIZE/60.0 + 0.5 * CAFire.CELL_SIZE / 60.0; m.lon = x * CAFire.CELL_SIZE/60.0 + 0.5 * CAFire.CELL_SIZE / 60.0; @@ -488,7 +488,7 @@ CAFireModels.update = func { var c = me.pending[0]; me.pending = subvec(me.pending, 1); work -= 1; - if (contains(c, "alt")) { + if (contains(c, "alt")) { if (me.grid[c.x] == nil) { me.grid[c.x] = {}; } @@ -606,7 +606,7 @@ CAFire.ignite = func (lat, lon) { # Resolve a water drop. # For now: Assume that water makes the affected cell nonflammable forever # and extinguishes it if burning. -# radius - meter : double +# radius - meter : double # Note: volume is unused ATM. CAFire.resolve_water_drop = func (lat, lon, radius, volume=0) { trace("CAFire.resolve_water_drop: Dumping water at " ~ lat ~", " ~ lon ~ @@ -652,7 +652,7 @@ CAFire.resolve_retardant_drop = func (lat, lon, radius, volume=0) { # Resolve a foam drop. # For now: Assume that water makes the affected cell nonflammable forever # and extinguishes it if burning. -# radius - meter : double +# radius - meter : double # Note: volume is unused ATM. CAFire.resolve_foam_drop = func (lat, lon, radius, volume=0) { trace("CAFire.resolve_foam_drop: Dumping foam at " ~ lat ~", " ~ lon ~ @@ -904,7 +904,7 @@ _setlistener("/sim/signals/nasal-dir-initialized", func { if (getprop(save_on_exit_pp)) CAFire.save_event_log(SAVEDIR ~ "fire_log.xml"); }); - + if (getprop(restore_on_startup_pp)) { settimer(func { # Delay loading the log until the terrain is there. Note: hack. @@ -952,7 +952,7 @@ var dialog = { me.x = x; me.y = y; me.bg = [0, 0, 0, 0.3]; # background color - me.fg = [[1.0, 1.0, 1.0, 1.0]]; + me.fg = [[1.0, 1.0, 1.0, 1.0]]; # # "private" me.title = "Wildfire"; @@ -979,12 +979,12 @@ var dialog = { titlebar.set("layout", "hbox"); titlebar.addChild("empty").set("stretch", 1); titlebar.addChild("text").set("label", "Wildfire settings"); + titlebar.addChild("empty").set("stretch", 1); var w = titlebar.addChild("button"); w.set("pref-width", 16); w.set("pref-height", 16); w.set("legend", ""); w.set("default", 0); - w.set("key", "esc"); w.setBinding("nasal", "wildfire.dialog.destroy(); "); w.setBinding("dialog-close"); me.dialog.addChild("hrule"); @@ -1011,13 +1011,25 @@ var dialog = { } me.dialog.addChild("hrule"); + # Buttons + var buttons = me.dialog.addChild("group"); + buttons.node.setValues({"layout" : "hbox"}); + # Load button. - var load = me.dialog.addChild("button"); + var load = buttons.addChild("button"); load.node.setValues({"legend" : "Load Wildfire log", "halign" : "center"}); load.setBinding("nasal", "wildfire.dialog.select_and_load()"); + # Close button + var close = buttons.addChild("button"); + close.node.setValues({"legend" : "Close", + "default" : "true", + "key" : "Esc"}); + close.setBinding("nasal", "wildfire.dialog.destroy();"); + close.setBinding("dialog-close"); + fgcommand("dialog-new", me.dialog.prop()); fgcommand("dialog-show", me.namenode); }, diff --git a/gui/dialogs/route-manager.xml b/gui/dialogs/route-manager.xml index f0ad2d1ca..5510ec147 100644 --- a/gui/dialogs/route-manager.xml +++ b/gui/dialogs/route-manager.xml @@ -21,7 +21,7 @@ command interface /autopilot/route-manager/input: var ft = getprop("/sim/startup/units") == "feet"; var dlg = props.globals.getNode("/sim/gui/dialogs/route-manager", 1); var selection = dlg.getNode("selection", 1); - var input = dlg.getNode("input", 1); + var input = dlg.getNode("input", 1); var routem = props.globals.getNode("/autopilot/route-manager", 1); selection.setIntValue(-1); @@ -32,7 +32,7 @@ command interface /autopilot/route-manager/input: var route = routem.getNode("route", 1); var dep = routem.getNode("departure", 1); var dest = routem.getNode("destination", 1); - + var sel_index = func { return int(selection.getValue()); } @@ -47,10 +47,10 @@ command interface /autopilot/route-manager/input: # when selection index is valid, insert *after* the waypoint insertIndex = insertIndex + 1; } - + cmd.setValue("@insert" ~ insertIndex ~ ":" ~ input.getValue()); input.setValue(""); - + if (insertIndex >= 0) { selection.setValue(insertIndex); gui.dialog_update("route-manager"); @@ -60,15 +60,15 @@ command interface /autopilot/route-manager/input: var remove = func { cmd.setValue("@delete" ~ sel_index()); } - + var route = func { cmd.setValue("@route" ~ sel_index()); } - + var jump_to = func { cmd.setValue("@jump" ~ sel_index()); } - + var load_route = func(path) { routem.getNode("file-path", 1).setValue(path.getValue()); cmd.setValue("@load"); @@ -80,26 +80,26 @@ command interface /autopilot/route-manager/input: cmd.setValue("@save"); gui.dialog_update("route-manager"); } - + var file_selector = gui.FileSelector.new(load_route, "Load flight-plan", "Load"); var save_selector = gui.FileSelector.new(save_route, "Save flight-plan", "Save"); var activate_fp = func { cmd.setValue("@activate"); } - + var departureRunways = dlg.getNode("departure-runways", 1); var destRunways = dlg.getNode("destination-runways", 1); var sids = dlg.getNode("sids", 1); var stars = dlg.getNode("stars", 1); - - var updateRunways = func { + + var updateRunways = func { var depIcao = dep.getNode("airport").getValue(); departureRunways.removeChildren("value"); var currentRunway = dep.getNode("runway").getValue(); var foundCurrent = 0; - + var apt = airportinfo(depIcao); if (apt != nil) { var i=0; @@ -111,16 +111,16 @@ command interface /autopilot/route-manager/input: } } } - + if (!foundCurrent) { dep.getNode("runway").clearValue(); } - + var destIcao = dest.getNode("airport").getValue(); destRunways.removeChildren("value"); currentRunway = dest.getNode("runway").getValue(); foundCurrent = 0; - + var apt = airportinfo(destIcao); if (apt != nil) { var i=0; @@ -132,15 +132,15 @@ command interface /autopilot/route-manager/input: } } } - + if (!foundCurrent) { dest.getNode("runway").clearValue(); } - + print("updated runways"); gui.dialog_update("route-manager"); } - + var updateSIDs = func { sids.removeChildren("value"); var depIcao = dep.getNode("airport").getValue(); @@ -151,17 +151,17 @@ command interface /autopilot/route-manager/input: gui.dialog_update("route-manager", "sid"); return; } - + sids.getNode("value[0]", 1).setValue("(none)"); var i=1; foreach (var s; apt.runways[rwy].sids) { sids.getNode("value[" ~ i ~ "]", 1).setValue(s); i += 1; } - + gui.dialog_update("route-manager", "sid"); } - + var updateSTARs = func { stars.removeChildren("value"); var icao = dest.getNode("airport").getValue(); @@ -172,20 +172,20 @@ command interface /autopilot/route-manager/input: gui.dialog_update("route-manager", "star"); return; } - + var i=1; stars.getNode("value[0]", 1).setValue("(none)"); foreach (var s; apt.runways[rwy].stars) { stars.getNode("value[" ~ i ~ "]", 1).setValue(s); i += 1; } - + gui.dialog_update("route-manager", "star"); } - + # initialise departure values based on current position cmd.setValue("@posinit"); - + updateRunways(); updateSIDs(); updateSTARs(); @@ -222,14 +222,19 @@ command interface /autopilot/route-manager/input: - + - hbox + table + 0 + 0 + right - 80 + 0 + 1 + left departure-airport 60 /autopilot/route-manager/departure/airport @@ -238,31 +243,38 @@ command interface /autopilot/route-manager/input: dialog-apply departure-airport - + nasal - + + 0 + 2 %s /autopilot/route-manager/departure/name true true fill - + + 0 + 3 + right + 0 + 4 + left departure-runway - 60 /autopilot/route-manager/departure/runway false /sim/gui/dialogs/route-manager/departure-runways - + dialog-apply departure-runway @@ -272,33 +284,40 @@ command interface /autopilot/route-manager/input: - + + 0 + 5 + right + 0 + 6 + left sid - 100 /autopilot/route-manager/departure/sid false /sim/gui/dialogs/route-manager/sids - + dialog-apply sid - - - - hbox + + 1 + 0 + right - 80 - destination-airport + 1 + 1 + left 60 + destination-airport /autopilot/route-manager/destination/airport true @@ -311,44 +330,57 @@ command interface /autopilot/route-manager/input: + 1 + 2 true + 200 %s /autopilot/route-manager/destination/name true fill - + + 1 + 3 + right + 1 + 4 + left destination-runway - 60 /autopilot/route-manager/destination/runway false /sim/gui/dialogs/route-manager/destination-runways - + dialog-apply destination-runway - + nasal - + + 1 + 5 + right + 1 + 6 + left star - 100 /autopilot/route-manager/destination/star false /sim/gui/dialogs/route-manager/stars - + dialog-apply star @@ -369,38 +401,38 @@ command interface /autopilot/route-manager/input: 150 /autopilot/route-manager/alternate/airport - + --> hbox + right - 80 cruise-speed true - fill + left true - 150 + 100 /autopilot/route-manager/cruise/speed-kts - + - 80 + right cruise-alt true - fill + left true - 150 + 100 /autopilot/route-manager/cruise/altitude-ft - + @@ -560,7 +592,7 @@ command interface /autopilot/route-manager/input: - + true +