albrechtroehm
11/06/2020, 1:20 PMclass MinimalExample : ListCellFragment<PrioThree>() {
val iconService by inject<IconService>()
private val prio = PrioThreeModel().bindTo(this)
override val root = hbox(5) {
togglebutton(prio.prio1) {
val icon = imageview() {
isPreserveRatio = true
fitHeight = 28.0
}
textProperty().onChange { buttonString ->
if (!buttonString.isNullOrEmpty())
runAsync {
queryIconUrl(buttonString)
} ui {
if (it.isNotEmpty())
icon.image = Image(it, true)
}
}
selectedProperty().bindBidirectional(prio.p1Collected)
}
togglebutton(prio.prio2) {
graphic = cache {
imageview() {
isPreserveRatio = true
fitHeight = 28.0
enableWhen(iconVisible)
textProperty().onChange { buttonString ->
if (!buttonString.isNullOrEmpty())
runAsync {
queryIconUrl(buttonString)
} ui {
if (it.isNotEmpty())
this.image = Image(it, true)
}
}
}
}
selectedProperty().bindBidirectional(prio.p2Collected)
}
togglebutton(prio.prio3) {
val icon = imageview() {
isPreserveRatio = true
fitHeight = 28.0
}
textProperty().onChange { buttonString ->
if (!buttonString.isNullOrEmpty())
runAsync {
queryIconUrl(buttonString)
} ui {
if (it.isNotEmpty()){
icon.isDisable = false
icon.image = Image(it)
}
else icon.isDisable = true
}
}
selectedProperty().bindBidirectional(prio.p3Collected)
}
}
}
albrechtroehm
11/06/2020, 2:02 PMval iconUrl1 = prio.prio1.stringBinding() { queryUrlWhenNotEmpty(it) }
togglebutton(prio.prio1) {
graphic = cache {
imageview(iconUrl1) {
isPreserveRatio = true
fitHeight = 28.0
}
}
selectedProperty().bindBidirectional(prio.p1Collected)
}
But somehow i cant figure out how to cache it the right waySamkeene
11/06/2020, 4:24 PMval icon = imageview {
isPreserveRatio = true
fitHeight = 28.0
enableWhen { // or visibleWhen/hiddenWhen/disableWhen
booleanBinding(myStringProp) {
this.value.isNullOrEmpty()
}
}
}
albrechtroehm
11/07/2020, 2:02 PMcellFormat {
graphic = cache(itemProperty().get().playerName) {
hbox(5) {
paddingTop = 1.0
paddingBottom = 1.0
addClass(Styles.prioButton)
label(itemProperty().get().playerName ) {
addClass(Styles.biggerFont)
prefWidth = 130.0
}
label(itemProperty().get().bonus) {
addClass(Styles.biggerFont)
prefWidth = 40.0
}
togglebutton(getNameOnly(itemProperty().get().prio1)) {
imageview(iconService.getIconPath(itemProperty().select { it.prio1 }.value)) {
isPreserveRatio = true
fitHeight = 28.0
}
selectedProperty().bindBidirectional(itemProperty().get().p1Collected)
prefWidth = prioButtonSize
}
...
}