Skip to content

Commit 3df4da9

Browse files
committed
Welcome Screen: Bugfixes
1 parent cb184fb commit 3df4da9

File tree

5 files changed

+39
-37
lines changed

5 files changed

+39
-37
lines changed

app/src/processing/app/Language.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ static public Language init() {
184184
}
185185

186186
static public void reload(){
187+
if(instance == null) return;
187188
synchronized (Language.class) {
188189
instance = new Language();
189190
}

app/src/processing/app/ui/Welcome.kt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ import androidx.compose.runtime.*
1414
import androidx.compose.ui.Alignment
1515
import androidx.compose.ui.Modifier
1616
import androidx.compose.ui.draw.clip
17+
import androidx.compose.ui.draw.scale
1718
import androidx.compose.ui.geometry.Offset
1819
import androidx.compose.ui.graphics.Brush
1920
import androidx.compose.ui.graphics.Color
2021
import androidx.compose.ui.graphics.ColorFilter
22+
import androidx.compose.ui.platform.LocalLayoutDirection
2123
import androidx.compose.ui.res.painterResource
24+
import androidx.compose.ui.unit.LayoutDirection
2225
import androidx.compose.ui.unit.dp
2326
import androidx.compose.ui.unit.min
2427
import com.formdev.flatlaf.util.SystemInfo
@@ -90,6 +93,10 @@ class Welcome @Throws(IOException::class) constructor(base: Base) {
9093
.height(200.dp)
9194
.offset (32.dp)
9295
.align(Alignment.BottomEnd)
96+
.scale(when(LocalLayoutDirection.current) {
97+
LayoutDirection.Rtl -> -1f
98+
else -> 1f
99+
}, 1f)
93100
)
94101
}
95102
}
@@ -139,7 +146,12 @@ class Welcome @Throws(IOException::class) constructor(base: Base) {
139146
painter = painterResource("welcome/intro/bubble.svg"),
140147
contentDescription = locale["welcome.intro.long"],
141148
modifier = Modifier
142-
.align{ _, space, _ -> space / 4 }
149+
.align(Alignment.Start)
150+
.scale(when(LocalLayoutDirection.current) {
151+
LayoutDirection.Rtl -> -1f
152+
else -> 1f
153+
}, 1f)
154+
.padding(start = 64.dp)
143155
)
144156
Row(
145157
horizontalArrangement = Arrangement.SpaceBetween,
@@ -151,13 +163,21 @@ class Welcome @Throws(IOException::class) constructor(base: Base) {
151163
contentDescription = locale["welcome.intro.long"],
152164
modifier = Modifier
153165
.offset(x = -32.dp)
166+
.scale(when(LocalLayoutDirection.current) {
167+
LayoutDirection.Rtl -> -1f
168+
else -> 1f
169+
}, 1f)
154170
)
155171
Image(
156172
painter = painterResource("welcome/intro/short.svg"),
157173
contentDescription = locale["welcome.intro.short"],
158174
modifier = Modifier
159175
.align(Alignment.Bottom)
160176
.offset(x = 16.dp, y = -16.dp)
177+
.scale(when(LocalLayoutDirection.current) {
178+
LayoutDirection.Rtl -> -1f
179+
else -> 1f
180+
}, 1f)
161181
)
162182
}
163183
}

app/src/processing/app/ui/components/LanuageSelector.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import processing.app.ui.theme.LocalLocale
2121
import processing.app.ui.theme.PDEChip
2222
import processing.app.watchFile
2323
import java.io.File
24+
import java.nio.file.FileSystem
2425
import java.nio.file.FileSystems
2526
import java.nio.file.Files
2627
import java.nio.file.Paths
@@ -34,6 +35,8 @@ data class Language(
3435
val properties: Properties
3536
)
3637

