Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

GUI library for ocaml based on SDL2

License

NotificationsYou must be signed in to change notification settings

sanette/bogue

Repository files navigation

Bogue is an all-purpose GUI (Graphical user interface) library forocaml, with animations, written from scratch inocaml, based onSDL2.

  • Can be used to add interactivity to any program.
  • Can work within an already existing event loop, for instance to addGUI elements to a game.
  • UsesGPU acceleration (thanks to theSDL2 renderer library),which makes it quite fast.
  • Can deal with several windows.
  • Bogue isthemable, and does not try to look like yourdesktop. Instead, it will look the same on every platform.
  • Graphics output is scalable (without need to recompile), and henceeasily adapts toHi-DPI displays.
  • Predefined animations (slide-in, fade-in, fade-out, rotate).
  • Built-in audio mixer.
  • Works with mouse, touchscreen, and even TAB focusing

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

Hello world

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

Features

Widgets

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

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

  • boxes with decorations (round corner, border, shadow, gradientbackground, 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, acheck 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
  • file chooser

Layouts can beanimated (slide-in, transparency, rotation). Alllayouts can be automaticallyresized when the user resizes thewindow.Timeouts are available to execute arbitrary actions aftera delay.

Screenshots

demo, tab1demo, tab2
demo1demo2

Seehere for the source codeof this demo.

Videos

randomize,demo 1907

Installation

Using the opam package

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

opam install bogue

That's it.But, if you want to stay in sync with the latestdevelopement, 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

SDL2 troubleshooting

Bogue needs the SDL2 library. In general you already have itinstalled, or, if everything goes smoothly, it will be installedautomatically withopam install tsdl.However,tsdl is not ableto automatically pick up the right version corresponding to your SDL2version. You might have to tellopam the version you need: forinstance for Bogue 20240928 on Ubuntu 20.04 you shouldopam install tsdl.1.0.0, because the more recenttsdl.1.1.0 requiresSDL >= 2.0.18 which you probably don't have on your system.

Seehttps://github.com/dbuenzli/tsdl/blob/master/CHANGES.md

Building from sources

Prerequisites

You need a workingocaml installation withopam, see theocaml doc. Then, make sureyou havedune,tsdl,tsdl-image andtsdl-ttf:

opam install dune tsdl tsdl-image tsdl-ttf

Get the latest source

Download thegit archive,unzip it, cd into thebogue-master dir, and then:

dune buildopam install .

CI

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

Documentation

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

You can also directly try thetutorials.

The public API can be foundhere.

Examples

You should first try aminimal example.

Theexamples directory contains more sophisticated examples. If youinstalled thebogue package withopam (as described above), theseexamples are available via theboguex program. For instance, runexamples 34 and 41 by:

boguex 34 41

Typeboguex -h to have the list of all examples.

A minimal app using Bogue

Seehere.


[8]ページ先頭

©2009-2025 Movatter.jp