natinusala / borealis

Hardware accelerated, controller and TV oriented UI library for PC and Nintendo Switch (libnx)
Apache License 2.0
267 stars 84 forks source link

Focus splitting fixes #54

Closed Chrscool8 closed 3 years ago

Chrscool8 commented 4 years ago

Got it! Turned out to be surprisingly simple once I learned a bit how it worked more deeply.

This fixes https://github.com/natinusala/borealis/issues/27 by using a simple bool lock.

The lock is activated when/if the focus is successfully changed and deactivated at the end of the main loop each step. This way, only one view change can happen in one frame. I can't find any weirdness or problems with this solution in extensive testing.

This also gracefully fixes the problem with the sticks in https://github.com/natinusala/borealis/pull/52 and removes the need for its 'band-aid' solution.

natinusala commented 4 years ago

Thanks for the PR! I left some nitpicky comments :D

I'll have to test this extensively to make sure it doesn't break some sidebar behavior (like press left/right to move, a/b to enter and exit etc...).

natinusala commented 4 years ago

Also I'll update the wiki to state that only one focus change can happen per frame.

A more elegant solution would probably be to defer all calls to navigate() and only actually run the latest of the frame (at the end of the frame). This might break my fancy pants WIP scrolling changes though.

Chrscool8 commented 4 years ago

Thanks for the PR! I left some nitpicky comments :D

Happy to have the tips! Those are done and done!

I'll have to test this extensively to make sure it doesn't break some sidebar behavior (like press left/right to move, a/b to enter and exit etc...).

Have at it! I've tried it on pretty much every view and interaction type I know of and haven't seen anything iffy yet.

Also I'll update the wiki to state that only one focus change can happen per frame.

A more elegant solution would probably be to defer all calls to navigate() and only actually run the latest of the frame (at the end of the frame). This might break my fancy pants WIP scrolling changes though.

For sure. I was toying around with that sorta idea and thinking about what might be good built-in key priorities but figured this went great as a temp solution at the very least!

natinusala commented 4 years ago

Do you have Discord? If so, can you join the RetroNX server and DM me?

Chrscool8 commented 4 years ago

Anything else this and #54 needed before being added to the main code? (I'm finally back on a PC to keep working on stuff!)

natinusala commented 4 years ago

No I just need to take care of it πŸ™ˆ

Le 30 septembre 2020 18:13:16 Chris Bradel notifications@github.com a Γ©crit :

Anything else this and #54 needed before being added to the main code? (I'm finally back on a PC to keep working on stuff!) β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

natinusala commented 3 years ago

@Chrscool8 Wow so it's really been three months since I said I would review it huh

The thing is, I am currently focusing my work on the yoga rework, and I'm not sure if I take contributions for the master branch?

So much stuff has changed and the two versions are basically incompatible now.

Are you working on something in particular with borealis now? Would you consider switching to the new version?

Chrscool8 commented 3 years ago

I... had no idea that was a thing. πŸ˜…

Just thought it would be nice if this and the other quick change would be merged so all the existing borealis apps out there could instantly update to use control sticks.

I just moments ago finished a humongous several month rewrite of my borealis-incorporating app, if that's what you mean, which does scare me to learn that the new version is going to be so different... but I can check it out, for sure.

natinusala commented 3 years ago

πŸ‘€ Well I hope you're not too scared of rewriting it again because I'm eventually going to drop support for the current version and go all in for the rework.

What part takes the UI in your code?

Chrscool8 commented 3 years ago

Most of it. πŸ™ƒ

I'll dive into the new version soon. I guess I'll just polish of what I can do with this one so far.

natinusala commented 3 years ago

Okay well I see that you are using components that are not yet reimplemented in the new version so I would advise to keep using the old one for now :D

Chrscool8 commented 3 years ago

Good deal! Good luck with the new project! I'll keep an eye on it!

natinusala commented 3 years ago

Unless... you want to help me out reimplementing everything? 😏

Chrscool8 commented 3 years ago

We'll be in touch lol

natinusala commented 3 years ago

FYI I will close this PR and apply this commit on yoga instead (keeping the authorship).