Nasal/multiplayer.nas: improved font handling in Pilot List dialog.
It looks like widgets don't inherit font or colour from parent widgets. Also, setting font=nil gives sublety different results compared to leaving font unspecified. So we now set font and colour explicitly for every widget using new function set_default(). Also set font and colour of 'Pilots:' widgets and heading widget to me.fg[1] to match other text.
This commit is contained in:
parent
0f741b16fe
commit
2d8ec16afc
1 changed files with 31 additions and 16 deletions
|
@ -191,25 +191,26 @@ var dialog = {
|
|||
if (me.font.name == nil) {
|
||||
# We try to cope if no font is specified, so that we inherit
|
||||
# whatever default there is.
|
||||
printf("Failed to find font for Pilot List dialog");
|
||||
me.font = nil;
|
||||
}
|
||||
|
||||
me.header = ["view", " callsign", " model", func dialog.dist_hdr, func dialog.alt_hdr ~ " ", "", " brg", "chat", "ignore" ~ " ", " code", "ver", "airport", " set"];
|
||||
me.columns = [
|
||||
{ type: "checkbox", legend: "", property: "view", halign: "right", "pref-height": 14, "pref-width": 14, callback: "multiplayer.view_select", argprop: "callsign", },
|
||||
{ type: "text", property: "callsign", format: " %s", label: "-----------", halign: "fill" , font: me.font },
|
||||
{ type: "text", property: "model-short", format: " %s", label: "--------------", halign: "fill" , font: me.font },
|
||||
{ type: "text", property: func dialog.dist_node, format:" %8.2f", label: "---------", halign: "right", font: me.font },
|
||||
{ type: "text", property: func dialog.alt_node, format:" %7.0f", label: "---------", halign: "right", font: me.font },
|
||||
{ type: "text", property: "ascent_descent", format: "%s", label: "-", halign: "right", font: me.font },
|
||||
{ type: "text", property: "bearing-to", format: " %3.0f", label: "----", halign: "right", font: me.font },
|
||||
{ type: "text", property: "callsign", format: " %s", label: "-----------", halign: "fill" },
|
||||
{ type: "text", property: "model-short", format: " %s", label: "--------------", halign: "fill" },
|
||||
{ type: "text", property: func dialog.dist_node, format:" %8.2f", label: "---------", halign: "right" },
|
||||
{ type: "text", property: func dialog.alt_node, format:" %7.0f", label: "---------", halign: "right" },
|
||||
{ type: "text", property: "ascent_descent", format: "%s", label: "-", halign: "right" },
|
||||
{ type: "text", property: "bearing-to", format: " %3.0f", label: "----", halign: "right" },
|
||||
{ type: "button", legend: "", halign: "right", callback: "multiplayer.compose_message", "pref-height": 14, "pref-width": 14 },
|
||||
{ type: "checkbox", property: "controls/invisible", callback: "multiplayer.dialog.toggle_ignore",
|
||||
argprop: "callsign", label: "---------", halign: "right", font: me.font },
|
||||
{ type: "text", property: "id-code", format: " %s", label: "-", halign: "fill" , font: me.font },
|
||||
{ type: "text", property: "sim/multiplay/protocol-version", format: " %s", label: "--", halign: "fill" , font: me.font },
|
||||
{ type: "text", property: "airport-id", format: "%s", label: "----", halign: "fill" , font: me.font },
|
||||
{ type: "text", property: "set-loaded", format: "%s", label: "----", halign: "fill" , font: me.font },
|
||||
argprop: "callsign", label: "---------", halign: "right" },
|
||||
{ type: "text", property: "id-code", format: " %s", label: "-", halign: "fill" },
|
||||
{ type: "text", property: "sim/multiplay/protocol-version", format: " %s", label: "--", halign: "fill" },
|
||||
{ type: "text", property: "airport-id", format: "%s", label: "----", halign: "fill" },
|
||||
{ type: "text", property: "set-loaded", format: "%s", label: "----", halign: "fill" },
|
||||
];
|
||||
me.cs_warnings = {};
|
||||
me.name = "who-is-online";
|
||||
|
@ -243,6 +244,15 @@ var dialog = {
|
|||
|
||||
me.dialog.setColor(me.bg[0], me.bg[1], me.bg[2], me.bg[3]);
|
||||
|
||||
# Sets out default foreground colour and also me.font if it is not nil.
|
||||
#
|
||||
set_default = func(w) {
|
||||
w.setColor(me.fg[1][0], me.fg[1][1], me.fg[1][2], me.fg[1][3],);
|
||||
if (me.font != nil) {
|
||||
w.node.setValues({ "font": me.font});
|
||||
}
|
||||
}
|
||||
|
||||
var titlebar = me.dialog.addChild("group");
|
||||
titlebar.set("layout", "hbox");
|
||||
|
||||
|
@ -257,10 +267,13 @@ var dialog = {
|
|||
w.setBinding("nasal", "multiplayer.dialog.toggle_unit(); multiplayer.dialog._redraw_()");
|
||||
|
||||
titlebar.addChild("empty").set("stretch", 1);
|
||||
titlebar.addChild("text").set("label", "Pilots: ");
|
||||
var w = titlebar.addChild("text");
|
||||
w.set("label", "Pilots: ");
|
||||
set_default(w);
|
||||
|
||||
var p = titlebar.addChild("text");
|
||||
p.node.setValues({ label: "---", live: 1, format: "%d", property: "ai/models/num-players" });
|
||||
var w = titlebar.addChild("text");
|
||||
set_default(w);
|
||||
w.node.setValues({ label: "---", live: 1, format: "%d", property: "ai/models/num-players" });
|
||||
titlebar.addChild("empty").set("stretch", 1);
|
||||
|
||||
var w = titlebar.addChild("button");
|
||||
|
@ -279,10 +292,9 @@ var dialog = {
|
|||
var col = 0;
|
||||
foreach (var h; me.header) {
|
||||
var w = content.addChild("text");
|
||||
if (me.font != nil) w.node.setValues({ "font" : me.font});
|
||||
|
||||
var l = typeof(h) == "func" ? h() : h;
|
||||
w.node.setValues({ "label": l, "row": row, "col": col, halign: me.columns[col].halign });
|
||||
set_default(w);
|
||||
w = content.addChild("hrule");
|
||||
w.node.setValues({ "row": row + 1, "col": col });
|
||||
col += 1;
|
||||
|
@ -312,6 +324,7 @@ var dialog = {
|
|||
if (column.type == "button") {
|
||||
w = content.addChild("button");
|
||||
w.node.setValues(column);
|
||||
set_default(w);
|
||||
w.setBinding("nasal", column.callback ~ "(\"" ~ mp.callsign ~ "\",);");
|
||||
w.node.setValues({ row: row, col: col});
|
||||
} else {
|
||||
|
@ -319,9 +332,11 @@ var dialog = {
|
|||
if (column.type == "text") {
|
||||
w = content.addChild("text");
|
||||
w.node.setValues(column);
|
||||
set_default(w);
|
||||
} elsif (column.type == "checkbox") {
|
||||
w = content.addChild("checkbox");
|
||||
w.setBinding("nasal", column.callback ~ "(getprop(\"" ~ mp.root ~ "/" ~ column.argprop ~ "\"))");
|
||||
set_default(w);
|
||||
}
|
||||
w.node.setValues({ row: row, col: col, live: 1, property: mp.root ~ "/" ~ p });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue