I’ve been thinking about how to implement GUI styles and wanted to pick the brains of those who’ve already thought deeply about it. How should the style class be improved? Are there any plans for the future of styles?
Background:
I was recently noticing how difficult it is to implement a consistent button look and feel. Simultaneously, the current style class only implements font-related properties (“for now”).
I wrote a very simple “copy properties” class that saves/loads a control’s look and feel. The discussion is found here and with playground, primarily implementing ApplyStyleToFrom(toControl, fromControl)
. It makes me wonder “how can it be improved?”
Questions:
1. Is CSS the aspirational model or are Babylon styles their own thing?
2. How similar to CSS programmatically should styles be? (likely CSSStyleDeclaration, but what about the other elements of CSSDOM?)
3. Can and should Babylon integrate with CSS where styles declared in HTML pass down to Babylon?
I think it’s fair to say that a primary limitation is the maintenance burden on core developers and the very related preservation of backward compatibility now and into the future.
Regarding CSS, there’s a ton there! The general categories: properties, cascading and cascade layers, inheritance, selectors, specificity, values/units, sizing, styling backgrounds and borders, animation, transitions, transforms, CSS flexible box, multi-column and grid layout, stacking and block-formatting contexts, etc, etc.
If this is the chosen path, it seems to start with inline style declarations because internal and external declarations would naturally use inline style functions. And no selectors are needed for inline, though inheritance is a little bit of a slippery slope towards needing selectors.
Inline styles almost immediately gets into properties, shorthand properties, values, units, and functions (calc()?) including dynamic and relative values. Knowing where we want to end up helps greatly with the first steps. It also helps inform how deeply modifications are warranted to other Babylon objects, such as fonts, AdvancedDynamicTexture, and GUI controls generally.
I hope you don’t mind me tagging you, I think you might be interested in this conversation: @mawa @jamessimo @PatrickRyan @tricotou @RaananW @carolhmj @julien-moreau @Dok11 @kintz_09
Shout outs to @RaananW for the initial implementation and continued maintenance of styles, @mawa for his boundless enthusiasm and encouragement and this positioning statement from PatrickRyan
If/when it becomes prudent, I’ll add a list here (or inline) of posts and links that have related questions, comments, ideas, and solutions that may help spur the conversation.