2018-01-03 20:24:41 +00:00
|
|
|
# PFD UI Element - Highlight UI Element. Can have values set and retrieved
|
2018-02-01 22:28:39 +00:00
|
|
|
# Highlighting flashes the element.
|
2018-01-03 20:24:41 +00:00
|
|
|
var HighlightElement =
|
2017-12-27 19:51:54 +00:00
|
|
|
{
|
2018-01-03 20:24:41 +00:00
|
|
|
new : func (pagename, svg, name, value="", style=nil)
|
2017-12-27 19:51:54 +00:00
|
|
|
{
|
|
|
|
var obj = {
|
2018-01-03 20:24:41 +00:00
|
|
|
parents : [ HighlightElement, PFD.UIElement ],
|
2017-12-27 19:51:54 +00:00
|
|
|
_name : pagename ~ name,
|
|
|
|
_value : value,
|
|
|
|
_style : style,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (style == nil) obj._style = PFD.DefaultStyle;
|
|
|
|
|
|
|
|
obj._symbol = svg.getElementById(obj._name);
|
|
|
|
assert(obj._symbol != nil, "Unable to find element " ~ obj._name);
|
|
|
|
|
2018-02-01 22:28:39 +00:00
|
|
|
# State and timer for flashing highlighting of elements
|
2018-02-04 22:40:48 +00:00
|
|
|
# We need a separate Enabled flag as the timers are in a separate thread.
|
|
|
|
obj._highlightEnabled = 0;
|
2018-02-01 22:28:39 +00:00
|
|
|
obj._highlighted = 0;
|
|
|
|
obj._flashTimer = nil;
|
|
|
|
|
|
|
|
obj.setVisible(0);
|
2017-12-27 19:51:54 +00:00
|
|
|
|
|
|
|
return obj;
|
|
|
|
},
|
|
|
|
|
|
|
|
getName : func() { return me._name; },
|
|
|
|
getValue : func() { return me._value; },
|
|
|
|
setValue : func(value) { me._value = value; },
|
|
|
|
setVisible : func(vis) { me._symbol.setVisible(vis); },
|
2018-02-01 22:28:39 +00:00
|
|
|
|
|
|
|
_flashElement : func() {
|
2019-03-12 20:33:35 +00:00
|
|
|
if (me._highlighted == 0) {
|
|
|
|
me._symbol.setVisible(1);
|
|
|
|
me._highlighted = 1;
|
|
|
|
} else {
|
2018-02-01 22:28:39 +00:00
|
|
|
me._symbol.setVisible(0);
|
|
|
|
me._highlighted = 0;
|
|
|
|
}
|
|
|
|
},
|
2017-12-27 19:51:54 +00:00
|
|
|
highlightElement : func() {
|
2018-02-04 22:40:48 +00:00
|
|
|
me._highlightEnabled = 1;
|
|
|
|
me._highlighted = 0;
|
2019-03-12 20:33:35 +00:00
|
|
|
# Force it to immediately display, rather than waiting for the timer
|
|
|
|
me._symbol.setVisible(1);
|
|
|
|
PFD.HighlightTimer.startHighlight(me, -1);
|
2017-12-27 19:51:54 +00:00
|
|
|
},
|
|
|
|
unhighlightElement : func() {
|
2019-03-12 20:33:35 +00:00
|
|
|
me._symbol.setVisible(0);
|
2018-02-01 22:28:39 +00:00
|
|
|
me._highlighted = 0;
|
2019-03-12 20:33:35 +00:00
|
|
|
me._highlightEnabled = 0;
|
|
|
|
PFD.HighlightTimer.stopHighlight(me);
|
2017-12-27 19:51:54 +00:00
|
|
|
},
|
|
|
|
isEditable : func () { return 0; },
|
|
|
|
isInEdit : func() { return 0; },
|
|
|
|
enterElement : func() { return me.getValue(); },
|
2019-03-12 20:33:35 +00:00
|
|
|
isHighlighted : func() { return me._highlighted; },
|
2017-12-27 19:51:54 +00:00
|
|
|
clearElement : func() { },
|
|
|
|
editElement : func() { },
|
|
|
|
incrSmall : func(value) { },
|
|
|
|
incrLarge : func(value) { },
|
|
|
|
};
|