20,741
edits
m (→Proof of concept: the weekend is over ...) |
m (→GUI frontend: add hooks for supporting tooltips) |
||
Line 297: | Line 297: | ||
myCanvas.setLayout(myLayout); | myCanvas.setLayout(myLayout); | ||
var setupWidgetTooltip = func(widget, tooltip) { | |||
widget._view._root.addEventListener("mouseover", func gui.popupTip(tooltip) ); | |||
var setupLabeledInput = func(root, layout, text, default_value, focus) { | } | ||
var setupLabeledInput = func(root, layout, text, default_value, focus, tooltip) { | |||
var label = canvas.gui.widgets.Label.new(root, canvas.style, {wordWrap: 0}); | var label = canvas.gui.widgets.Label.new(root, canvas.style, {wordWrap: 0}); | ||
Line 312: | Line 317: | ||
if (focus) | if (focus) | ||
input.setFocus(); | input.setFocus(); | ||
# input._view._root.addEventListener("mouseover", func gui.popupTip(tooltip) ); | |||
setupWidgetTooltip(widget:input, tooltip: tooltip); | |||
} # setupLabeledInput() | } # setupLabeledInput() | ||
Line 366: | Line 374: | ||
var inputs = [ | var inputs = [ | ||
{text: 'Aircraft root property:', default_value:'/position', focus:1, callback:nil, tooltip: | {text: 'Aircraft root property:', default_value:'/position', focus:1, callback:nil, tooltip:'property path', validate: 'AircraftRoot', convert:nil}, | ||
{text: 'Airport:', default_value:'KSFO', focus:0, callback:nil, tooltip: | {text: 'Airport:', default_value:'KSFO', focus:0, callback:nil, tooltip:'ICAO ID, e.g. KSFO', validate: 'Airport', convert:nil}, | ||
{text: 'Runway:', default_value:'28R', focus:0, callback:nil, tooltip: | {text: 'Runway:', default_value:'28R', focus:0, callback:nil, tooltip:'runway identifier, e.g. 28L', validate: 'Runway', convert:nil}, | ||
{text: 'Final Approach (nm):', default_value:'10.00', focus:0, callback:nil, tooltip: | {text: 'Final Approach (nm):', default_value:'10.00', focus:0, callback:nil, tooltip:'length of final approach leg', validate: 'FinalApproach', convert:nil}, | ||
{text: 'Glidepath:', default_value:'3.00', focus:0, callback:nil, tooltip: | {text: 'Glidepath:', default_value:'3.00', focus:0, callback:nil, tooltip:'glidepath in degrees, e.g. 3', validate: 'Glidepath', convert:nil}, | ||
{text: 'Safety Slope:', default_value:'2.00', focus:0, callback:nil, tooltip: | {text: 'Safety Slope:', default_value:'2.00', focus:0, callback:nil, tooltip:'safety slope in degrees', validate: 'SafetySlope', convert:nil}, | ||
{text: 'Decision Height (ft):', default_value:'200.00', focus:0, callback:nil, tooltip: | {text: 'Decision Height (ft):', default_value:'200.00', focus:0, callback:nil, tooltip:'decision height (vertical offset)', validate: 'DecisionHeight', convert:nil}, | ||
{text: 'Touchdown Offset (m):', default_value:'0.00', focus:0, callback:nil, tooltip: | {text: 'Touchdown Offset (m):', default_value:'0.00', focus:0, callback:nil, tooltip:'touchdown offset', validate: 'TouchdownOffset', convert:nil}, | ||
]; # input fields | ]; # input fields | ||
Line 381: | Line 389: | ||
foreach(var input; inputs) { | foreach(var input; inputs) { | ||
# TODO: pass input hash | # TODO: pass input hash | ||
setupLabeledInput(root, myLayout, input.text, input.default_value, input.focus); | setupLabeledInput(root, myLayout, input.text, input.default_value, input.focus, input.tooltip); | ||
} | } | ||
Line 414: | Line 422: | ||
# print("Button clicked !"); | # print("Button clicked !"); | ||
}); | }); | ||
setupWidgetTooltip(widget:button, tooltip: "toggle GCA on/off"); | |||
myLayout.addItem(button); | myLayout.addItem(button); |