package bogue

  1. Overview
  2. Docs
GUI library for ocaml, with animations, based on SDL2

Install

Dune Dependency

Authors

Maintainers

Sources

20240225.tar.gz
md5=e03c1e72b29262bdeae37ffdfdb520b3
sha512=0d643de102fcf43847db11de6bcc640327f2d96175ef988b306fbb18c00906204be8c155b434692e3322d19f35d0260d4a6ebecfb05a5cb86258f59289fe4fe6

Description

Bogue is an all-purpose GUI library for ocaml, with animations, based on SDL2.

This library can be used for games or for adding GUI elements to any ocaml program.

It uses the SDL2 renderer library, which makes it quite fast.

It is themable, and does not try to look like your desktop. Instead, it will look the same on every platform.

Graphics output is scalable, and hence easily adapts to Hi-DPI displays.

Programming with bogue is easy if you're used to GUIs with widgets, layouts, callbacks, and of course it has a functional flavor. It uses Threads when non-blocking reactions are needed.

Tags

gui

Published: 27 Feb 2024

README

Bogue

Bogue is an all-purpose GUI (Graphical user interface) library for ocaml, with animations, written from scratch in ocaml, based on SDL2.

  • Can be used to add interactivity to any program.

  • Can work within an already existing event loop, for instance to add GUI elements to a game.

  • Uses GPU acceleration (thanks to the SDL2 renderer library), which makes it quite fast.

  • Can deal with several windows.

  • Bogue is themable, and does not try to look like your desktop. Instead, it will look the same on every platform.

  • Graphics output is scalable (without need to recompile), and hence easily adapts to Hi-DPI displays.

  • Predefined animations (slide-in, fade-in, fade-out, rotate).

  • Built-in audio mixer.

  • Works with mouse, touchscreen, and even TAB focusing

Programming with bogue is easy if you're used to GUIs with widgets, layouts, callbacks, and of course it has a functional flavor. ​It uses Threads when non-blocking reactions are needed.

Hello world

open Bogue

let () =
  Widget.label "Hello world"
  |> Layout.resident
  |> Bogue.of_layout
  |> Bogue.run

Features

Widgets

Widgets are the building bricks, responsible for graphic elements that respond to events (mouse, touchscreen, keyboard, etc.).

For a more "functional" use, they can be "connected" instead of reacting with callbacks (see examples).

  • boxes with decorations (round corner, border, shadow, gradient background, image pattern)

  • check box

  • push button (with labels or images)

  • rich text display (bold, italics, underline), any TTF font can be used.

  • image (all usual formats, including SVG)

  • slider (horizontal, vertical, or circular)

  • text input with select and copy-paste

  • SDL area for free drawing with the whole SDL Renderer API

Layouts

widgets can be combined in various ways into layouts. For instance, a check box followed by a text label is a common layout.

Several predefined layouts are available:

  • sliders (horizontal, vertical, circular). Can be used as progress bars

  • scrollable lists (that can easily handle a large number of elements, like one million)

  • multi-column tables with sortable columns

  • multiple tabs with slide-in animation

  • modal popups

  • various menus (menu bar, drop down menus with submenus)

  • drop-down select lists

  • radio lists

  • automatic tooltips can be attached to any element

Layouts can be animated (slide-in, transparency, rotation). All layouts can be automatically resized when the user resizes the window. Timeouts are available to execute arbitrary actions after a delay.

Screenshots

demo, tab1 demo, tab2
demo1 demo2

See here for the source code of this demo.

Videos

randomize, demo 1907

Installation

Using the opam package

It's the easiest way unless you want to try out the development version.

opam install bogue

That's it. But, if you want to stay in sync with the latest developement, you can directly "pin" the github repository:

opam pin add https://github.com/sanette/bogue.git

(Then update/upgrade opam). And this can easily be undone with

opam unpin https://github.com/sanette/bogue.git

Building from sources

Prerequisites

You need a working ocaml installation with opam, see the ocaml doc. Then, make sure you have dune, tsdl, tsdl-image and tsdl-ttf:

opam install dune tsdl tsdl-image tsdl-ttf

Get the latest source

Download the git archive, unzip it, cd into the bogue-master dir, and then:

dune build
opam install .

CI

https://ci.ocamllabs.io/github/sanette/bogue

Documentation

It's good to first have a look at Bogue's general principles.

You can also directly try the tutorials.

The public API can be found here.

Examples

You should first try a minimal example.

The examples directory contains more sophisticated examples. If you installed the bogue package with opam (as described above), these examples are available via the boguex program. For instance, run examples 34 and 41 by:

boguex 34 41

Type boguex -h to have the list of all examples.

A minimal app using Bogue

See here.

Dependencies (6)

  1. xdg >= "3.4.0"
  2. tsdl >= "0.9.7" & < "0.9.9"
  3. ocaml >= "4.08.0"
  4. tsdl-ttf >= "0.3"
  5. tsdl-image >= "0.3.0"
  6. dune >= "2.7"

Dev Dependencies (1)

  1. odoc with-doc

Conflicts

None

OCaml

Innovation. Community. Security.