Merge pull request #54 from llemoi/control_scrolling_fix

Fixed scrolled widgets not scrolling fully (or at all)
This commit is contained in:
Brendan Hagan
2022-12-30 22:01:51 -05:00
committed by GitHub
3 changed files with 15 additions and 5 deletions
+2 -2
View File
@@ -73,14 +73,14 @@ void GalleryList::select(size_t item, size_t subcolumn, bool event) {
void GalleryList::update() {
// ensure selection is visible
SubColumn col = subcolumns[active_subcolumn];
/*SubColumn col = subcolumns[active_subcolumn];
if (col.selection != NO_SELECTION) {
if (itemStart(col.selection) < visible_start) {
scrollTo(itemStart(col.selection), false);
} else if (itemEnd(col.selection) > visibleEnd()) {
scrollTo(itemEnd(col.selection) + visible_start - visibleEnd(), false);
}
}
}*/
updateScrollbar();
Refresh(false);
InvalidateBestSize();
+10 -3
View File
@@ -85,7 +85,7 @@ void NativeLookEditor::resizeViewers() {
y = y - vspace + margin;
SetVirtualSize(w, (int)y);
if (CanScroll(wxVERTICAL)) {
SetScrollbar(wxVERTICAL, 0, h, (int)y);
SetScrollbar(wxVERTICAL, cached_scroll, h, (int)y);
}
if (y >= h) {
// Doesn't fit vertically, add scrollbar and resize
@@ -127,10 +127,15 @@ void NativeLookEditor::onScroll(wxScrollWinEvent& ev) {
y = y - page;
} else if (ev.GetEventType() == wxEVT_SCROLLWIN_PAGEDOWN) {
y = y + page;
} else if (ev.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK ||
ev.GetEventType() == wxEVT_SCROLLWIN_THUMBRELEASE) {
} else if (ev.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK) {
y = ev.GetPosition();
cached_thumb_pos = y;
} else if (ev.GetEventType() == wxEVT_SCROLLWIN_THUMBRELEASE) {
// THUMBRELEASE GetPosition() was giving the thumb's original position, *prior to* all the preceding THUMBTRACK events,
// not its position at time of release
y = cached_thumb_pos;
}
scrollTo(wxVERTICAL, y);
}
}
@@ -159,6 +164,7 @@ void NativeLookEditor::scrollTo(int direction, int pos) {
pos = max(0, min(bottom, pos));
if (pos != y) {
SetScrollPos(wxVERTICAL, pos);
cached_scroll = pos;
// move child controls
FOR_EACH(v, viewers) {
@@ -168,6 +174,7 @@ void NativeLookEditor::scrollTo(int direction, int pos) {
}
// redraw
onChange();
Update();
}
}
+3
View File
@@ -39,6 +39,9 @@ private:
static const int label_margin = 10;
int label_width;
int cached_thumb_pos = 0;
int cached_scroll = 0;
DECLARE_EVENT_TABLE();
void onSize(wxSizeEvent&);