Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8090610

Add support for prefWidth/prefHeight on StyleSheets

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 7u6
    • javafx

      I know that this feature has been requested in other ways and has been marked as "Won't fix" so let me try to explain why I think it could be interesting.

      I developed an application for Ticket Vending Machines and Points of Sale for different Metros and train systems all over the world. Basically (this particularly true for TVMs) the visualization is similar in every project, for example the screen in which you pay has always the same components but there is a heavy need for customization: change background images, colors etc. Part of that customization is layout, I rely heavily on translateX/Y (I would have preferred to have layoutX/Y) for customizing those screen for the different clients but I need also to set prefWidth/prefHeight because for example the are more accepted notes in USA than in Europe needing more space in the FlowPane I use.

      Back in old 1.2 days this was posible because it was done by reflection (I now how slow is was ;-)), but dissappeared in 1.3. It was so important that I created my custom stylesheet parser, for ccss files (custom css), in those I include the properties directly i.e.:

      prefWidth: 120; (This actually JavaFX 2.x sintaxis not 1.3, but it was simillar)

      An using reflection I apply it to the nodes as a second wave of styling, obviously I use this hand-made solution only for those features that are supported through the standard stylesheets.

      Recently I've been investigating how the styles are includes in the nodes and I managed to create a CustomText with a new "-fx-wrapping-width" style property. The same could be done if I subclass Panes and Control but I don't want to go that way.

      Anyway the most interesting thing is that supporting layout customizing reduces drastically the time needed for adjusting every single component in the screen. This could sound strange but I've developed a helper tool, that I can launch in parallel with my application. One of its option is to autorefresh the stylesheets when they change (both css and ccss), so for laying out, I launch the application, open a text editor and I start changing x/y positions and prefWidth/prefHeight, seeing the changes directly in the interface without needing to stop/change the code/restart and so on.

      I've been working with Jonathan Giles for a month to merge this and more features inside your ScenicView application and I think that this could be very useful for every single developer and could reduce dramatically the time spent on layout.

      Technically it could be done (that's what I think after seeing Text and wrapping-width) and it is only an option, so why not allow it?

            Unassigned Unassigned
            anruizjfx Ander Ruiz (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported: