module Bogue: MainAlias for Main
type board
The board is the whole universe of your GUI. It contains everything. Most
of the time, though, you don't really care, because you will immediately
run your board after creating it, like in run (of_layout my_layout).
However, nothing prevents you from creating several boards and finally choosing the one you want to run. What you should not do is to simultaneously run several boards in different threads, because SDL can manage events only from the main thread.
type shortcuts
Shortcut maps can be passed to the board to associate an arbitrary action with specific keys (like quitting when ESC is pressed). See Creating global keyboard shortcuts.
exception Exit
Raising the Exit exception will tell the GUI loop to terminate.
val create : ?shortcuts:shortcuts ->
?connections:Widget.connection list ->
?on_user_event:(Tsdl.Sdl.event -> unit) ->
Window.t list -> boardCreate a board from a list of layouts and connections. The list of
connections can be empty, because connections can be added
afterwards. Each Layout in the list will open as a new window.
shortcuts : This optional argument is a shortcut map.on_user_event : This optional argument is a function to be executed
(by the main thread) when a Trigger.user_event is emitted.val get_monitor_refresh_rate : board -> int optionget_monitor_refresh_rate board returns the monitor refresh rate, for the
monitor containing board. In case of several monitors with different
refresh rates, return the greatest common divisor, or the minimum if the
gcd is less than 30.
val of_windows : ?shortcuts:shortcuts ->
?connections:Widget.connection list ->
?on_user_event:(Tsdl.Sdl.event -> unit) ->
Window.t list -> boardSynonym for Main.create. (Since 20220418)
val of_layouts : ?shortcuts:shortcuts ->
?connections:Widget.connection list ->
?on_user_event:(Tsdl.Sdl.event -> unit) ->
Layout.t list -> boardSimilar to Main.create. Each layout in the list will be displayed in a
different window. (Since 20220418)
val of_layout : ?shortcuts:shortcuts ->
?connections:Widget.connection list ->
?on_user_event:(Tsdl.Sdl.event -> unit) -> Layout.t -> boardSimilar to Main.of_layout but with only one layout. (Since 20220418)
val make : ?shortcuts:shortcuts ->
Widget.connection list -> Layout.t list -> boardSimilar to Main.of_layouts.
val run : ?vsync:bool ->
?before_display:(unit -> unit) ->
?after_display:(unit -> unit) -> board -> unitThis is finally how you run your app! It creates the SDL windows
associated with the Window.ts registered with the board, and launches
the main loop. This function only returns when all windows are closed (in
case at least one window was created), or when the Main.Exit exception is
raised.
vsync defaults to true and enables synchronization to monitor refresh rate
where possible, otherwise a 60 FPS Time.adaptive_fps is used.
A shortcut consists of two integers: one for the key modifier (shift, ctrl, etc.) and one for the key code (from SDL table), plus an action to be executed when this key combination is pressed.
For the shortcuts to take effect, one has to pass a shortcuts argument
to the board creating functions. This argument can be created with
shortcuts_of_list, or by using the shortcuts_add* functions below.
typeshortcut_action =board -> unit
val shortcuts_of_list : (Tsdl.Sdl.keymod * Tsdl.Sdl.keycode * shortcut_action) list ->
shortcutsConstruct shortcuts from a list of (SDL keycode, SDL keymod, action).
val exit_on_escape : Tsdl.Sdl.keymod * Tsdl.Sdl.keycode * shortcut_actionThe exit_on_escape shortcut will raise the Main.Exit exception upon
pressing the Escape key.
val shortcuts_empty : unit -> shortcuts
val shortcuts_add : shortcuts ->
?keymod:Tsdl.Sdl.keymod ->
Tsdl.Sdl.keycode -> shortcut_action -> shortcuts
val shortcuts_add_ctrl : shortcuts ->
Tsdl.Sdl.keycode -> shortcut_action -> shortcuts
val shortcuts_add_ctrl_shift : shortcuts ->
Tsdl.Sdl.keycode -> shortcut_action -> shortcuts
val get_shortcut : ?map:shortcuts ->
?keymod:Tsdl.Sdl.keymod -> int -> shortcut_action option
val remove_shortcut : ?board:board -> ?keymod:Tsdl.Sdl.keymod -> int -> unit
val add_shortcut : ?board:board ->
?keymod:Tsdl.Sdl.keymod -> int -> shortcut_action -> unitSee the embed example.
val make_sdl_windows : ?windows:Tsdl.Sdl.window list -> board -> unitThis is only useful if you have your own graphics loop, and do not use
Main.run. This function creates an SDL window for each top layout in the
board. One can use predefined windows with the optional argument
windows. They will be host the layouts in the order they appear in the
list. If there are fewer windows than layouts, new windows are created. If
there are more, the excess is disregarded.
val refresh_custom_windows : board -> unitAsk the GUI to refresh (ie. repaint) the custom windows (those that were not created by Bogue itself).
val one_step : ?before_display:(unit -> unit) ->
bool ->
(unit -> unit) * (unit -> unit) -> ?clear:bool -> board -> boolThis is only useful if you have your own graphics loop, and do not use
Main.run. Calling one_step ~before_display anim (start_fps, fps) ~clear is what is executed at each step of the Bogue mainloop. If
boardanim=true this step is non blocking; this is what you want if either
Bogue or your loop has an animation running. If anim=false then the
function will wait until an event is received.
true if the GUI currently handles an animation. In this case
fps() was executed by one_step. If not, you should handle the frame rate
yourself.val get_frame : unit -> intNumber of displayed frames since startup.
val quit : unit -> unit