Coder Social home page Coder Social logo

scalaswingcontrib's Introduction

ScalaSwingContrib

A collection of community-contributed extensions to Scala Swing, including

  • A Tree and TreeModel for wrapping JTree, contributed by Ken Scambler & Sciss
  • A GroupPanel to display items using javax.swing.GroupLayout, contributed by Andreas Flierl
  • A PopupMenu wrapper contributed by https://github.com/sullivan-
  • A ColorChooser contributed by Andy Hicks
  • RichColor enriches java.awt.Color with methods to move around in color space, contributed by Ben Hutchison
  • AbsoluteLayoutPanel supports absolute layouts (Swing's null LayoutManager) in ScalaSwing, contributed by Ben Hutchison and Ken Scambler
  • RichFont enriches java.awt.Font

All classes reside in the scalaswingcontrib package namespace.

ScalaSwingContrib is derived from https://github.com/kenbot/scala-swing and https://github.com/ingoem/scala-swing/pulls, and is maintained by Ben Hutchison and Ken Scambler.

Changelog

  • 1.4: Not Recorded
  • 1.5 April 2013: Fixes/enhancements to Tree (thanks @Sciss)
  • 1.6 Dec 2015: Fixes/enhancements to Tree (thanks @OndrejSpanel)
  • 1.7 Nov 2016: Scala 2.12, library upgrades, jdk8 only
  • 1.8 Jan 2020: Scala 2.13, drops 2.10.x (thanks @OndrejSpanel)
  • 1.9 Apr 2022: Scala 3.x, drops 2.11 (thanks @OndrejSpanel)

Maven details

1.9 is Cross-built for 2.12.x, 2.13.x and 3.1.x:

"com.github.benhutchison" %% "scalaswingcontrib" % "1.9"

Publishing Instructions

Ensure sonatype credentials at $HOME/.sbt/(sbt-version)/sonatype.sbt More info

+publishSigned

sonatypeRelease

Other

Bug reports and pull requests welcome.

Be aware that ScalaSwingContrib is intended to be strictly an extension, not a modification to ScalaSwing, so changes to existing ScalaSwing APIs should be submitted to the core Scala team.

scalaswingcontrib's People

Contributors

benhutchison avatar freewind avatar kenbot avatar ondrejspanel avatar sciss avatar tommycli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

scalaswingcontrib's Issues

GroupPanel type woes

I am regularly running into trouble trying to figure out how to massage my components to fit into the GroupPanel's groups. I have come up with all sorts of crazy type conversions, and once again I forgot how I managed. It would be great to have an example that shows how to accomplish the IMO standard case of creating a group from a collection of widgets:

val labels  = (1 to 10).map(i => new Label(i.toString))
val fields  = (1 to 10).map(i => new TextField(10))

new GroupPanel {
  theHorizontalLayout is Sequential(
    Parallel(labels: _*), Parallel(fields: _*)  // type mismatch: required: Seq[this.InParallel]
  )
  theVerticalLayout is Sequential(              // type mismatch: required: Seq[this.InSequential]
    (labels zip fields).map { case (lb, f) =>
      Parallel(Baseline)(lb, f)
    }: _*
  )
}

This drives me nuts. InParallel and InSequential are private types, so the straight forward : InParallel doesn't work.

Am I blind not to see the solution?

Tree: Should treePathToPath handle null? And how?

The documentation says

/**
 * Implicitly converts javax.swing.tree.TreePath objects to Tree.Path[A] lists recognised in Scala Swing.  
 * TreePaths will include the underlying JTree's hidden root node, which is omitted for Tree.Paths.
 */
implicit def treePathToPath(tp: jst.TreePath): Path[A] = model treePathToPath tp

And treePathToPath maps null to null. Since as I understand, the Scala version drops root from the path, we cannot use Path.empty here, right?

Then I suggest that getClosestPathForLocation should return an Option[Path[A]] instead of a nullable Path[A].

Scala 2.13 support - future of this project?

Will this package be released for 2.13?

I will be happy do attempt the porting needed on the source code, as long as I know the version will be eventually released to 2.13.

Or should it be instead merged into scala.swing and released to 2.13 as part of it (#19)? If it should, what could one do for this to happen?

Release for 2.11

We should release a version for 2.11. Do we have crossbuilds, with scalaswingcontrib_2.10.4, scalaswingcontrib_2.11.0 and this kind of thing? It might be a thing to consider if not.

Bad match in dispatchToScalaRenderer - hiddenRoot not matching

When working with a Tree with InternalTreeModel I have experienced an exception when changing a model. The exception is because function dispatchToScalaRenderer matches value against TreeModel.hiddenRoot, but the object in value is actually of type DefaultMutableTreeNode, and therefore cannot match. I think what should be matched is a userObject member of the DefaultMutableTreeNode, not the value itself.

The dispatchToScalaRenderer is called from getTreeCellRendererComponent / getNodeDimensions.

ExternalTreeModel skips insertFunc and removeFunc on root level

I was chasing a bug when finally arriving at step debugging into model insertions and deletions with ExternalTreeModel. My external insertFunc and removeFunc keep a children list up to date, so I was bitten in the foot by insertUnder and remove when the changes happen on the root level.

Perhaps I'm misunderstanding the external model (still), but IMO it makes no sense that insertFunc and removeFunc are only called on sub trees but not the root level. E.g.

def insertUnder(parentPath: Path[A], newValue: A, index: Int): Boolean = {
  val succeeded = if (parentPath.nonEmpty) {
    insertFunc(parentPath, newValue, index)
  }
  else {     // not call to insertFunc !!
    val (before, after) = rootsVar splitAt index
    rootsVar = before ::: newValue :: after
    true 
  }
  ...
}

Shouldn't that be

def insertUnder(parentPath: Path[A], newValue: A, index: Int): Boolean = {
  val succeeded = insertFunc(parentPath, newValue, index)
  if(parentPath.isEmpty) {
    val (before, after) = rootsVar splitAt index
    rootsVar = before ::: newValue :: after
  }
  ...
}

?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.