Allow scrolling the subtitles grid a page past the last row. Closes #888.

This commit is contained in:
Thomas Goyne 2012-10-20 08:26:38 -07:00
parent 7553534d96
commit 40bb3b857e

View file

@ -787,31 +787,37 @@ void BaseGrid::OnContextMenu(wxContextMenuEvent &evt) {
void BaseGrid::ScrollTo(int y) { void BaseGrid::ScrollTo(int y) {
int h = GetClientSize().GetHeight(); int h = GetClientSize().GetHeight();
int nextY = mid(0, y, GetRows() + 2 - h / lineHeight); int nextY = mid(0, y, GetRows() - 1);
if (yPos != nextY) { if (yPos != nextY) {
yPos = nextY; yPos = nextY;
if (scrollBar->IsEnabled()) scrollBar->SetThumbPosition(yPos); scrollBar->SetThumbPosition(yPos);
Refresh(false); Refresh(false);
} }
} }
void BaseGrid::AdjustScrollbar() { void BaseGrid::AdjustScrollbar() {
int w,h,sw,sh; wxSize clientSize = GetClientSize();
GetClientSize(&w,&h); wxSize scrollbarSize = scrollBar->GetSize();
int drawPerScreen = h/lineHeight;
int rows = GetRows();
bool barToEnable = drawPerScreen < rows+2;
yPos = mid(0,yPos,rows - drawPerScreen);
scrollBar->Freeze(); scrollBar->Freeze();
scrollBar->GetSize(&sw,&sh); scrollBar->SetSize(clientSize.GetWidth() - scrollbarSize.GetWidth(), 0, scrollbarSize.GetWidth(), clientSize.GetHeight());
scrollBar->SetSize(w-sw,0,sw,h);
if (barToEnable != scrollBar->IsEnabled()) scrollBar->Enable(barToEnable); if (GetRows() <= 1) {
if (barToEnable) { scrollBar->Enable(false);
scrollBar->SetScrollbar(yPos,drawPerScreen,rows+2,drawPerScreen-2,true); scrollBar->Thaw();
return;
} }
if (!scrollBar->IsEnabled()) {
scrollBar->Enable(true);
}
int drawPerScreen = clientSize.GetHeight() / lineHeight;
int rows = GetRows();
yPos = mid(0, yPos, rows - 1);
scrollBar->SetScrollbar(yPos, drawPerScreen, rows + drawPerScreen - 1, drawPerScreen - 2, true);
scrollBar->Thaw(); scrollBar->Thaw();
} }