diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..e2bd2c7 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,42 @@ +plugins { + kotlin("jvm") version "2.0.0" + id("org.openjfx.javafxplugin") version "0.0.13" + application + distribution +} + +application { + mainClass.set("xyz.maxwellj.glide.MainKt") + layout.buildDirectory.dir("distributions/") +} + +group = "xyz.maxwellj.glide" +version = "0.0.1" + +repositories { + mavenCentral() +} + +tasks.withType { + manifest { + attributes["Main-Class"] = "xyz.maxwellj.glide.MainKt" + } +} + +dependencies { + testImplementation(kotlin("test")) + implementation(kotlin("stdlib-jdk8")) + testImplementation(kotlin("test")) +} + +javafx { + version = "17.0.2" + modules = listOf("javafx.controls", "javafx.fxml") +} + +tasks.test { + useJUnitPlatform() +} +kotlin { + jvmToolchain(17) +} diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..3874b62 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,5 @@ +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" +} +rootProject.name = "glide" + diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt new file mode 100644 index 0000000..64d936e --- /dev/null +++ b/src/main/kotlin/Main.kt @@ -0,0 +1,65 @@ +package xyz.maxwellj.glide + +import javafx.application.Application +import javafx.geometry.Insets +import javafx.scene.Scene +import javafx.scene.control.Label +import javafx.scene.control.TextArea +import javafx.scene.layout.BorderPane +import javafx.scene.layout.HBox +import javafx.scene.layout.VBox +import javafx.stage.Stage +import javafx.scene.Cursor + +import java.io.File + +class MainApp: Application() { + override fun start(primaryStage: Stage) { + + val root = BorderPane() + + val centerPanel = TextArea(File("/home/max/dingus").readText().toString()).apply { + isWrapText = true + } + val topPanel = HBox().apply { + padding = Insets(10.0) + style = "-fx-background-color: #e6e6e6;" + children.add(saveButton("Save", centerPanel.text)) + } + val leftPanel = VBox().apply { + padding = Insets(10.0) + prefWidth = 200.0 + style = "-fx-background-color: #d9d9d9" + } + root.top = topPanel + root.left = leftPanel + root.center = centerPanel + val scene = Scene(root, 800.0, 600.0) + primaryStage.title = "glide" + primaryStage.scene = scene + primaryStage.show() + } + private fun saveButton(text: String, textAreaContent: String): Label { + return Label(text).apply { + cursor = Cursor.HAND + setOnMouseClicked { + println(textAreaContent) + println("Save button pressed! Saving...") + val file = File("/home/max/dingus") + file.writeText(textAreaContent) + } + } + } + private fun fileButton(text: String): Label { + return Label(text).apply { + cursor = Cursor.HAND + setOnMouseClicked { + println("Clickable label $text clicked") + } + } + } +} + +fun main() { + Application.launch(MainApp::class.java) +}