widgets/wrapper: round child position when centering

Fixes misalignment when resizeChild is false and wrapper width is odd.
This commit is contained in:
outfoxxed 2025-06-26 12:43:59 -07:00
parent d949f91347
commit f842b84a5a
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E

View file

@ -1,4 +1,5 @@
#include "marginwrapper.hpp"
#include <cmath>
#include <qobject.h>
#include <qquickitem.h>
@ -39,7 +40,7 @@ MarginWrapperManager::MarginWrapperManager(QObject* parent): WrapperManager(pare
auto total = this->bLeftMargin + this->bRightMargin;
auto mul = total == 0 ? 0.5 : this->bLeftMargin / total;
auto margin = this->bWrapperWidth - this->bChildImplicitWidth;
return margin * mul;
return std::round(margin * mul);
});
this->bChildY.setBinding([this] {
@ -48,7 +49,7 @@ MarginWrapperManager::MarginWrapperManager(QObject* parent): WrapperManager(pare
auto total = this->bTopMargin + this->bBottomMargin;
auto mul = total == 0 ? 0.5 : this->bTopMargin / total;
auto margin = this->bWrapperHeight - this->bChildImplicitHeight;
return margin * mul;
return std::round(margin * mul);
});
this->bChildWidth.setBinding([this] {