Fluid 0.6.0 — UI library for D

cookiewitch artha at samerion.com
Thu Jan 25 12:33:31 UTC 2024


Fluid is a library I started developing 3 years ago when I joined 
the D community, after failing to find a suitable library for my 
gamedev project. Developing user interfaces through websites, 
games or applications is something I've spent a significant 
amount of time in the past, so I saw this as an opportunity for 
developing a solution that combines the best aspects of different 
frameworks I have previously used, whereas targeted at web 
browsers, mobile applications, games or desktop. Similarly to how 
many praise D for being both great for prototyping and amazingly 
scalable, I found that I would love to build something that 
shares both of those traits.

![Hello World from 
Fluid!](https://git.samerion.com/Samerion/Fluid/media/branch/main/resources/hello-fluid.png)

Fluid is a flexible UI library for the D programming language. 
Minimal setup. Declarative. Non-intrusive.

```d
auto root = vspace(
     .layout!"center",
     label(
         .layout!"center",
         "Hello World from"
     ),
     imageView("./logo.png"),
);
```

Fluid is not standalone, but relies on other libraries to provide 
input and output facilities. It comes with build in support for 
[Raylib 5][raylib] and [arsd.simpledisplay][sdpy]. Integration is 
seamless, as one or two calls do the job.

```d
while (!WindowShouldClose) {

     BeginDrawing();

         ClearBackground(color!"#fff");
         root.draw();

     EndDrawing();

}
```

Fluid comes with a number of helpful nodes that you can use to 
build your interface. Communicate with the user using `label`, 
`button`, `textInput`, `fileInput`, `scrollInput`, and quickly 
build layouts using simple and easy to learn `space`, `frame`, 
`nodeSlot`, `grid`, `mapSpace`.

Fluid exposes a high-level API, provides layout capabilities that 
are responsive-by-default, Unicode support and text rendering 
with Freetype2, reliable mouse, keyboard and gamepad support, is 
themable, extensible and looks great on HiDPI displays.

Supported platforms: Windows, Linux, macOS*, with plans to 
support Android and WASM.

The showcase should be a nice introduction to the library, 
describing each feature, providing live examples and code 
snippets. It's still a work in progress, so don't expect it to be 
complete nor perfect by any means, but I hope to improve it with 
further updates.

```
dub run fluid:showcase
```

If you'd like to start a new DUB projects with Fluid, you can 
start with a template:

```
dub init -t fluid
```

## Release 0.6.0

While I still have work to do to make Fluid as good as I want it 
to be, both in regards of performance and usability, I believe 
that 0.6.0, being the biggest update yet, is a breakthrough 
moment in Fluid's development, and the library is only about to 
gain stability.

Most importantly, 0.6.0 is the first release to no longer 
exclusively rely on Raylib. As noted earlier, it's already 
possible to use Fluid with [arsd.simpledisplay][sdpy]. This opens 
a lot of new possibilities, since Fluid could be used with 
*anything* as long as you implement the `FluidBackend` interface.

This release also completely reworked input, making the entire 
interface immediately controllable with tabs and arrow keys. All 
mouse, keyboard and gamepad binds are configurable and can easily 
be used in user-provided nodes via Input Actions. It is also the 
first to introduce the new showcase. A full changelog is 
available on 
https://git.samerion.com/Samerion/Fluid/releases/tag/v0.6.0

## The future

Fluid is still lacking a number of features. Speaking of numbers, 
no `numberInput`, for example. But having just reinforced the 
code of the library, I think it's a great time to add all that is 
now missing, see 
<https://git.samerion.com/Samerion/Fluid/issues/74>. Despite of 
this, Fluid is already in a great state and can be used in 
practical scenarios. New nodes aren't difficult to add.

The roadmap for Fluid sees just two missing major pre-releases, 
with only one of them possibly introducing any greater breaking 
changes. The theming system needs a refactor, which I believe 
will make it more powerful and easier to use, and I plan to do so 
in 0.7.0.

Changes I made to the backend side of Fluid make it possible to 
expand the reach of Fluid. I'm interested in making it work with 
[Hipreme Engine](https://github.com/MrcSnm/HipremeEngine) because 
of the engine's great portability. I'm also very excited to 
expand outside of game development and try and make the library 
integrate with naive UI frameworks or at least mimic their look.

Later on, along with 0.8.0, I plan to develop a graphical, live 
editor for Fluid user interfaces, with support for debugging and 
analysis of running programs.

## Maintenance

It's typical for many D projects now that they come and go, 
libraries are born out of hobby projects just to be forgotten and 
abandoned later. Will this happen to Fluid?

Fluid has mostly been developed in bursts. Development slows 
downs or stops for some time, then resumes with me pushing a lot 
of changes and new features. This is a model that I find 
necessary since I'm the sole maintainer. Fluid however, has been 
in development for 3 years now, which bodes it well in regards to 
its future. Moreover, now almost every project of mine depends on 
Fluid in one way or another.

I'm active on the [D language 
Discord](https://discord.gg/MZ9eB37Uta), and in the future I 
might also consider the option of commercial support, if someone 
finds it needed.

Even if at this point Fluid doesn't satisfy all needs, I really 
hope in the future it'll grow to be a suitable solution for 
developing different kinds of user interfaces.

[raylib]: https://www.raylib.com/
[sdpy]: https://arsd-official.dpldocs.info/arsd.simpledisplay.html


More information about the Digitalmars-d-announce mailing list