package bogue

  1. Overview
  2. Docs

A GUI Library for Ocaml

Entirely written in ocaml except for the hardware accelerated graphics library SDL2.

  • version 20190717 @author Vu Ngoc San

Quick start

For a quick start, see Bogue's general principles.

List of Modules

module Utils : sig ... end

Utilities

module Theme : sig ... end

Theming variables

module Time : sig ... end

Time in msec

module Var : sig ... end

Global variables with mutex

module Timeout : sig ... end

Delayed actions

module Trigger : sig ... end

Dealing with events

module Mixer : sig ... end

Basic audio mixer for sound effects

module Sync : sig ... end

Synchronized execution queue FIFO queue of actions to be executed by the main thread at each graphical frame. It is much easier to use this rather than letting actions be executed by various threads and try to guess in which order...

module Draw : sig ... end

Low-level graphics

module Mouse : sig ... end

Mouse information

module Tvar : sig ... end

Transform variables

module Avar : sig ... end

Animated variables

module Selection : sig ... end

Unions of ranges of integers

Widgets

Widgets are building blocks of the GUI. They also receive all events (mouse focus, etc.) and contain the intelligence of your GUI, through connections (or callbacks, see Widget.connection). However, in order to be displayed, they need to be packed into layouts (Layout.t).

module Image : sig ... end

Image widget

module Style : sig ... end

Line and box styles

module Label : sig ... end

One-line text widget

module Button : sig ... end

Button widget with text or icon

module Slider : sig ... end

Slider widget

module Check : sig ... end

Checkbox widget

module Text_display : sig ... end

Multi-line text display widget

module Text_input : sig ... end

One-line text-input widget

module Box : sig ... end

Box widget

module Widget : sig ... end

Creating and using widgets

module Update : sig ... end

Updating widgets

Layouts

Layouts are rectangular graphical placeholders, in which you should pack all your widgets in order to display your GUI. Sophisticated gadgets are usually obtained by combining several layouts together.

module Layout : sig ... end

The main, all-purpose graphics container

module Space : sig ... end

Adjust various spacings and sizes of layouts

module Print : sig ... end

Convert Bogue objects to strings for debugging

module Snapshot : sig ... end

Create an image from a Layout

module Long_list : sig ... end

Handle large lists by not displaying all elements at once

module Tabs : sig ... end

Switch between layouts using Tabs

module Popup : sig ... end

Put layouts on top of others

module Menu : sig ... end

Various types of menus

module Select : sig ... end

Drop-down select list

module Radiolist : sig ... end

Check list with a single choice

module Table : sig ... end

Tables with sortable columns and selectable rows

The Bogue mainloop

Because a GUI continuously waits for user interaction, everything has to run inside a loop.

module Main : sig ... end

Control the workflow of the GUI mainloop

module Bogue = Main

Alias for Main

Example

Here is a minimal example with a label and a check box.

open Bogue
module W = Widget
module L = Layout

let main () =

  let b = W.check_box () in
  let l = W.label "Hello world" in
  let layout = L.flat_of_w [b;l] in

  let board = Bogue.make [] [layout] in
  Bogue.run board;;

let () = main ();
  Draw.quit ()

This can be compiled to bytecode with

ocamlfind ocamlc -package bogue -linkpkg -o minimal -thread minimal.ml

and to native code with

ocamlfind ocamlopt -package bogue -linkpkg -o minimal -thread minimal.ml
OCaml

Innovation. Community. Security.