question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discussion: Approaches to scene2d Layout/Widget measuring

See original GitHub issue

This would probably be a better fit for a forum, but this place seems to be a better fit to reach other contributors

After seeing cae2342f08a368d15bed2d8d923f4f79f903d6f1 and fighting with similar issues myself:

How about we added Android-style onMeasure() instead of getMin/Pref/MaxSize?

  • Working with wrapped Labels without it is a pain (and probably with some other widgets as well),
  • it clearly defines when should a widget measure itself
  • and generally, from my experience, it is more predictable to use.

I don’t like many Android constructs, but this one is IMO pretty good. iOS seems to be doing something similar, under the hood of Autolayout.

It would be a breaking change, but it shouldn’t be hard to write some temporary bridges to ease the transition. I know that there are some big applications written in scene2d.ui, so the costs of rewriting could prevent this from happening (maybe libGDX 2.0). But even if that would be the case, I’d like to know what the general opinion is about these two approaches.

Of course this is just about the general idea, it probably wouldn’t have the exact Android API. I’d volunteer to write the PR for this, given enough positive feedback. Implementation details could be further discussed there.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
NathanSweetcommented, Jun 5, 2018

Looking forward to seeing your prototype! 😄

An animation system is maybe tougher than it appears. Sometimes animations can be combined, other times they need to be cancelled, other times they need to be fast forwarded to the end. I have a feeling the most flexible solution is some sort of animation controller that handles just one type of animation, then application code can define what happens as the user takes more actions.

Using HarfBuzz for shaping would be awesome. We don’t have RTL support, but we already have on-the-fly glyph generation, enabling typing in CJK or most other LTR languages, even when the glyphs typed are not known beforehand.

0reactions
Darkyenuscommented, Jun 3, 2018

Ah, it didn’t occur to me to look into the getGlyphLayout(), so I guess that solves that.

I like the simplicity of current system (and the awesomesauce of Table). The only problem is, that some parts are not very intuitive (Label wrap) and sometimes slightly confusing (Group moving children around during drawing), but thanks to the overall simplicity, it is usually not hard to just write some code and do whatever.

I still feel that it could be possible to iron out some of these unexpected behaviors I’ve been struggling with, but I can’t really argue about replacing the proven system with something experimental and untested. So this discussion will be probably meaningful only after coming up and testing the proposed solution 😄

Wow, that Gloomhaven app looks really polished. And the animate functions are also pretty cool.

I agree with what you are saying about animations - making sure that they all play nice together, when user keeps tapping, resizing screen, etc. is really tricky. Some time ago I was (over)thinking about a solution, and I came up with idea to make a system which would track two scene-graphs: first immediate, in which logical state of the application would be kept, with all hierarchy changes applied immediately, and second that would be shown to the user and some manager would continuously animate the shown scene to match the logical one. Input events would be disabled on elements that are currently being animated, or could be applied immediately to the logical scene. I never got the time to actually implement it, but I think that there is some potential for some wild animations/transitions in this system.

Another idea is to put all changes to the scene, animated or not, into a queue, with an overseer, that would make sure that some animations/changes start only after there are no other animations to the same elements in hierarchy, possibly merging some changes in the process (merge running “show overlay” animation with “hide overlay” so that it looks like the showing stopped mid-way and seamlessly turned into hiding). The queue manager/applier would probably also have to maintain the state before current animation started, to correctly handle things like screen rotation or resizing, though that could be cheated by fast-forwarding currently running animation, then allowing the screen to rotate and then launching next animation in queue, if any. Input events could use the same mutual exclusion system used on animations, discarding those events that would affect currently animated elements.

Both approaches are, compared to yours, pretty general, but also much more complicated, so I am not sure if it would be possible to reach the easily debuggable levels of complexity, which scene2d.ui currently has.

I’d like to experiment with this as soon as I got some time. Another thing to try would be dynamic FreeType font generation, possibly with HarfBuzz layout, so that libGDX can support any language out of the box.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Precise Position Of Widgets For Libgdx Scene2D - ADocLib
A stack is a container that sizes its children to its size and positions them at 0 Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui. changes...
Read more >
Feature #2252: implement GUI client support - User Interface
The client will need significant changes to implement GUI support. One important change that is necessary is to enhance the driver model.
Read more >
Activity | | Cocos2d-x - Cocos Creator
Hello everyody, its me agian with a newbie question. I'm trying to add the enemies to my game, are not enemies per s......
Read more >
Android 9 Development Cookbook Third Edition - n3wton.net
Chapter 7, Data Storage, compares multiple methods Android offers for persisting ... We'll use the (auto-generated) TextView view to display the message.
Read more >
Projects Related with android - ProgramCreek.com
Bind Android views and callbacks to fields and methods. ... SDK for Android to measure your apps with Matomo. ... Java LibGDX Android...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found