Skip to content

Application

mdavisprog edited this page Apr 5, 2023 · 2 revisions

Application

The Application class encapsulates the GUI controls used for all windows of an application. Callbacks must also be provided to handle the various events that occur within the application that allow for the implementer to manage rendering and event handling while the library manages the GUI controls and their states.

There should only be a single instance of the Application class for any applications using OctaneGUI. Once all callbacks are registered and Initialized has been called, the Run function must be called to begin the GUI event loop.

Functions

Name Description
Initialize This is the first function that needs to be called before anything else in order to use the Application object. The JSON stream given must include certain properties:

  • Theme: This should be the name of the file that contains a list of definitions to define the look of the application.
  • Icons: A JSON object that defines the icons to be used.
  • Windows: List of windows to create for this application. A 'Main' window must always be defined.
  • HighDPI: A boolean flag to determine if the implementing frontend should support high DPI awareness.
  • CustomTitleBar: Forces all windows to be created with no system title bar.
  • UseSystemFileDialog: Notifies the FileSystem object to use the system's file dialog instead of the custom one using the libraries controls.


The second parameter is a reference to a map<string, ControlList>, which returns all controls that has a 'ID' property in their JSON for their respective window defined by a string.

JsonStreamA JSON string object with the above properties defined. WindowControlsList of controls that has a defined 'ID' property within their JSON description for any defined window. True if initialized successfully. False otherwise.
Shutdown This function can be called manually, but is also called automatically when the Run function has ended.
Update The state of each window is updated with each call to Update. The windows keep tracks of all controls that need to be updated. Most of the time, no updates will occur if no controls need to be layed out.

This will also perform any re-painting of invalidated windows.
Run This function will run every loop iteration as a frame and will sleep if no updates occurred within the frame. This is a blocking function and the object will be cleaned up when this returns. Exit code for the function. 0 is success.
Quit Forces the application to break out of the Run loop.
GetMainWindow std::shared_ptr object.
GetWindow IDString representing the window ID. std::shared_ptr object.
IsMainWindow InWindowPointer to a Window object. True if the given window is the Main window. False otherwise.
HasWindow To clarify, this does not mean the Window has a frontend representation i.e. a system window. Just that a Window object and all of its contents exists.

IDString representing the window ID. True if the Window object exists. False otherwise.
NewWindow This function will only create the window object, but will not display the window. Use the DisplayWindow function to notify the frontend to create a system window.

IDString representing the Window object. JsonStreamJSON object defining the controls for the given window. Refer to the Window documentation on the details of the JSON object. std::shared_ptr object.
NewWindow IDString representing the Window object. JsonStreamJSON object defining the controls for the given window. Refer to the Window documentation on the details of the JSON object. ListList of controls that have ID properties defined for them. std::shared_ptr object.
DisplayWindow IDString representing the Window object. True if displayed by frontend or already displayed. False otherwise.
CloseWindow IDString representing the Window object.
GetTheme std::shared_ptr object.
GetIcons std::shared_ptr object.
GetTextureCache TextureCache reference.
SetClipboardContents This function will invoke the callback given to SetOnSetClipboardContents which should be implemented by the frontend.

ContentsString to add to the clipboard.
ClipboardContents This function will invoke the callback given to SetOnGetClipboardContents which should be implemented by the frontend.

String value of the system's clipboard contents.
SetMouseCursor This function will invoke the callback given to SetOnSetMouseCursur which should be implemented by the frontend.

TargetThe Window object requesting the change. CursorThe mouse cursor type defined by the Cursor enum. The Application object for chaining.
FS const FileSystem reference.
FS FileSystem reference.
LS const LanguageServer reference.
LS LanguageServer reference.
SetOnWindowAction This callback is invoked whenever a window requests an action to occur in the frontend, such as window creation, destruction, reposition, etc. Refer to the WindowAction enum for a list of actions that may be requested.

FnThe OnWindowActionSignature callback. The Application object to allow for chaining methods.
SetOnPaint This callback is invoked whenever a Window object needs to be repainted due to any updates that may have occurred within the window.

FnThe OnWindowPaintSignature callback. The Application object to allow for chaining methods.
SetOnNewFrame A new frame occurs during a Run loop whenever a new iteration begins and before any updates to Window objects are applied.

FnAn OnEmptySignature callback. The Application object to allow for chaining methods.
SetOnEvent This callback is invoked during the Run loop and for each Window. This callback will continued to be invoked for a Window until an Event type of None is returned.

FnThe OnWindowEventSignature callback. The Application object to allow for chaining methods.
SetOnLoadTexture This callback is invoked whenever the library makes a request to load a texture.

FnThe OnLoadTextureSignature callback. The Application object to allow for chaining methods.
SetOnExit This is a good time for the frontend to cleanup any allocated resources.

FnAn OnEmptySignature callback. The Application object to allow for chaining methods.
SetOnSetClipboardContents FnThe OnSetClipboardContentsSignature callback. The Application object to allow for chaining methods.
SetOnGetClipboardContents FnThe OnGetClipboardContentsSignature callback. The Application object to allow for chaining methods.
SetOnSetWindowTitle Whenever a Window object's title has changed, this callback will be invoked to notify the frontend to change the system window's title.

FnThe OnSetWindowTitleSignature callback. The Application object to allow for chaining methods.
SetOnSetMouseCursor FnThe OnSetMouseCursorSignature callback. The Application object to allow for chaining methods.

Clone this wiki locally