IMGuiService Class Reference

#include <imguiservice.h>

Public Member Functions

 IMGuiService (ServiceConfiguration *configuration)
void draw ()
void selectWindow (nap::ResourcePtr< RenderWindow > window)
void processInputEvent (InputEvent &event)
bool isCapturingKeyboard ()
bool isCapturingMouse ()
- Public Member Functions inherited from Service
 Service (ServiceConfiguration *configuration)
virtual ~Service ()
CoregetCore ()
const std::string getTypeName () const

Protected Member Functions

virtual bool init (utility::ErrorState &error) override
virtual void getDependentServices (std::vector< rtti::TypeInfo > &dependencies) override
virtual void update (double deltaTime) override
virtual void shutdown () override
- Protected Member Functions inherited from Service
virtual void registerObjectCreators (rtti::Factory &factory)
virtual void created ()
virtual void preUpdate (double deltaTime)
virtual void postUpdate (double deltaTime)
virtual void resourcesLoaded ()
template<typename SERVICE_CONFIG >
SERVICE_CONFIG * getConfiguration ()
template<typename SERVICE_CONFIG >
const SERVICE_CONFIG * getConfiguration () const

Detailed Description

This service manages the global ImGui state. Use selectWindow() to select the window to draw the GUI on to. By default the GUI is drawn to the primary window, as defined by the renderer. Make sure to call draw() inside your application to render the gui to the right window. When doing so make sure the window that you selected is active, otherwise the GUI will not appear. When there is no actively selected window call draw() after making the primary window active. The service automatically creates a new GUI frame before calling update.

Inheritance diagram for IMGuiService:
Collaboration diagram for IMGuiService:

Constructor & Destructor Documentation

◆ IMGuiService()

IMGuiService ( ServiceConfiguration configuration)

Default constructor

Member Function Documentation

◆ draw()

void draw ( )

Draws the all the GUI elements to screen You need to call this just before swapping buffers for the primary window

◆ getDependentServices()

virtual void getDependentServices ( std::vector< rtti::TypeInfo > &  dependencies)

ImGui depends on the renderer

dependenciesthe type of services this service depends on

Reimplemented from Service.

◆ init()

virtual bool init ( utility::ErrorState error)

Initializes the IMGui library. This will also create all associated gui devices objects Note that a GUI can only be associated with the primary window (for now).

errorcontains the error message if the lib could not be initialized correctly
if the lib was initialized successfully

Reimplemented from Service.

◆ isCapturingKeyboard()

bool isCapturingKeyboard ( )
if the gui is capturing keyboard events

◆ isCapturingMouse()

bool isCapturingMouse ( )
if the gui is capturing mouse events

◆ processInputEvent()

void processInputEvent ( InputEvent event)

Handles input for gui related tasks, called from the Gui App Event Handler This is separate from other input related event handling

◆ selectWindow()

void selectWindow ( nap::ResourcePtr< RenderWindow window)

Explicitly set the window that is used for drawing the GUI elements When no window is specified the system uses the primary window to draw GUI elements Only set the window on init() of your application.

windowthe window to use for drawing the GUI elements

◆ shutdown()

virtual void shutdown ( )

Disables the imgui library

Reimplemented from Service.

◆ update()

virtual void update ( double  deltaTime)

Allows IMGUI to draw a new frame. This is called automatically by core in the app loop

deltaTimethe time in seconds between ticks

Reimplemented from Service.