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}"
|
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 {
|
kotlin {
|
||||||
val hostOsName = getHostOsName()
|
val hostOsName = getHostOsName()
|
||||||
|
if (ideaActive) {
|
||||||
|
when (hostOsName) {
|
||||||
|
"linux" -> linuxX64("native")
|
||||||
|
"macos" -> macosX64("native")
|
||||||
|
"windows" -> mingwX64("native")
|
||||||
|
}
|
||||||
|
}
|
||||||
android()
|
android()
|
||||||
runningOnLinuxx86_64 {
|
runningOnLinuxx86_64 {
|
||||||
jvm()
|
jvm()
|
||||||
@ -88,13 +94,13 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Disable for now as libui doesnt support arm64
|
||||||
linuxArm64() {
|
// linuxArm64() {
|
||||||
binaries {
|
// binaries {
|
||||||
executable {
|
// executable {
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,17 +228,54 @@ kotlin {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 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 {
|
val nativeMain by creating {
|
||||||
dependsOn(commonMain)
|
dependsOn(commonMain)
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation(Deps.Desktop.libui)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nativeMain
|
||||||
|
}
|
||||||
|
|
||||||
|
val nativeTest = if (ideaActive) {
|
||||||
|
val nativeTest by getting {
|
||||||
|
dependsOn(commonTest)
|
||||||
|
dependencies {
|
||||||
|
implementation(Deps.Native.coroutines)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nativeTest
|
||||||
|
} else {
|
||||||
val nativeTest by creating {
|
val nativeTest by creating {
|
||||||
dependsOn(commonTest)
|
dependsOn(commonTest)
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation(Deps.Native.coroutines)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nativeTest
|
||||||
|
}
|
||||||
|
|
||||||
runningOnLinuxx86_64 {
|
runningOnLinuxx86_64 {
|
||||||
val jvmMain by getting {
|
val jvmMain by getting {
|
||||||
@ -280,12 +323,12 @@ kotlin {
|
|||||||
dependsOn(nativeTest)
|
dependsOn(nativeTest)
|
||||||
}
|
}
|
||||||
|
|
||||||
val linuxArm64Main by getting {
|
// val linuxArm64Main by getting {
|
||||||
dependsOn(nativeMain)
|
// dependsOn(nativeMain)
|
||||||
}
|
// }
|
||||||
val linuxArm64Test by getting {
|
// val linuxArm64Test by getting {
|
||||||
dependsOn(nativeTest)
|
// dependsOn(nativeTest)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
runningOnMacos {
|
runningOnMacos {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import com.ionspin.kotlin.crypto.sample.Sample
|
import com.ionspin.kotlin.crypto.sample.Sample
|
||||||
|
|
||||||
fun main() {
|
fun main() : Unit {
|
||||||
Sample.runSample()
|
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