mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Welcome Screen: Close Functionality
This commit is contained in:
@@ -250,7 +250,10 @@ class Welcome @Throws(IOException::class) constructor(base: Base) {
|
||||
text = locale["welcome.action.startup"],
|
||||
)
|
||||
}
|
||||
PDEButton(onClick = { println("Open") }) {
|
||||
val window = LocalWindow.current
|
||||
PDEButton(onClick = {
|
||||
window.dispose()
|
||||
}) {
|
||||
Text(
|
||||
text = locale["welcome.action.go"],
|
||||
modifier = Modifier
|
||||
|
||||
@@ -54,7 +54,7 @@ class WelcomeToBeta {
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun welcomeToBeta(close: () -> Unit = {}) {
|
||||
fun welcomeToBeta() {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.padding(20.dp, 10.dp)
|
||||
@@ -87,9 +87,10 @@ class WelcomeToBeta {
|
||||
text = locale["beta.message"]
|
||||
)
|
||||
Row {
|
||||
val window = LocalWindow.current
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
PDEButton(onClick = {
|
||||
close()
|
||||
window.dispose()
|
||||
}) {
|
||||
Text(
|
||||
text = locale["beta.button"],
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package processing.app.ui.theme
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
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.CompositionLocalProvider
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.compositionLocalOf
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.awt.ComposePanel
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.DpSize
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Window
|
||||
@@ -20,12 +17,12 @@ import androidx.compose.ui.window.WindowPosition
|
||||
import androidx.compose.ui.window.application
|
||||
import androidx.compose.ui.window.rememberWindowState
|
||||
import com.formdev.flatlaf.util.SystemInfo
|
||||
import processing.app.ui.WelcomeToBeta.Companion.welcomeToBeta
|
||||
|
||||
import java.awt.event.KeyAdapter
|
||||
import java.awt.event.KeyEvent
|
||||
import javax.swing.JFrame
|
||||
|
||||
val LocalWindow = compositionLocalOf<JFrame> { error("No Window Set") }
|
||||
|
||||
class PDEWindow(titleKey: String = "", fullWindowContent: Boolean = false, content: @Composable () -> Unit): JFrame(){
|
||||
init{
|
||||
@@ -39,19 +36,22 @@ class PDEWindow(titleKey: String = "", fullWindowContent: Boolean = false, conte
|
||||
defaultCloseOperation = DISPOSE_ON_CLOSE
|
||||
ComposePanel().apply {
|
||||
setContent {
|
||||
ProcessingTheme {
|
||||
val locale = LocalLocale.current
|
||||
this@PDEWindow.title = locale[titleKey]
|
||||
LaunchedEffect(locale){
|
||||
this@PDEWindow.pack()
|
||||
this@PDEWindow.setLocationRelativeTo(null)
|
||||
}
|
||||
CompositionLocalProvider(LocalWindow provides this@PDEWindow) {
|
||||
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)
|
||||
) {
|
||||
content()
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(top = if (mac && !fullWindowContent) 22.dp else 0.dp)
|
||||
) {
|
||||
content()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,11 +90,14 @@ fun pdeapplication(titleKey: String = "", fullWindowContent: Boolean = false,con
|
||||
window.pack()
|
||||
window.setLocationRelativeTo(null)
|
||||
}
|
||||
Surface(color = colors.background) {
|
||||
Box(modifier = Modifier
|
||||
.padding(top = if (mac && !fullWindowContent) 22.dp else 0.dp)
|
||||
) {
|
||||
content()
|
||||
CompositionLocalProvider(LocalWindow provides window) {
|
||||
Surface(color = colors.background) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(top = if (mac && !fullWindowContent) 22.dp else 0.dp)
|
||||
) {
|
||||
content()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user