Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lolgab/scalaui
Scala Native GUI framework based on libui
https://github.com/lolgab/scalaui
cocoa gtk gui libui scala scala-native win32
Last synced: 28 days ago
JSON representation
Scala Native GUI framework based on libui
- Host: GitHub
- URL: https://github.com/lolgab/scalaui
- Owner: lolgab
- License: mit
- Created: 2017-09-14T19:16:31.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-07-18T16:14:34.000Z (5 months ago)
- Last Synced: 2024-11-07T12:45:58.820Z (about 1 month ago)
- Topics: cocoa, gtk, gui, libui, scala, scala-native, win32
- Language: Scala
- Homepage:
- Size: 120 KB
- Stars: 68
- Watchers: 8
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-scala-native - libui - GUI framework based on [libui](https://github.com/andlabs/libui). (Bindings)
README
# scalaui
Scala Native GUI framework based on [libui](https://github.com/andlabs/libui)## Example text editor
![How it looks like in elementary](https://image.ibb.co/cMVcgw/editor.png)[scalaui-texteditor](https://github.com/lolgab/scalaui-texteditor/)
## Getting Started
Once you have setup your Scala Native project and enviroment, you have to compile [libui](https://github.com/andlabs/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:
```scala
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:
```scala
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:
```scala
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 `_`:
```scala
val button = new Button("My Button", greeting _)
```Then you create a window passing the button as content:
```scala
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:
```scala
def main(args: Array[String]) = {
scalaui.render(window)
}
```
You now should see a nice window with a button, let's click it:![](https://image.ibb.co/bWFa1w/scalaui.png)
### It works! :tada::tada::tada: