galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::core::Window Class Referencefinal

Handles events, input & display. More...

#include <Window.hpp>

+ Collaboration diagram for galaxy::core::Window:

Public Member Functions

 Window (const WindowSettings &settings)
 Window creation constructor.
 
 ~Window ()
 Destructor.
 
bool is_open () const
 Checks if window is currently open or not.
 
void close ()
 Closes the current window.
 
void destroy ()
 Destroys Window and related context and data.
 
void poll_events ()
 Poll for events.
 
void resize (const int width, const int height)
 Resizes window.
 
void request_attention ()
 Notify's user of an event without interrupting.
 
void focus () const
 Force window into focus.
 
void maximize ()
 Maximize window.
 
void restore ()
 Restore window.
 
void minimize () const
 Minimize window.
 
void fullscreen ()
 Set window into borderless fullscreen mode.
 
void set_title (const std::string &title)
 Set window title.
 
void append_title (const std::string &append)
 Append to window title.
 
void set_icon (const std::string &icon)
 Set window icon.
 
void set_icon (std::span< std::uint8_t > buffer)
 Set window icon.
 
void set_dispatcher (entt::dispatcher *dispatcher)
 Set current event dispatcher to use.
 
bool is_focused () const
 Check if windows is in focus.
 
int window_width () const
 
int window_height () const
 
int frame_width () const
 
int frame_height () const
 
float aspect_ratio () const
 
template<meta::is_input_device Device>
Device & get_input ()
 Get a window input device.
 
const meta::vector< std::string > & get_drop_paths () const
 Get a list of paths dropped on window.
 
glm::ivec2 get_framebuffer_size ()
 Get framebuffer size taking into account DPI.
 
glm::vec2 get_content_scale ()
 Get window content scale.
 
float get_content_scale_max ()
 Get max window content scale.
 
GLFWwindow * handle ()
 Retrieve pointer to GLFWwindow object.
 

Private Member Functions

 Window ()=delete
 Constructor.
 
 Window (const Window &)=delete
 Copy constructor.
 
 Window (Window &&)=delete
 Move constructor.
 
Windowoperator= (const Window &)=delete
 Copy assignment operator.
 
Windowoperator= (Window &&)=delete
 Move assignment operator.
 

Private Attributes

std::string m_title
 Window title.
 
int m_window_width
 Width of window (or fullscreen).
 
int m_window_height
 Height of window (or fullscreen).
 
int m_frame_width
 The virtual or final framebuffer width.
 
int m_frame_height
 The virtual or final framebuffer height.
 
float m_aspect_ratio
 Window aspect ratio.
 
GLFWwindow * m_window
 GLFW window data.
 
entt::dispatcher * m_dispatcher
 Currently active event dispatcher.
 
GLFWallocator m_glfw_allocator
 Custom GLFW window allocator.
 
input::Keyboard m_keyboard
 Keyboard assigned to window.
 
input::Mouse m_mouse
 Mouse assigned to window.
 
input::Cursor m_cursor
 Mouse cursor.
 
input::Clipboard m_clipboard
 Clipboard access.
 
meta::vector< std::string > m_drop_paths
 Cache of last dropped paths.
 

Detailed Description

Handles events, input & display.

Definition at line 28 of file Window.hpp.

Constructor & Destructor Documentation

◆ Window() [1/4]

galaxy::core::Window::Window ( const WindowSettings & settings)

Window creation constructor.

Calls open().

Parameters
settingsSettings of the window.

Definition at line 60 of file Window.cpp.

+ Here is the call graph for this function:

◆ ~Window()

galaxy::core::Window::~Window ( )

Destructor.

Definition at line 493 of file Window.cpp.

+ Here is the call graph for this function:

◆ Window() [2/4]

galaxy::core::Window::Window ( )
privatedelete

Constructor.

◆ Window() [3/4]

galaxy::core::Window::Window ( const Window & )
privatedelete

Copy constructor.

◆ Window() [4/4]

galaxy::core::Window::Window ( Window && )
privatedelete

Move constructor.

Member Function Documentation

◆ is_open()

bool galaxy::core::Window::is_open ( ) const
nodiscard

Checks if window is currently open or not.

Returns
Returns true if window is currently open, false if not.

Definition at line 574 of file Window.cpp.

◆ close()

void galaxy::core::Window::close ( )

Closes the current window.

Internally, sets isOpen to false.

Definition at line 579 of file Window.cpp.

◆ destroy()

void galaxy::core::Window::destroy ( )

Destroys Window and related context and data.

Definition at line 584 of file Window.cpp.

+ Here is the caller graph for this function:

◆ poll_events()

void galaxy::core::Window::poll_events ( )

Poll for events.

Definition at line 603 of file Window.cpp.

◆ resize()

void galaxy::core::Window::resize ( const int width,
const int height )

Resizes window.

Parameters
widthWidth of the window.
heightHeight of the window.

Definition at line 608 of file Window.cpp.

◆ request_attention()

void galaxy::core::Window::request_attention ( )

Notify's user of an event without interrupting.

Think like windows flashing tray icon.

Definition at line 616 of file Window.cpp.

◆ focus()

void galaxy::core::Window::focus ( ) const

Force window into focus.

Definition at line 621 of file Window.cpp.

◆ maximize()

void galaxy::core::Window::maximize ( )

Maximize window.

Definition at line 626 of file Window.cpp.

+ Here is the caller graph for this function:

◆ restore()

void galaxy::core::Window::restore ( )

Restore window.

Definition at line 632 of file Window.cpp.

◆ minimize()

void galaxy::core::Window::minimize ( ) const

Minimize window.

Definition at line 638 of file Window.cpp.

◆ fullscreen()

void galaxy::core::Window::fullscreen ( )

Set window into borderless fullscreen mode.

Definition at line 643 of file Window.cpp.

+ Here is the caller graph for this function:

◆ set_title()

void galaxy::core::Window::set_title ( const std::string & title)

Set window title.

Parameters
titleNew title to set window to.

Definition at line 500 of file Window.cpp.

◆ append_title()

void galaxy::core::Window::append_title ( const std::string & append)

Append to window title.

Parameters
appendAppends to existing title, does not preserve last append when called again.

Definition at line 505 of file Window.cpp.

◆ set_icon() [1/2]

void galaxy::core::Window::set_icon ( const std::string & icon)

Set window icon.

Parameters
iconIcon to load.

Definition at line 511 of file Window.cpp.

◆ set_icon() [2/2]

void galaxy::core::Window::set_icon ( std::span< std::uint8_t > buffer)

Set window icon.

Parameters
bufferMemory buffer containing pixels.

Definition at line 545 of file Window.cpp.

◆ set_dispatcher()

void galaxy::core::Window::set_dispatcher ( entt::dispatcher * dispatcher)

Set current event dispatcher to use.

Parameters
dispatcherEvent dispatcher to use for processing input, etc.

Definition at line 569 of file Window.cpp.

◆ is_focused()

bool galaxy::core::Window::is_focused ( ) const
nodiscard

Check if windows is in focus.

Returns
True if window is in input focus.

Definition at line 652 of file Window.cpp.

◆ window_width()

int galaxy::core::Window::window_width ( ) const
nodiscard

Definition at line 657 of file Window.cpp.

◆ window_height()

int galaxy::core::Window::window_height ( ) const
nodiscard

Definition at line 662 of file Window.cpp.

◆ frame_width()

int galaxy::core::Window::frame_width ( ) const
nodiscard

Definition at line 667 of file Window.cpp.

◆ frame_height()

int galaxy::core::Window::frame_height ( ) const
nodiscard

Definition at line 672 of file Window.cpp.

◆ aspect_ratio()

float galaxy::core::Window::aspect_ratio ( ) const
nodiscard

Definition at line 677 of file Window.cpp.

◆ get_input()

