Skip to content

Commit 8382ec5

Browse files
committed
Merge branch 'welcome-screen-impl' into settings-screen
2 parents 6e8c1db + f19b256 commit 8382ec5

38 files changed

+2676
-774
lines changed
File renamed without changes.
File renamed without changes.

app/build.gradle.kts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import org.gradle.internal.jvm.Jvm
22
import org.gradle.internal.os.OperatingSystem
33
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
4+
import org.jetbrains.compose.ExperimentalComposeLibrary
45
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
56
import org.jetbrains.compose.desktop.application.tasks.AbstractJPackageTask
67
import org.jetbrains.compose.internal.de.undercouch.gradle.tasks.download.Download
@@ -16,6 +17,7 @@ plugins{
1617

1718
alias(libs.plugins.compose.compiler)
1819
alias(libs.plugins.jetbrainsCompose)
20+
1921
alias(libs.plugins.serialization)
2022
alias(libs.plugins.download)
2123
}
@@ -59,7 +61,7 @@ compose.desktop {
5961
).map { "-D${it.first}=${it.second}" }.toTypedArray())
6062

6163
nativeDistributions{
62-
modules("jdk.jdi", "java.compiler", "jdk.accessibility", "java.management.rmi", "java.scripting", "jdk.httpserver")
64+
modules("jdk.jdi", "java.compiler", "jdk.accessibility", "jdk.zipfs", "java.management.rmi", "java.scripting", "jdk.httpserver")
6365
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
6466
packageName = "Processing"
6567

@@ -107,25 +109,29 @@ dependencies {
107109

108110
implementation(compose.runtime)
109111
implementation(compose.foundation)
110-
implementation(compose.material)
111112
implementation(compose.ui)
112113
implementation(compose.components.resources)
113114
implementation(compose.components.uiToolingPreview)
115+
implementation(compose.materialIconsExtended)
114116

115117
implementation(compose.desktop.currentOs)
118+
implementation(libs.material3)
116119

117120
implementation(libs.compottie)
118121
implementation(libs.kaml)
119122
implementation(libs.markdown)
120123
implementation(libs.markdownJVM)
121124

125+
implementation(libs.clikt)
126+
implementation(libs.kotlinxSerializationJson)
127+
128+
@OptIn(ExperimentalComposeLibrary::class)
129+
testImplementation(compose.uiTest)
122130
testImplementation(kotlin("test"))
123131
testImplementation(libs.mockitoKotlin)
124132
testImplementation(libs.junitJupiter)
125133
testImplementation(libs.junitJupiterParams)
126-
127-
implementation(libs.clikt)
128-
implementation(libs.kotlinxSerializationJson)
134+
129135
}
130136

131137
tasks.test {
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

app/src/processing/app/Base.java

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,29 @@
2323

2424
package processing.app;
2525

26-
import java.awt.*;
27-
import java.awt.event.ActionListener;
28-
import java.io.*;
29-
import java.lang.reflect.InvocationTargetException;
30-
import java.util.*;
31-
import java.util.List;
32-
import java.util.Map.Entry;
33-
34-
import javax.swing.*;
35-
import javax.swing.tree.DefaultMutableTreeNode;
36-
3726
import com.formdev.flatlaf.FlatDarkLaf;
3827
import com.formdev.flatlaf.FlatLaf;
3928
import com.formdev.flatlaf.FlatLightLaf;
4029
import processing.app.contrib.*;
4130
import processing.app.tools.Tool;
4231
import processing.app.ui.*;
4332
import processing.app.ui.Toolkit;
44-
import processing.core.*;
33+
import processing.core.PApplet;
4534
import processing.data.StringList;
4635

36+
import javax.swing.*;
37+
import javax.swing.tree.DefaultMutableTreeNode;
38+
import java.awt.*;
39+
import java.awt.event.ActionListener;
40+
import java.io.File;
41+
import java.io.FileInputStream;
42+
import java.io.IOException;
43+
import java.io.InputStream;
44+
import java.lang.reflect.InvocationTargetException;
45+
import java.util.*;
46+
import java.util.List;
47+
import java.util.Map.Entry;
48+
4749
/**
4850
* The base class for the main processing application.
4951
* Primary role of this class is for platform identification and
@@ -328,13 +330,7 @@ static private void handleWelcomeScreen(Base base) {
328330
// Needs to be shown after the first editor window opens, so that it
329331
// shows up on top, and doesn't prevent an editor window from opening.
330332
if (Preferences.getBoolean("welcome.four.show")) {
331-
try {
332-
new Welcome(base);
333-
} catch (IOException e) {
334-
Messages.showTrace("Unwelcoming",
335-
"Please report this error to\n" +
336-
"https://github.com/processing/processing4/issues", e, false);
337-
}
333+
PDEWelcomeKt.showWelcomeScreen(base);
338334
}
339335
}
340336

@@ -598,7 +594,7 @@ public JMenu initDefaultFileMenu() {
598594
defaultFileMenu.add(item);
599595

600596
item = Toolkit.newJMenuItemShift(Language.text("menu.file.examples"), 'O');
601-
item.addActionListener(e -> thinkDifferentExamples());
597+
item.addActionListener(e -> showExamplesFrame());
602598
defaultFileMenu.add(item);
603599

604600
return defaultFileMenu;
@@ -1874,7 +1870,7 @@ public void handleRestart() {
18741870
// }
18751871

18761872

1877-
public void thinkDifferentExamples() {
1873+
public void showExamplesFrame() {
18781874
nextMode.showExamplesFrame();
18791875
}
18801876

@@ -2180,10 +2176,10 @@ static private Mode findSketchMode(File folder, List<Mode> modeList) {
21802176
* Show the Preferences window.
21812177
*/
21822178
public void handlePrefs() {
2183-
if (preferencesFrame == null) {
2184-
preferencesFrame = new PreferencesFrame(this);
2185-
}
2186-
preferencesFrame.showFrame();
2179+
if (preferencesFrame == null) {
2180+
preferencesFrame = new PreferencesFrame(this);
2181+
}
2182+
preferencesFrame.showFrame();
21872183
}
21882184

21892185

app/src/processing/app/Messages.kt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,27 @@
1818
*/
1919
package processing.app
2020

21+
import androidx.compose.foundation.layout.Column
22+
import androidx.compose.foundation.layout.padding
23+
import androidx.compose.material3.Button
24+
import androidx.compose.material3.Text
25+
import androidx.compose.ui.Modifier
26+
import androidx.compose.ui.unit.DpSize
27+
import androidx.compose.ui.unit.dp
28+
import androidx.compose.ui.window.Window
29+
import androidx.compose.ui.window.application
30+
import androidx.compose.ui.window.rememberWindowState
31+
import com.formdev.flatlaf.FlatLightLaf
2132
import processing.app.ui.Toolkit
33+
import processing.app.ui.theme.PDETheme
2234
import java.awt.EventQueue
2335
import java.awt.Frame
2436
import java.io.PrintWriter
2537
import java.io.StringWriter
2638
import javax.swing.JFrame
2739
import javax.swing.JOptionPane
40+
import javax.swing.UIManager
41+
2842

2943
class Messages {
3044
companion object {
@@ -270,6 +284,37 @@ class Messages {
270284
}
271285
}
272286
}
287+
fun main(){
288+
val types = mapOf(
289+
"message" to { Messages.showMessage("Test Title", "This is a test message.") },
290+
"warning" to { Messages.showWarning("Test Warning", "This is a test warning.", Exception("dfdsfjk")) },
291+
"trace" to { Messages.showTrace("Test Trace", "This is a test trace.", Exception("Test Exception"), false) },
292+
"tiered_warning" to { Messages.showWarningTiered("Test Tiered Warning", "Primary message", "Secondary message", null) },
293+
"yes_no" to { Messages.showYesNoQuestion(null, "Test Yes/No", "Do you want to continue?", "Choose yes or no.") },
294+
"custom_question" to { Messages.showCustomQuestion(null, "Test Custom Question", "Choose an option:", "Select one of the options below.", 1, "Option 1", "Option 2", "Option 3") },
295+
"error" to { Messages.showError("Test Error", "This is a test error.", null) },
296+
)
297+
Platform.init()
298+
UIManager.setLookAndFeel(FlatLightLaf())
299+
application {
300+
val state = rememberWindowState(
301+
size = DpSize(500.dp, 300.dp)
302+
)
303+
Window(state = state, onCloseRequest = ::exitApplication, title = "Test Messages") {
304+
PDETheme {
305+
Column {
306+
for ((type, action) in types) {
307+
Button(onClick = { action() }, modifier = Modifier.padding(8.dp)) {
308+
Text("Show $type dialog")
309+
}
310+
}
311+
}
312+
}
313+
}
314+
315+
}
316+
317+
}
273318

274319
// Helper functions to give the base classes a color
275320
fun String.formatClassName() = this

app/src/processing/app/Preferences.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ static public void skipInit() {
136136
initialized = true;
137137
}
138138

139+
/**
140+
* Check whether Preferences.init() has been called. If not, we are probably not running the full application.
141+
* @return true if Preferences has been initialized
142+
*/
143+
static public boolean isInitialized() {
144+
return initialized;
145+
}
146+
139147

140148
static void handleProxy(String protocol, String hostProp, String portProp) {
141149
String proxyHost = get("proxy." + protocol + ".host");

0 commit comments

Comments
 (0)