1919package processing .app
2020
2121import androidx .compose .foundation .layout .Column
22- import androidx .compose .foundation .layout .fillMaxSize
2322import androidx .compose .foundation .layout .padding
2423import androidx .compose .material .icons .Icons
25- import androidx .compose .material .icons .filled .Alarm
2624import androidx .compose .material .icons .filled .Error
2725import androidx .compose .material .icons .filled .Info
2826import androidx .compose .material .icons .filled .Warning
29- import androidx .compose .material3 .AlertDialog
30- import androidx .compose .material3 .Button
31- import androidx .compose .material3 .ButtonDefaults
32- import androidx .compose .material3 .Icon
33- import androidx .compose .material3 .MaterialTheme
34- import androidx .compose .material3 .OutlinedButton
35- import androidx .compose .material3 .Text
27+ import androidx .compose .material3 .*
3628import androidx .compose .runtime .Composable
29+ import androidx .compose .ui .ExperimentalComposeUiApi
3730import androidx .compose .ui .Modifier
3831import androidx .compose .ui .awt .ComposeDialog
32+ import androidx .compose .ui .graphics .RectangleShape
33+ import androidx .compose .ui .layout .onSizeChanged
34+ import androidx .compose .ui .platform .LocalDensity
3935import androidx .compose .ui .text .font .FontWeight
4036import androidx .compose .ui .unit .DpSize
4137import androidx .compose .ui .unit .dp
@@ -46,14 +42,13 @@ import com.formdev.flatlaf.FlatLightLaf
4642import processing .app .ui .Toolkit
4743import processing .app .ui .theme .PDETheme
4844import java .awt .Dimension
49- import java .awt .EventQueue
5045import java .awt .Frame
5146import java .io .PrintWriter
5247import java .io .StringWriter
53- import javax .swing .JFrame
5448import javax .swing .JOptionPane
5549import javax .swing .UIManager
5650
51+
5752class Messages {
5853 companion object {
5954 /**
@@ -65,9 +60,11 @@ class Messages {
6560 if (Base .isCommandLine ()) {
6661 println ("$title: $message" )
6762 } else {
68- showDialog (title ) { dismiss ->
63+ showDialog (title ) { modifier , dismiss ->
6964 AlertDialog (
65+ modifier = modifier ,
7066 onDismissRequest = { },
67+ shape = RectangleShape ,
7168 icon = { Icon (Icons .Default .Info , contentDescription = "Info!" ) },
7269 title = { Text (title ) },
7370 text = { Text (message ) },
@@ -96,9 +93,11 @@ class Messages {
9693 if (Base .isCommandLine ()) {
9794 println ("$title : $message ")
9895 } else {
99- showDialog (title ){ dismiss ->
96+ showDialog(title){ modifier, dismiss ->
10097 AlertDialog(
98+ modifier = modifier,
10199 onDismissRequest = { },
100+ shape = RectangleShape,
102101 icon = { Icon(Icons.Default.Warning, contentDescription = " Alert !") },
103102 iconContentColor = MaterialTheme.colorScheme.tertiary,
104103 title = { Text(title) },
@@ -134,9 +133,11 @@ class Messages {
134133 // proper parsing on the command line. Many have \n in them.
135134 println(" $title : $primary \n $secondary ")
136135 } else {
137- showDialog (title ){ dismiss ->
136+ showDialog(title){ modifier, dismiss ->
138137 AlertDialog(
138+ modifier = modifier,
139139 onDismissRequest = { },
140+ shape = RectangleShape,
140141 icon = { Icon(Icons.Default.Warning, contentDescription = " Alert !") },
141142 iconContentColor = MaterialTheme.colorScheme.tertiary,
142143 title = { Text(title) },
@@ -173,9 +174,11 @@ class Messages {
173174 if (Base.isCommandLine()) {
174175 System.err.println(" $title : $message ")
175176 } else {
176- showDialog (title ){ dismiss ->
177+ showDialog(title){ modifier, dismiss ->
177178 AlertDialog(
179+ modifier = modifier,
178180 onDismissRequest = { },
181+ shape = RectangleShape,
179182 icon = { Icon(Icons.Default.Error, contentDescription = " Alert !") },
180183 iconContentColor = MaterialTheme.colorScheme.error,
181184 title = { Text(title) },
@@ -360,17 +363,24 @@ class Messages {
360363 }
361364}
362365
363- fun showDialog (title : String , content : @ Composable (dismiss : () -> Unit ) -> Unit ) {
366+ @ OptIn (ExperimentalComposeUiApi ::class )
367+ fun showDialog (title : String , content : @ Composable (modifier : Modifier , dismiss : () -> Unit ) -> Unit ) {
364368 ComposeDialog ().apply {
365- // isUndecorated = true
366- // isTransparent = true
367369 isModal = true
368370 setTitle (title )
369- size = Dimension (400 , 200 )
371+ size = Dimension (400 , 400 )
372+ rootPane .putClientProperty ("apple.awt.fullWindowContent" , true )
373+ rootPane .putClientProperty ("apple.awt.transparentTitleBar" , true )
374+ rootPane .putClientProperty ("apple.awt.windowTitleVisible" , false );
375+
370376
371- setContent {
377+ setContent {
372378 PDETheme {
373- content (::dispose )
379+ val density = LocalDensity .current
380+ content (Modifier .onSizeChanged {
381+ size = Dimension ((it .width / density .density ).toInt (), (it .height / density .density ).toInt ())
382+ setLocationRelativeTo (null )
383+ },::dispose )
374384 }
375385 }
376386 setLocationRelativeTo (null )
0 commit comments