38+
var jarFs: FileSystem? = null
39+
3740
@Composable
3841
fun LanguageChip(){
3942
var expanded by remember { mutableStateOf(false) }
@@ -44,9 +47,6 @@ fun LanguageChip(){
4447

4548
val main = ClassLoader.getSystemResource("PDE.properties")?: return
4649

47-
48-
49-
5050
val languages = remember {
5151
val list = when(main.protocol){
5252
"file" -> {
@@ -55,8 +55,8 @@ fun LanguageChip(){
5555
}
5656
"jar" -> {
5757
val uri = main.toURI()
58-
val fs = FileSystems.newFileSystem(uri, emptyMap<String, Any>())
59-
Files.list(fs.getPath("/"))
58+
jarFs = jarFs ?: FileSystems.newFileSystem(uri, emptyMap<String, Any>()) ?: return@remember null
59+
Files.list(jarFs!!.getPath("/"))
6060
}
6161
else -> null
6262
} ?: return@remember null
@@ -81,6 +81,7 @@ fun LanguageChip(){
8181
)
8282
}
8383
}
84+
.sortedBy { it.name.lowercase() }
8485
} ?: return
8586

8687
val current = languageFile.readText(Charsets.UTF_8).substring(0, 2)

app/src/processing/app/ui/components/examples/Examples.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fun examples(){
135135
randoms = randoms + List(4 - randoms.size) { Example(
136136
folder = Paths.get(""),
137137
library = Paths.get(""),
138-
title = "Test",
138+
title = "Example",
139139
image = ClassLoader.getSystemResource("default.png")?.toURI()?.let { Paths.get(it) } ?: Paths.get(""),
140140
) }
141141
}
@@ -154,7 +154,7 @@ fun examples(){
154154
}
155155
}
156156
}
157-
@OptIn(ExperimentalComposeUiApi::class, ExperimentalResourceApi::class)
157+
@OptIn(ExperimentalResourceApi::class)
158158
@Composable
159159
fun Example(example: Example){
160160
val base = LocalBase.current

app/src/processing/app/ui/theme/Window.kt

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.compose.material.MaterialTheme.colors
66
import androidx.compose.material.Surface
77
import androidx.compose.material.Text
88
import androidx.compose.runtime.Composable
9+
import androidx.compose.runtime.LaunchedEffect
910
import androidx.compose.ui.Alignment
1011
import androidx.compose.ui.Modifier
1112
import androidx.compose.ui.awt.ComposePanel
@@ -41,6 +42,10 @@ class PDEWindow(titleKey: String = "", fullWindowContent: Boolean = false, conte
4142
ProcessingTheme {
4243
val locale = LocalLocale.current
4344
this@PDEWindow.title = locale[titleKey]
45+
LaunchedEffect(locale){
46+
this@PDEWindow.pack()
47+
this@PDEWindow.setLocationRelativeTo(null)
48+
}
4449

4550
Box(modifier = Modifier
4651
.padding(top = if (mac && !fullWindowContent) 22.dp else 0.dp)
@@ -81,6 +86,10 @@ fun pdeapplication(titleKey: String = "", fullWindowContent: Boolean = false,con
8186
putClientProperty("apple.awt.fullWindowContent", mac)
8287
putClientProperty("apple.awt.transparentTitleBar", mac)
8388
}
89+
LaunchedEffect(locale){
90+
window.pack()
91+
window.setLocationRelativeTo(null)
92+
}
8493
Surface(color = colors.background) {
8594
Box(modifier = Modifier
8695
.padding(top = if (mac && !fullWindowContent) 22.dp else 0.dp)
@@ -92,32 +101,3 @@ fun pdeapplication(titleKey: String = "", fullWindowContent: Boolean = false,con
92101
}
93102
}
94103
}
95-
96-
97-
fun main(){
98-
application {
99-
val windowState = rememberWindowState(
100-
size = DpSize.Unspecified,
101-
position = WindowPosition(Alignment.Center)
102-
)
103-
Window(onCloseRequest = ::exitApplication, title = "Welcome to Processing", state = windowState) {
104-
Row{
105-
Text("Hello, Processing!")
106-
Column(
107-
modifier = Modifier
108-
// .wrapContentSize()
109-
) {
110-
Box(
111-
modifier = Modifier
112-
.background(Color.Red)
113-
.sizeIn(minHeight = 100.dp)
114-
) {
115-
116-
}
117-
Text("Hello, Processing!")
118-
}
119-
}
120-
121-
}
122-
}
123-
}

0 commit comments

Comments
 (0)