1
0
Fork 0

The cached tip dialog broke when layout management went in (previous

x/y/width/height values went into the calculation for the next popup,
and things got iteratively worse due to padding issues).  But the
good news is that this whole subsystem is vastly simpler when
implemented with the new interface.
This commit is contained in:
andy 2004-05-12 18:41:29 +00:00
parent f49f0d18c7
commit 42cd87bbfe

View file

@ -6,20 +6,13 @@
# is finished, you lose. :) # is finished, you lose. :)
# #
popupTip = func { popupTip = func {
msg = arg[0];
delay = if(size(arg) > 1) {arg[1]} else {DELAY}; delay = if(size(arg) > 1) {arg[1]} else {DELAY};
labelNode.setValue(msg); tmpl = { name : "PopTip", modal : 0, layout : "hbox",
y: screenHProp.getValue() - 140,
# The "width" value here is a hardcoded hack that assumes 9 pixels text : { label : arg[0], padding : 6 } };
# as a "typical" character width and adds some extra for the
# widgets to play with. Bah. Pui needs a layout engine...
width = 9 * size(msg) + 40;
popupNode.getNode("width").setIntValue(width);
popupNode.getNode("x").setIntValue((screenWProp.getValue() - width)/2);
popupNode.getNode("y").setIntValue(screenHProp.getValue() - 140);
popdown(); popdown();
fgcommand("dialog-new", popupNode); fgcommand("dialog-new", props.Node.new(tmpl));
fgcommand("dialog-show", tipArg); fgcommand("dialog-show", tipArg);
currTimer = currTimer + 1; currTimer = currTimer + 1;
@ -33,22 +26,13 @@ popupTip = func {
## ##
# Initialize property nodes via a timer, to insure the props module is # Initialize property nodes via a timer, to insure the props module is
# loaded. See notes in view.nas # loaded. See notes in view.nas. Simply cache the screen height
# property and the argument for the "dialog-show" command. This
# probably isn't really needed...
# #
screenWProp = screenHProp = popupNode = labelNode = tipArg = nil; screenHProp = tipArg = nil;
INIT = func { INIT = func {
screenWProp = props.globals.getNode("/sim/startup/xsize");
screenHProp = props.globals.getNode("/sim/startup/ysize"); screenHProp = props.globals.getNode("/sim/startup/ysize");
# Set up the dialog property node:
tmpl = { name : "PopTip", modal : 0,
x : 100, y : 100, width : 120, height : 40,
text : { x : 10, y : 6, label : "NOTE" } };
popupNode = props.Node.new(tmpl);
labelNode = popupNode.getNode("text/label");
fgcommand("dialog-new", popupNode);
# Cache the command argument for popup/popdown
tipArg = props.Node.new({ "dialog-name" : "PopTip" }); tipArg = props.Node.new({ "dialog-name" : "PopTip" });
} }
settimer(INIT, 0); settimer(INIT, 0);