Shorten some names

pull/3516/head
Travis Evans 2023-08-27 21:55:40 -05:00
parent 1307d3b21c
commit b64806e96a
1 changed files with 21 additions and 21 deletions

View File

@ -208,8 +208,8 @@ class MainScreen {
this.stampLog = stampLog; this.stampLog = stampLog;
// Values set up by start() // Values set up by start()
this.logItemsPerPage = null; this.itemsPerPage = null;
this.logScrollPos = null; this.scrollPos = null;
this.layout = null; this.layout = null;
// Handlers/listeners // Handlers/listeners
@ -220,7 +220,7 @@ class MainScreen {
// Launch this UI and make it live // Launch this UI and make it live
start() { start() {
this._initLayout(); this._initLayout();
this.scrollLog('b'); this.scroll('b');
this.render(); this.render();
this._initTouch(); this._initTouch();
@ -257,7 +257,7 @@ class MainScreen {
}, },
{type: 'custom', {type: 'custom',
id: 'logScroll', id: 'logScroll',
render: elem => { renderScrollBar(elem, this.logScrollInfo()); } render: elem => { renderScrollBar(elem, this.scrollInfo()); }
}, },
], ],
}, },
@ -279,15 +279,15 @@ class MainScreen {
let availableHeight = layout.placeholder.h; let availableHeight = layout.placeholder.h;
g.setFont(settings.logItemFont); g.setFont(settings.logItemFont);
let logItemHeight = g.getFontHeight() * 2; let logItemHeight = g.getFontHeight() * 2;
this.logItemsPerPage = Math.floor(availableHeight / logItemHeight); this.itemsPerPage = Math.floor(availableHeight / logItemHeight);
// Populate log items in layout // Populate log items in layout
for (i = 0; i < this.logItemsPerPage; i++) { for (i = 0; i < this.itemsPerPage; i++) {
layout.logItems.c.push( layout.logItems.c.push(
{type: 'custom', render: renderLogItem, item: undefined, fillx: 1, height: logItemHeight} {type: 'custom', render: renderLogItem, item: undefined, fillx: 1, height: logItemHeight}
); );
} }
layout.logScroll.height = logItemHeight * this.logItemsPerPage; layout.logScroll.height = logItemHeight * this.itemsPerPage;
layout.logScroll.width = SCROLL_BAR_WIDTH; layout.logScroll.width = SCROLL_BAR_WIDTH;
layout.update(); layout.update();
@ -298,7 +298,7 @@ class MainScreen {
render(item) { render(item) {
if (!item || item == 'log') { if (!item || item == 'log') {
let layLogItems = this.layout.logItems; let layLogItems = this.layout.logItems;
let logIdx = this.logScrollPos - this.logItemsPerPage; let logIdx = this.scrollPos - this.itemsPerPage;
for (let elem of layLogItems.c) { for (let elem of layLogItems.c) {
logIdx++; logIdx++;
elem.item = this.stampLog.log[logIdx]; elem.item = this.stampLog.log[logIdx];
@ -342,7 +342,7 @@ class MainScreen {
} else { } else {
// Drag ended // Drag ended
if (Math.abs(distanceY) > DRAG_THRESHOLD) { if (Math.abs(distanceY) > DRAG_THRESHOLD) {
this.scrollLog(distanceY > 0 ? 'u' : 'd'); this.scroll(distanceY > 0 ? 'u' : 'd');
this.render('log'); this.render('log');
} }
distanceY = null; distanceY = null;
@ -356,36 +356,36 @@ class MainScreen {
// Add current timestamp to log and update UI display // Add current timestamp to log and update UI display
addTimestamp() { addTimestamp() {
this.stampLog.addEntry(); this.stampLog.addEntry();
this.scrollLog('b'); this.scroll('b');
this.render('log'); this.render('log');
} }
// Get scroll information for log display // Get scroll information for log display
logScrollInfo() { scrollInfo() {
return { return {
pos: this.logScrollPos, pos: this.scrollPos,
min: (this.stampLog.log.length - 1) % this.logItemsPerPage, min: (this.stampLog.log.length - 1) % this.itemsPerPage,
max: this.stampLog.log.length - 1, max: this.stampLog.log.length - 1,
itemsPerPage: this.logItemsPerPage itemsPerPage: this.itemsPerPage
}; };
} }
// Scroll display in given direction or to given position: // Scroll display in given direction or to given position:
// 'u': up, 'd': down, 't': to top, 'b': to bottom // 'u': up, 'd': down, 't': to top, 'b': to bottom
scrollLog(how) { scroll(how) {
let scroll = this.logScrollInfo(); let scroll = this.scrollInfo();
if (how == 'u') { if (how == 'u') {
this.logScrollPos -= scroll.itemsPerPage; this.scrollPos -= scroll.itemsPerPage;
} else if (how == 'd') { } else if (how == 'd') {
this.logScrollPos += scroll.itemsPerPage; this.scrollPos += scroll.itemsPerPage;
} else if (how == 't') { } else if (how == 't') {
this.logScrollPos = scroll.min; this.scrollPos = scroll.min;
} else if (how == 'b') { } else if (how == 'b') {
this.logScrollPos = scroll.max; this.scrollPos = scroll.max;
} }
this.logScrollPos = E.clip(this.logScrollPos, scroll.min, scroll.max); this.scrollPos = E.clip(this.scrollPos, scroll.min, scroll.max);
} }
} }