Draw the whole interface in Compose

Etappen 3 to 6a of the migration (129 commits). Every window the operator sees
is Compose; the JavaFX ones still exist beside them so the two could be
compared against a live session, which is the only way the differences came to
light.

The toolchain first, then the settings window with its eleven tabs and 72 real
preferences; then the multi-column table as a component, and with it the rules
it needs -- stable row identity, a selection that survives a refresh, column
order the operator can drag, and a repaint when the rows change rather than
when the list instance does. Then the update and monitor windows, and the main
window: 22 station columns, the filter bar, the selected-station panel, the
message tabs, the priority bar, the sked controls, the status indicators and
the timeline, assembled behind a splitter because Compose has none.

The map stops being a WebView. A Compose canvas projects WebMercator tiles
itself, with the clustering in core and an asynchronous fetcher in place of the
local tile proxy; derive() becomes a pure Kotlin reimplementation instead of a
reflection call into com.sun.javafx.

Most of the volume here is parity the operator would notice rather than new
behaviour: desktop density instead of Material's phone minimums, colours taken
from the JavaFX stylesheets instead of Material's palette, row dividers, band
columns, grid-square labels and their colours, the home marker and antenna
beam, pinch-to-zoom under Wayland, and layouts that survive a window narrower
than the chart they stack.

Two lessons are worth more than the diff. A control bound to a value Compose
cannot observe writes through and never redraws -- that one shipped repeatedly
with a green build, because no test drew anything. And a layout that clips
instead of wrapping is worse than one that is merely too narrow: half a word
is the worst available outcome.
This commit is contained in:
Rsclub2_2 committed 2026-10-05 22:33:28 +02:00
1 parent a6fba12f01
commit cc8c90204e
173 files changed
+26500 -4305

No files matched your search

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 607 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 834 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 800 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 617 KiB

