Skip to content

Commit 582ad5e

Browse files
soloturnclaude
andcommitted
Compose GUI: add icons to Rip/Stop/Panic buttons
Rip and Stop reuse icon.png/stop.png, the same assets MainWindow's ripButton/stopButton use. MainWindow's panicButton has no icon of its own; Panic does an immediate hard-abort (ripper.stop() + panic(), no graceful finish-current-item like Stop) so it gets a warning-triangle vector icon from material-icons-core (new dependency) rather than an unrelated resource PNG - a first attempt reused the otherwise-unused wrench.png, but a wrench reads as "settings/tool", not "abort". Verified live against the built jar (-Dripme.gui=compose). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 3e203bf commit 582ad5e

2 files changed

Lines changed: 45 additions & 10 deletions

File tree

build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ dependencies {
3535
// material3 is versioned independently of the Compose Multiplatform release train (the alias
3636
// resolved it to 1.9.0, not 1.11.1 - verified via `gradlew dependencies`).
3737
implementation("org.jetbrains.compose.material3:material3:1.9.0")
38+
// Vector icons (e.g. the Panic button's warning triangle) that don't have a matching PNG in
39+
// src/main/resources. Versioned independently of the Compose Multiplatform release train (like
40+
// material3 above) - 1.7.3 is the latest published release as of this writing.
41+
implementation("org.jetbrains.compose.material:material-icons-core:1.7.3")
3842
implementation("org.jetbrains.compose.ui:ui:1.11.1")
3943
// Nav for the Compose Desktop GUI (RipMe #2082 GUI parity pass) is a plain hand-rolled
4044
// mutableStateOf<Panel> controller (see ui/compose/nav/Panel.kt) rather than a navigation

src/main/kotlin/com/rarchives/ripme/ui/compose/MainScreen.kt

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import androidx.compose.foundation.layout.height
1111
import androidx.compose.foundation.layout.padding
1212
import androidx.compose.foundation.layout.size
1313
import androidx.compose.foundation.layout.width
14+
import androidx.compose.material.icons.Icons
15+
import androidx.compose.material.icons.filled.Warning
1416
import androidx.compose.material3.Button
1517
import androidx.compose.material3.Icon
1618
import androidx.compose.material3.LinearProgressIndicator
@@ -61,27 +63,34 @@ fun MainScreen(nav: NavController, queueController: QueueController, panels: Pan
6163
modifier = Modifier.weight(1f)
6264
)
6365
Spacer(modifier = Modifier.width(8.dp))
64-
Button(onClick = {
66+
// Matches MainWindow: "Rip"/"Stop"/"Panic!" are hardcoded literals, never
67+
// routed through Utils.getLocalizedString. icon.png/stop.png are the same
68+
// icons MainWindow's ripButton/stopButton use. MainWindow's panicButton has
69+
// no icon of its own; Panic does an immediate hard-abort (ripper.stop() +
70+
// ripper.panic(), no graceful finish-current-item like Stop), so it gets a
71+
// warning triangle from Compose's bundled material-icons-core rather than
72+
// reusing an unrelated resource PNG.
73+
IconActionButton("Rip", onClick = {
6574
queueController.enqueue(urlText)
6675
urlText = ""
6776
}) {
68-
// Matches MainWindow: "Rip"/"Stop"/"Panic!" are hardcoded literals, never
69-
// routed through Utils.getLocalizedString.
70-
Text("Rip")
77+
ResourcePngIcon("icon.png")
7178
}
7279
Spacer(modifier = Modifier.width(8.dp))
73-
Button(
80+
IconActionButton(
81+
"Stop",
7482
onClick = { queueController.stop() },
75-
enabled = queueController.busy
83+
enabled = queueController.busy,
7684
) {
77-
Text("Stop")
85+
ResourcePngIcon("stop.png")
7886
}
7987
Spacer(modifier = Modifier.width(8.dp))
80-
Button(
88+
IconActionButton(
89+
"Panic!",
8190
onClick = { queueController.panic() },
82-
enabled = queueController.busy
91+
enabled = queueController.busy,
8392
) {
84-
Text("Panic!")
93+
Icon(imageVector = Icons.Filled.Warning, contentDescription = null, modifier = Modifier.size(20.dp))
8594
}
8695
}
8796

@@ -133,6 +142,28 @@ fun MainScreen(nav: NavController, queueController: QueueController, panels: Pan
133142
}
134143
}
135144

145+
@Composable
146+
private fun IconActionButton(
147+
label: String,
148+
onClick: () -> Unit,
149+
enabled: Boolean = true,
150+
icon: @Composable () -> Unit,
151+
) {
152+
Button(onClick = onClick, enabled = enabled) {
153+
icon()
154+
Spacer(modifier = Modifier.width(6.dp))
155+
Text(label)
156+
}
157+
}
158+
159+
@Composable
160+
private fun ResourcePngIcon(resourceName: String) {
161+
val painter = rememberResourceIcon(resourceName)
162+
if (painter != null) {
163+
Icon(painter = painter, contentDescription = null, modifier = Modifier.size(20.dp))
164+
}
165+
}
166+
136167
@Composable
137168
private fun OptionButton(label: String, iconResource: String, active: Boolean, onClick: () -> Unit) {
138169
val icon = rememberResourceIcon(iconResource)

0 commit comments

Comments
 (0)