Skip to content

Commit

Permalink
Merge pull request #5 from korlibs/bump/korge-5.1.0
Browse files Browse the repository at this point in the history
Bump to KorGE 5.1.0
  • Loading branch information
soywiz committed Dec 14, 2023
2 parents 879f435 + 3e19707 commit dbb78e2
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 61 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Add this line to your kproject dependency file:

### `deps.kproject.yml`

```kotlin
```yaml
dependencies:
- git::korge-compose::korlibs/korge-compose::/korge-compose::c6a980492155bb2cc480e3beda0fef4d6312ac3b
```
Expand Down
21 changes: 10 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import korlibs.korge.gradle.*

plugins {
//id("com.soywiz.korge") version "999.0.0.999"
id("com.soywiz.korge") version "4.0.5a"
id("org.jetbrains.compose") version "1.4.0"
alias(libs.plugins.korge)
id("org.jetbrains.compose") version "1.5.11"
}

allprojects {
Expand All @@ -20,19 +19,19 @@ korge {

// To enable all targets at once

//targetAll()
targetAll()

// To enable targets based on properties/environment variables
//targetDefault()

// To selectively enable targets

targetJvm()
targetJs()
targetDesktop()
//targetJvm()
//targetJs()
//targetDesktop()
//targetDesktopCross()
targetIos()
targetAndroidDirect()
//targetIos()
//targetAndroidDirect()
//serializationJson()
//targetAndroidIndirect() // targetAndroidDirect()

Expand All @@ -46,6 +45,6 @@ dependencies {
}

compose {
kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=1.8.21")
kotlinCompilerPlugin.set(dependencies.compiler.forKotlin("1.8.20"))
kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=1.9.20")
kotlinCompilerPlugin.set(dependencies.compiler.forKotlin("1.9.20"))
}
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[plugins]
korge = { id = "com.soywiz.korge", version = "5.1.0" }
#korge = { id = "com.soywiz.korge", version = "999.0.0.999" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions korge-compose/build.extra.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
compose {
kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=1.8.21")
kotlinCompilerPlugin.set(dependencies.compiler.forKotlin("1.8.20"))
kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=1.9.20")
kotlinCompilerPlugin.set(dependencies.compiler.forKotlin("1.9.20"))
}
3 changes: 2 additions & 1 deletion korge-compose/kproject.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ dependencies:
# https://androidx.dev/storage/compose-compiler/repository
# https://github.com/JetBrains/compose-jb/issues/2108#issuecomment-1157978869
- "maven::common::com.soywiz.korlibs.korge2:korge"
- "maven::common::org.jetbrains.compose.runtime:runtime:1.4.0"
- "maven::common::org.jetbrains.compose.runtime:runtime:1.5.11"
#platforms: [jvm]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import korlibs.io.async.delay
import korlibs.math.interpolation.Easing
import korlibs.math.interpolation.interpolate
import korlibs.math.interpolation.toRatio
import korlibs.memory.clamp01
import korlibs.time.TimeSpan
import korlibs.time.milliseconds
import korlibs.time.seconds
Expand All @@ -24,10 +23,10 @@ class Animatable<T>(initialValue: T, val interpolator: Float.(start: T, end: T)
val start = this.value
var elapsed = 0.milliseconds
while (true) {
val ratio = (elapsed / time).clamp01()
value = interpolator(easing(ratio).toFloat(), start, end)
val ratio = (elapsed / time).toDouble().coerceIn(0.0, 1.0)
value = interpolator(easing(ratio.toFloat()), start, end)
//println("ratio=$ratio, value=$value")
delay(10.milliseconds)
kotlinx.coroutines.delay(10.milliseconds)
elapsed += 10.milliseconds
if (ratio >= 1.0) break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ fun View.applyModifiers(modifier: Modifier) {
is ClickableModifier -> this.mouse.click.also { it.clear() }.add { mod.onClick?.invoke() }
is SizeModifier -> size(mod.width, mod.height)
is FillMaxWidthModifier -> {
this.x = 0f
this.scaledWidth = (parent!!.width * mod.ratio).toFloat()
this.x = 0.0
this.scaledWidth = (parent!!.width * mod.ratio).toDouble()
}
is ClipModifier -> {
// @TODO: Fix this!
val mask = Circle(32f)
val mask = Circle(32.0)
this.mask = mask
(this as Container).addChild(mask)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fun Button(text: String, onClick: () -> Unit = {}) {
}

@Composable
fun VStack(width: Float = UI_DEFAULT_SIZE.width, adjustSize: Boolean = false, content: @Composable () -> Unit) {
fun VStack(width: Double = UI_DEFAULT_SIZE.width, adjustSize: Boolean = false, content: @Composable () -> Unit) {
ComposeKorgeView(
{ UIVerticalStack(width, adjustSize = adjustSize) },
{
Expand All @@ -60,7 +60,7 @@ fun VStack(width: Float = UI_DEFAULT_SIZE.width, adjustSize: Boolean = false, co
}

@Composable
fun HStack(height: Float = UI_DEFAULT_SIZE.height, content: @Composable () -> Unit) {
fun HStack(height: Double = UI_DEFAULT_SIZE.height, content: @Composable () -> Unit) {
ComposeKorgeView(
{ UIHorizontalStack(height) },
{
Expand Down
49 changes: 18 additions & 31 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
//dependencyResolutionManagement {
// this.components {
// this.all {
// //this.
// }
// }
//}
pluginManagement {
repositories {
mavenLocal(); mavenCentral(); google(); gradlePluginPortal()
}
//resolutionStrategy {
// eachPlugin {
// println("details: ${this.requested}")
// }
// /*
// eachDependency { details: DependencyResolveDetails ->
// println("details")
// /*
// if (details.requested.group == 'io.swagger.parser.v3' && details.requested.name =='swagger-parser') {
// details.useVersion("2.0.26")
// }
// */
// }
// */
//}
repositories { mavenLocal(); mavenCentral(); google(); gradlePluginPortal() }
}

plugins {
//id("com.soywiz.kproject.settings") version "0.0.1-SNAPSHOT"
id("com.soywiz.kproject.settings") version "0.3.0"
}
buildscript {
val libsTomlFile = File(this.sourceFile?.parentFile, "gradle/libs.versions.toml").readText()
var plugins = false
var version = ""
for (line in libsTomlFile.lines().map { it.trim() }) {
if (line.startsWith("#")) continue
if (line.startsWith("[plugins]")) plugins = true
if (plugins && line.startsWith("korge") && Regex("^korge\\s*=.*").containsMatchIn(line)) version = Regex("version\\s*=\\s*\"(.*?)\"").find(line)?.groupValues?.get(1) ?: error("Can't find korge version")
}
if (version.isEmpty()) error("Can't find korge version in $libsTomlFile")

rootProject.name = "${rootDir.name}-example"
repositories { mavenLocal(); mavenCentral(); google(); gradlePluginPortal() }

dependencies {
classpath("com.soywiz.korge.settings:com.soywiz.korge.settings.gradle.plugin:$version")
}
}

kproject("./deps")
apply(plugin = "com.soywiz.korge.settings")
10 changes: 5 additions & 5 deletions src/commonMain/kotlin/MainComposable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private fun MainApp(width: Int, height: Int) {
val r = n.toDouble() / nsteps.toDouble()
ratio = r
color = r.interpolate(Colors.RED, Colors.WHITE)
delay(10.milliseconds)
kotlinx.coroutines.delay(10.milliseconds)
}
println("LaunchedEffect=$count..ended")
} catch (e: CancellationException) {
Expand All @@ -83,20 +83,20 @@ private fun MainApp(width: Int, height: Int) {
LaunchedEffect(true) {
while (true) {
bitmap = resourcesVfs["korge.png"].readBitmapSlice()
delay(2.0.seconds)
kotlinx.coroutines.delay(2.0.seconds)
bitmap = resourcesVfs["korim.png"].readBitmapSlice()
delay(2.0.seconds)
kotlinx.coroutines.delay(2.0.seconds)
}
}
VStack(width.toFloat(), adjustSize = true) {
VStack(width.toDouble(), adjustSize = true) {
Text("$count", color)
HStack {
Button("-") { count-- }
Button("+") { count += 2 }
}
Text("this is a reallly long text to see how, korge-compose handles long texts and figure out if this works or not")
Canvas(color) {
fillStroke(color, Stroke(Colors.YELLOWGREEN, thickness = 4f)) {
fillStroke(color, Stroke(Colors.YELLOWGREEN, thickness = 4.0)) {
//roundRect(0.0, 0.0, 100.0, 100.0, 50 * ratio, 50 * ratio)
star(8, 45.0, 100.0, x = 100.0, y = 100.0)
}
Expand Down

0 comments on commit dbb78e2

Please sign in to comment.