Skip to content

Commit 1237c55

Browse files
SteftervSableRaf
andauthored
Welcome screen (#1353)
* Refactor Locale class and add LocaleProvider test * Make setLocale parameter nullable in Locale class Changed the setLocale parameter in the Locale class to be nullable and updated its usage to safely invoke it. This allows for more flexible instantiation when a setLocale function is not required. * Add compose ui test to the deps * Update locale change method in test Replaces the call to locale.setLocale with locale.set in LocaleKtTest to match the updated API for changing the locale. * Add PDE window utilities for Compose and Swing Introduces PDESwingWindow and PDEComposeWindow classes to simplify creating themed and localized windows in Compose and Swing applications. Includes macOS-specific handling for full window content and localization support for window titles. * Refactor beta welcome window handling Replaces custom JFrame setup in WelcomeToBeta with PDESwingWindow and PDEComposeWindow, centralizing window logic and close handling. Adds onClose callback to PDESwingWindow for improved lifecycle management. Also ensures beta welcome preference is reset on forced update check. * Remove ContributionManager and ContributionPane UI files (#1276) Deleted ContributionManager.kt and ContributionPane.kt from the contrib/ui directory. This removes the Compose-based contributions manager and its detail pane prototypes which got merged unnecessarily * Refactor Locale class and add LocaleProvider test (#1283) * Refactor Locale class and add LocaleProvider test * Make setLocale parameter nullable in Locale class Changed the setLocale parameter in the Locale class to be nullable and updated its usage to safely invoke it. This allows for more flexible instantiation when a setLocale function is not required. * Add compose ui test to the deps * Update locale change method in test Replaces the call to locale.setLocale with locale.set in LocaleKtTest to match the updated API for changing the locale. * Theming (#1298) * Add Material3-based Processing theme and typography Introduces Colors.kt with custom color schemes for light and dark themes using Material3. Refactors Theme.kt to use Material3 theming, adds a PDETheme composable, and provides a desktop preview app for theme components. Updates Typography.kt to use Space Grotesk font family and defines new typography styles for Material3. * Refactor to use Material3 and update theme usage Replaces Material2 components with Material3 in WelcomeToBeta, removes custom PDEButton in favor of Material3 Button, and updates theme usage to PDETheme. Also simplifies background modifier in PDETheme and removes unused Kotlin Multiplatform plugin from build.gradle.kts. * Add Space Grotesk font files and license Includes SpaceGrotesk font variants (Bold, Light, Medium, Regular, SemiBold) and the associated SIL Open Font License. This enables usage of the Space Grotesk typeface in the project. * Update markdown renderer to m3 and adjust UI Switched markdown renderer imports from m2 to m3 and updated the dependency version to 0.37.0. Adjusted WelcomeToBeta window size, layout, and logo dimensions for improved appearance. Ensured Box in Theme.kt fills available space for better layout consistency. * Switch from ProcessingTheme to PDETheme in window UI Replaces the use of ProcessingTheme with PDETheme in the PDEWindowContent composable * Refactor preferences to Jetpack Compose UI Replaces the legacy PreferencesFrame with a new Jetpack Compose-based preferences UI. Adds reactive preferences management using a custom ReactiveProperties class, and introduces modular preference groups (General, Interface, Other) with composable controls. Updates Base.java to launch the new preferences window, and refactors theme and window code for Compose integration. * Remove obsolete TODO for onClose callback * Clean up handlePrefs method by removing comments Removed commented-out code for preferences frame initialization. * Composable Preferences rewrite (#1277) * Remove ContributionManager and ContributionPane UI files Deleted ContributionManager.kt and ContributionPane.kt from the contrib/ui directory. This removes the Compose-based contributions manager and its detail pane prototypes which got merged unnecessarily * Enhance Preferences reactivity and test coverage Refactored ReactiveProperties to use snapshotStateMap for Compose reactivity. Improved PreferencesProvider and watchFile composables with better file watching, override support via system properties, and added documentation. Updated PreferencesKtTest to use temporary files and verify file-to-UI reactivity. * Small bugfix for removed function * Add compose ui test to the deps * Welcome screen implementation (#1307) * Remove ContributionManager and ContributionPane UI files Deleted ContributionManager.kt and ContributionPane.kt from the contrib/ui directory. This removes the Compose-based contributions manager and its detail pane prototypes which got merged unnecessarily * Enhance Preferences reactivity and test coverage Refactored ReactiveProperties to use snapshotStateMap for Compose reactivity. Improved PreferencesProvider and watchFile composables with better file watching, override support via system properties, and added documentation. Updated PreferencesKtTest to use temporary files and verify file-to-UI reactivity. * Small bugfix for removed function * Add compose ui test to the deps * Refactor theme system to Material 3 color schemes Replaces legacy color definitions with Material 3 color schemes and introduces extended color support for warnings. Dialogs in Messages.kt are now implemented using Compose Material 3 components for a modern UI. Removes deprecated color sets and updates PDETheme to use new color schemes, improving consistency and maintainability. * Add PDEWelcome Composable UI screen Introduces a new PDEWelcome.kt file with a Composable UI for the Processing welcome screen. Includes layout with buttons for language selection, new sketch, examples, and sketchbook, as well as a placeholder for right-side content and a main entry point for launching the window. * Initial layout * Revamp welcome screen UI and add social icons Refactors the PDEWelcome screen to improve layout, update button icons, and add support for Discord, GitHub, and Instagram SVG icons. The welcome screen now receives a Base instance for proper action handling, and new methods replace deprecated ones in Base.java. Updates related menu actions to pass the Base instance as needed. * Add example previews to welcome screen Replaces placeholder text on the right side of the PDEWelcome screen with a LazyColumn displaying example sketches. Each example attempts to show a preview image if available, or a placeholder icon otherwise. Introduces an Example data class and related image loading logic. * Add hover-activated play button to example previews Introduced a hover effect on example preview images in the welcome screen, displaying a play button that opens the example when clicked. Refactored title key usage for consistency. * Localize welcome screen UI strings Replaced hardcoded strings in the PDEWelcome screen with localized values using the LocalLocale context. Added new keys for the welcome screen to the English and Dutch language property files to support internationalization. * Add language selector and UI improvements to welcome screen Introduces a language selection dropdown to the PDE welcome screen using a shared composable from preferences. Refactors the layout for better spacing, updates example cards with animated overlays, and replaces the show-on-startup button with a checkbox. Also adds a new translation key for the open example button. * Refactor example listing and randomize welcome sketches Moved example folder listing logic in Contributions.ExamplesList to a companion object function for reuse. Updated PDEWelcome to display a randomized selection of sketches from all available examples, replacing the previous static list. * Refactor example handling to use Sketch objects Replaces Example objects with Sketch objects for managing example sketches in the welcome screen. Updates all relevant usages to reference Sketch properties, simplifying the code and improving clarity. * Add vertical scrollbar to welcome screen examples Introduces a VerticalScrollbar to the examples list in the PDEWelcome screen for improved navigation. Also adjusts spacing and arrangement in several UI components for better layout consistency, and updates the welcome screen title in the language properties. * Add rounded corners to buttons in PDEWelcome Introduced a RoundedCornerShape with 12.dp radius and applied it to various buttons in the PDEWelcome screen for improved UI consistency and aesthetics. * Refactor PDEWelcome UI and add Sketch card composable Refactored the PDEWelcome screen for improved structure and readability, including extracting the example preview into a reusable Sketch.card composable. Updated icon usage for RTL support, adjusted layout and padding, and improved the examples list initialization. Also, customized scrollbar style in PDETheme for a more consistent UI appearance. * Add unique window handling to prevent duplicates Introduces a 'unique' parameter to PDESwingWindow and PDEComposeWindow, allowing windows to be identified by a KClass and preventing multiple instances of the same window. If a window with the same unique identifier exists, it is brought to the front and the new one is disposed. This helps avoid duplicate welcome or other singleton windows. * Refactor dialog handling and improve AlertDialog UI Refactored the showDialog function to accept a modifier and updated all AlertDialog usages to use RectangleShape and the modifier parameter. Improved dialog sizing and positioning by dynamically adjusting the window size based on content, and set additional window properties for better integration on macOS. * Set application window icon using Toolkit.setIcon Added calls to Toolkit.setIcon(window) in Start.kt and Window.kt to ensure the application window icon is set consistent * Simplify imports and update scrollbar colors in Theme.kt Consolidated import statements for Compose libraries using wildcard imports to reduce verbosity. Updated scrollbar hover and unhover colors to use the default outlineVariant color without alpha modification. * Removing the Preferences work to keep the PR clean * Update background color in PDEWelcome UI Changed the background color from surfaceContainerLow to surfaceContainerLowest in the PDEWelcome composable for improved visual consistency with the MaterialTheme. * Tweak welcome actions naming and order - Rename `Empty Sketch` to `New Sketch` - Rename `Sketchbook` to `My Sketches` - Move `Open Examples` below `My Sketches` * Rather than setting the decorations app wide, just modify the editor screen --------- Co-authored-by: Raphaël de Courville <groupes.raphael@gmail.com> * Replace ProcessingTheme with PDETheme in WelcomeSurvey * Add Material Theme Builder file headers Added autogenerated file headers to Color.kt and Theme.kt indicating they were generated by the Material Theme Builder tool and should not be edited directly. Also reordered imports in Theme.kt for consistency. * Fix preferences file override and update test property Corrects the logic for selecting the preferences file in PreferencesProvider to use the override if present. Updates the test to set the correct system property for the settings folder. * Added survey button to the new welcome screen --------- Co-authored-by: Raphaël de Courville <groupes.raphael@gmail.com>
1 parent 467cee7 commit 1237c55

39 files changed

+2715
-814
lines changed

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/main/resources/languages/PDE.properties

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,23 @@ welcome.survey.description=Processing is free, open-source, and shaped by its co
643643
color_chooser = Color Selector
644644
color_chooser.select = Select
645645

646+
647+
# ---------------------------------------
648+
# Welcome Screen
649+
welcome.processing.logo = Processing Logo
650+
welcome.processing.title = Welcome to Processing
651+
welcome.actions.sketch.new = New Sketch
652+
welcome.actions.examples = Open Examples
653+
welcome.actions.sketchbook = My Sketches
654+
welcome.actions.show_startup = Show this window at startup
655+
welcome.resources.title = Resources
656+
welcome.resources.get_started = Get Started
657+
welcome.resources.tutorials = Tutorials
658+
welcome.resources.documentation = Reference
659+
welcome.community.title = Join our community
660+
welcome.community.forum = Forum
661+
welcome.sketch.open = Open
662+
646663
# ---------------------------------------
647664
# Movie Maker
648665

app/src/main/resources/languages/PDE_nl.properties

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,22 @@ beta.title = Dankuwel voor het testen van deze Processing Beta!
327327
beta.message = Deze preview release laat ons feedback verzamelen en problemen oplossen. **Sommige functies werken mogelijk niet zoals verwacht.** Als u problemen ondervindt, [post dan op het forum](https://discourse.processing.org) of [open een GitHub issue](https://github.com/processing/processing4/issues).
328328
beta.button = Ok
329329

330+
331+
# ---------------------------------------
332+
# Welcome Screen
333+
welcome.processing.logo = Processing Logo
334+
welcome.processing.title = Welkom bij Processing!
335+
welcome.actions.sketch.new = Nieuwe Schets
336+
welcome.actions.examples = Open Voorbeelden
337+
welcome.actions.show_startup = Laat dit scherm zien bij opstarten
338+
welcome.resources.title = Resources
339+
welcome.resources.video = Video Cursus
340+
welcome.resources.get_started = Om te beginnen
341+
welcome.resources.tutorials = Tutorials
342+
welcome.resources.documentation = Handleiding
343+
welcome.community.title = Neem deel aan de Community
344+
welcome.community.forum = Forum
345+
330346
# ---------------------------------------
331347
# Color Chooser
332348
color_chooser = Kies een kleur...

app/src/processing/app/Base.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,7 @@ static private void handleWelcomeScreen(Base base) {
328328
// Needs to be shown after the first editor window opens, so that it
329329
// shows up on top, and doesn't prevent an editor window from opening.
330330
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-
}
331+
PDEWelcomeKt.showWelcomeScreen(base);
338332
}
339333
}
340334

@@ -598,7 +592,7 @@ public JMenu initDefaultFileMenu() {
598592
defaultFileMenu.add(item);
599593

600594
item = Toolkit.newJMenuItemShift(Language.text("menu.file.examples"), 'O');
601-
item.addActionListener(e -> thinkDifferentExamples());
595+
item.addActionListener(e -> showExamplesFrame());
602596
defaultFileMenu.add(item);
603597

604598
return defaultFileMenu;
@@ -1874,7 +1868,7 @@ public void handleRestart() {
18741868
// }
18751869

18761870

1877-
public void thinkDifferentExamples() {
1871+
public void showExamplesFrame() {
18781872
nextMode.showExamplesFrame();
18791873
}
18801874

@@ -2180,10 +2174,10 @@ static private Mode findSketchMode(File folder, List<Mode> modeList) {
21802174
* Show the Preferences window.
21812175
*/
21822176
public void handlePrefs() {
2183-
if (preferencesFrame == null) {
2184-
preferencesFrame = new PreferencesFrame(this);
2185-
}
2186-
preferencesFrame.showFrame();
2177+
if (preferencesFrame == null) {
2178+
preferencesFrame = new PreferencesFrame(this);
2179+
}
2180+
preferencesFrame.showFrame();
21872181
}
21882182

21892183

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

0 commit comments

Comments
 (0)