mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-01 06:00:15 +02:00
Fix local save browser crashing in some cases
This also fixes local save thumbnails being resized such that they are just short of filling the space they are supposed to. Also fix textboxes drawing their borders in the wrong place.
This commit is contained in:
@@ -131,10 +131,13 @@ void VideoBuffer::ResizeToFit(Vec2<int> bound, bool resample)
|
||||
Vec2<int> 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);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user