I am trying to make a responsive tilepanel with re...
# tornadofx
h
I am trying to make a responsive tilepanel with responsive images by ´fitToWidthProperty().bind(halfStagewidth)´. My first thought was something like
val halfStagewidth = SimpleDoubleProperty(primaryStage.width/2.0)
, but the required type is
ObservableValue<out Boolean!>!
, any ideas?
Copy code
override val root = scrollpane {
        hbarPolicy = ScrollPane.ScrollBarPolicy.NEVER
        vbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED

        tilepane {
            prefColumns = 2
            prefTileWidthProperty().bind(primaryStage.widthProperty().divide(2))

            children.bind(images) {
                imageview(it) {
                    fitToParentWidth()
                    isPreserveRatio = true
                }
            }
        }
    }
I guess this wasn't a tornadofx question 😃
a
that's an interesting way of choosing divide
why not use
primaryStage.widthProperty()/2
?
h
Then it become a Tornadofx question 🙂 neat overload.
fitToParentWidth() didn't cut it for upscaling of images, only downscaling. So I need to have a direct reference to the primaryStage from the imageview. That's not ideal.
I'm also doing some drawing on the image (groups in a stackpanel), I would have hoped I could have scaled the whole stackpanel, and not the individual components.
Should I change to a canvas instead?
a
bringing the conversation to the main panel 🙂