Merge /u/jsb1685/fgdata/ branch next into next
https://sourceforge.net/p/flightgear/fgdata/merge-requests/127/
This commit is contained in:
commit
d9c13e9a81
3 changed files with 102 additions and 25 deletions
|
@ -92,6 +92,7 @@ var Window = {
|
||||||
# Destructor
|
# Destructor
|
||||||
del: func
|
del: func
|
||||||
{
|
{
|
||||||
|
me._title.del();
|
||||||
me.clearFocus();
|
me.clearFocus();
|
||||||
|
|
||||||
if( me["_canvas"] != nil )
|
if( me["_canvas"] != nil )
|
||||||
|
@ -288,9 +289,9 @@ var Window = {
|
||||||
|
|
||||||
var suffix = me._focused ? "" : "-unfocused";
|
var suffix = me._focused ? "" : "-unfocused";
|
||||||
me._title_bar_bg.set("fill", style.getColor("title" ~ suffix));
|
me._title_bar_bg.set("fill", style.getColor("title" ~ suffix));
|
||||||
me._frame.set("stroke", style.getColor("title" ~ suffix));
|
me._frame.setStroke(style.getColor("title" ~ suffix));
|
||||||
me._title.set( "fill", style.getColor("title-text" ~ suffix));
|
me._title.setColor(style.getColor("title-text" ~ suffix));
|
||||||
me._top_line.set( "stroke", style.getColor("title-highlight" ~ suffix));
|
me._top_line.setStroke(style.getColor("title-highlight" ~ suffix));
|
||||||
|
|
||||||
me.getCanvasDecoration()
|
me.getCanvasDecoration()
|
||||||
.data("focused", me._focused)
|
.data("focused", me._focused)
|
||||||
|
@ -457,17 +458,15 @@ var Window = {
|
||||||
button_close.listen("clicked", func me.del());
|
button_close.listen("clicked", func me.del());
|
||||||
|
|
||||||
# title
|
# title
|
||||||
me._title = title_bar.createChild("text", "title")
|
|
||||||
.set("alignment", "left-center")
|
|
||||||
.set("character-size", 14)
|
|
||||||
.set("font", "LiberationFonts/LiberationSans-Bold.ttf")
|
|
||||||
.setTranslation( int(x + 1.5 * w + 0.5),
|
|
||||||
int(y + 0.5 * h + 0.5) );
|
|
||||||
|
|
||||||
var title = me.get("title", "Canvas Dialog");
|
var title = me.get("title", "Canvas Dialog");
|
||||||
me._node.getNode("title", 1).alias(me._title._node.getPath() ~ "/text");
|
me._title = title_bar.createChild("text", "title")
|
||||||
me.set("title", title);
|
.setText(title)
|
||||||
|
.setAlignment("left-center")
|
||||||
|
.set("character-size", 14)
|
||||||
|
.setFont("LiberationFonts/LiberationSans-Bold.ttf")
|
||||||
|
.setTranslation(int(x + 1.5 * w + 0.5), int(y + 0.5 * h + 0.5));
|
||||||
|
|
||||||
|
me._node.getNode("title", 1).alias(me._title._node.getPath() ~ "/text");
|
||||||
title_bar.addEventListener("drag", func(e) me.move(e.deltaX, e.deltaY));
|
title_bar.addEventListener("drag", func(e) me.move(e.deltaX, e.deltaY));
|
||||||
|
|
||||||
me._resizeDecoration();
|
me._resizeDecoration();
|
||||||
|
@ -495,7 +494,7 @@ var Window = {
|
||||||
.moveTo(border_radius - 2, 2)
|
.moveTo(border_radius - 2, 2)
|
||||||
.lineTo(me.get("size[0]") - border_radius + 2, 2);
|
.lineTo(me.get("size[0]") - border_radius + 2, 2);
|
||||||
}
|
}
|
||||||
};
|
}; #Window
|
||||||
|
|
||||||
# Clear focus on click outside any window
|
# Clear focus on click outside any window
|
||||||
getDesktop().addEventListener("mousedown", func {
|
getDesktop().addEventListener("mousedown", func {
|
||||||
|
|
|
@ -725,7 +725,7 @@ var parsesvg = func(group, path, options = nil)
|
||||||
id = tspan.attr['id'];
|
id = tspan.attr['id'];
|
||||||
|
|
||||||
pushElement('text', id);
|
pushElement('text', id);
|
||||||
stack[-1].set("text", tspan.text);
|
stack[-1].setText(tspan.text);
|
||||||
|
|
||||||
if( x != 0 or y != 0 )
|
if( x != 0 or y != 0 )
|
||||||
stack[-1].setTranslation(x, y);
|
stack[-1].setTranslation(x, y);
|
||||||
|
|
|
@ -7,8 +7,12 @@
|
||||||
# debug.local([<frame:int>]) ... dump local variables of current
|
# debug.local([<frame:int>]) ... dump local variables of current
|
||||||
# or given frame
|
# or given frame
|
||||||
#
|
#
|
||||||
# debug.backtrace([<comment:string>]} ... writes backtrace with local variables
|
# debug.backtrace([<comment:string>], [<dump:bool=1>], [<skip_level:int=0>]}
|
||||||
# (similar to gdb's "bt full)
|
# ... writes backtrace (similar to gdb's "bt full)
|
||||||
|
# dump=0: only call stack
|
||||||
|
# dump=1 (default): with local variables
|
||||||
|
# skip_level: remove this many levels from
|
||||||
|
# call stack
|
||||||
#
|
#
|
||||||
# debug.proptrace([<property [, <frames>]]) ... trace property write/add/remove
|
# debug.proptrace([<property [, <frames>]]) ... trace property write/add/remove
|
||||||
# events under the <property> subtree for
|
# events under the <property> subtree for
|
||||||
|
@ -264,14 +268,15 @@ var local = func(frame = 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var backtrace = func(desc = nil) {
|
var backtrace = func(desc = nil, dump_vars = 1, skip_level = 0) {
|
||||||
var d = desc == nil ? "" : " '" ~ desc ~ "'";
|
var d = (desc == nil) ? "" : " '" ~ desc ~ "'";
|
||||||
print("\n" ~ _title("\n### backtrace" ~ d ~ " ###"));
|
print("");
|
||||||
for (var i = 1; 1; i += 1) {
|
print(_title("### backtrace" ~ d ~ " ###"));
|
||||||
if ((var v = caller(i)) == nil)
|
skip_level += 1;
|
||||||
return;
|
for (var i = skip_level; 1; i += 1) {
|
||||||
print(_section(sprintf("#%-2d called from %s, line %s:", i - 1, v[2], v[3])));
|
if ((var v = caller(i)) == nil) return;
|
||||||
dump(v[0]);
|
print(_section(sprintf("#%-2d called from %s, line %s:", i - skip_level, v[2], v[3])));
|
||||||
|
if (dump_vars) dump(v[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var bt = backtrace;
|
var bt = backtrace;
|
||||||
|
@ -433,6 +438,79 @@ var isnan = func {
|
||||||
return !!size(err);
|
return !!size(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Breakpoint (BP) - do conditional backtrace (BT) controlled via property tree
|
||||||
|
# * count how often the BP was hit
|
||||||
|
# * do only a limited number of BT, avoid flooding the log / console
|
||||||
|
#
|
||||||
|
# Data can be viewed / modified in the prop tree /_debug/nas/bp-<myLabel>/*
|
||||||
|
# * tokens: number of backtraces to do; each hit will decrease this by 1
|
||||||
|
# * hits: total number of hits
|
||||||
|
#
|
||||||
|
# == Example ==
|
||||||
|
# var myBP = debug.Breakpoint.new("myLabel", 0);
|
||||||
|
# myBP.enable(4); # allow 4 hits, then be quiet
|
||||||
|
#
|
||||||
|
# #at the place of interest (e.g. in some loop or class method) insert:
|
||||||
|
# myBP.hit(); # do backtrace here if tokens > 0, reduce tokens by 1
|
||||||
|
#
|
||||||
|
# print(myBP.getHits()); # print total number of hits
|
||||||
|
#
|
||||||
|
var Breakpoint = {
|
||||||
|
# label: Used in property path and as text for backtrace.
|
||||||
|
# dump_locals: bool passed to backtrace. Dump variables in BT.
|
||||||
|
new: func(label, dump_locals = 1) {
|
||||||
|
var obj = {
|
||||||
|
parents: [Breakpoint],
|
||||||
|
_tokensN: nil,
|
||||||
|
tokens: 0,
|
||||||
|
_hitsN: nil,
|
||||||
|
hits: 0,
|
||||||
|
label: "",
|
||||||
|
dump_locals: num(dump_locals),
|
||||||
|
};
|
||||||
|
label = globals.string.replace(label, " ", "_");
|
||||||
|
obj.label = globals.string.replace(label, "/", "_");
|
||||||
|
var prop_path = "/_debug/nas/bp-"~obj.label~"/";
|
||||||
|
obj._tokensN = props.globals.getNode(prop_path~"token", 1);
|
||||||
|
obj._hitsN = props.globals.getNode(prop_path~"hits", 1);
|
||||||
|
obj._hitsN.setIntValue(0);
|
||||||
|
obj.disable();
|
||||||
|
return obj;
|
||||||
|
},
|
||||||
|
|
||||||
|
# enable BP and set hit limit;
|
||||||
|
# tokens: int > 0; default: 1 (single shot); 0 allowed (=disable);
|
||||||
|
enable: func(tokens = 1) {
|
||||||
|
if (num(tokens) == nil) tokens = 1;
|
||||||
|
if (tokens < 0) tokens = 0;
|
||||||
|
me.tokens = tokens;
|
||||||
|
me._tokensN.setIntValue(tokens);
|
||||||
|
return me;
|
||||||
|
},
|
||||||
|
|
||||||
|
# set tokens to zero, disables backtrace in hit()
|
||||||
|
disable: func {
|
||||||
|
me._tokensN.setIntValue(0);
|
||||||
|
return me;
|
||||||
|
},
|
||||||
|
|
||||||
|
# get total number of hits (not #backtraces done)
|
||||||
|
getHits: func {
|
||||||
|
return me.hits;
|
||||||
|
},
|
||||||
|
|
||||||
|
# hit the breakpoint, e.g. do backtrace if we have tokens available
|
||||||
|
hit: func() {
|
||||||
|
me.hits += 1;
|
||||||
|
me._hitsN.setIntValue(me.hits);
|
||||||
|
me.tokens = me._tokensN.getValue();
|
||||||
|
if (me.tokens > 0) {
|
||||||
|
debug.backtrace(me.label, me.dump_locals, 1);
|
||||||
|
me._tokensN.setValue(me.tokens - 1);
|
||||||
|
}
|
||||||
|
return me;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
# --prop:debug=1 enables debug mode with additional warnings
|
# --prop:debug=1 enables debug mode with additional warnings
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue