QuasarEngine
Cross-platform 3D engine and editor
Loading...
Searching...
No Matches
Quasar::ImGuiLayer Class Referencefinal

Overlay that starts Dear ImGui with its GLFW and OpenGL backends, and wraps each frame. More...

#include <quasar/core/ImGuiLayer.h>

Inheritance diagram for Quasar::ImGuiLayer:
Quasar::Layer

Public Member Functions

 ImGuiLayer (Window &window)
 Creates the layer for a window that has an OpenGL context.
void OnAttach () override
 Starts ImGui and its GLFW and OpenGL backends.
void OnDetach () override
 Stops the backends, then ImGui.
void OnEvent (Event &event) override
 Marks the mouse and keyboard events as handled while ImGui uses them. See SetBlockEvents().
void Begin ()
 Starts a new ImGui frame. The application calls it before the OnImGuiRender() hooks.
void End ()
 Draws the ImGui frame in the window, then the ImGui windows outside it.
void SetBlockEvents (bool block)
 Chooses whether the events used by ImGui are kept from the layers below.
Public Member Functions inherited from Quasar::Layer
 Layer (const Layer &)=delete
Layer & operator= (const Layer &)=delete
 Layer (Layer &&)=delete
Layer & operator= (Layer &&)=delete
virtual void OnUpdate (Timestep timestep)
 Called once per frame to update the layer.
virtual void OnRender ()
 Called once per frame, after OnUpdate(), to render the layer.
virtual void OnImGuiRender ()
 Called once per frame, after OnRender(), to draw the ImGui windows of the layer.
const std::string & GetName () const
 Returns the name of the layer, for debugging.

Additional Inherited Members

Protected Member Functions inherited from Quasar::Layer
 Layer (std::string name="Layer")
 Creates a layer with a name, used in logs and debugging tools.

Detailed Description

Overlay that starts Dear ImGui with its GLFW and OpenGL backends, and wraps each frame.

The application creates it when its window has an OpenGL context, and keeps it above every other layer and overlay. Each frame, the application calls Begin(), then Layer::OnImGuiRender() on every layer from the bottom to the top, then End().

The interface uses the engine theme and font, scaled for the monitor. See ImGuiTheme.

Docking and multiple viewports are enabled: ImGui windows can be docked into each other or into a dock space, and dragged outside the main window, where each one gets its own platform window. On Wayland, the GLFW backend cannot place windows, so the viewports are turned off and ImGui windows stay inside the main window. Docking still works.

While ImGui uses the mouse or the keyboard, for example when the cursor is over an ImGui window or a text field has the focus, the mouse or keyboard events are marked as handled, so the layers below do not receive them.

Constructor & Destructor Documentation

◆ ImGuiLayer()

Quasar::ImGuiLayer::ImGuiLayer ( Window & window)
explicit

Creates the layer for a window that has an OpenGL context.

ImGui starts when the layer is attached.

Parameters
windowThe window where ImGui draws and reads its input. It must outlive the layer.

Member Function Documentation

◆ OnAttach()

void Quasar::ImGuiLayer::OnAttach ( )
overridevirtual

Starts ImGui and its GLFW and OpenGL backends.

Reimplemented from Quasar::Layer.

◆ OnDetach()

void Quasar::ImGuiLayer::OnDetach ( )
overridevirtual

Stops the backends, then ImGui.

Reimplemented from Quasar::Layer.

◆ OnEvent()

void Quasar::ImGuiLayer::OnEvent ( Event & event)
overridevirtual

Marks the mouse and keyboard events as handled while ImGui uses them. See SetBlockEvents().

Reimplemented from Quasar::Layer.

◆ End()

void Quasar::ImGuiLayer::End ( )

Draws the ImGui frame in the window, then the ImGui windows outside it.

The application calls it after the OnImGuiRender() hooks.

◆ SetBlockEvents()

void Quasar::ImGuiLayer::SetBlockEvents ( bool block)
inline

Chooses whether the events used by ImGui are kept from the layers below.

True by default.

The editor turns it off while the cursor is over the scene view, so the scene receives the input.


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