undoStudio
The IDE of the undoRT ecosystem
Loading...
Searching...
No Matches
undoStudio::services::WindowService Class Referenceabstract

Abstract interface for window management service. More...

#include <WindowService.hpp>

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

Public Types

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()>
 

Public Member Functions

virtual ~WindowService ()=default
 
virtual bool initialize (const WindowConfig &config)=0
 Initialize the window with the given configuration.
 
virtual void shutdown ()=0
 Shutdown and destroy the window.
 
virtual bool shouldClose () const =0
 Check if the window should be closed.
 
virtual void pollEvents ()=0
 Poll and process all pending events.
 
virtual void setFileDropHandler (FileDropHandler handler)=0
 
virtual void swapBuffers ()=0
 Swap the front and back buffers.
 
virtual glm::ivec2 getWindowSize () const =0
 Get the current window size.
 
virtual void setWindowSize (int width, int height)=0
 Set the window size.
 
virtual void setTitle (const std::string &title)=0
 Set the window title.
 
virtual void * getNativeHandle () const =0
 Get the native window handle.
 
virtual void setResizeCallback (ResizeCallback callback)=0
 Set the window resize callback.
 
virtual void setKeyCallback (KeyCallback callback)=0
 Set the keyboard input callback.
 
virtual void setMouseCallback (MouseCallback callback)=0
 Set the mouse movement callback.
 
virtual void setMouseButtonCallback (MouseButtonCallback callback)=0
 Set the mouse button callback.
 
virtual void setScrollCallback (ScrollCallback callback)=0
 Set the scroll wheel callback.
 
virtual void setCloseCallback (CloseCallback callback)=0
 Set the window close callback.
 

Static Public Member Functions

static WindowService & getInstance ()
 Get the singleton instance of WindowService.
 

Detailed Description

Abstract interface for window management service.

This service provides platform-independent window management. It handles window creation, event processing, and rendering context management.

Member Typedef Documentation

◆ CloseCallback

◆ FileDropHandler

using undoStudio::services::WindowService::FileDropHandler = std::function<void(const std::vector<std::string>&)>

Be told which paths were dropped onto the window.

Parameters
handlerCalled with the dropped paths, or with an empty list for a drop that carried none, which a drag from inside a browser does not.

The handler is called from pollEvents, so it runs on the same thread as the rest of the window's events and may set a request that a later frame picks up. It may be null, and then drops are still delivered by the platform and simply go nowhere.

A drop arrives here rather than through ImGui because the paths come from the window system, and the window is this service's. The undoApp that opens them is not: see ImGuiManager::requestOpenFile.

◆ KeyCallback

using undoStudio::services::WindowService::KeyCallback = std::function<void(int, int, int, int)>

◆ MouseButtonCallback

using undoStudio::services::WindowService::MouseButtonCallback = std::function<void(int, int, int)>

◆ MouseCallback

using undoStudio::services::WindowService::MouseCallback = std::function<void(double, double)>

◆ ResizeCallback

using undoStudio::services::WindowService::ResizeCallback = std::function<void(int, int)>

◆ ScrollCallback

using undoStudio::services::WindowService::ScrollCallback = std::function<void(double, double)>

Constructor & Destructor Documentation

◆ ~WindowService()

virtual undoStudio::services::WindowService::~WindowService ( )
virtualdefault

Member Function Documentation

◆ getInstance()

WindowService & undoStudio::services::WindowService::getInstance ( )
static

Get the singleton instance of WindowService.

Returns
Reference to the single WindowService instance

◆ getNativeHandle()

virtual void * undoStudio::services::WindowService::getNativeHandle ( ) const
pure virtual

Get the native window handle.

Returns
Pointer to the native window handle (platform-specific)

Implemented in undoStudio::services::WindowServiceGLFW.

◆ getWindowSize()

virtual glm::ivec2 undoStudio::services::WindowService::getWindowSize ( ) const
pure virtual

Get the current window size.

Returns
glm::ivec2 containing width and height

Implemented in undoStudio::services::WindowServiceGLFW.

◆ initialize()

virtual bool undoStudio::services::WindowService::initialize ( const WindowConfig &  config)
pure virtual

Initialize the window with the given configuration.

Parameters
configWindow configuration parameters
Returns
true if initialization succeeded, false otherwise

Implemented in undoStudio::services::WindowServiceGLFW.

◆ pollEvents()

virtual void undoStudio::services::WindowService::pollEvents ( )
pure virtual

Poll and process all pending events.

This method processes all pending window events including input, resize, and close events.

Implemented in undoStudio::services::WindowServiceGLFW.

◆ setCloseCallback()

virtual void undoStudio::services::WindowService::setCloseCallback ( CloseCallback  callback)
pure virtual

Set the window close callback.

Parameters
callbackFunction to call on window close

Implemented in undoStudio::services::WindowServiceGLFW.

◆ setFileDropHandler()

virtual void undoStudio::services::WindowService::setFileDropHandler ( FileDropHandler  handler)
pure virtual

◆ setKeyCallback()

virtual void undoStudio::services::WindowService::setKeyCallback ( KeyCallback  callback)
pure virtual

Set the keyboard input callback.

Parameters
callbackFunction to call on keyboard events

Implemented in undoStudio::services::WindowServiceGLFW.

◆ setMouseButtonCallback()

virtual void undoStudio::services::WindowService::setMouseButtonCallback ( MouseButtonCallback  callback)
pure virtual

Set the mouse button callback.

Parameters
callbackFunction to call on mouse button events

Implemented in undoStudio::services::WindowServiceGLFW.

◆ setMouseCallback()

virtual void undoStudio::services::WindowService::setMouseCallback ( MouseCallback  callback)
pure virtual

Set the mouse movement callback.

Parameters
callbackFunction to call on mouse movement

Implemented in undoStudio::services::WindowServiceGLFW.

◆ setResizeCallback()

virtual void undoStudio::services::WindowService::setResizeCallback ( ResizeCallback  callback)
pure virtual

Set the window resize callback.

Parameters
callbackFunction to call on window resize

Implemented in undoStudio::services::WindowServiceGLFW.

◆ setScrollCallback()

virtual void undoStudio::services::WindowService::setScrollCallback ( ScrollCallback  callback)
pure virtual

Set the scroll wheel callback.

Parameters
callbackFunction to call on scroll events

Implemented in undoStudio::services::WindowServiceGLFW.

◆ setTitle()

virtual void undoStudio::services::WindowService::setTitle ( const std::string &  title)
pure virtual

Set the window title.

Parameters
titleNew window title string

Implemented in undoStudio::services::WindowServiceGLFW.

◆ setWindowSize()

virtual void undoStudio::services::WindowService::setWindowSize ( int  width,
int  height 
)
pure virtual

Set the window size.

Parameters
widthNew window width in pixels
heightNew window height in pixels

Implemented in undoStudio::services::WindowServiceGLFW.

◆ shouldClose()

virtual bool undoStudio::services::WindowService::shouldClose ( ) const
pure virtual

Check if the window should be closed.

Returns
true if the close event has been triggered

Implemented in undoStudio::services::WindowServiceGLFW.

◆ shutdown()

virtual void undoStudio::services::WindowService::shutdown ( )
pure virtual

Shutdown and destroy the window.

Implemented in undoStudio::services::WindowServiceGLFW.

◆ swapBuffers()

virtual void undoStudio::services::WindowService::swapBuffers ( )
pure virtual

Swap the front and back buffers.

This method swaps the OpenGL/DirectX buffers, displaying the rendered frame.

Implemented in undoStudio::services::WindowServiceGLFW.


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