I've written my first JavaFX component (calendarpicker) complete with two skins and behavior. And something is not quite sitting right on the skin part, especially when considering future application skinning.
For example: my skin uses colors derrived from the Caspian skin; blues and grays. But suppose that some time in the future an application using my component may like to use a new skin, say orangish. My component will not become orange all of a sudden.
Compared some of my Swing component, there is a fundamental difference; for my swing components I try to derrive colors from what is present in the UIManager. For example: I have a fancier progressbar UI which uses colors from textfield and jtable in order to do some gradients. A new skin is automatically adopted.
Another thing is focus. I want my calendar picker to adopt the Caspian focus look. I already asked Jasper what exactly the focus effect is, because I have to reimplement that border effect. Yes, I just said "reimplement". Not wise.
What I would suggest for JFX is some kind of Skin descriptor, providing all kinds of colors (foreground, background, highlight, alternating, etc, maybe even all kinds of side colors), borders, effects, etc, that are used by a control's skin, Something similar to Swing's UIManager, but more fancy. For example: what if I have a component that requires two different highlighting colors? Maybe it is possible to devise an algorithm that is able to generate colors like these palette generators available on the web.
In Swing there would be a work around (which I use sometimes because not all skins set UIManager); simply create a dummy JTextField and ask for its foreground color. This is possible because of the enormous methods collections available in Swing components. JFX is cleaning stuff up, which is good, but a foreground color may totally not relevant to the control; it's a skin property. So basically I may not be able to ask a JFX textfield for its foreground color. And since I'm not certain which skin is active, I cannot go about and cast it. So especially considering the better separation of concerns, a skin descriptor is really required if we want to go anywhere else but Caspian in the future.
Components should be able to adapt to new skins instead of someone using CSS to tell them to. (Good defaults over configuration.)
For example: my skin uses colors derrived from the Caspian skin; blues and grays. But suppose that some time in the future an application using my component may like to use a new skin, say orangish. My component will not become orange all of a sudden.
Compared some of my Swing component, there is a fundamental difference; for my swing components I try to derrive colors from what is present in the UIManager. For example: I have a fancier progressbar UI which uses colors from textfield and jtable in order to do some gradients. A new skin is automatically adopted.
Another thing is focus. I want my calendar picker to adopt the Caspian focus look. I already asked Jasper what exactly the focus effect is, because I have to reimplement that border effect. Yes, I just said "reimplement". Not wise.
What I would suggest for JFX is some kind of Skin descriptor, providing all kinds of colors (foreground, background, highlight, alternating, etc, maybe even all kinds of side colors), borders, effects, etc, that are used by a control's skin, Something similar to Swing's UIManager, but more fancy. For example: what if I have a component that requires two different highlighting colors? Maybe it is possible to devise an algorithm that is able to generate colors like these palette generators available on the web.
In Swing there would be a work around (which I use sometimes because not all skins set UIManager); simply create a dummy JTextField and ask for its foreground color. This is possible because of the enormous methods collections available in Swing components. JFX is cleaning stuff up, which is good, but a foreground color may totally not relevant to the control; it's a skin property. So basically I may not be able to ask a JFX textfield for its foreground color. And since I'm not certain which skin is active, I cannot go about and cast it. So especially considering the better separation of concerns, a skin descriptor is really required if we want to go anywhere else but Caspian in the future.
Components should be able to adapt to new skins instead of someone using CSS to tell them to. (Good defaults over configuration.)
- relates to
-
JDK-8102210 Add API to JavaFX to allow for setting preferred user agent stylesheet
-
- Closed
-