Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation of right-aligned windows is twitchy #1243

Open
niello opened this issue Jan 7, 2022 · 1 comment
Open

Animation of right-aligned windows is twitchy #1243

niello opened this issue Jan 7, 2022 · 1 comment

Comments

@niello
Copy link
Contributor

niello commented Jan 7, 2022

See GameMenu sample for example. LabelDelete is animated through the parent container resizing. At some point the parent container size is rounded so that the label position shifts one pixel right although the animation must smoothly move it to the left. This produces noticeable twitch.

Here are logs from Element::getUnclippedOuterRect_impl:

old: x:447 y:329, pos: x:447.49219, size: w:19, parent rect: l:403 r:466
old: x:447 y:329, pos: x:447.5, size: w:19, parent rect: l:402 r:466

They are obtained by inserting this code:

const auto prevPos = getUnclippedOuterRect().getCurrent().d_min;
...
if (auto label = dynamic_cast<const Window*>(this))
	if (label->getName() == "LabelDelete")// && prevPos.x < offset.x)
		Logger::getSingleton().logEvent(
			"***DBG old: " + PropertyHelper<glm::vec2>::toString(prevPos)
			+ ", pos: " + PropertyHelper<glm::vec2>::toString(offset)
			+ ", size: " + PropertyHelper<Sizef>::toString(pixel_size)
			+ ", parent rect: " + PropertyHelper<Rectf>::toString(parent_rect), LoggingLevel::Warning);

The fix might be in calculating parent-child rects without pixel alignment, and aligning only when render, but this may have unpredictable consequences. Need to think about it.

@niello niello added bug and removed bug labels Jan 7, 2022
@niello
Copy link
Contributor Author

niello commented Jan 7, 2022

I've found that disabling pixel alignment of problematic widgets almost solves the problem.

    if (auto wnd = d_root->getChild("InnerButtonsContainer/PopupLinesCharacters/LabelDelete"))
        wnd->setPixelAligned(false);
    if (auto wnd = d_root->getChild("InnerButtonsContainer/PopupLinesCharacters/LabelSelect"))
        wnd->setPixelAligned(false);

This produces a lot smoother animation, yet it doesn't eliminate logical twitching, and also it may work bad with texts, when the pixel alignment in not animated directions is desired. I.e. it is ok to disable horizontal pixel alignment when animate X axis, but Y must be aligned all the time, and when an animation ends, X must be aligned too. So this solution is only partial yet acceptable for basic cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant