undoStudio
The IDE of the undoRT ecosystem
Loading...
Searching...
No Matches
undoStudio::services::WindowServiceGLFW Class Reference

GLFW implementation of WindowService. More...

Inheritance diagram for undoStudio::services::WindowServiceGLFW:
Inheritance graph
Collaboration diagram for undoStudio::services::WindowServiceGLFW:
Collaboration graph

Public Member Functions

 WindowServiceGLFW ()=default
 
 ~WindowServiceGLFW () override=default
 
bool initialize (const WindowConfig &config) override
 Initialize GLFW and create a window.
 
void shutdown () override
 Shutdown GLFW and destroy the window.
 
bool shouldClose () const override
 Check if window close event has been triggered.
 
void pollEvents () override
 Poll and process all pending events.
 
void swapBuffers () override
 Swap the OpenGL front and back buffers.
 
glm::ivec2 getWindowSize () const override
 Get current window size.
 
void setWindowSize (int width, int height) override
 Set window size.
 
void setTitle (const std::string &title) override
 Set window title.
 
void * getNativeHandle () const override
 Get native GLFW window handle.
 
void setResizeCallback (ResizeCallback callback) override
 Set the window resize callback.
 
void setKeyCallback (KeyCallback callback) override
 Set the keyboard input callback.
 
void setMouseCallback (MouseCallback callback) override
 Set the mouse movement callback.
 
void setMouseButtonCallback (MouseButtonCallback callback) override
 Set the mouse button callback.
 
void setScrollCallback (ScrollCallback callback) override
 Set the scroll wheel callback.
 
void setCloseCallback (CloseCallback callback) override
 Set the window close callback.
 
- Public Member Functions inherited from undoStudio::services::WindowService
virtual ~WindowService ()=default
 

Private Member Functions

void reportDisplaySetup ()
 Write the platform, the monitors and this window's scale to the log.
 
void setupCallbacks ()
 Setup all GLFW callbacks.
 
void setFileDropHandler (FileDropHandler handler) override
 

Private Attributes

GLFWwindow * m_window = nullptr
 
ResizeCallback m_resizeCallback
 
KeyCallback m_keyCallback
 
MouseCallback m_mouseCallback
 
MouseButtonCallback m_mouseButtonCallback
 
ScrollCallback m_scrollCallback
 
CloseCallback m_closeCallback
 
FileDropHandler m_fileDropHandler
 

Additional Inherited Members

- Public Types inherited from undoStudio::services::WindowService
using FileDropHandler = std::function< void(const std::vector< std::string > &)>
 Be told which paths were dropped onto the window.
 
using ResizeCallback = std::function< void(int, int)>
 
using KeyCallback = std::function< void(int, int, int, int)>
 
using MouseCallback = std::function< void(double, double)>
 
using MouseButtonCallback = std::function< void(int, int, int)>
 
using ScrollCallback = std::function< void(double, double)>
 
using CloseCallback = std::function< void()>
 
- Static Public Member Functions inherited from undoStudio::services::WindowService
static WindowService & getInstance ()
 Get the singleton instance of WindowService.
 

Detailed Description

GLFW implementation of WindowService.

This class uses the GLFW library for window management and event handling. It provides OpenGL context creation and cross-platform window operations.

Constructor & Destructor Documentation

◆ WindowServiceGLFW()

undoStudio::services::WindowServiceGLFW::WindowServiceGLFW ( )
default

◆ ~WindowServiceGLFW()

undoStudio::services::WindowServiceGLFW::~WindowServiceGLFW ( )
overridedefault

Member Function Documentation

◆ getNativeHandle()

void * undoStudio::services::WindowServiceGLFW::getNativeHandle ( ) const
inlineoverridevirtual

Get native GLFW window handle.

Returns
Pointer to GLFWwindow

Implements undoStudio::services::WindowService.

◆ getWindowSize()

glm::ivec2 undoStudio::services::WindowServiceGLFW::getWindowSize ( ) const
inlineoverridevirtual

Get current window size.

Returns
glm::ivec2 containing width and height

Implements undoStudio::services::WindowService.

◆ initialize()

bool undoStudio::services::WindowServiceGLFW::initialize ( const WindowConfig &  config)
inlineoverridevirtual

Initialize GLFW and create a window.

Parameters
configWindow configuration
Returns
true on success, false on failure

Implements undoStudio::services::WindowService.

◆ pollEvents()

void undoStudio::services::WindowServiceGLFW::pollEvents ( )
inlineoverridevirtual

Poll and process all pending events.

Implements undoStudio::services::WindowService.

◆ reportDisplaySetup()

void undoStudio::services::WindowServiceGLFW::reportDisplaySetup ( )
inlineprivate

Write the platform, the monitors and this window's scale to the log.

The one line that decides whether two displays can be mixed is the window's content scale against the monitor's: the first is what the framebuffer is sized from and the second is what a popup on that monitor is sized from, and when they differ the popup is drawn for a density the window is not.

◆ setCloseCallback()

void undoStudio::services::WindowServiceGLFW::setCloseCallback ( CloseCallback  callback)
inlineoverridevirtual

Set the window close callback.

Parameters
callbackFunction to call on window close

Implements undoStudio::services::WindowService.

◆ setFileDropHandler()

void undoStudio::services::WindowServiceGLFW::setFileDropHandler ( FileDropHandler  handler)
inlineoverrideprivatevirtual

◆ setKeyCallback()

void undoStudio::services::WindowServiceGLFW::setKeyCallback ( KeyCallback  callback)
inlineoverridevirtual

Set the keyboard input callback.

Parameters
callbackFunction to call on keyboard events

Implements undoStudio::services::WindowService.

◆ setMouseButtonCallback()

void undoStudio::services::WindowServiceGLFW::setMouseButtonCallback ( MouseButtonCallback  callback)
inlineoverridevirtual

Set the mouse button callback.

Parameters
callbackFunction to call on mouse button events

Implements undoStudio::services::WindowService.

◆ setMouseCallback()

void undoStudio::services::WindowServiceGLFW::setMouseCallback ( MouseCallback  callback)
inlineoverridevirtual

Set the mouse movement callback.

Parameters
callbackFunction to call on mouse movement

Implements undoStudio::services::WindowService.

◆ setResizeCallback()

void undoStudio::services::WindowServiceGLFW::setResizeCallback ( ResizeCallback  callback)
inlineoverridevirtual

Set the window resize callback.

Parameters
callbackFunction to call on window resize

Implements undoStudio::services::WindowService.

◆ setScrollCallback()

void undoStudio::services::WindowServiceGLFW::setScrollCallback ( ScrollCallback  callback)
inlineoverridevirtual

Set the scroll wheel callback.

Parameters
callbackFunction to call on scroll events

Implements undoStudio::services::WindowService.

◆ setTitle()

void undoStudio::services::WindowServiceGLFW::setTitle ( const std::string &  title)
inlineoverridevirtual

Set window title.

Parameters
titleNew window title

Implements undoStudio::services::WindowService.

◆ setupCallbacks()

void undoStudio::services::WindowServiceGLFW::setupCallbacks ( )
inlineprivate

Setup all GLFW callbacks.

This method registers all necessary GLFW callbacks and forwards them to the appropriate C++ callbacks.

◆ setWindowSize()

void undoStudio::services::WindowServiceGLFW::setWindowSize ( int  width,
int  height 
)
inlineoverridevirtual

Set window size.

Parameters
widthNew window width
heightNew window height

Implements undoStudio::services::WindowService.

◆ shouldClose()

bool undoStudio::services::WindowServiceGLFW::shouldClose ( ) const
inlineoverridevirtual

Check if window close event has been triggered.

Returns
true if window should close

Implements undoStudio::services::WindowService.

◆ shutdown()

void undoStudio::services::WindowServiceGLFW::shutdown ( )
inlineoverridevirtual

Shutdown GLFW and destroy the window.

Implements undoStudio::services::WindowService.

◆ swapBuffers()

void undoStudio::services::WindowServiceGLFW::swapBuffers ( )
inlineoverridevirtual

Swap the OpenGL front and back buffers.

Implements undoStudio::services::WindowService.

Member Data Documentation

◆ m_closeCallback

CloseCallback undoStudio::services::WindowServiceGLFW::m_closeCallback
private

◆ m_fileDropHandler

FileDropHandler undoStudio::services::WindowServiceGLFW::m_fileDropHandler
private

◆ m_keyCallback

KeyCallback undoStudio::services::WindowServiceGLFW::m_keyCallback
private

◆ m_mouseButtonCallback

MouseButtonCallback undoStudio::services::WindowServiceGLFW::m_mouseButtonCallback
private

◆ m_mouseCallback

MouseCallback undoStudio::services::WindowServiceGLFW::m_mouseCallback
private

◆ m_resizeCallback

ResizeCallback undoStudio::services::WindowServiceGLFW::m_resizeCallback
private

◆ m_scrollCallback

ScrollCallback undoStudio::services::WindowServiceGLFW::m_scrollCallback
private

◆ m_window

GLFWwindow* undoStudio::services::WindowServiceGLFW::m_window = nullptr
private

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