* 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.
This commit is contained in:
Stef Tervelde
2025-10-22 04:46:57 +02:00
committed by GitHub
parent bf4d163c2e
commit 77eba30bb2
13 changed files with 703 additions and 140 deletions

View File

@@ -17,6 +17,7 @@ plugins{
alias(libs.plugins.compose.compiler)
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.serialization)
alias(libs.plugins.download)
}
@@ -60,7 +61,7 @@ compose.desktop {
).map { "-D${it.first}=${it.second}" }.toTypedArray())
nativeDistributions{
modules("jdk.jdi", "java.compiler", "jdk.accessibility", "java.management.rmi", "java.scripting", "jdk.httpserver")
modules("jdk.jdi", "java.compiler", "jdk.accessibility", "jdk.zipfs", "java.management.rmi", "java.scripting", "jdk.httpserver")
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "Processing"
@@ -108,27 +109,29 @@ dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.ui)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(compose.materialIconsExtended)
implementation(compose.desktop.currentOs)
implementation(libs.material3)
implementation(libs.compottie)
implementation(libs.kaml)
implementation(libs.markdown)
implementation(libs.markdownJVM)
implementation(libs.clikt)
implementation(libs.kotlinxSerializationJson)
@OptIn(ExperimentalComposeLibrary::class)
testImplementation(compose.uiTest)
testImplementation(kotlin("test"))
testImplementation(libs.mockitoKotlin)
testImplementation(libs.junitJupiter)
testImplementation(libs.junitJupiterParams)
implementation(libs.clikt)
implementation(libs.kotlinxSerializationJson)
}
tasks.test {

View File

@@ -5,11 +5,11 @@ import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
import androidx.compose.material.MaterialTheme.colors
import androidx.compose.material.MaterialTheme.typography
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
@@ -31,17 +31,16 @@ import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState
import com.formdev.flatlaf.util.SystemInfo
import com.mikepenz.markdown.compose.Markdown
import com.mikepenz.markdown.m2.markdownColor
import com.mikepenz.markdown.m2.markdownTypography
import com.mikepenz.markdown.m3.markdownColor
import com.mikepenz.markdown.m3.markdownTypography
import com.mikepenz.markdown.model.MarkdownColors
import com.mikepenz.markdown.model.MarkdownTypography
import processing.app.Preferences
import processing.app.Base.getRevision
import processing.app.Base.getVersionName
import processing.app.ui.theme.LocalLocale
import processing.app.ui.theme.LocalTheme
import processing.app.ui.theme.Locale
import processing.app.ui.theme.ProcessingTheme
import processing.app.ui.theme.PDETheme
import java.awt.Cursor
import java.awt.Dimension
import java.awt.event.KeyAdapter
@@ -54,7 +53,7 @@ import javax.swing.SwingUtilities
class WelcomeToBeta {
companion object{
val windowSize = Dimension(400, 200)
val windowSize = Dimension(400, 250)
val windowTitle = Locale()["beta.window.title"]
@JvmStatic
@@ -72,7 +71,7 @@ class WelcomeToBeta {
contentPane.add(ComposePanel().apply {
size = windowSize
setContent {
ProcessingTheme {
PDETheme(darkTheme = false) {
Box(modifier = Modifier.padding(top = if (mac) 22.dp else 0.dp)) {
welcomeToBeta(close)
}
@@ -99,7 +98,7 @@ class WelcomeToBeta {
Row(
modifier = Modifier
.padding(20.dp, 10.dp)
.size(windowSize.width.dp, windowSize.height.dp),
.fillMaxSize(),
horizontalArrangement = Arrangement
.spacedBy(20.dp)
){
@@ -109,7 +108,7 @@ class WelcomeToBeta {
contentDescription = locale["beta.logo"],
modifier = Modifier
.align(Alignment.CenterVertically)
.size(100.dp, 100.dp)
.size(120.dp)
.offset(0.dp, (-25).dp)
)
Column(
@@ -123,7 +122,7 @@ class WelcomeToBeta {
) {
Text(
text = locale["beta.title"],
style = typography.subtitle1,
style = typography.titleLarge,
)
val text = locale["beta.message"]
.replace('$' + "version", getVersionName())
@@ -131,80 +130,36 @@ class WelcomeToBeta {
Markdown(
text,
colors = markdownColor(),
typography = markdownTypography(text = typography.body1, link = typography.body1.copy(color = colors.primary)),
typography = markdownTypography(),
modifier = Modifier.background(Color.Transparent).padding(bottom = 10.dp)
)
Row {
Spacer(modifier = Modifier.weight(1f))
PDEButton(onClick = {
Button(onClick = {
close()
}) {
Text(
text = locale["beta.button"],
color = colors.onPrimary
color = MaterialTheme.colorScheme.onPrimary
)
}
}
}
}
}
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun PDEButton(onClick: () -> Unit, content: @Composable BoxScope.() -> Unit) {
val theme = LocalTheme.current
var hover by remember { mutableStateOf(false) }
var clicked by remember { mutableStateOf(false) }
val offset by animateFloatAsState(if (hover) -5f else 5f)
val color by animateColorAsState(if(clicked) colors.primaryVariant else colors.primary)
Box(modifier = Modifier.padding(end = 5.dp, top = 5.dp)) {
Box(
modifier = Modifier
.offset((-offset).dp, (offset).dp)
.background(theme.getColor("toolbar.button.pressed.field"))
.matchParentSize()
)
Box(
modifier = Modifier
.onPointerEvent(PointerEventType.Press) {
clicked = true
}
.onPointerEvent(PointerEventType.Release) {
clicked = false
onClick()
}
.onPointerEvent(PointerEventType.Enter) {
hover = true
}
.onPointerEvent(PointerEventType.Exit) {
hover = false
}
.pointerHoverIcon(PointerIcon(Cursor(Cursor.HAND_CURSOR)))
.background(color)
.padding(10.dp)
.sizeIn(minWidth = 100.dp),
contentAlignment = Alignment.Center,
content = content
)
}
}
@JvmStatic
fun main(args: Array<String>) {
application {
val windowState = rememberWindowState(
size = DpSize.Unspecified,
size = windowSize.let { DpSize(it.width.dp, it.height.dp) },
position = WindowPosition(Alignment.Center)
)
Window(onCloseRequest = ::exitApplication, state = windowState, title = windowTitle) {
ProcessingTheme {
Surface(color = colors.background) {
welcomeToBeta {
exitApplication()
}
PDETheme(darkTheme = false) {
welcomeToBeta {
exitApplication()
}
}
}

View File

@@ -0,0 +1,134 @@
package processing.app.ui.theme
import androidx.compose.material.Colors
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.ui.graphics.Color
class ProcessingColors{
companion object{
val blue = Color(0xFF0251c8)
val lightBlue = Color(0xFF82AFFF)
val deepBlue = Color(0xFF1e32aa)
val darkBlue = Color(0xFF0F195A)
val white = Color(0xFFFFFFFF)
val lightGray = Color(0xFFF5F5F5)
val gray = Color(0xFFDBDBDB)
val darkGray = Color(0xFF898989)
val darkerGray = Color(0xFF727070)
val veryDarkGray = Color(0xFF1E1E1E)
val black = Color(0xFF0D0D0D)
val error = Color(0xFFFF5757)
val errorContainer = Color(0xFFFFA6A6)
val p5Light = Color(0xFFfd9db9)
val p5Mid = Color(0xFFff4077)
val p5Dark = Color(0xFFaf1f42)
val foundationLight = Color(0xFFd4b2fe)
val foundationMid = Color(0xFF9c4bff)
val foundationDark = Color(0xFF5501a4)
val downloadInactive = Color(0xFF8890B3)
val downloadBackgroundActive = Color(0x14508BFF)
}
}
@Deprecated("Use PDE3LightColor instead")
val PDE2LightColors = Colors(
primary = ProcessingColors.blue,
primaryVariant = ProcessingColors.lightBlue,
onPrimary = ProcessingColors.white,
secondary = ProcessingColors.deepBlue,
secondaryVariant = ProcessingColors.darkBlue,
onSecondary = ProcessingColors.white,
background = ProcessingColors.white,
onBackground = ProcessingColors.darkBlue,
surface = ProcessingColors.lightGray,
onSurface = ProcessingColors.darkerGray,
error = ProcessingColors.error,
onError = ProcessingColors.white,
isLight = true,
)
@Deprecated("Use PDE3DarkColor instead")
val PDE2DarkColors = Colors(
primary = ProcessingColors.deepBlue,
primaryVariant = ProcessingColors.darkBlue,
onPrimary = ProcessingColors.white,
secondary = ProcessingColors.lightBlue,
secondaryVariant = ProcessingColors.blue,
onSecondary = ProcessingColors.white,
background = ProcessingColors.veryDarkGray,
onBackground = ProcessingColors.white,
surface = ProcessingColors.darkerGray,
onSurface = ProcessingColors.lightGray,
error = ProcessingColors.error,
onError = ProcessingColors.white,
isLight = false,
)
val PDELightColor = lightColorScheme(
primary = ProcessingColors.blue,
onPrimary = ProcessingColors.white,
primaryContainer = ProcessingColors.downloadBackgroundActive,
onPrimaryContainer = ProcessingColors.darkBlue,
secondary = ProcessingColors.deepBlue,
onSecondary = ProcessingColors.white,
secondaryContainer = ProcessingColors.downloadInactive,
onSecondaryContainer = ProcessingColors.white,
tertiary = ProcessingColors.p5Mid,
onTertiary = ProcessingColors.white,
tertiaryContainer = ProcessingColors.p5Light,
onTertiaryContainer = ProcessingColors.p5Dark,
background = ProcessingColors.white,
onBackground = ProcessingColors.darkBlue,
surface = ProcessingColors.lightGray,
onSurface = ProcessingColors.darkerGray,
error = ProcessingColors.error,
onError = ProcessingColors.white,
errorContainer = ProcessingColors.errorContainer,
onErrorContainer = ProcessingColors.white
)
val PDEDarkColor = darkColorScheme(
primary = ProcessingColors.deepBlue,
onPrimary = ProcessingColors.white,
secondary = ProcessingColors.lightBlue,
onSecondary = ProcessingColors.white,
tertiary = ProcessingColors.blue,
onTertiary = ProcessingColors.white,
background = ProcessingColors.veryDarkGray,
onBackground = ProcessingColors.white,
surface = ProcessingColors.darkerGray,
onSurface = ProcessingColors.lightGray,
error = ProcessingColors.error,
onError = ProcessingColors.white,
)

View File

@@ -1,75 +1,364 @@
package processing.app.ui.theme
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.Colors
import androidx.compose.material.MaterialTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Map
import androidx.compose.material3.AssistChip
import androidx.compose.material3.Badge
import androidx.compose.material3.BadgedBox
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.Checkbox
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.FilterChip
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.RadioButton
import androidx.compose.material3.RangeSlider
import androidx.compose.material3.Slider
import androidx.compose.material3.Switch
import androidx.compose.material3.TextButton
import androidx.compose.material3.TextField
import androidx.compose.material3.TriStateCheckbox
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.graphics.Color
import processing.app.LocalPreferences
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.state.ToggleableState
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.WindowPosition
import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState
import processing.app.PreferencesProvider
import java.io.InputStream
import java.util.Properties
class Theme(themeFile: String? = "") : Properties() {
init {
load(ClassLoader.getSystemResourceAsStream("theme.txt"))
load(ClassLoader.getSystemResourceAsStream(themeFile) ?: InputStream.nullInputStream())
}
fun getColor(key: String): Color {
return Color(getProperty(key).toColorInt())
}
}
val LocalTheme = compositionLocalOf<Theme> { error("No theme provided") }
/**
* Processing Theme for Jetpack Compose Desktop
* Based on Material3
*
* Makes Material3 components follow Processing color scheme and typography
* We experimented with using the material3 theme builder, but it made it look too Android-y
* So we defined our own color scheme and typography based on Processing design guidelines
*
* This composable also provides Preferences and Locale context to all child composables
*
* Also, important: sets a default density of 1.25 for better scaling on desktop screens, [LocalDensity]
*
* Usage:
* ```
* PDETheme {
* val pref = LocalPreferences.current
* val locale = LocalLocale.current
* ...
* // Your composables here
* }
* ```
*
* @param darkTheme Whether to use dark theme or light theme. Defaults to system setting.
*/
@Composable
fun ProcessingTheme(
fun PDETheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable() () -> Unit
) {
content: @Composable () -> Unit
){
PreferencesProvider {
val preferences = LocalPreferences.current
val theme = Theme(preferences.getProperty("theme"))
val colors = Colors(
primary = theme.getColor("editor.gradient.top"),
primaryVariant = theme.getColor("toolbar.button.pressed.field"),
secondary = theme.getColor("editor.gradient.bottom"),
secondaryVariant = theme.getColor("editor.scrollbar.thumb.pressed.color"),
background = theme.getColor("editor.bgcolor"),
surface = theme.getColor("editor.bgcolor"),
error = theme.getColor("status.error.bgcolor"),
onPrimary = theme.getColor("toolbar.button.enabled.field"),
onSecondary = theme.getColor("toolbar.button.enabled.field"),
onBackground = theme.getColor("editor.fgcolor"),
onSurface = theme.getColor("editor.fgcolor"),
onError = theme.getColor("status.error.fgcolor"),
isLight = theme.getProperty("laf.mode").equals("light")
)
CompositionLocalProvider(LocalTheme provides theme) {
LocaleProvider {
MaterialTheme(
colors = colors,
typography = Typography,
content = content
)
LocaleProvider {
MaterialTheme(
colorScheme = if(darkTheme) PDEDarkColor else PDELightColor,
typography = PDETypography
){
Box(modifier = Modifier.background(color = MaterialTheme.colorScheme.background).fillMaxSize()) {
CompositionLocalProvider(
LocalContentColor provides MaterialTheme.colorScheme.onBackground,
LocalDensity provides Density(1.25f, 1.25f),
content = content
)
}
}
}
}
}
fun String.toColorInt(): Int {
if (this[0] == '#') {
var color = substring(1).toLong(16)
if (length == 7) {
color = color or 0x00000000ff000000L
} else if (length != 9) {
throw IllegalArgumentException("Unknown color")
/**
* Simple app to preview the Processing Theme components
* Includes buttons, text fields, checkboxes, sliders, etc.
* Run by executing the main() function by clicking the green arrow next to it in intelliJ IDEA
*/
fun main() {
application {
val windowState = rememberWindowState(
size = DpSize(800.dp, 600.dp),
position = WindowPosition(Alignment.Center)
)
var darkTheme by remember { mutableStateOf(false) }
Window(onCloseRequest = ::exitApplication, state = windowState, title = "Processing Theme") {
PDETheme(darkTheme = darkTheme) {
Column(modifier = Modifier.padding(16.dp)) {
Text("Processing Theme Components", style = MaterialTheme.typography.titleLarge)
Card {
Row {
Checkbox(darkTheme, onCheckedChange = { darkTheme = !darkTheme })
Text(
"Dark Theme",
modifier = Modifier.align(Alignment.CenterVertically)
)
}
}
val scrollable = rememberScrollState()
Column(
modifier = Modifier
.verticalScroll(scrollable),
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
ComponentPreview("Colors") {
Column {
Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
Button(
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.primary),
onClick = {}) {
Text("Primary", color = MaterialTheme.colorScheme.onPrimary)
}
Button(
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.secondary),
onClick = {}) {
Text("Secondary", color = MaterialTheme.colorScheme.onSecondary)
}
Button(
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.tertiary),
onClick = {}) {
Text("Tertiary", color = MaterialTheme.colorScheme.onTertiary)
}
}
Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
Button(
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.primaryContainer),
onClick = {}) {
Text("Primary Container", color = MaterialTheme.colorScheme.onPrimaryContainer)
}
Button(
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.secondaryContainer),
onClick = {}) {
Text("Secondary Container", color = MaterialTheme.colorScheme.onSecondaryContainer)
}
Button(
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.tertiaryContainer),
onClick = {}) {
Text("Tertiary Container", color = MaterialTheme.colorScheme.onTertiaryContainer)
}
Button(
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.errorContainer),
onClick = {}) {
Text("Error Container", color = MaterialTheme.colorScheme.onErrorContainer)
}
}
Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
Button(
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.background),
onClick = {}) {
Text("Background", color = MaterialTheme.colorScheme.onBackground)
}
Button(
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.surface),
onClick = {}) {
Text("Surface", color = MaterialTheme.colorScheme.onSurface)
}
Button(
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
onClick = {}) {
Text("Surface Variant", color = MaterialTheme.colorScheme.onSurfaceVariant)
}
Button(
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.error),
onClick = {}) {
Text("Error", color = MaterialTheme.colorScheme.onError)
}
}
}
}
ComponentPreview("Text & Fonts") {
Column {
Text("displayLarge", style = MaterialTheme.typography.displayLarge)
Text("displayMedium", style = MaterialTheme.typography.displayMedium)
Text("displaySmall", style = MaterialTheme.typography.displaySmall)
Text("headlineLarge", style = MaterialTheme.typography.headlineLarge)
Text("headlineMedium", style = MaterialTheme.typography.headlineMedium)
Text("headlineSmall", style = MaterialTheme.typography.headlineSmall)
Text("titleLarge", style = MaterialTheme.typography.titleLarge)
Text("titleMedium", style = MaterialTheme.typography.titleMedium)
Text("titleSmall", style = MaterialTheme.typography.titleSmall)
Text("bodyLarge", style = MaterialTheme.typography.bodyLarge)
Text("bodyMedium", style = MaterialTheme.typography.bodyMedium)
Text("bodySmall", style = MaterialTheme.typography.bodySmall)
Text("labelLarge", style = MaterialTheme.typography.labelLarge)
Text("labelMedium", style = MaterialTheme.typography.labelMedium)
Text("labelSmall", style = MaterialTheme.typography.labelSmall)
}
}
ComponentPreview("Buttons") {
Button(onClick = {}) {
Text("Filled")
}
Button(onClick = {}, enabled = false) {
Text("Disabled")
}
OutlinedButton(onClick = {}) {
Text("Outlined")
}
TextButton(onClick = {}) {
Text("Text")
}
}
ComponentPreview("Icon Buttons") {
IconButton(onClick = {}) {
Icon(Icons.Default.Map, contentDescription = "Icon Button")
}
}
ComponentPreview("Chip") {
AssistChip(onClick = {}, label = {
Text("Assist Chip")
})
FilterChip(selected = false, onClick = {}, label = {
Text("Filter not Selected")
})
FilterChip(selected = true, onClick = {}, label = {
Text("Filter Selected")
})
}
ComponentPreview("Progress Indicator") {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(16.dp)){
CircularProgressIndicator()
LinearProgressIndicator()
}
}
ComponentPreview("Radio Button") {
var state by remember { mutableStateOf(true) }
RadioButton(!state, onClick = { state = false })
RadioButton(state, onClick = { state = true })
}
ComponentPreview("Checkbox") {
var state by remember { mutableStateOf(true) }
Checkbox(state, onCheckedChange = { state = it })
Checkbox(!state, onCheckedChange = { state = !it })
Checkbox(state, onCheckedChange = {}, enabled = false)
TriStateCheckbox(ToggleableState.Indeterminate, onClick = {})
}
ComponentPreview("Switch") {
var state by remember { mutableStateOf(true) }
Switch(state, onCheckedChange = { state = it })
Switch(!state, enabled = false, onCheckedChange = { state = it })
}
ComponentPreview("Slider") {
Column{
var state by remember { mutableStateOf(0.5f) }
Slider(state, onValueChange = { state = it })
var rangeState by remember { mutableStateOf(0.25f..0.75f) }
RangeSlider(rangeState, onValueChange = { rangeState = it })
}
}
ComponentPreview("Badge") {
IconButton(onClick = {}) {
BadgedBox(badge = { Badge() }) {
Icon(Icons.Default.Map, contentDescription = "Icon with Badge")
}
}
}
ComponentPreview("Number Field") {
var number by remember { mutableStateOf("123") }
TextField(number, onValueChange = {
if(it.all { char -> char.isDigit() }) {
number = it
}
}, label = { Text("Number Field") })
}
ComponentPreview("Text Field") {
Row {
var text by remember { mutableStateOf("Text Field") }
TextField(text, onValueChange = { text = it })
}
var text by remember { mutableStateOf("Outlined Text Field") }
OutlinedTextField(text, onValueChange = { text = it})
}
ComponentPreview("Dropdown Menu") {
var show by remember { mutableStateOf(false) }
AssistChip(
onClick = { show = true },
label = { Text("Show Menu") }
)
DropdownMenu(
expanded = show,
onDismissRequest = {
show = false
},
) {
DropdownMenuItem(onClick = { show = false }, text = {
Text("Menu Item 1", modifier = Modifier.padding(8.dp))
})
DropdownMenuItem(onClick = { show = false }, text = {
Text("Menu Item 2", modifier = Modifier.padding(8.dp))
})
DropdownMenuItem(onClick = { show = false }, text = {
Text("Menu Item 3", modifier = Modifier.padding(8.dp))
})
}
}
ComponentPreview("Scrollable View") {
}
ComponentPreview("Tabs") {
}
}
}
}
}
return color.toInt()
}
throw IllegalArgumentException("Unknown color")
}
@Composable
private fun ComponentPreview(title: String, content: @Composable () -> Unit) {
Column {
Text(title, style = MaterialTheme.typography.titleLarge)
HorizontalDivider()
Row(horizontalArrangement = Arrangement.spacedBy(16.dp), modifier = Modifier.padding(vertical = 8.dp)) {
content()
}
HorizontalDivider()
}
}

View File

@@ -1,6 +1,5 @@
package processing.app.ui.theme
import androidx.compose.material.MaterialTheme.typography
import androidx.compose.material.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
@@ -21,18 +20,108 @@ val processingFont = FontFamily(
style = FontStyle.Normal
)
)
val spaceGroteskFont = FontFamily(
Font(
resource = "SpaceGrotesk-Bold.ttf",
weight = FontWeight.Bold,
),
Font(
resource = "SpaceGrotesk-Regular.ttf",
weight = FontWeight.Normal,
),
Font(
resource = "SpaceGrotesk-Medium.ttf",
weight = FontWeight.Medium,
),
Font(
resource = "SpaceGrotesk-SemiBold.ttf",
weight = FontWeight.SemiBold,
),
Font(
resource = "SpaceGrotesk-Light.ttf",
weight = FontWeight.Light,
)
)
val Typography = Typography(
body1 = TextStyle(
fontFamily = processingFont,
@Deprecated("Use PDE3Typography instead")
val PDE2Typography = Typography(
defaultFontFamily = spaceGroteskFont,
h1 = TextStyle(
fontWeight = FontWeight.Bold,
fontSize = 42.725.sp,
lineHeight = 48.sp
),
h2 = TextStyle(
fontWeight = FontWeight.Bold,
fontSize = 34.18.sp,
lineHeight = 40.sp
),
h3 = TextStyle(
fontWeight = FontWeight.Bold,
fontSize = 27.344.sp,
lineHeight = 32.sp
),
h4 = TextStyle(
fontWeight = FontWeight.Normal,
fontSize = 13.sp,
fontSize = 21.875.sp,
lineHeight = 28.sp
),
h5 = TextStyle(
fontWeight = FontWeight.Normal,
fontSize = 17.5.sp,
lineHeight = 22.sp
),
h6 = TextStyle(
fontWeight = FontWeight.Normal,
fontSize = 14.sp,
lineHeight = 18.sp
),
body1 = TextStyle(
fontWeight = FontWeight.Normal,
fontSize = 14.sp,
lineHeight = 18.sp
),
body2 = TextStyle(
fontWeight = FontWeight.Normal,
fontSize = 12.8.sp,
lineHeight = 16.sp
),
subtitle1 = TextStyle(
fontFamily = processingFont,
fontWeight = FontWeight.Bold,
fontWeight = FontWeight.Medium,
fontSize = 16.sp,
lineHeight = 20.sp
),
subtitle2 = TextStyle(
fontWeight = FontWeight.Medium,
fontSize = 13.824.sp,
lineHeight = 16.sp,
),
caption = TextStyle(
fontWeight = FontWeight.Normal,
fontSize = 11.2.sp,
lineHeight = 14.sp
),
overline = TextStyle(
fontWeight = FontWeight.Normal,
fontSize = 8.96.sp,
lineHeight = 10.sp
)
)
val base = androidx.compose.material3.Typography()
val PDETypography = androidx.compose.material3.Typography(
displayLarge = base.displayLarge.copy(fontFamily = spaceGroteskFont),
displayMedium = base.displayMedium.copy(fontFamily = spaceGroteskFont),
displaySmall = base.displaySmall.copy(fontFamily = spaceGroteskFont),
headlineLarge = base.headlineLarge.copy(fontFamily = spaceGroteskFont),
headlineMedium = base.headlineMedium.copy(fontFamily = spaceGroteskFont),
headlineSmall = base.headlineSmall.copy(fontFamily = spaceGroteskFont),
titleLarge = base.titleLarge.copy(fontFamily = spaceGroteskFont),
titleMedium = base.titleMedium.copy(fontFamily = spaceGroteskFont),
titleSmall = base.titleSmall.copy(fontFamily = spaceGroteskFont),
bodyLarge = base.bodyLarge.copy(fontFamily = spaceGroteskFont),
bodyMedium = base.bodyMedium.copy(fontFamily = spaceGroteskFont),
bodySmall = base.bodySmall.copy(fontFamily = spaceGroteskFont),
labelLarge = base.labelLarge.copy(fontFamily = spaceGroteskFont),
labelMedium = base.labelMedium.copy(fontFamily = spaceGroteskFont),
labelSmall = base.labelSmall.copy(fontFamily = spaceGroteskFont),
)

View File

@@ -1,6 +1,5 @@
plugins {
kotlin("jvm") version libs.versions.kotlin apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.jetbrainsCompose) apply false

Binary file not shown.

View File

@@ -0,0 +1,93 @@
Copyright 2020 The Space Grotesk Project Authors (https://github.com/floriankarsten/space-grotesk)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,9 +1,10 @@
[versions]
kotlin = "2.0.20"
compose-plugin = "1.7.1"
kotlin = "2.2.20"
compose-plugin = "1.9.1"
jogl = "2.5.0"
antlr = "4.13.2"
jupiter = "5.12.0"
markdown = "0.37.0"
[libraries]
jogl = { module = "org.jogamp.jogl:jogl-all-main", version.ref = "jogl" }
@@ -31,14 +32,14 @@ antlr4Runtime = { module = "org.antlr:antlr4-runtime", version.ref = "antlr" }
composeGradlePlugin = { module = "org.jetbrains.compose:compose-gradle-plugin", version.ref = "compose-plugin" }
kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlinComposePlugin = { module = "org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin", version.ref = "kotlin" }
markdown = { module = "com.mikepenz:multiplatform-markdown-renderer-m2", version = "0.31.0" }
markdownJVM = { module = "com.mikepenz:multiplatform-markdown-renderer-jvm", version = "0.31.0" }
markdown = { module = "com.mikepenz:multiplatform-markdown-renderer-m3", version.ref = "markdown" }
markdownJVM = { module = "com.mikepenz:multiplatform-markdown-renderer-jvm", version.ref = "markdown" }
clikt = { module = "com.github.ajalt.clikt:clikt", version = "5.0.2" }
kotlinxSerializationJson = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.6.3" }
material3 = { module = "org.jetbrains.compose.material3:material3", version = "1.9.0" }
[plugins]
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
download = { id = "de.undercouch.download", version = "5.6.0" }