Clamp window position/size to graphics surface
This commit is contained in:
parent
351dc6ec87
commit
3edb8c4233
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user