Fix std::clamp() assert fail in ui::fit_bounds()

This commit is contained in:
David Capello 2023-03-15 16:32:56 -03:00
parent e6cd13d7e1
commit 5831cda066

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2019-2023 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
@ -128,8 +128,8 @@ void fit_bounds(const Display* parentDisplay,
if (fitLogic)
fitLogic(workarea, frame, [](Widget* widget){ return widget->boundsOnScreen(); });
frame.x = std::clamp(frame.x, workarea.x, workarea.x2() - frame.w);
frame.y = std::clamp(frame.y, workarea.y, workarea.y2() - frame.h);
frame.x = std::clamp(frame.x, workarea.x, std::max(workarea.x, workarea.x2() - frame.w));
frame.y = std::clamp(frame.y, workarea.y, std::max(workarea.y, workarea.y2() - frame.h));
// Set frame bounds directly
window->setBounds(gfx::Rect(0, 0, frame.w / scale, frame.h / scale));