diff --git a/src/textwin.cpp b/src/textwin.cpp index 2a7b3ebf..11d30484 100644 --- a/src/textwin.cpp +++ b/src/textwin.cpp @@ -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; diff --git a/src/ui.h b/src/ui.h index 284e9d60..a2985598 100644 --- a/src/ui.h +++ b/src/ui.h @@ -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 {