Adding native libui ui
This commit is contained in:
parent
edcadc1a0c
commit
aa7bc8dd65
@ -141,6 +141,10 @@ object Deps {
|
||||
val timber = "com.jakewharton.timber:timber:${Versions.timber}"
|
||||
}
|
||||
|
||||
object Desktop {
|
||||
val libui = "com.github.msink:libui:0.1.8"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,7 +52,13 @@ val ideaActive = System.getProperty("idea.active") == "true"
|
||||
|
||||
kotlin {
|
||||
val hostOsName = getHostOsName()
|
||||
|
||||
if (ideaActive) {
|
||||
when (hostOsName) {
|
||||
"linux" -> linuxX64("native")
|
||||
"macos" -> macosX64("native")
|
||||
"windows" -> mingwX64("native")
|
||||
}
|
||||
}
|
||||
android()
|
||||
runningOnLinuxx86_64 {
|
||||
jvm()
|
||||
@ -88,13 +94,13 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
linuxArm64() {
|
||||
binaries {
|
||||
executable {
|
||||
}
|
||||
}
|
||||
}
|
||||
//Disable for now as libui doesnt support arm64
|
||||
// linuxArm64() {
|
||||
// binaries {
|
||||
// executable {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@ -222,16 +228,53 @@ kotlin {
|
||||
|
||||
|
||||
|
||||
val nativeMain by creating {
|
||||
dependsOn(commonMain)
|
||||
dependencies {
|
||||
// val nativeMain by creating {
|
||||
// dependsOn(commonMain)
|
||||
// dependencies {
|
||||
// implementation(Deps.Desktop.libui)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// val nativeTest by creating {
|
||||
// dependsOn(commonTest)
|
||||
// dependencies {
|
||||
// }
|
||||
// }
|
||||
|
||||
val nativeMain = if (ideaActive) {
|
||||
val nativeMain by getting {
|
||||
dependsOn(commonMain)
|
||||
dependencies {
|
||||
implementation(Deps.Desktop.libui)
|
||||
}
|
||||
}
|
||||
nativeMain
|
||||
} else {
|
||||
val nativeMain by creating {
|
||||
dependsOn(commonMain)
|
||||
dependencies {
|
||||
implementation(Deps.Desktop.libui)
|
||||
}
|
||||
}
|
||||
nativeMain
|
||||
}
|
||||
|
||||
val nativeTest by creating {
|
||||
dependsOn(commonTest)
|
||||
dependencies {
|
||||
val nativeTest = if (ideaActive) {
|
||||
val nativeTest by getting {
|
||||
dependsOn(commonTest)
|
||||
dependencies {
|
||||
implementation(Deps.Native.coroutines)
|
||||
}
|
||||
}
|
||||
nativeTest
|
||||
} else {
|
||||
val nativeTest by creating {
|
||||
dependsOn(commonTest)
|
||||
dependencies {
|
||||
implementation(Deps.Native.coroutines)
|
||||
}
|
||||
}
|
||||
nativeTest
|
||||
}
|
||||
|
||||
runningOnLinuxx86_64 {
|
||||
@ -280,12 +323,12 @@ kotlin {
|
||||
dependsOn(nativeTest)
|
||||
}
|
||||
|
||||
val linuxArm64Main by getting {
|
||||
dependsOn(nativeMain)
|
||||
}
|
||||
val linuxArm64Test by getting {
|
||||
dependsOn(nativeTest)
|
||||
}
|
||||
// val linuxArm64Main by getting {
|
||||
// dependsOn(nativeMain)
|
||||
// }
|
||||
// val linuxArm64Test by getting {
|
||||
// dependsOn(nativeTest)
|
||||
// }
|
||||
}
|
||||
|
||||
runningOnMacos {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import com.ionspin.kotlin.crypto.sample.Sample
|
||||
|
||||
fun main() {
|
||||
fun main() : Unit {
|
||||
Sample.runSample()
|
||||
ui()
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
import com.ionspin.kotlin.crypto.hash.Hash
|
||||
import com.ionspin.kotlin.crypto.util.encodeToUByteArray
|
||||
import com.ionspin.kotlin.crypto.util.toHexString
|
||||
import libui.ktx.TextArea
|
||||
import libui.ktx.appWindow
|
||||
import libui.ktx.button
|
||||
import libui.ktx.textarea
|
||||
import libui.ktx.vbox
|
||||
|
||||
fun ui() = appWindow(
|
||||
title = "Hello",
|
||||
width = 320,
|
||||
height = 240
|
||||
) {
|
||||
val hash = Hash.sha512("123".encodeToUByteArray())
|
||||
val text = "Hash (SHA512) of 123: ${hash.toHexString()}"
|
||||
vbox {
|
||||
lateinit var scroll: TextArea
|
||||
|
||||
button("Test") {
|
||||
action {
|
||||
scroll.append(text.trimMargin())
|
||||
}
|
||||
}
|
||||
scroll = textarea {
|
||||
readonly = true
|
||||
stretchy = true
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user