Stk.App
STK application.
The way SDL events are handled.
`Detached
means that events are handled in a detached Lwt thread,`Lwt_engine
will register event handling in Lwt loop.val init :
?force_mouse_focus_clickthrough:bool ->
?window_flags:Tsdl.Sdl.Window.flags ->
?renderer_flags:Tsdl.Sdl.Renderer.flags option ->
?event_delay:int ->
?sdl_events_mode:sdl_events_mode ->
unit ->
unit Lwt.t
Initializing the application. Optional arguments:
force_mouse_focus_clickthrough
will set the MOUSE_FOCUS_CLICKTHROUGH hint. Default is true
.window_flags
sets the default flags used when creating windows. Default is no flag.renderer_flags
sets the default flags used when creating windows. If not provided, the content of the STK_APP_RENDERER_FLAGS
environment variable is used to retrieve comma-separatd list of flags (among "software", "accelerated", "presentvsync" and "targettexture"). For example, to use the accelerated renderer by default, you can run your application with
$ STK_APP_RENDERER_FLAGS=accelerated,presentvsync ./my_app
event_delay
indicates the timeout delay (in ms) when polling events (in `Detached
mode) or the timer delay (in `Lwt_engine
mode).sdl_events_mode
sets the way to handle sdl events. Default is `Lwt_engine
.Note that when the application is initialized, it is not run yet and run
must be called to handle events.
val app : unit -> app
Returns the application. Raises Failure
if application is not initialized.
val create_window :
?modal_for:Window.window ->
?flags:Tsdl.Sdl.Window.flags ->
?rflags:Tsdl.Sdl.Renderer.flags ->
?resizable:bool ->
?show:bool ->
?x:int ->
?y:int ->
?w:int ->
?h:int ->
string ->
Window.window
create_window title
creates a new window with the given title. Application must have been initialized.
Windows should be created with this function rather than directly using function and classes of the Window
module, because they must be registered in the application, so that events are correctly propagated.
Optional arguments:
modal_for
can be used to block a given window while the new window is not closed.flags
are passed to SDL to create the window. Default flags are the application window flags.rflags
are passed to SDL to create the window renderer. Default flags are the application renderer flags.resizable
specifies whether to add the resizable flag to windows flags.show
specifies whether to show the window after its creation (default is true
).x
sets the initial x position of the window.y
sets the initial y position of the window.w
sets the initial width of the window.h
sets the initial height of the window.Note that when the window is not resizable, then it will have automatic width if no width is specified and automatic height if no height is specified. Automatic means depending of the contents required min width and height.
val create_scrolled_window :
?modal_for:Window.window ->
?flags:Tsdl.Sdl.Window.flags ->
?rflags:Tsdl.Sdl.Renderer.flags ->
?resizable:bool ->
?show:bool ->
?x:int ->
?y:int ->
w:int ->
h:int ->
?hpolicy:Bin.PScrollbar_policy.t ->
?vpolicy:Bin.PScrollbar_policy.t ->
string ->
Window.window * Bin.scrollbox
Same as create_window
but creates also a Bin.scrollbox
, which is has child of the window and returned. The child of the window being a Bin.scrollbox
, it has no minimum width and height, so w
and h
arguments are mandatory when creating the window. Additional optional arguments:
hpolicy
policy to display horizontal scrollbar.vpolicy
policy to display vertical scrollbar.val stop : app -> unit
stop app
stops the application. Application can be run again.
popup_menu widget
creates and display a menu window, i.e. e window with no decoration. Menu windows are handled specially, being all closed usually when a menu item is activated. Optional arguments:
x
: initial x position of the window.y
: initial y position of the window.on_close
: callback called when the window is closed. the boolean argument indicates whether this is the last menu window to be closed.close_menu_windows ()
closes all menu windows.