diff --git a/src/graphics/Graphics.cpp b/src/graphics/Graphics.cpp index c2ce36bf3..13c9c907c 100644 --- a/src/graphics/Graphics.cpp +++ b/src/graphics/Graphics.cpp @@ -131,10 +131,13 @@ void VideoBuffer::ResizeToFit(Vec2 bound, bool resample) Vec2 size = Size(); if (size.X > bound.X || size.Y > bound.Y) { + auto ceilDiv = [](int a, int b) { + return a / b + ((a % b) ? 1 : 0); + }; if (bound.X * size.Y < bound.Y * size.X) - size = size * bound.X / size.X; + size = { ceilDiv(size.X * bound.X, size.X), ceilDiv(size.Y * bound.X, size.X) }; else - size = size * bound.Y / size.Y; + size = { ceilDiv(size.X * bound.Y, size.Y), ceilDiv(size.Y * bound.Y, size.Y) }; } Resize(size, resample); } diff --git a/src/gui/interface/Textbox.cpp b/src/gui/interface/Textbox.cpp index 1a6f18591..1b44f2cc1 100644 --- a/src/gui/interface/Textbox.cpp +++ b/src/gui/interface/Textbox.cpp @@ -614,7 +614,7 @@ void Textbox::Draw(const Point& screenPos) if(IsFocused()) { if(border) - g->DrawRect(RectSized(Position, Size), 0xFFFFFF_rgb); + g->DrawRect(RectSized(screenPos, Size), 0xFFFFFF_rgb); g->DrawLine( screenPos + textPosition + Vec2{ cursorPositionX, cursorPositionY-2 }, screenPos + textPosition + Vec2{ cursorPositionX, cursorPositionY+9 }, @@ -627,7 +627,7 @@ void Textbox::Draw(const Point& screenPos) g->BlendText(screenPos + textPosition, placeHolder, textColour.NoAlpha().WithAlpha(170)); } if(border) - g->DrawRect(RectSized(Position, Size), 0xA0A0A0_rgb); + g->DrawRect(RectSized(screenPos, Size), 0xA0A0A0_rgb); } if(Appearance.icon) g->draw_icon(screenPos.X+iconPosition.X, screenPos.Y+iconPosition.Y, Appearance.icon);