Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance widget rendering to ensure that the active Widget is always visible #258

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/BaseItemManyWidgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ class BaseItemManyWidgets : public MenuItem {
for (uint8_t i = 0; i < size; i++) {
index += widgets[i]->draw(buf, index);
if (i == activeWidget && renderer->isInEditMode()) {
// Calculate the available space for the widgets after the text
size_t v_size = renderer->getEffectiveCols() - strlen(text) - 1;
// Adjust the view shift to ensure the active widget is visible
renderer->viewShift = index > v_size ? index - v_size : 0;
// Draw the item with the renderer, indicating if it's the last widget
renderer->drawItem(text, buf, i == size - 1);
// Calculate the cursor column position for the active widget
cursorCol = renderer->getCursorCol() - 1 - widgets[i]->cursorOffset;
}
}
Expand Down Expand Up @@ -151,6 +157,7 @@ class BaseItemManyWidgets : public MenuItem {

void back(MenuRenderer* renderer) {
renderer->setEditMode(false);
renderer->viewShift = 0;
reset();
handleCommit();
renderer->clearBlinker();
Expand Down
Loading