Loading...
Searching...
No Matches
Appabstract

#include <AppCore/App.h>

Overview

Main application singleton (use this if you want to let the library manage window creation).

This convenience class sets up everything you need to display web-based content in a desktop application.

The App class initializes the Platform singleton with OS-specific defaults, creates a Renderer, and automatically manages window creation, run loop, input events, and painting.

Creating the App

Call App::Create() to initialize the library and create the App singleton.

auto app = App::Create();
static RefPtr< App > Create(Settings settings=Settings(), Config config=Config())
Create the App singleton.

Creating a Window

Call Window::Create() to create one or more windows during the lifetime of your app.

auto window = Window::Create(app->main_monitor(), 1024, 768, false,
static RefPtr< Window > Create(Monitor *monitor, uint32_t width, uint32_t height, bool fullscreen, unsigned int window_flags)
Create a new Window.
@ kWindowFlags_Titled
Definition Window.h:78
@ kWindowFlags_Resizable
Definition Window.h:79

Creating an Overlay in a Window

Each Window can have one or more Overlay instances. Overlays are used to display web-based content in a portion of the window.

Call Overlay::Create() to create an overlay in a window.

auto overlay = Overlay::Create(window, 1024, 768, 0, 0);
static RefPtr< Overlay > Create(RefPtr< Window > window, uint32_t width, uint32_t height, int x, int y)
Create a new Overlay.

Each Overlay has a View instance that you can use to load web content into.

overlay->view()->LoadURL("https://google.com");

Running the App

Call App::Run() to start the main run loop.

using namespace ultralight;
int main() {
// Initialize app, window, overlay, etc. here...
app->Run();
return 0;
}
Definition App.h:14

Shutting Down the App

Call App::Quit() to stop the main run loop and shut down the app.

app->Quit();
Note
This is optional, you can use the Renderer class directly if you want to manage your own windows and run loop.
Inheritance diagram for App:
RefCounted

Static Public Member Functions

static RefPtr< AppCreate (Settings settings=Settings(), Config config=Config())
 Create the App singleton.
 
static Appinstance ()
 Get the App singleton.
 

Public Member Functions

virtual const Settingssettings () const =0
 Get the settings this App was created with.
 
virtual void set_listener (AppListener *listener)=0
 Set an AppListener to receive callbacks for app-related events.
 
virtual AppListenerlistener ()=0
 Get the AppListener, if any.
 
virtual bool is_running () const =0
 Whether or not the App is running.
 
virtual Monitormain_monitor ()=0
 Get the main monitor (this is never NULL).
 
virtual RefPtr< Rendererrenderer ()=0
 Get the underlying Renderer instance.
 
virtual void Run ()=0
 Run the main loop.
 
virtual void Quit ()=0
 Quit the application.
 
- Public Member Functions inherited from RefCounted
virtual void AddRef () const =0
 
virtual void Release () const =0
 
virtual int ref_count () const =0
 

Protected Member Functions

virtual ~App ()
 
- Protected Member Functions inherited from RefCounted
virtual ~RefCounted ()
 

Constructor & Destructor Documentation

◆ ~App()

virtual ~App ( )
protectedvirtual

Member Function Documentation

◆ Create()

static RefPtr< App > Create ( Settings settings = Settings(),
Config config = Config() )
static

Create the App singleton.

Parameters
settingsSettings to customize App runtime behavior.
configConfig options for the Ultralight renderer.
Returns
Returns a ref-pointer to the created App instance.
Note
You should only create one of these per application lifetime.
Certain Config options may be overridden during App creation, most commonly Config::face_winding and Config::cache_path.

◆ instance()

static App * instance ( )
static

Get the App singleton.

◆ is_running()

virtual bool is_running ( ) const
pure virtual

Whether or not the App is running.

◆ listener()

virtual AppListener * listener ( )
pure virtual

Get the AppListener, if any.

◆ main_monitor()

virtual Monitor * main_monitor ( )
pure virtual

Get the main monitor (this is never NULL).

Note
We'll add monitor enumeration later.

◆ Quit()

virtual void Quit ( )
pure virtual

Quit the application.

◆ renderer()

virtual RefPtr< Renderer > renderer ( )
pure virtual

Get the underlying Renderer instance.

◆ Run()

virtual void Run ( )
pure virtual

Run the main loop.

◆ set_listener()

virtual void set_listener ( AppListener * listener)
pure virtual

Set an AppListener to receive callbacks for app-related events.

Note
Ownership remains with the caller.

◆ settings()

virtual const Settings & settings ( ) const
pure virtual

Get the settings this App was created with.


The documentation for this class was generated from the following file: