mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 22:22:05 +00:00
Facelist to cannedmessage screen
This commit is contained in:
parent
b5f74cead1
commit
bed25406c1
@ -1516,41 +1516,69 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Canned Messages List ===
|
// === Canned Messages List ===
|
||||||
if (this->messagesCount > 0) {
|
if (this->messagesCount > 0) {
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->drawStringf(0 + x, 0 + y, buffer, "To: %s", getNodeName(this->dest));
|
|
||||||
int lines = (display->getHeight() / FONT_HEIGHT_SMALL) - 1;
|
|
||||||
|
|
||||||
if (lines == 3) {
|
const int rowSpacing = FONT_HEIGHT_SMALL - 4;
|
||||||
display->fillRect(0 + x, 0 + y + FONT_HEIGHT_SMALL * 2, x + display->getWidth(), y + FONT_HEIGHT_SMALL);
|
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
||||||
display->setColor(BLACK);
|
const int boxYOffset = (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
||||||
display->drawString(0 + x, 0 + y + FONT_HEIGHT_SMALL * 2, getCurrentMessage());
|
|
||||||
display->setColor(WHITE);
|
|
||||||
|
|
||||||
if (this->messagesCount > 1) {
|
// Draw header (To: ...)
|
||||||
display->drawString(0 + x, 0 + y + FONT_HEIGHT_SMALL, getPrevMessage());
|
switch (this->destSelect) {
|
||||||
display->drawString(0 + x, 0 + y + FONT_HEIGHT_SMALL * 3, getNextMessage());
|
case CANNED_MESSAGE_DESTINATION_TYPE_NODE:
|
||||||
|
display->drawStringf(x + 0, y + 0, buffer, "To: >%s<@%s", getNodeName(this->dest), channels.getName(this->channel));
|
||||||
|
break;
|
||||||
|
case CANNED_MESSAGE_DESTINATION_TYPE_CHANNEL:
|
||||||
|
display->drawStringf(x + 0, y + 0, buffer, "To: %s@>%s<", getNodeName(this->dest), channels.getName(this->channel));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (display->getWidth() > 128) {
|
||||||
|
display->drawStringf(x + 0, y + 0, buffer, "To: %s@%s", getNodeName(this->dest), channels.getName(this->channel));
|
||||||
|
} else {
|
||||||
|
display->drawStringf(x + 0, y + 0, buffer, "To: %.5s@%.5s", getNodeName(this->dest), channels.getName(this->channel));
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
int topMsg = (messagesCount > lines && currentMessageIndex >= lines - 1) ? currentMessageIndex - lines + 2 : 0;
|
}
|
||||||
for (int i = 0; i < std::min(messagesCount, lines); i++) {
|
|
||||||
if (i == currentMessageIndex - topMsg) {
|
// Shift message list upward by 3 pixels to reduce spacing between header and first message
|
||||||
|
const int listYOffset = y + FONT_HEIGHT_SMALL - 3;
|
||||||
|
const int visibleRows = (display->getHeight() - listYOffset) / rowSpacing;
|
||||||
|
|
||||||
|
int topMsg = (messagesCount > visibleRows && currentMessageIndex >= visibleRows - 1)
|
||||||
|
? currentMessageIndex - visibleRows + 2
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < std::min(messagesCount, visibleRows); i++) {
|
||||||
|
int lineY = listYOffset + rowSpacing * i;
|
||||||
|
const char* msg = getMessageByIndex(topMsg + i);
|
||||||
|
|
||||||
|
if ((topMsg + i) == currentMessageIndex) {
|
||||||
#ifdef USE_EINK
|
#ifdef USE_EINK
|
||||||
display->drawString(0 + x, 0 + y + FONT_HEIGHT_SMALL * (i + 1), ">");
|
display->drawString(x + 0, lineY, ">");
|
||||||
display->drawString(12 + x, 0 + y + FONT_HEIGHT_SMALL * (i + 1), getCurrentMessage());
|
display->drawString(x + 12, lineY, msg);
|
||||||
#else
|
#else
|
||||||
display->fillRect(0 + x, 0 + y + FONT_HEIGHT_SMALL * (i + 1), x + display->getWidth(), y + FONT_HEIGHT_SMALL);
|
int scrollPadding = 8;
|
||||||
display->setColor(BLACK);
|
display->fillRect(x + 0, lineY + 2, display->getWidth() - scrollPadding, FONT_HEIGHT_SMALL - 5);
|
||||||
display->drawString(0 + x, 0 + y + FONT_HEIGHT_SMALL * (i + 1), getCurrentMessage());
|
display->setColor(BLACK);
|
||||||
display->setColor(WHITE);
|
display->drawString(x + 2, lineY, msg);
|
||||||
|
display->setColor(WHITE);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
display->drawString(0 + x, 0 + y + FONT_HEIGHT_SMALL * (i + 1), getMessageByIndex(topMsg + i));
|
display->drawString(x + 0, lineY, msg);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scrollbar
|
||||||
|
if (messagesCount > visibleRows) {
|
||||||
|
int scrollHeight = display->getHeight() - listYOffset;
|
||||||
|
int scrollTrackX = display->getWidth() - 6;
|
||||||
|
display->drawRect(scrollTrackX, listYOffset, 4, scrollHeight);
|
||||||
|
int barHeight = (scrollHeight * visibleRows) / messagesCount;
|
||||||
|
int scrollPos = listYOffset + (scrollHeight * topMsg) / messagesCount;
|
||||||
|
display->fillRect(scrollTrackX, scrollPos, 4, barHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user