FlowArithmeticCalculator 1.0.0
Flow Arithmetic Calculator
Loading...
Searching...
No Matches
gui::window::GLFWQtWindowImpl< RendererImpl, Canvas > Class Template Reference

Class responsible for managing the GLFW main window, any Qt dialogs / modals and their lifecycle. More...

#include <GLFWQtWindowImpl.h>

+ Inheritance diagram for gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >:
+ Collaboration diagram for gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >:

Public Member Functions

 GLFWQtWindowImpl (int width, int height, const char *title)
 Constructs a new GLFWQtWindowImpl.
 
 GLFWQtWindowImpl (const GLFWQtWindowImpl &)=delete
 
GLFWQtWindowImploperator= (const GLFWQtWindowImpl &)=delete
 
 GLFWQtWindowImpl (GLFWQtWindowImpl &&)=delete
 
GLFWQtWindowImploperator= (GLFWQtWindowImpl &&)=delete
 
void postInitialize ()
 
 ~GLFWQtWindowImpl () override
 Destructor that cleans up the GLFW window and terminates GLFW.
 
void run () override
 Runs the main window loop.
 
 operator GLFWwindow * () const
 Allows conversion of GLFWQtWindowImpl instance that gets the underlying GLFW window handle.
 
- Public Member Functions inherited from gui::window::WindowBase< Canvas >
 WindowBase (int width, int height, std::shared_ptr< spdlog::logger > logger)
 
 ~WindowBase () override=default
 
 WindowBase (const WindowBase &)=delete
 
WindowBaseoperator= (const WindowBase &)=delete
 
 WindowBase (WindowBase &&) noexcept=default
 
WindowBaseoperator= (WindowBase &&) noexcept=default
 
void handleMouseDown ()
 Handles the mouse down event; should be called internally by the window implementation.
 
void handleMouseUp ()
 Handles the mouse up event; should be called internally by the window implementation.
 
void handleNumericKeyPress (int number)
 Handles the numeric key press event; should be called internally by the window implementation.
 
void handleEscapeKeyPress ()
 Handles the ESC key press event; should be called internally by the window implementation.
 
void handleRightClick ()
 Handles the right click event; should be called internally by the window implementation.
 
void handleMouseMove (int x, int y)
 Handles the mouse move event; should be called internally by the window implementation.
 
business_logic::geometry::Size2D getWindowSize () override
 Get the window size.
 
business_logic::geometry::Size2D getFramebufferSize () override
 Get the framebuffer size.
 
- Public Member Functions inherited from business_logic::delegate::IWindowDelegate
virtual ~IWindowDelegate ()=default
 

Static Public Member Functions

static GLFWQtWindowImpl< RendererImpl, Canvas > MakeFullscreen (const char *title)
 Constructs a new GLFWQtWindowImpl that takes the full size of the primary monitor.
 

Private Member Functions

bool shouldClose () const override
 Whether the window should close.
 
void initializeGLFWWindow (int width, int height, const char *title)
 Initializes the GLFW window.
 
void focusWindow () override
 Focus the window.
 
void showWarning (const std::string &title, const std::string &message) override
 Show a warning message.
 
std::optional< FloatingPointpromptFloatingPointInput (const std::string &title, const std::string &message, const std::optional< FloatingPoint > &defaultValue) override
 Prompt for a floating point input.
 
bool promptConfirmation (const std::string &title, const std::string &message) override
 Prompt for user confirmation.
 

Static Private Member Functions

static void initGLFW ()
 Initializes GLFW.
 
static void handleWindowResized (GLFWwindow *window, int winWidth, int winHeight)
 Handles the window resized event.
 

Private Attributes

GLFWwindow * glfwWindow {}
 
std::unique_ptr< RendererImpl > renderer
 

Static Private Attributes

static bool initializedGLFW
 

Additional Inherited Members

- Protected Member Functions inherited from business_logic::Loggable< GLFWQtWindowImpl< RendererImpl, Canvas > >
 Loggable ()
 
- Protected Member Functions inherited from gui::window::WindowBase< Canvas >
 WindowBase (int width, int height, std::shared_ptr< spdlog::logger > logger)
 
 ~WindowBase () override=default
 
 WindowBase (const WindowBase &)=delete
 
WindowBaseoperator= (const WindowBase &)=delete
 
 WindowBase (WindowBase &&) noexcept=default
 
