Home

Awesome

scalaui

Scala Native GUI framework based on libui

Example text editor

How it looks like in elementary

scalaui-texteditor

Getting Started

Once you have setup your Scala Native project and enviroment, you have to compile libui and, on linux, copy the libui.so.0 and libui.so files to /usr/lib (probably you need to change their permissions too).

Then you have to add the following to your build.sbt:

libraryDependencies += "com.github.lolgab" %%% "scalaui" % "0.0.1"

(there is no release yet, you have to publishLocal the library to let it work!)

Then you can import scalaui:

import scalaui._

We want to create a simple window with a button that prints "Hello World!" on the console when clicked.

First you have to define a method which will be executed everytime the button is clicked:

def greeting(): Unit = println("Hello World!")

Then you create a button in your Main object, passing a name and the method name followed by a _:

val button = new Button("My Button", greeting _)

Then you create a window passing the button as content:

val window = new Window("My Window", width = 200, height = 200, content = button)

Then you can actually trigger the creation of the window with all its components in your main method:

def main(args: Array[String]) = {
  scalaui.render(window)
}

You now should see a nice window with a button, let's click it:

It works! :tada::tada::tada: