Inital commit

This commit is contained in:
Maxwell Jeffress 2024-10-14 12:14:44 +11:00
parent cdeefe45ac
commit 56eebe387c
3 changed files with 112 additions and 0 deletions

42
build.gradle.kts Normal file
View File

@ -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<Jar> {
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)
}

5
settings.gradle.kts Normal file
View File

@ -0,0 +1,5 @@
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}
rootProject.name = "glide"

65
src/main/kotlin/Main.kt Normal file
View File

@ -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)
}