WindowBaseoperator= (WindowBase &&) noexcept=default
 
void handleMouseDown ()
 Handles the mouse down event; should be called internally by the window implementation.
 
void handleMouseUp ()
 Handles the mouse up event; should be called internally by the window implementation.
 
void handleNumericKeyPress (int number)
 Handles the numeric key press event; should be called internally by the window implementation.
 
void handleEscapeKeyPress ()
 Handles the ESC key press event; should be called internally by the window implementation.
 
void handleRightClick ()
 Handles the right click event; should be called internally by the window implementation.
 
void handleMouseMove (int x, int y)
 Handles the mouse move event; should be called internally by the window implementation.
 
business_logic::geometry::Size2D getWindowSize () override
 Get the window size.
 
business_logic::geometry::Size2D getFramebufferSize () override
 Get the framebuffer size.
 
- Protected Member Functions inherited from business_logic::delegate::IWindowDelegate
virtual ~IWindowDelegate ()=default
 
- Protected Attributes inherited from business_logic::Loggable< GLFWQtWindowImpl< RendererImpl, Canvas > >
std::shared_ptr< spdlog::logger > logger
 
- Protected Attributes inherited from gui::window::WindowBase< Canvas >
std::shared_ptr< business_logic::BlocksManagerblocksManager
 
std::shared_ptr< spdlog::logger > logger
 
business_logic::geometry::Size2D winSize
 
business_logic::geometry::Size2D framebufferSize
 

Detailed Description

template<typename RendererImpl, typename Canvas>
class gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >

Class responsible for managing the GLFW main window, any Qt dialogs / modals and their lifecycle.

Template Parameters
RendererImplThe renderer implementation type
CanvasThe canvas type

Definition at line 25 of file GLFWQtWindowImpl.h.

Constructor & Destructor Documentation

◆ GLFWQtWindowImpl() [1/3]

template<typename RendererImpl , typename Canvas >
gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::GLFWQtWindowImpl ( int  width,
int  height,
const char *  title 
)
inlineexplicit

Constructs a new GLFWQtWindowImpl.

Parameters
widthInitial window width
heightInitial window height
titleGLFWQtWindowImpl title

Definition at line 35 of file GLFWQtWindowImpl.h.

References gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::initGLFW(), gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::initializeGLFWWindow(), and gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::postInitialize().

+ Here is the call graph for this function:

◆ GLFWQtWindowImpl() [2/3]

template<typename RendererImpl , typename Canvas >
gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::GLFWQtWindowImpl ( const GLFWQtWindowImpl< RendererImpl, Canvas > &  )
delete

◆ GLFWQtWindowImpl() [3/3]

template<typename RendererImpl , typename Canvas >
gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::GLFWQtWindowImpl ( GLFWQtWindowImpl< RendererImpl, Canvas > &&  )
delete

◆ ~GLFWQtWindowImpl()

template<typename RendererImpl , typename Canvas >
gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::~GLFWQtWindowImpl ( )
inlineoverride

Destructor that cleans up the GLFW window and terminates GLFW.

Definition at line 90 of file GLFWQtWindowImpl.h.

References gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::glfwWindow, gui::window::WindowBase< Canvas >::logger, and business_logic::stringifyAddressOf().

+ Here is the call graph for this function:

Member Function Documentation

◆ focusWindow()

template<typename RendererImpl , typename Canvas >
void gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::focusWindow ( )
inlineoverrideprivatevirtual

Focus the window.

Helpful e.g. when closing a Qt dialog.

Implements business_logic::delegate::IWindowDelegate.

Definition at line 297 of file GLFWQtWindowImpl.h.

References gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::glfwWindow.

◆ handleWindowResized()

template<typename RendererImpl , typename Canvas >
static void gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::handleWindowResized ( GLFWwindow *  window,
int  winWidth,
int  winHeight 
)
inlinestaticprivate

Handles the window resized event.

Parameters
windowThe GLFW window
winWidthThe width of the window
winHeightThe height of the window

Definition at line 262 of file GLFWQtWindowImpl.h.

References business_logic::stringifyAddressOf().

Referenced by gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::initializeGLFWWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initGLFW()

template<typename RendererImpl , typename Canvas >
static void gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::initGLFW ( )
inlinestaticprivate

◆ initializeGLFWWindow()

