Today I was feeling very frustrated with the LookAndFeel approach in JUCE when CSS crossed my mind as a solution and as expected, somebody had already thought about it!
However I’d like to bring a new perspective to this old thread because incorporating CSS doesn’t necessarily mean to me using HTML and CSS to render an interface in the very same way that web browsers do it.
CSS could be simply used as a format to configure a Component in a better way than the current LookAndFeel approach. So all that I’m suggesting is that a “setStyle('font:arial;background:#FFFFFF;align:left)” method is added to every component to replace the current enum ColourIds and replace most of the “setter” methods.
Why do I say “better”? The current LookAndFeel makes changes to the set of Components provided by JUCE quite difficult. If you want to add a new parameter to the ComboBox for example to change the width and color of its border, now you can’t do it without modifying the LookAndFeel base code or creating a brand new custom Component. With CSS, it would be enough to create a base class with a virtual void setStyle(String) from which you could inherit in your custom components. You could then expand the existing JUCE components by inheriting from them and supporting more parameters in the style definition.
The CSS design would also allow to define the appearance of several components in a single file to create different themes in a very clean way (the designer would be able to relate to those CSS settings much better than to the current LookAndFeel list of colours and the current arbitrary set of setter methods to change basic things like the border width or the text-alignment of certain components).
The only disadvantage of this approach is that the parsing of large CSS files could slow down large UI’s. However you could also define a setStyle with an (void*) pointer to leave room for the use of more optimized data structures than the default CSS style text in more demanding situations.
Does it make any sense to you?