OSHGui
OSHGui copied to clipboard
Dynamically 'anchoring' elements is broken due to mistake in the code
Take a look at this these lines of code (line ~160-180 in Control.cpp, Control::SetSize
):
size_ = size;
OnSizeChanged();
Invalidate();
const auto offset = size_ - GetSize();
for (auto &control : controls_)
{
const auto anchor = control->GetAnchor();
if (anchor != (AnchorStyles::Top | AnchorStyles::Left))
It changes the member variable size_
and then calculates offset, which is obviously going to be {0, 0}. This breaks dynamic resizing of the parent controls, as the children will not be correctly placed after the resize.
EDIT: fixing this would be as simple as doing size - GetSize()
instead of size_ - GetSize()