diff --git a/src/common/Vec2.h b/src/common/Vec2.h index b17041fd3..aee87b7c6 100644 --- a/src/common/Vec2.h +++ b/src/common/Vec2.h @@ -112,6 +112,14 @@ struct Vec2 ); } + Vec2 Min(Vec2 other) const + { + return Vec2( + std::min(X, other.X), + std::min(Y, other.Y) + ); + } + // Return a rectangle starting at origin, whose dimensions match this vector template>> constexpr inline Rect OriginRect() const diff --git a/src/gui/interface/Engine.cpp b/src/gui/interface/Engine.cpp index 75b4134a2..7cf9555a9 100644 --- a/src/gui/interface/Engine.cpp +++ b/src/gui/interface/Engine.cpp @@ -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({0, 0}, g->Size())); /*if(window->Position.Y > 0) { windowTargetPosition = window->Position;