Skip to content
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

Setup microsite #45

Merged
merged 1 commit into from
Aug 13, 2023
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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ To know more about the library and how to get started check the [examples](https
- Text
- Buttons
- Checkboxes
- Radio Buttons
- Radio buttons
- Select boxes
- Sliders
- Text Input
- Movable components (including windows)
- Text input
- Movable/Closable windows

### Layouts

Expand Down
19 changes: 8 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@ ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision
ThisBuild / scalafixOnCompile := true

def docSettings(projectName: String) = Seq(
val siteSettings = Seq(
Compile / doc / scalacOptions ++= (
Seq(
"-project",
projectName,
"-project-version",
version.value,
"-social-links:" +
"github::https://github.com/JD557/interim"
)
if (scalaBinaryVersion.value.startsWith("3"))
Seq("-siteroot", "docs")
else Seq()
)
)

Expand All @@ -44,10 +39,12 @@ lazy val core = (projectMatrix in file("core"))
Compile / doc / scalacOptions ++=
Seq(
"-project",
"interim",
"InterIm",
"-project-version",
version.value,
"-social-links:github::https://github.com/JD557/interim"
"-social-links:github::https://github.com/JD557/interim",
"-siteroot",
"docs"
)
)
.jvmPlatform(scalaVersions = Seq("3.3.0"))
Expand Down
59 changes: 59 additions & 0 deletions docs/_docs/advanced-usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: Advanced Usage
---

# Advanced Usage

## Custom Backends

InterIm applications will usually be function of the type
`(InputState, UiContext) => (List[RenderOp], Unit)` or `(InputState, UiContext, ApplicationState) => (List[RenderOp], ApplicationState)` (depending on how pure the application is).

For simplicity, let's assume a mutable app in this example.

```scala
def application(inputState: InputState, uiState: UiState) = ??? // Our application code
```

The first thing that the backend needs to do is to create an `UiContext`. This is a class that will keep the internal mutable state of the UI.

```scala
val uiContext = new UiContext()
```

Then, in the render loop, the backend needs to:
- Build the input state
- Call the application code
- Render the operations

```scala
while (true) // Hypothetical render loop
val inputState: InputState =
InputState(
mouseX = ???,
mouseY = ???,
mouseDown = ???,
keyboardInput = ???
)
val (renderOps, _) = application(inputState, uiContext)
renderOps.foreach {
case op: RenderOp.DrawRect => ??? // Draw Rectangle
case op: RenderOp.DrawText => ??? // Draw Text
case op: RenderOp.Custom => ??? // Custom logic
}
```

And that's it!

## Custom operations

You might have noticed the `RenderOp.Custom` in the example above.

This operation is designed so that you can extend InterIm with your own operations (e.g. draw a circle). The default InterIm components will never use this operation.

Custom operations are defined as:
```scala
final case class Custom[T](area: Rect, color: Color, data: T) extends RenderOp
```

Notice the `area` and the `color`. This allows you to simply draw a colored rectangle when you receive a custom operation that your backend is not able to interpret.
32 changes: 32 additions & 0 deletions docs/_docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Getting Started
---

# Getting Started

To include InterIm, simply add the `interim` library to your project:

```scala
// JVM Only
libraryDependencies += "eu.joaocosta" %% "interim" % "{{ projectVersion }}"
// For JVM/JS/Native cross-compilation
libraryDependencies += "eu.joaocosta" %%% "interim" % "{{ projectVersion }}"
```

## Tutorial

The easiest way to start using the library is to follow the tutorials in the [`examples`](https://github.com/JD557/minart/tree/master/examples) directory.

The examples in [`examples/release`](https://github.com/JD557/minart/tree/master/examples/release) target the latest released version,
while the examples in [`examples/snapshot`](https://github.com/JD557/minart/tree/master/examples/snapshot) target the code in the repository.

All the examples are `.md` files that can be executed via [scala-cli](https://scala-cli.virtuslab.org/).

## Example backend

Since InterIm doesn't come with any graphical backend, it's quite useless to create apps with just
InterIm.

However, on the examples folder you will find a simple backend powered by [Minart](https://github.com/jd557/minart)
in `example-minart-backend.scala`.
While this backend is quite limited, it is powerful enough for most small projects.
30 changes: 30 additions & 0 deletions docs/_docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: InterIm
---

<h1>InterIm</h1>

<h2>What is InterIm?</h2>
<p>
IterIm is a minimal Scala library for immediate mode GUIs.
</p>

<p>
The library itself doesn't perform any rendering or IO by itself, but it provides a simple interface so that it can be
easilly integrated on custom backends: The backend sends InterIm the current input and gets back a list of colored
rectangles and text regions to render.
</p>

<p>
The lack of a backend also ensures that the library can be used in JVM, Scala.js and Scala Native applications.
</p>

<h2>Development status</h2>
<p>
InterIm is still in a <strong>0.x version</strong>. Quoting the semver specification:
<blockquote>
Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable.
</blockquote>

As such, while it's OK to use InterIm for small demos, it's not recommended to use it for commercial projects.
</p>
39 changes: 39 additions & 0 deletions docs/_docs/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: Feature Overview
---

# Feature Overview

## Cross-compilation

InterIm can target **JVM**, **JS** and **Native**.

## Simple integration with custom backends

InterIm is designed to be simple to integrate with other graphical applications, such as
Minart demos or Indigo games.

## Supported features

### Primitives and Components

- Rectangles
- Text
- Buttons
- Checkboxes
- Radio buttons
- Select boxes
- Sliders
- Text input
- Movable/Closable windows

### Layouts

- Grid based
- Row based (equally sized or dynamically sized)
- Column based (equally sized or dynamically sized)

### Skins

- Configurable skins for all components
- Light and dark mode
8 changes: 8 additions & 0 deletions docs/sidebar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
index: index.html
subsection:
- title: Feature Overview
page: overview.md
- title: Getting Started
page: getting-started.md
- title: Advanced Usage
page: advanced-usage.md
2 changes: 1 addition & 1 deletion examples/snapshot/1-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Now that our application is defined, we can call it from our backend:
In pseudo code, this looks like the following:

```
val uiContext = new UiContext
val uiContext = new UiContext()

def application(inputState: InputState) = ??? // Our application code

Expand Down
Loading