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() { void GalleryList::update() {
// ensure selection is visible // ensure selection is visible
SubColumn col = subcolumns[active_subcolumn]; /*SubColumn col = subcolumns[active_subcolumn];
if (col.selection != NO_SELECTION) { if (col.selection != NO_SELECTION) {
if (itemStart(col.selection) < visible_start) { if (itemStart(col.selection) < visible_start) {
scrollTo(itemStart(col.selection), false); scrollTo(itemStart(col.selection), false);
} else if (itemEnd(col.selection) > visibleEnd()) { } else if (itemEnd(col.selection) > visibleEnd()) {
scrollTo(itemEnd(col.selection) + visible_start - visibleEnd(), false); scrollTo(itemEnd(col.selection) + visible_start - visibleEnd(), false);
} }
} }*/
updateScrollbar(); updateScrollbar();
Refresh(false); Refresh(false);
InvalidateBestSize(); InvalidateBestSize();
+10 -3
View File
@@ -85,7 +85,7 @@ void NativeLookEditor::resizeViewers() {
y = y - vspace + margin; y = y - vspace + margin;
SetVirtualSize(w, (int)y); SetVirtualSize(w, (int)y);
if (CanScroll(wxVERTICAL)) { if (CanScroll(wxVERTICAL)) {
SetScrollbar(wxVERTICAL, 0, h, (int)y); SetScrollbar(wxVERTICAL, cached_scroll, h, (int)y);
} }
if (y >= h) { if (y >= h) {
// Doesn't fit vertically, add scrollbar and resize // Doesn't fit vertically, add scrollbar and resize
@@ -127,10 +127,15 @@ void NativeLookEditor::onScroll(wxScrollWinEvent& ev) {
y = y - page; y = y - page;
} else if (ev.GetEventType() == wxEVT_SCROLLWIN_PAGEDOWN) { } else if (ev.GetEventType() == wxEVT_SCROLLWIN_PAGEDOWN) {
y = y + page; y = y + page;
} else if (ev.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK || } else if (ev.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK) {
ev.GetEventType() == wxEVT_SCROLLWIN_THUMBRELEASE) {
y = ev.GetPosition(); 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); scrollTo(wxVERTICAL, y);
} }
} }
@@ -159,6 +164,7 @@ void NativeLookEditor::scrollTo(int direction, int pos) {
pos = max(0, min(bottom, pos)); pos = max(0, min(bottom, pos));
if (pos != y) { if (pos != y) {
SetScrollPos(wxVERTICAL, pos); SetScrollPos(wxVERTICAL, pos);
cached_scroll = pos;
// move child controls // move child controls
FOR_EACH(v, viewers) { FOR_EACH(v, viewers) {
@@ -168,6 +174,7 @@ void NativeLookEditor::scrollTo(int direction, int pos) {
} }
// redraw // redraw
onChange(); onChange();
Update();
} }
} }
+3
View File
@@ -39,6 +39,9 @@ private:
static const int label_margin = 10; static const int label_margin = 10;
int label_width; int label_width;
int cached_thumb_pos = 0;
int cached_scroll = 0;
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
void onSize(wxSizeEvent&); void onSize(wxSizeEvent&);