Recompute property browser viewport on resize.

Before this commit, resizing the property browser would cut off
the rows at the bottom, or else add black space, until next refresh.

This could be perhaps more elegantly done by adding an onResize event
but given that each of them would be followed by onRender anyway, it
seems there's no benefit to adding onResize.
pull/507/head
whitequark 2019-11-23 15:04:31 +00:00
parent 54015b6777
commit f0359556d8
2 changed files with 18 additions and 12 deletions

View File

@ -563,21 +563,24 @@ void TextWindow::Show() {
}
}
if(window) {
double width, height;
window->GetContentSize(&width, &height);
if(window) Resize();
}
halfRows = (int)height / (LINE_HEIGHT/2);
void TextWindow::Resize()
{
double width, height;
window->GetContentSize(&width, &height);
int bottom = top[rows-1] + 2;
scrollPos = min(scrollPos, bottom - halfRows);
scrollPos = max(scrollPos, 0);
halfRows = (int)height / (LINE_HEIGHT/2);
window->ConfigureScrollbar(0, top[rows - 1] + 1, halfRows);
window->SetScrollbarPosition(scrollPos);
window->SetScrollbarVisible(top[rows - 1] + 1 > halfRows);
window->Invalidate();
}
int bottom = top[rows-1] + 2;
scrollPos = min(scrollPos, bottom - halfRows);
scrollPos = max(scrollPos, 0);
window->ConfigureScrollbar(0, top[rows - 1] + 1, halfRows);
window->SetScrollbarPosition(scrollPos);
window->SetScrollbarVisible(top[rows - 1] + 1 > halfRows);
window->Invalidate();
}
void TextWindow::DrawOrHitTestIcons(UiCanvas *uiCanvas, TextWindow::DrawOrHitHow how,
@ -909,6 +912,8 @@ void TextWindow::Paint() {
double width, height;
window->GetContentSize(&width, &height);
if(halfRows != (int)height / (LINE_HEIGHT/2))
Resize();
Camera camera = {};
camera.width = width;

View File

@ -253,6 +253,7 @@ public:
void ClearScreen();
void Show();
void Resize();
// State for the screen that we are showing in the text window.
enum class Screen : uint32_t {