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:
parent
60a7ce1aae
commit
3eb3481fda
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user