1
0
Fork 0

Fix badly flashing UI elements due to timers

This commit is contained in:
Stuart Buchanan 2018-02-04 22:40:48 +00:00
parent 857e983524
commit c8072e5e2c
7 changed files with 123 additions and 64 deletions

View file

@ -228,6 +228,7 @@ var DirectToController =
# We're in the Waypoint Submenu, in which case the outer FMS knob
# selects between the different waypoints in the Waypoint Submenu.
me.page.WaypointSubmenuSelect.unhighlightElement();
me.page.WaypointSubmenuScroll.showCRSR();
me.page.WaypointSubmenuScroll.incrLarge(value);
} else if (me._cursorElements[me._selectedElement].isInEdit()) {
# If we're editing an element, then get on with it!

View file

@ -35,8 +35,11 @@ var DataEntryElement =
# State and timer for flashing highlighting of elements
obj._highlighted = 0;
obj._highlightedChar = 0;
obj._highlightEnabled = 0;
obj._flashTimer = nil;
obj._highlightChar = 0;
obj._highlightCharEnabled = 0;
obj._flashCharTimer = nil;
return obj;
@ -54,19 +57,28 @@ var DataEntryElement =
for (var i = 0; i < me._size; i = i + 1) me._dataEntrySymbol[i].setVisible(0);
}
},
_flashElement : func() {
if (me._highlighted == 0) {
me._symbol.setDrawMode(canvas.Text.TEXT + canvas.Text.FILLEDBOUNDINGBOX);
me._symbol.setColorFill(me._style.HIGHLIGHT_COLOR);
me._symbol.setColor(me._style.HIGHLIGHT_TEXT_COLOR);
me._highlighted = 1;
} else {
if (me._highlightEnabled == 0) {
me._symbol.setDrawMode(canvas.Text.TEXT);
me._symbol.setColor(me._style.NORMAL_TEXT_COLOR);
me._highlighted = 0;
} else {
if (me._highlighted == 0) {
me._symbol.setDrawMode(canvas.Text.TEXT + canvas.Text.FILLEDBOUNDINGBOX);
me._symbol.setColorFill(me._style.HIGHLIGHT_COLOR);
me._symbol.setColor(me._style.HIGHLIGHT_TEXT_COLOR);
me._highlighted = 1;
} else {
me._symbol.setDrawMode(canvas.Text.TEXT);
me._symbol.setColor(me._style.NORMAL_TEXT_COLOR);
me._highlighted = 0;
}
}
},
highlightElement : func() {
me._highlightEnabled = 1;
me._highlighted = 0;
me._flashElement();
me._flashTimer = maketimer(me._style.CURSOR_BLINK_PERIOD, me, me._flashElement);
me._flashTimer.start();
@ -74,25 +86,32 @@ var DataEntryElement =
unhighlightElement : func() {
if (me._flashTimer != nil) me._flashTimer.stop();
me._flashTimer = nil;
# Reset the highlight to a non-highlighted state.
me._highlighted = 1;
me._highlightEnabled = 0;
me._highlighted = 0;
me._flashElement();
},
_flashCharElement : func() {
if (me._highlighted == 0) {
me._dataEntrySymbol[me._dataEntryPos].setDrawMode(canvas.Text.TEXT + canvas.Text.FILLEDBOUNDINGBOX);
me._dataEntrySymbol[me._dataEntryPos].setColorFill(me._style.HIGHLIGHT_COLOR);
me._dataEntrySymbol[me._dataEntryPos].setColor(me._style.HIGHLIGHT_TEXT_COLOR);
me._highlightedChar = 1;
} else {
if (me._highlightCharEnabled == 0) {
me._dataEntrySymbol[me._dataEntryPos].setDrawMode(canvas.Text.TEXT);
me._dataEntrySymbol[me._dataEntryPos].setColor(me._style.NORMAL_TEXT_COLOR);
me._highlightedChar = 0;
me._highlightChar = 0;
} else {
if (me._highlightChar == 0) {
me._dataEntrySymbol[me._dataEntryPos].setDrawMode(canvas.Text.TEXT + canvas.Text.FILLEDBOUNDINGBOX);
me._dataEntrySymbol[me._dataEntryPos].setColorFill(me._style.HIGHLIGHT_COLOR);
me._dataEntrySymbol[me._dataEntryPos].setColor(me._style.HIGHLIGHT_TEXT_COLOR);
me._highlightChar = 1;
} else {
me._dataEntrySymbol[me._dataEntryPos].setDrawMode(canvas.Text.TEXT);
me._dataEntrySymbol[me._dataEntryPos].setColor(me._style.NORMAL_TEXT_COLOR);
me._highlightChar = 0;
}
}
},
highlightCharElement : func() {
me._highlightCharEnabled = 1;
me._highlightChar = 0;
me._flashCharElement();
me._flashCharTimer = maketimer(me._style.CURSOR_BLINK_PERIOD, me, me._flashCharElement);
me._flashCharTimer.start();
@ -100,9 +119,8 @@ var DataEntryElement =
unhighlightCharElement : func() {
if (me._flashCharTimer != nil) me._flashCharTimer.stop();
me._flashCharTimer = nil;
# Reset the highlight to a non-highlighted state.
me._highlightedChar = 1;
me._highlightCharEnabled = 0;
me._highlightChar = 0;
me._flashCharElement();
},
isEditable : func () { return 1; },

View file

@ -17,6 +17,8 @@ var HighlightElement =
assert(obj._symbol != nil, "Unable to find element " ~ obj._name);
# State and timer for flashing highlighting of elements
# We need a separate Enabled flag as the timers are in a separate thread.
obj._highlightEnabled = 0;
obj._highlighted = 0;
obj._flashTimer = nil;
@ -31,15 +33,22 @@ var HighlightElement =
setVisible : func(vis) { me._symbol.setVisible(vis); },
_flashElement : func() {
if (me._highlighted == 0) {
me._symbol.setVisible(1);
me._highlighted = 1;
} else {
if (me._highlightEnabled == 0) {
me._symbol.setVisible(0);
me._highlighted = 0;
} else {
if (me._highlighted == 0) {
me._symbol.setVisible(1);
me._highlighted = 1;
} else {
me._symbol.setVisible(0);
me._highlighted = 0;
}
}
},
highlightElement : func() {
me._highlightEnabled = 1;
me._highlighted = 0;
me._flashElement();
me._flashTimer = maketimer(me._style.CURSOR_BLINK_PERIOD, me, me._flashElement);
me._flashTimer.start();
@ -47,10 +56,9 @@ var HighlightElement =
unhighlightElement : func() {
if (me._flashTimer != nil) me._flashTimer.stop();
me._flashTimer = nil;
# Reset the highlight to a non-highlighted state.
me._symbol.setVisible(0);
me._highlightEnabled = 0;
me._highlighted = 0;
me._flashElement();
},
isEditable : func () { return 0; },
isInEdit : func() { return 0; },

View file

@ -22,6 +22,8 @@ var PointerElement =
obj.setValue(value);
# State and timer for flashing highlighting of elements
# We need a separate Enabled flag as the timers are in a separate thread.
obj._highlightEnabled = 0;
obj._highlighted = 0;
obj._flashTimer = nil;
@ -59,15 +61,22 @@ var PointerElement =
setVisible : func(vis) { me._symbol.setVisible(vis); },
_flashElement : func() {
if (me._highlighted == 0) {
me._symbol.setVisible(1);
me._highlighted = 1;
} else {
if (me._highlightEnabled == 0) {
me._symbol.setVisible(0);
me._highlighted = 0;
} else {
if (me._highlighted == 0) {
me._symbol.setVisible(1);
me._highlighted = 1;
} else {
me._symbol.setVisible(0);
me._highlighted = 0;
}
}
},
highlightElement : func() {
me._highlightEnabled = 1;
me._highlighted = 0;
me._flashElement();
me._flashTimer = maketimer(me._style.CURSOR_BLINK_PERIOD, me, me._flashElement);
me._flashTimer.start();
@ -75,9 +84,8 @@ var PointerElement =
unhighlightElement : func() {
if (me._flashTimer != nil) me._flashTimer.stop();
me._flashTimer = nil;
# Reset the highlight to a non-highlighted state.
me._highlighted = 1;
me._highlightEnabled = 0;
me._highlighted = 0;
me._flashElement();
},
isEditable : func () { return 0; },

View file

@ -27,6 +27,8 @@ var RotatingElement =
obj.setValue(value);
# State and timer for flashing highlighting of elements
# We need a separate Enabled flag as the timers are in a separate thread.
obj._highlightEnabled = 0;
obj._highlighted = 0;
obj._flashTimer = nil;
@ -51,15 +53,22 @@ var RotatingElement =
setVisible : func(vis) { me._symbol.setVisible(vis); },
_flashElement : func() {
if (me._highlighted == 0) {
me._symbol.setVisible(1);
me._highlighted = 1;
} else {
if (me._highlightEnabled == 0) {
me._symbol.setVisible(0);
me._highlighted = 0;
} else {
if (me._highlighted == 0) {
me._symbol.setVisible(1);
me._highlighted = 1;
} else {
me._symbol.setVisible(0);
me._highlighted = 0;
}
}
},
highlightElement : func() {
me._highlightEnabled = 1;
me._highlighted = 0;
me._flashElement();
me._flashTimer = maketimer(me._style.CURSOR_BLINK_PERIOD, me, me._flashElement);
me._flashTimer.start();
@ -67,9 +76,8 @@ var RotatingElement =
unhighlightElement : func() {
if (me._flashTimer != nil) me._flashTimer.stop();
me._flashTimer = nil;
# Reset the highlight to a non-highlighted state.
me._highlighted = 1;
me._highlightEnabled = 0;
me._highlighted = 0;
me._flashElement();
},
isEditable : func () { return 0; },

View file

@ -29,6 +29,8 @@ var ScrollElement =
assert(initialIndex < size(values) , "Initial index " ~ initialIndex ~ " extends past end of value array");
# State and timer for flashing highlighting of elements
# We need a separate Enabled flag as the timers are in a separate thread.
obj._highlightEnabled = 0;
obj._highlighted = 0;
obj._flashTimer = nil;
@ -77,30 +79,35 @@ var ScrollElement =
me._rightsymbol.setVisible(vis);
},
_flashElement : func() {
if (me._highlighted == 0) {
me._symbol.setDrawMode(canvas.Text.TEXT + canvas.Text.FILLEDBOUNDINGBOX);
me._symbol.setColorFill(me._style.HIGHLIGHT_COLOR);
me._symbol.setColor(me._style.HIGHLIGHT_TEXT_COLOR);
me._highlighted = 1;
} else {
if (me._highlightEnabled == 0) {
me._symbol.setDrawMode(canvas.Text.TEXT);
me._symbol.setColor(me._style.NORMAL_TEXT_COLOR);
me._highlighted = 0;
} else {
if (me._highlighted == 0) {
me._symbol.setDrawMode(canvas.Text.TEXT + canvas.Text.FILLEDBOUNDINGBOX);
me._symbol.setColorFill(me._style.HIGHLIGHT_COLOR);
me._symbol.setColor(me._style.HIGHLIGHT_TEXT_COLOR);
me._highlighted = 1;
} else {
me._symbol.setDrawMode(canvas.Text.TEXT);
me._symbol.setColor(me._style.NORMAL_TEXT_COLOR);
me._highlighted = 0;
}
}
},
highlightElement : func() {
if (me._flashTimer == nil) {
me._flashElement();
me._flashTimer = maketimer(0.5, me, me._flashElement);
me._flashTimer.start();
}
me._highlightEnabled = 1;
me._highlighted = 0;
me._flashElement();
me._flashTimer = maketimer(me._style.CURSOR_BLINK_PERIOD, me, me._flashElement);
me._flashTimer.start();
},
unhighlightElement : func() {
if (me._flashTimer != nil) me._flashTimer.stop();
me._flashTimer = nil;
# Reset the highlight to a non-highlighted state.
me._highlighted = 1;
me._highlightEnabled = 0;
me._highlighted = 0;
me._flashElement();
},
isEditable : func () { return 0; },

View file

@ -17,6 +17,8 @@ var TextElement =
obj.setValue(value);
# State and timer for flashing highlighting of elements
# We need a separate Enabled flag as the timers are in a separate thread.
obj._highlightEnabled = 0;
obj._highlighted = 0;
obj._flashTimer = nil;
@ -28,18 +30,26 @@ var TextElement =
setValue : func(value) { me._symbol.setText(value); },
setVisible : func(vis) { me._symbol.setVisible(vis); },
_flashElement : func() {
if (me._highlighted == 0) {
me._symbol.setDrawMode(canvas.Text.TEXT + canvas.Text.FILLEDBOUNDINGBOX);
me._symbol.setColorFill(me._style.HIGHLIGHT_COLOR);
me._symbol.setColor(me._style.HIGHLIGHT_TEXT_COLOR);
me._highlighted = 1;
} else {
if (me._highlightEnabled == 0) {
me._symbol.setDrawMode(canvas.Text.TEXT);
me._symbol.setColor(me._style.NORMAL_TEXT_COLOR);
me._highlighted = 0;
} else {
if (me._highlighted == 0) {
me._symbol.setDrawMode(canvas.Text.TEXT + canvas.Text.FILLEDBOUNDINGBOX);
me._symbol.setColorFill(me._style.HIGHLIGHT_COLOR);
me._symbol.setColor(me._style.HIGHLIGHT_TEXT_COLOR);
me._highlighted = 1;
} else {
me._symbol.setDrawMode(canvas.Text.TEXT);
me._symbol.setColor(me._style.NORMAL_TEXT_COLOR);
me._highlighted = 0;
}
}
},
highlightElement : func() {
me._highlightEnabled = 1;
me._highlighted = 0;
me._flashElement();
me._flashTimer = maketimer(me._style.CURSOR_BLINK_PERIOD, me, me._flashElement);
me._flashTimer.start();
@ -47,9 +57,8 @@ var TextElement =
unhighlightElement : func() {
if (me._flashTimer != nil) me._flashTimer.stop();
me._flashTimer = nil;
# Reset the highlight to a non-highlighted state.
me._highlighted = 1;
me._highlightEnabled = 0;
me._highlighted = 0;
me._flashElement();
},
isEditable : func () { return 0; },