Table fixes (when using big tables)
This commit is contained in:
+9
-3
@@ -191,13 +191,19 @@ class Table: public FormField
|
||||
{
|
||||
selection = index;
|
||||
if (scroll) {
|
||||
coord_t y = index * TABLE_LINE_HEIGHT;
|
||||
Window * window = this;
|
||||
while (window->getWindowFlags() & FORWARD_SCROLL) {
|
||||
y += window->top();
|
||||
window = window->getParent();
|
||||
}
|
||||
const rect_t rect = {
|
||||
0,
|
||||
index * TABLE_LINE_HEIGHT,
|
||||
y,
|
||||
width(),
|
||||
TABLE_LINE_HEIGHT
|
||||
};
|
||||
scrollTo(rect);
|
||||
window->scrollTo(rect);
|
||||
}
|
||||
invalidate();
|
||||
if (index >= 0) {
|
||||
@@ -288,10 +294,10 @@ class Table: public FormField
|
||||
|
||||
void setFocus(uint8_t flag) override
|
||||
{
|
||||
body.setFocus(flag);
|
||||
if (body.selection < 0 && !body.lines.empty()) {
|
||||
select(flag == SET_FOCUS_BACKWARD ? body.lines.size() - 1 : 0);
|
||||
}
|
||||
body.setFocus(flag);
|
||||
}
|
||||
|
||||
void select(int index, bool scroll = true)
|
||||
|
||||
+21
-21
@@ -130,22 +130,21 @@ void Window::setFocus(uint8_t flag)
|
||||
TRACE_WINDOWS("%s setFocus()", getWindowDebugString().c_str());
|
||||
|
||||
if (focusWindow != this) {
|
||||
// scroll before calling focusHandler so that the window can adjust the scroll position if needed
|
||||
Window * parent = this->parent;
|
||||
while (parent && parent->getWindowFlags() & FORWARD_SCROLL) {
|
||||
parent = parent->parent;
|
||||
}
|
||||
if (parent) {
|
||||
parent->scrollTo(this);
|
||||
invalidate();
|
||||
}
|
||||
clearFocus();
|
||||
focusWindow = this;
|
||||
if (focusHandler) {
|
||||
focusHandler(true);
|
||||
}
|
||||
}
|
||||
|
||||
Window * parent = this->parent;
|
||||
while (parent && parent->getWindowFlags() & FORWARD_SCROLL) {
|
||||
parent = parent->parent;
|
||||
}
|
||||
|
||||
if (parent) {
|
||||
parent->scrollTo(this);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void Window::setScrollPositionX(coord_t value)
|
||||
@@ -176,20 +175,21 @@ void Window::scrollTo(Window * child)
|
||||
coord_t offsetX = 0;
|
||||
coord_t offsetY = 0;
|
||||
|
||||
Window * parent = child->getParent();
|
||||
while (parent && parent != this) {
|
||||
offsetX += parent->left();
|
||||
offsetY += parent->top();
|
||||
parent = parent->getParent();
|
||||
Window * parentWindow = child->getParent();
|
||||
while (parentWindow && parentWindow != this) {
|
||||
offsetX += parentWindow->left();
|
||||
offsetY += parentWindow->top();
|
||||
parentWindow = parentWindow->getParent();
|
||||
}
|
||||
|
||||
const rect_t rect = {
|
||||
offsetX + child->left(),
|
||||
offsetY + child->top(),
|
||||
child->width(),
|
||||
child->height()
|
||||
const rect_t scrollRect = {
|
||||
offsetX + child->left(),
|
||||
offsetY + child->top(),
|
||||
min(child->width(), width()),
|
||||
min(child->height(), height())
|
||||
};
|
||||
scrollTo(rect);
|
||||
|
||||
scrollTo(scrollRect);
|
||||
}
|
||||
|
||||
void Window::scrollTo(const rect_t & rect)
|
||||
|
||||
Reference in New Issue
Block a user