mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-19 06:31:26 +02:00
Clamp window position/size to graphics surface
This commit is contained in:
@@ -112,6 +112,14 @@ struct Vec2
|
||||
);
|
||||
}
|
||||
|
||||
Vec2<T> Min(Vec2<T> other) const
|
||||
{
|
||||
return Vec2<T>(
|
||||
std::min(X, other.X),
|
||||
std::min(Y, other.Y)
|
||||
);
|
||||
}
|
||||
|
||||
// Return a rectangle starting at origin, whose dimensions match this vector
|
||||
template<typename S = T, typename = std::enable_if_t<std::is_integral_v<S>>>
|
||||
constexpr inline Rect<T> OriginRect() const
|
||||
|
@@ -83,6 +83,8 @@ void Engine::ShowWindow(Window * window)
|
||||
{
|
||||
window->Position.Y = (g->Size().Y - window->Size.Y) / 2;
|
||||
}
|
||||
window->Size = window->Size.Min(g->Size());
|
||||
window->Position = window->Position.Clamp(RectBetween<int>({0, 0}, g->Size()));
|
||||
/*if(window->Position.Y > 0)
|
||||
{
|
||||
windowTargetPosition = window->Position;
|
||||
|
Reference in New Issue
Block a user