template<meta::is_input_device Device>
Device & galaxy::core::Window::get_input ( )
inlinenodiscard

Get a window input device.

Template Parameters
DeviceThe type of input device to get. Constrained to a derived InputDevice.
Returns
Reference to the input device.

Definition at line 314 of file Window.hpp.

◆ get_drop_paths()

const meta::vector< std::string > & galaxy::core::Window::get_drop_paths ( ) const
nodiscard

Get a list of paths dropped on window.

Reset when a new path is dropped.

Definition at line 682 of file Window.cpp.

◆ get_framebuffer_size()

glm::ivec2 galaxy::core::Window::get_framebuffer_size ( )
nodiscard

Get framebuffer size taking into account DPI.

Returns
glm::ivec2.

Definition at line 687 of file Window.cpp.

◆ get_content_scale()

glm::vec2 galaxy::core::Window::get_content_scale ( )
nodiscard

Get window content scale.

Returns
glm::vec2.

Definition at line 695 of file Window.cpp.

+ Here is the caller graph for this function:

◆ get_content_scale_max()

float galaxy::core::Window::get_content_scale_max ( )
nodiscard

Get max window content scale.

Returns
Float.

Definition at line 703 of file Window.cpp.

+ Here is the call graph for this function:

◆ handle()

GLFWwindow * galaxy::core::Window::handle ( )
nodiscard

Retrieve pointer to GLFWwindow object.

Returns
Returns pointer to GLFWwindow.

Definition at line 709 of file Window.cpp.

◆ operator=() [1/2]

Window & galaxy::core::Window::operator= ( const Window & )
privatedelete

Copy assignment operator.

◆ operator=() [2/2]

Window & galaxy::core::Window::operator= ( Window && )
privatedelete

Move assignment operator.

Member Data Documentation

◆ m_title

std::string galaxy::core::Window::m_title
private

Window title.

Definition at line 245 of file Window.hpp.

◆ m_window_width

int galaxy::core::Window::m_window_width
private

Width of window (or fullscreen).

Definition at line 250 of file Window.hpp.

◆ m_window_height

int galaxy::core::Window::m_window_height
private

Height of window (or fullscreen).

Definition at line 255 of file Window.hpp.

◆ m_frame_width

int galaxy::core::Window::m_frame_width
private

The virtual or final framebuffer width.

Definition at line 260 of file Window.hpp.

◆ m_frame_height

int galaxy::core::Window::m_frame_height
private

The virtual or final framebuffer height.

Definition at line 265 of file Window.hpp.

◆ m_aspect_ratio

float galaxy::core::Window::m_aspect_ratio
private

Window aspect ratio.

Definition at line 270 of file Window.hpp.

◆ m_window

GLFWwindow* galaxy::core::Window::m_window
private

GLFW window data.

Definition at line 275 of file Window.hpp.

◆ m_dispatcher

entt::dispatcher* galaxy::core::Window::m_dispatcher
private

Currently active event dispatcher.

Definition at line 280 of file Window.hpp.

◆ m_glfw_allocator

GLFWallocator galaxy::core::Window::m_glfw_allocator
private

Custom GLFW window allocator.

Definition at line 285 of file Window.hpp.

◆ m_keyboard

input::Keyboard galaxy::core::Window::m_keyboard
private

Keyboard assigned to window.

Definition at line 290 of file Window.hpp.

◆ m_mouse

input::Mouse galaxy::core::Window::m_mouse
private

Mouse assigned to window.

Definition at line 295 of file Window.hpp.

◆ m_cursor

input::Cursor galaxy::core::Window::m_cursor
private

Mouse cursor.

Definition at line 300 of file Window.hpp.

◆ m_clipboard

input::Clipboard galaxy::core::Window::m_clipboard
private

Clipboard access.

Definition at line 305 of file Window.hpp.

◆ m_drop_paths

meta::vector<std::string> galaxy::core::Window::m_drop_paths
private

Cache of last dropped paths.

Definition at line 310 of file Window.hpp.


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