FlexBox really need to be FINAL

gui

#1

Does the FlexBox class really need to be marked Final?

I had previously extended FlexBox to add animation capability.

Thanks,
Mike.


#2

Oh god, no, don’t inherit from flexbox!! Agh…!

Although I apologise again for breaking the code of people who had already done horrible things with inheritance before we could forbid it with the final keyword, we stand by the comments in the other threads where people are also moaning about this - it’s for your own good!

And I’ll say again: Please feel free to convince our panel of C++ gurus that inheriting from one of the classes we’ve marked as final is genuinely the best/only way to do something, and we’ll happily go back on our decision. So far, nobody has succeeded in arguing a good case!


#3

Thank you for the quick reply, even though slightly more generic that I’d like!

I guess classes in frameworks and OS’ go through vigorous scrutiny when the decision is made to mark previously released code as final.

Kind regards,
Mike.


#4

Let’s try flipping the problem around then - sounds like a feature request for animation support in FlexBox!


#5

Is there a recommended way of animating FlexBox items? As in - if the size of one item is changed with animation, the other items in the FlexBox should be adjusted appropriately (potentially resized and/or moved).

The FlexBox functionality is pretty new, so I would be surprised if animation of items was not considered when it was designed or when marking it as ‘final’.


#6

Cant’ you just use the Desktop::getAnimator() to animate each component the flexbox is positioning?

https://juce.com/doc/classDesktop#a80aea7a339408d22a84d447d3cd95755


#7

Flexbox itself is only concerned with layout - animation isn’t something that should be its responsibility (and I doubt whether the original web standard has any kind of special support for animation either).

The way you’d approach animating items that are using a flexbox would just be to keep modifyng the Flexbox properties, and re-applying the layout. I guess that’s how you’d do it in a web-page with javascript.

Currently we don’t have a class that would specifically automate that process like the ComponentAnimator does for components (and no, @matkatmusic, it would be a really bad idea to get flexbox and the animator class to both fight over who positions a component). But you could do it with an AnimatedPosition and a bit of boilerplate to apply that value to the flexbox layout.