◆ MakeFullscreen()

template<typename RendererImpl , typename Canvas >
static GLFWQtWindowImpl< RendererImpl, Canvas > gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::MakeFullscreen ( const char *  title)
inlinestatic

Constructs a new GLFWQtWindowImpl that takes the full size of the primary monitor.

Parameters
titleGLFWQtWindowImpl title

Definition at line 49 of file GLFWQtWindowImpl.h.

References gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::initGLFW().

+ Here is the call graph for this function:

◆ operator GLFWwindow *()

template<typename RendererImpl , typename Canvas >
gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::operator GLFWwindow * ( ) const
inlineexplicit

Allows conversion of GLFWQtWindowImpl instance that gets the underlying GLFW window handle.

Returns
GLFWwindow* The window handle

Definition at line 124 of file GLFWQtWindowImpl.h.

References gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::glfwWindow.

◆ operator=() [1/2]

template<typename RendererImpl , typename Canvas >
GLFWQtWindowImpl & gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::operator= ( const GLFWQtWindowImpl< RendererImpl, Canvas > &  )
delete

◆ operator=() [2/2]

template<typename RendererImpl , typename Canvas >
GLFWQtWindowImpl & gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::operator= ( GLFWQtWindowImpl< RendererImpl, Canvas > &&  )
delete

◆ postInitialize()

template<typename RendererImpl , typename Canvas >
void gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::postInitialize ( )
inline

Definition at line 76 of file GLFWQtWindowImpl.h.

References gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::glfwWindow, and gui::window::WindowBase< Canvas >::handleMouseMove().

Referenced by gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::GLFWQtWindowImpl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ promptConfirmation()

template<typename RendererImpl , typename Canvas >
bool gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::promptConfirmation ( const std::string &  title,
const std::string &  message 
)
inlineoverrideprivatevirtual

Prompt for user confirmation.

Parameters
titleThe title of the dialog
messageThe message to show
Returns
True if the user confirmed, false otherwise

Implements business_logic::delegate::IWindowDelegate.

Definition at line 320 of file GLFWQtWindowImpl.h.

References gui::window::prompt::GuiMessageBox::promptConfirmation().

+ Here is the call graph for this function:

◆ promptFloatingPointInput()

template<typename RendererImpl , typename Canvas >
std::optional< FloatingPoint > gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::promptFloatingPointInput ( const std::string &  title,
const std::string &  message,
const std::optional< FloatingPoint > &  defaultValue 
)
inlineoverrideprivatevirtual

Prompt for a floating point input.

Parameters
titleThe title of the input
messageThe message to show
defaultValueThe default value to use for the input
Returns
The input value or std::nullopt if the user cancels the input

Implements business_logic::delegate::IWindowDelegate.

Definition at line 309 of file GLFWQtWindowImpl.h.

References gui::window::prompt::TextInputDialog::promptForFloatingPointInput().

+ Here is the call graph for this function:

◆ run()

template<typename RendererImpl , typename Canvas >
void gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::run ( )
inlineoverridevirtual

◆ shouldClose()

template<typename RendererImpl , typename Canvas >
bool gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::shouldClose ( ) const
inlineoverrideprivatevirtual

Whether the window should close.

Returns
bool True if the window should close, false otherwise

Implements gui::window::WindowBase< Canvas >.

Definition at line 161 of file GLFWQtWindowImpl.h.

References gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::glfwWindow.

Referenced by gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::run().

+ Here is the caller graph for this function:

◆ showWarning()

template<typename RendererImpl , typename Canvas >
void gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::showWarning ( const std::string &  title,
const std::string &  message 
)
inlineoverrideprivatevirtual

Show a warning message.

Parameters
titleThe title of the warning
messageThe message to show

Implements business_logic::delegate::IWindowDelegate.

Definition at line 302 of file GLFWQtWindowImpl.h.

References gui::window::prompt::GuiMessageBox::showWarning().

+ Here is the call graph for this function:

Member Data Documentation

◆ glfwWindow

◆ initializedGLFW

template<typename RendererImpl , typename Canvas >
bool gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::initializedGLFW
inlinestaticprivate

◆ renderer

template<typename RendererImpl , typename Canvas >
std::unique_ptr<RendererImpl> gui::window::GLFWQtWindowImpl< RendererImpl, Canvas >::renderer
private

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