Skip to content

Dotty 3.0.0-M1 support #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ scala-swing.iml
.DS_Store

target/
/.bloop/
/.bsp/
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ scala:
- 2.11.12
- 2.12.11
- 2.13.3
- 3.0.0-M1

env:
- ADOPTOPENJDK=8
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
[<img src="https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-swing_2.12.svg?label=latest%20release%20for%202.12"/>](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-swing_2.12)
[<img src="https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-swing_2.13.svg?label=latest%20release%20for%202.13"/>](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-swing_2.13)

This is now community maintained by [@Sciss](https://github.com/Sciss) and [@benhutchison](https://github.com/benhutchison). If you are interested in helping then contact them or [@adriaanm](https://github.com/adriaanm).
This is now community maintained by [@Sciss](https://github.com/Sciss) and [@benhutchison](https://github.com/benhutchison).
If you are interested in helping then contact them or [@adriaanm](https://github.com/adriaanm).

## Adding an sbt dependency

To use scala-swing from sbt, add this to your `build.sbt`:

```
libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "2.1.1"
libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "3.0.0"
```

## About scala-swing
Expand Down Expand Up @@ -113,6 +114,7 @@ new Frame {
- When using Scala 2.11, you can use the Scala swing 2.0.x releases on JDK 6 or newer.
- Scala 2.12 requires you to use JDK 8 (that has nothing to do with scala-swing).
- The `2.1.x` series adds support for Scala 2.13, while dropping Scala 2.10.
- The `3.0.x` series adds support for Scala 3.0.

The reason to have different major versions is to allow for binary incompatible changes. Also, some java-swing classes were
generified in JDK 7 (see [SI-3634](https://issues.scala-lang.org/browse/SI-3634)) and require the scala-swing sources to be adjusted.
Expand Down
16 changes: 14 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
lazy val scalaTestVersion = "3.2.3"

lazy val commonSettings = Seq(
crossScalaVersions := Seq("3.0.0-M1", "2.13.3", "2.12.12", "2.11.12"),
scalaVersion := "2.13.3",
scalacOptions ++= Seq("-deprecation", "-feature"),
)

lazy val swing = project.in(file("."))
.settings(ScalaModulePlugin.scalaModuleSettings)
.settings(ScalaModulePlugin.scalaModuleOsgiSettings)
.settings(commonSettings)
.settings(
name := "scala-swing",
OsgiKeys.exportPackage := Seq(s"scala.swing.*;version=${version.value}"),
scalaModuleMimaPreviousVersion := Some("2.1.0"),
// set the prompt (for this build) to include the project id.
ThisBuild / shellPrompt := { state => Project.extract(state).currentRef.project + "> " },
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest-flatspec" % "3.2.0" % Test,
"org.scalatest" %% "scalatest-shouldmatchers" % "3.2.0" % Test,
"org.scalatest" %% "scalatest-flatspec" % scalaTestVersion % Test,
"org.scalatest" %% "scalatest-shouldmatchers" % scalaTestVersion % Test,
),
// Adds a `src/main/scala-2.13+` source directory for Scala 2.13 and newer
// and a `src/main/scala-2.13-` source directory for Scala version older than 2.13
Compile / unmanagedSourceDirectories += {
val sourceDir = (Compile / sourceDirectory).value
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 13 => sourceDir / "scala-2.13+"
case Some((3, _)) => sourceDir / "scala-2.13+" // Dotty
case _ => sourceDir / "scala-2.13-"
}
}
)

lazy val examples = project.in(file("examples"))
.dependsOn(swing)
.settings(commonSettings)
.settings(
scalaVersion := (swing / scalaVersion).value,
run / fork := true,
Expand All @@ -32,6 +43,7 @@ lazy val examples = project.in(file("examples"))

lazy val uitest = project.in(file("uitest"))
.dependsOn(swing)
.settings(commonSettings)
.settings(
scalaVersion := (swing / scalaVersion).value,
run / fork := true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ object LinePainting extends SimpleSwingApplication {
var path = new geom.GeneralPath

def lineTo(p: Point): Unit = {
path.lineTo(p.x, p.y); repaint()
path.lineTo(p.x.toFloat, p.y.toFloat); repaint()
}

def moveTo(p: Point): Unit = {
path.moveTo(p.x, p.y); repaint()
path.moveTo(p.x.toFloat, p.y.toFloat); repaint()
}

override def paintComponent(g: Graphics2D): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ class ButtonHtmlDemo extends FlowPanel {
listenTo(enable)

reactions += {
case ButtonClicked(`enable`) => enableMiddle
case ButtonClicked(`disable`) => disableMiddle
case ButtonClicked(`enable`) => enableMiddle()
case ButtonClicked(`disable`) => disableMiddle()
}

def enableMiddle(): Unit = {
enable.enabled = false
middle.enabled = true
disable.enabled = true
enable .enabled = false
middle .enabled = true
disable .enabled = true
}
def disableMiddle(): Unit = {
enable.enabled = true
middle.enabled = false
disable.enabled = false
enable .enabled = true
middle .enabled = false
disable .enabled = false
}
def createImageIcon(path: String): Option[javax.swing.ImageIcon] = {
val imgURL: java.net.URL = getClass().getResource(path)
Expand Down
Loading