StyledObject -> View -> Text
StyledObject -> View -> ViewContainer -> Button -> ToggleButton -> MyCustomToggleButton
StyledObject -> View -> ViewContainer -> VerticalLayout -> ListView
StyledObject -> View -> Text
StyledObject -> View -> ViewContainer -> Button -> ToggleButton -> MyCustomToggleButton
StyledObject -> View -> ViewContainer -> VerticalLayout -> ListView
That's so 1991. We're on to GUI's as pure functions of state these days, get on with the program :-)
https://www.freecodecamp.org/news/the-revolution-of-pure-vie...
https://raphlinus.github.io/ui/druid/2019/11/22/reactive-ui....
https://raphlinus.github.io/rust/druid/2020/09/25/principled...
I made the comment because such an abstraction doesn't at all map to reality.
Only if you choose to model your system that way. You can push the same paradigm all the way through: immutable events, and pure functions that transform an event and a previous (immutable) state into a new state.
You’re going to recreate framebuffers and font atlases and invalidate your entire UI every single time? Good joke.
A better approach are mixins. Separate ones for layout and behavior. This is much more flexible, and avoids code duplication or "crazy" inheritance hierarchies at the same time.
Rust Traits are ideal for mixins. So a GUI toolkit in Rust should be just fine.
why does it work fine in Qt then ?
Components managing their own state is a textbook definition of OOP.
i've never seen that not being called oop
Right, this is textbook interfaces used for composition.
Let me paste you a few paragraphs from the GoF book, released in 1994:
> Inheritance versus Composition
> The two most common techniques for reusing functionality in object-oriented systems are class inheritance and object composition. As we've explained, class inheritance lets you define the implementation of one class in terms of another's. Reuse by subclassing is often referred to as white-box reuse. The term "white-box" refers to visibility: With inheritance, the internals of parent classes are often visible to subclasses.
> Object composition is an alternative to class inheritance. Here, new functionality is obtained by assembling or composing objects to get more complex functionality. Object composition requires that the objects being composed have well-defined interfaces. This style of reuse is called black-box reuse, because no internal details of objects are visible. Objects appear only as "black boxes."
...
> Object composition has another effect on system design. Favoring object composition over class inheritance helps you keep each class encapsulated and focused on one task. Your classes and class hierarchies will remain small and will be less likely to grow into unmanageable monsters. On the other hand, a design based on object composition will have more objects (if fewer classes), and the system's behavior will depend on their interrelationships instead of being defined in one class.
Like, it's the most well-known OOP design book and it states exactly that - more than a QUARTER CENTURY ago. Who in hell argues that this isn't oop ?!
Maybe widen the bibliography of OOP programming languages beyond Smalltalk and C++ patterns?
Just like placing ECS against OOP, when they are discussed across OOP SIGPLAN papers and are the genesis of language features like Objective-C, CLOS/Flavor protocols and Smalltalk categories.
I guess, as always, the blame lies in how we teach these subjects and many don't do it properly.
Which I consider a better approach than inheritance, ymmv.
There are plenty of ACM and IEEE papers if you want to see it being called OOP.
OOP means that an object which does not exist now can be written in the future, and loaded into code which has already been compiled and is already running now. The method calls in this existing code will correctly resolve to the method implementations in that object.
But my point is that it's pretty weird to bring up SML in particular around GUI programming. The GUI framework only example I know of is mGTK and SML/tk which are far from idiomatic and pretty much require you to write imperative OOP code in SML. Meanwhile SML has existed for decades. It's one thing to say "people aren't using this great model we've developed the basics off, please help make it better", but if you wanted to write an idiomatic GUI app in SML today, your first step would be to have to write the GUI framework itself because no one else has. They don't provide any real options even if you fully buy in and want to jump in with what they're saying.
But we are not at the 80's anymore, and have more options now. There is very little you can do with OOP that you can't in Rust, and a whole lot of things Rust adds to it. Just because things evolved this way it does not mean they are optimal.