+207
View File
@@ -0,0 +1,207 @@
package kst4contest.view.compose
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@OptIn(ExperimentalLayoutApi::class)
@Composable
fun StationFilterBar(
filters: StationFilterState,
onChanged: () -> Unit,
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier.fillMaxWidth().padding(4.dp),
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
// ROW 1: Reset, QRB, QTF
FlowRow(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(16.dp),
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
// Group 1: Reset & QRB
Row(horizontalArrangement = Arrangement.spacedBy(Density.BUTTON_GAP), verticalAlignment = Alignment.CenterVertically) {
androidx.compose.material3.Button(
onClick = {
filters.reset()
onChanged()
},
shape = Density.BUTTON_SHAPE,
contentPadding = Density.BUTTON_CONTENT_PADDING,
modifier = Modifier.heightIn(min = Density.BUTTON_MIN_HEIGHT)
) {
Text("Reset filters", style = MaterialTheme.typography.bodySmall)
}
FilterToggle("Show only QRB [km] <=", filters.maxQrbEnabled) {
filters.maxQrbEnabled = it
onChanged()
}
OutlinedTextField(
value = if (filters.maxQrbKm.rem(1) == 0.0) filters.maxQrbKm.toInt().toString() else filters.maxQrbKm.toString(),
onValueChange = {
val parsed = it.toDoubleOrNull()
if (parsed != null) {
filters.maxQrbKm = parsed
if (filters.maxQrbEnabled) onChanged()
} else if (it.isEmpty()) {
filters.maxQrbKm = 0.0
if (filters.maxQrbEnabled) onChanged()
}
},
modifier = Modifier.width(60.dp).heightIn(min = Density.BUTTON_MIN_HEIGHT),
singleLine = true,
textStyle = MaterialTheme.typography.bodySmall
)
}
// Group 2: QTF
Row(horizontalArrangement = Arrangement.spacedBy(Density.BUTTON_GAP), verticalAlignment = Alignment.CenterVertically) {
FilterToggle("Show only QTF:", filters.qtfEnabled) {
filters.qtfEnabled = it
onChanged()
}
OutlinedTextField(
value = if (filters.qtfDegrees.rem(1) == 0.0) filters.qtfDegrees.toInt().toString() else filters.qtfDegrees.toString(),
onValueChange = {
val parsed = it.toDoubleOrNull()
if (parsed != null) {
filters.qtfDegrees = parsed
filters.bearing = null
if (filters.qtfEnabled) onChanged()
} else if (it.isEmpty()) {
filters.qtfDegrees = 0.0
filters.bearing = null
if (filters.qtfEnabled) onChanged()
}
},
modifier = Modifier.width(55.dp).heightIn(min = Density.BUTTON_MIN_HEIGHT),
singleLine = true,
textStyle = MaterialTheme.typography.bodySmall
)
Text("± BW/2", style = MaterialTheme.typography.bodySmall)
Bearing.entries.forEach { bearing ->
FilterToggle(bearing.name, filters.bearing == bearing) {
filters.selectBearing(bearing)
if (filters.qtfEnabled) {
onChanged()
}
}
}
}
}
// ROW 2: Find, Hide worked, Misc
FlowRow(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(16.dp),
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
// Find
OutlinedTextField(
value = filters.searchText,
onValueChange = {
filters.searchText = it
onChanged()
},
placeholder = { Text("Find...", style = MaterialTheme.typography.bodySmall) },
modifier = Modifier.width(120.dp).heightIn(min = Density.BUTTON_MIN_HEIGHT),
singleLine = true,
textStyle = MaterialTheme.typography.bodySmall
)
// Hide worked
Row(horizontalArrangement = Arrangement.spacedBy(Density.BUTTON_GAP), verticalAlignment = Alignment.CenterVertically) {
Text("Hide worked:", style = MaterialTheme.typography.bodySmall)
FilterToggle("wkd", filters.hideWorkedAny) {
filters.hideWorkedAny = it
onChanged()
}
WorkedBandFilter.entries.forEach { band ->
FilterToggle(band.label, filters.isHideWorkedOn(band)) {
filters.setHideWorkedOn(band, it)
onChanged()
}
}
}
// Others
Row(horizontalArrangement = Arrangement.spacedBy(Density.BUTTON_GAP), verticalAlignment = Alignment.CenterVertically) {
FilterToggle("Inactive stations", filters.hideInactive) {
filters.hideInactive = it
onChanged()
}
FilterToggle("Only new grids", filters.onlyNewGrids) {
filters.onlyNewGrids = it
onChanged()
}
}
}
// ROW 3: More misc
FlowRow(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(Density.BUTTON_GAP),
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
FilterToggle("Grid color", filters.gridColouring) { filters.gridColouring = it }
FilterToggle("Tropo >=0dB", filters.tropoReachable) {
filters.tropoReachable = it
onChanged()
}
FilterToggle("New bands", filters.newBands) {
filters.newBands = it
onChanged()
}
FilterToggle("AS next 5m", filters.airScoutNext5Min) {
filters.airScoutNext5Min = it
onChanged()
}
}
}
}
@Composable
private fun FilterToggle(label: String, on: Boolean, onChange: (Boolean) -> Unit) {
val colours = if (on) {
androidx.compose.material3.ButtonDefaults.buttonColors()
} else {
androidx.compose.material3.ButtonDefaults.outlinedButtonColors(
contentColor = MaterialTheme.colorScheme.onSurface
)
}
androidx.compose.material3.Button(
onClick = { onChange(!on) },
colors = colours,
shape = Density.BUTTON_SHAPE,
contentPadding = Density.BUTTON_CONTENT_PADDING,
border = if (on) null else androidx.compose.foundation.BorderStroke(
Density.HAIRLINE,
MaterialTheme.colorScheme.outline,
),
modifier = Modifier.heightIn(min = Density.BUTTON_MIN_HEIGHT),
) {
Text(label, style = MaterialTheme.typography.bodySmall, maxLines = 1)
}
}
+182
View File
@@ -0,0 +1,182 @@
import sys
content = """package kst4contest.view.compose
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
/**
* The filter bar above the station list.
*/
@OptIn(ExperimentalLayoutApi::class)
@Composable
fun StationFilterBar(
filters: StationFilterState,
onChanged: () -> Unit,
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier.fillMaxWidth().padding(2.dp),
verticalArrangement = Arrangement.spacedBy(2.dp),
) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Row(horizontalArrangement = Arrangement.spacedBy(Density.BUTTON_GAP), verticalAlignment = Alignment.CenterVertically) {
androidx.compose.material3.OutlinedTextField(
value = filters.searchText,
onValueChange = {
filters.searchText = it
onChanged()
},
label = { Text("User filter", style = MaterialTheme.typography.bodySmall) },
modifier = Modifier.width(150.dp).heightIn(min = Density.BUTTON_MIN_HEIGHT),
singleLine = true,
textStyle = MaterialTheme.typography.bodySmall
)
androidx.compose.material3.Button(
onClick = {
filters.reset()
onChanged()
},
shape = Density.BUTTON_SHAPE,
contentPadding = Density.BUTTON_CONTENT_PADDING,
modifier = Modifier.heightIn(min = Density.BUTTON_MIN_HEIGHT)
) {
Text("Reset filters", style = MaterialTheme.typography.bodySmall)
}
}
}
FlowRow(horizontalArrangement = Arrangement.spacedBy(Density.BUTTON_GAP)) {
FilterToggle("Only new grids", filters.onlyNewGrids) {
filters.onlyNewGrids = it
onChanged()
}
FilterToggle("Tropo >=0dB", filters.tropoReachable) {
filters.tropoReachable = it
onChanged()
}
FilterToggle("New bands", filters.newBands) {
filters.newBands = it
onChanged()
}
FilterToggle("AS next 5m", filters.airScoutNext5Min) {
filters.airScoutNext5Min = it
onChanged()
}
FilterToggle("Inactive stations", filters.hideInactive) {
filters.hideInactive = it
onChanged()
}
/* Not a filter. It colours the locator cell and hides nothing. */
FilterToggle("Grid color", filters.gridColouring) { filters.gridColouring = it }
}
Row(verticalAlignment = Alignment.CenterVertically) {
Text("Hide worked:", style = MaterialTheme.typography.bodySmall,
modifier = Modifier.width(90.dp))
FilterToggle("wkd", filters.hideWorkedAny) {
filters.hideWorkedAny = it
onChanged()
}
FlowRow(horizontalArrangement = Arrangement.spacedBy(Density.BUTTON_GAP)) {
WorkedBandFilter.entries.forEach { band ->
FilterToggle(band.label, filters.isHideWorkedOn(band)) {
filters.setHideWorkedOn(band, it)
onChanged()
}
}
}
}
Row(verticalAlignment = Alignment.CenterVertically) {
Text("Show only QTF:", style = MaterialTheme.typography.bodySmall,
modifier = Modifier.width(90.dp))
FilterToggle("on", filters.qtfEnabled) {
filters.qtfEnabled = it
onChanged()
}
androidx.compose.material3.OutlinedTextField(
value = if (filters.qtfDegrees.rem(1) == 0.0) filters.qtfDegrees.toInt().toString() else filters.qtfDegrees.toString(),
onValueChange = {
val parsed = it.toDoubleOrNull()
if (parsed != null) {
filters.qtfDegrees = parsed
filters.bearing = null
if (filters.qtfEnabled) {
onChanged()
}
} else if (it.isEmpty()) {
filters.qtfDegrees = 0.0
filters.bearing = null
if (filters.qtfEnabled) {
onChanged()
}
}
},
modifier = Modifier.width(60.dp).padding(start = 6.dp).heightIn(min = Density.BUTTON_MIN_HEIGHT),
singleLine = true,
textStyle = MaterialTheme.typography.bodySmall
)
FlowRow(
horizontalArrangement = Arrangement.spacedBy(Density.BUTTON_GAP),
modifier = Modifier.padding(start = 6.dp),
) {
Bearing.entries.forEach { bearing ->
FilterToggle(bearing.name, filters.bearing == bearing) {
filters.selectBearing(bearing)
if (filters.qtfEnabled) {
onChanged()
}
}
}
}
}
}
}
/** A toggle in the filter bar: pressed means on, and it says so by its colour. */
@Composable
private fun FilterToggle(label: String, on: Boolean, onChange: (Boolean) -> Unit) {
val colours = if (on) {
androidx.compose.material3.ButtonDefaults.buttonColors()
} else {
androidx.compose.material3.ButtonDefaults.outlinedButtonColors()
}
androidx.compose.material3.Button(
onClick = { onChange(!on) },
colors = colours,
shape = Density.BUTTON_SHAPE,
contentPadding = Density.BUTTON_CONTENT_PADDING,
border = if (on) null else androidx.compose.foundation.BorderStroke(
Density.HAIRLINE,
MaterialTheme.colorScheme.outline,
),
modifier = Modifier.heightIn(min = Density.BUTTON_MIN_HEIGHT),
) {
Text(label, style = MaterialTheme.typography.bodySmall, maxLines = 1)
}
}