Lazyload listview cell elements
This commit is contained in:
parent
f5126e2d9e
commit
892058c47e
@ -39,50 +39,60 @@ private class EntryCell(
|
|||||||
private val hostServices: HostServices,
|
private val hostServices: HostServices,
|
||||||
) : ListCell<DictionaryEntryFx?>() {
|
) : ListCell<DictionaryEntryFx?>() {
|
||||||
|
|
||||||
private val labelHeadword = Label().apply {
|
private val labelHeadword by lazy {
|
||||||
styleClass.add("headword")
|
Label().apply {
|
||||||
styleProperty().bind(
|
styleClass.add("headword")
|
||||||
Bindings.concat(
|
styleProperty().bind(
|
||||||
"-fx-font-size: ",
|
Bindings.concat(
|
||||||
config.searchResults.headwordFontSize.asString(),
|
"-fx-font-size: ",
|
||||||
"px;"
|
config.searchResults.headwordFontSize.asString(),
|
||||||
|
"px;"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val labelDefinition = Label().apply {
|
private val labelDefinition by lazy {
|
||||||
styleClass.add("definition")
|
Label().apply {
|
||||||
styleProperty().bind(
|
styleClass.add("definition")
|
||||||
Bindings.concat(
|
styleProperty().bind(
|
||||||
"-fx-font-size: ",
|
Bindings.concat(
|
||||||
config.searchResults.definitionFontSize.asString(),
|
"-fx-font-size: ",
|
||||||
"px;"
|
config.searchResults.definitionFontSize.asString(),
|
||||||
|
"px;"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
visibleProperty().bind(config.searchResults.shouldShowDefinition)
|
||||||
visibleProperty().bind(config.searchResults.shouldShowDefinition)
|
managedProperty().bind(config.searchResults.shouldShowDefinition)
|
||||||
managedProperty().bind(config.searchResults.shouldShowDefinition)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val labelPronunciation = Label().apply {
|
private val labelPronunciation by lazy {
|
||||||
styleClass.add("pronunciation")
|
Label().apply {
|
||||||
styleProperty().bind(
|
styleClass.add("pronunciation")
|
||||||
Bindings.concat(
|
styleProperty().bind(
|
||||||
"-fx-font-size: ",
|
Bindings.concat(
|
||||||
config.searchResults.pronunciationFontSize.asString(),
|
"-fx-font-size: ",
|
||||||
"px;"
|
config.searchResults.pronunciationFontSize.asString(),
|
||||||
|
"px;"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
visibleProperty().bind(config.searchResults.shouldShowPronunciation)
|
||||||
visibleProperty().bind(config.searchResults.shouldShowPronunciation)
|
managedProperty().bind(config.searchResults.shouldShowPronunciation)
|
||||||
managedProperty().bind(config.searchResults.shouldShowPronunciation)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val flowPane = FlowPane(labelHeadword, labelPronunciation).apply {
|
private val flowPane by lazy {
|
||||||
hgap = FLOW_PANE_HGAP
|
FlowPane(labelHeadword, labelPronunciation).apply {
|
||||||
rowValignment = VPos.BASELINE
|
hgap = FLOW_PANE_HGAP
|
||||||
|
rowValignment = VPos.BASELINE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val root = VBox(flowPane, labelDefinition).apply {
|
private val root by lazy {
|
||||||
styleClass.add("search-result")
|
VBox(flowPane, labelDefinition).apply {
|
||||||
|
styleClass.add("search-result")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -36,11 +36,16 @@ private class SentenceCell(
|
|||||||
private val hostServices: HostServices,
|
private val hostServices: HostServices,
|
||||||
) : ListCell<SentenceFx?>() {
|
) : ListCell<SentenceFx?>() {
|
||||||
|
|
||||||
private val labelSentence = Label().apply {
|
private val labelSentence by lazy {
|
||||||
styleClass.add("sentence")
|
Label().apply {
|
||||||
isWrapText = true
|
styleClass.add("sentence")
|
||||||
|
isWrapText = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val root by lazy {
|
||||||
|
VBox(labelSentence)
|
||||||
}
|
}
|
||||||
private val root = VBox(labelSentence)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
text = null
|
text = null
|
||||||
@ -50,6 +55,7 @@ private class SentenceCell(
|
|||||||
super.updateItem(sentence, empty)
|
super.updateItem(sentence, empty)
|
||||||
if (empty || sentence == null) {
|
if (empty || sentence == null) {
|
||||||
graphic = null
|
graphic = null
|
||||||
|
contextMenu = null
|
||||||
} else {
|
} else {
|
||||||
labelSentence.textProperty().bind(
|
labelSentence.textProperty().bind(
|
||||||
Bindings.createStringBinding(
|
Bindings.createStringBinding(
|
||||||
|
Loading…
Reference in New Issue
Block a user