Welcome Screen: Bugfixes

This commit is contained in:
Stef Tervelde
2025-02-09 12:57:55 +01:00
parent cb184fb104
commit 3df4da9461
5 changed files with 39 additions and 37 deletions
+1
View File
@@ -184,6 +184,7 @@ public class Language {
}
static public void reload(){
if(instance == null) return;
synchronized (Language.class) {
instance = new Language();
}
+21 -1
View File
@@ -14,11 +14,14 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.scale
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.min
import com.formdev.flatlaf.util.SystemInfo
@@ -90,6 +93,10 @@ class Welcome @Throws(IOException::class) constructor(base: Base) {
.height(200.dp)
.offset (32.dp)
.align(Alignment.BottomEnd)
.scale(when(LocalLayoutDirection.current) {
LayoutDirection.Rtl -> -1f
else -> 1f
}, 1f)
)
}
}
@@ -139,7 +146,12 @@ class Welcome @Throws(IOException::class) constructor(base: Base) {
painter = painterResource("welcome/intro/bubble.svg"),
contentDescription = locale["welcome.intro.long"],
modifier = Modifier
.align{ _, space, _ -> space / 4 }
.align(Alignment.Start)
.scale(when(LocalLayoutDirection.current) {
LayoutDirection.Rtl -> -1f
else -> 1f
}, 1f)
.padding(start = 64.dp)
)
Row(
horizontalArrangement = Arrangement.SpaceBetween,
@@ -151,6 +163,10 @@ class Welcome @Throws(IOException::class) constructor(base: Base) {
contentDescription = locale["welcome.intro.long"],
modifier = Modifier
.offset(x = -32.dp)
.scale(when(LocalLayoutDirection.current) {
LayoutDirection.Rtl -> -1f
else -> 1f
}, 1f)
)
Image(
painter = painterResource("welcome/intro/short.svg"),
@@ -158,6 +174,10 @@ class Welcome @Throws(IOException::class) constructor(base: Base) {
modifier = Modifier
.align(Alignment.Bottom)
.offset(x = 16.dp, y = -16.dp)
.scale(when(LocalLayoutDirection.current) {
LayoutDirection.Rtl -> -1f
else -> 1f
}, 1f)
)
}
}
@@ -21,6 +21,7 @@ import processing.app.ui.theme.LocalLocale
import processing.app.ui.theme.PDEChip
import processing.app.watchFile
import java.io.File
import java.nio.file.FileSystem
import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.Paths
@@ -34,6 +35,8 @@ data class Language(
val properties: Properties
)
var jarFs: FileSystem? = null
@Composable
fun LanguageChip(){
var expanded by remember { mutableStateOf(false) }
@@ -44,9 +47,6 @@ fun LanguageChip(){
val main = ClassLoader.getSystemResource("PDE.properties")?: return
val languages = remember {
val list = when(main.protocol){
"file" -> {
@@ -55,8 +55,8 @@ fun LanguageChip(){
}
"jar" -> {
val uri = main.toURI()
val fs = FileSystems.newFileSystem(uri, emptyMap<String, Any>())
Files.list(fs.getPath("/"))
jarFs = jarFs ?: FileSystems.newFileSystem(uri, emptyMap<String, Any>()) ?: return@remember null
Files.list(jarFs!!.getPath("/"))
}
else -> null
} ?: return@remember null
@@ -81,6 +81,7 @@ fun LanguageChip(){
)
}
}
.sortedBy { it.name.lowercase() }
} ?: return
val current = languageFile.readText(Charsets.UTF_8).substring(0, 2)
@@ -135,7 +135,7 @@ fun examples(){
randoms = randoms + List(4 - randoms.size) { Example(
folder = Paths.get(""),
library = Paths.get(""),
title = "Test",
title = "Example",
image = ClassLoader.getSystemResource("default.png")?.toURI()?.let { Paths.get(it) } ?: Paths.get(""),
) }
}
@@ -154,7 +154,7 @@ fun examples(){
}
}
}
@OptIn(ExperimentalComposeUiApi::class, ExperimentalResourceApi::class)
@OptIn(ExperimentalResourceApi::class)
@Composable
fun Example(example: Example){
val base = LocalBase.current
+9 -29
View File
@@ -6,6 +6,7 @@ import androidx.compose.material.MaterialTheme.colors
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.awt.ComposePanel
@@ -41,6 +42,10 @@ class PDEWindow(titleKey: String = "", fullWindowContent: Boolean = false, conte
ProcessingTheme {
val locale = LocalLocale.current
this@PDEWindow.title = locale[titleKey]
LaunchedEffect(locale){
this@PDEWindow.pack()
this@PDEWindow.setLocationRelativeTo(null)
}
Box(modifier = Modifier
.padding(top = if (mac && !fullWindowContent) 22.dp else 0.dp)
@@ -81,6 +86,10 @@ fun pdeapplication(titleKey: String = "", fullWindowContent: Boolean = false,con
putClientProperty("apple.awt.fullWindowContent", mac)
putClientProperty("apple.awt.transparentTitleBar", mac)
}
LaunchedEffect(locale){
window.pack()
window.setLocationRelativeTo(null)
}
Surface(color = colors.background) {
Box(modifier = Modifier
.padding(top = if (mac && !fullWindowContent) 22.dp else 0.dp)
@@ -92,32 +101,3 @@ fun pdeapplication(titleKey: String = "", fullWindowContent: Boolean = false,con
}
}
}
fun main(){
application {
val windowState = rememberWindowState(
size = DpSize.Unspecified,
position = WindowPosition(Alignment.Center)
)
Window(onCloseRequest = ::exitApplication, title = "Welcome to Processing", state = windowState) {
Row{
Text("Hello, Processing!")
Column(
modifier = Modifier
// .wrapContentSize()
) {
Box(
modifier = Modifier
.background(Color.Red)
.sizeIn(minHeight = 100.dp)
) {
}
Text("Hello, Processing!")
}
}
}
}
}