Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
|
A class providing access to various window management methods and window event Signals. More...
#include <window_context_manager.hpp>
Public Member Functions | |
SDL_GLContext | getGLContext () const |
Accessor for the OpenGL context pointer. | |
SDL_Window * | getSDLWindow () const |
Accessor for the SDL Window pointer. | |
Assimp::Importer * | getAssetImporter () const |
Accessor for asset importer (which for some reason is tied to this WindowContext) | |
void | handleWindowEvent (const SDL_WindowEvent &windowEvent) |
Converts an SDL window event into its corresponding engine Signal equivalent, which it then broadcasts. | |
void | swapBuffers () |
Swaps the back and front buffers of the framebuffer associated with the application window. | |
const std::string & | getTitle () const |
Gets the title of this window. | |
bool | isMaximized () const |
Tests whether this window is maximized. | |
bool | isMinimized () const |
Tests whether this window is minimized. | |
bool | isResizable () const |
Tests whether this window is resizable. | |
bool | isHidden () const |
Tests whether this window is hidden (as in, there is another window on top of it, or it is minimized (I think)). | |
bool | isShown () const |
Tests whether this window is shown, inverse of hidden. | |
bool | hasKeyFocus () const |
Tests whether this window has keyboard focus. | |
bool | hasMouseFocus () const |
Tests whether this window has mouse focus. | |
bool | hasCapturedMouse () const |
Tests whether this window has captured the mouse. | |
bool | isFullscreen () const |
Tests whether this window is in fullscreen. | |
bool | isExclusiveFullscreen () const |
Tests whether a fullscreen window is using exclusive fullscreen. | |
bool | isBorderless () const |
Tests whether this window is using windowed borderless fullscreen. | |
int | getDisplayID () const |
Gets the ID associated with the monitor this window is primarily being displayed on. | |
const glm::ivec2 | getPosition () const |
Gets the position of this window (relative to the top left corner of the screen) in screen coordinates. | |
const glm::uvec2 | getDimensions () const |
Gets the dimensions of this window (in pixels). | |
const glm::uvec2 | getDimensionsMinimum () const |
Gets the minimum dimensions allowed for this window (in screen coordinates). | |
const glm::uvec2 | getDimensionsMaximum () const |
Gets the maximum dimensions allowed for this window (in screen coordinates). | |
void | setPosition (const glm::uvec2 &position) |
Sets the position of this window relative to the top left corner of the screen, in screen coordinates. | |
void | setDimensions (const glm::uvec2 &dimensions) |
Sets the width and height of the window, in pixels (since SDL_WINDOW_ALLOW_HIGHDPI ought to have been called). | |
void | setResizeAllowed (bool allowed) |
Enables or disables the resizing of this window. | |
void | setBorder (bool state) |
Adds or removes the border around this window. | |
void | setHidden (bool hide) |
Sets this window's visibility. | |
void | setTitle (const std::string &newTitle) |
Sets the title for this window. | |
void | setDimensionsMinimum (const glm::uvec2 &dimensions) |
Sets the minimum allowable dimensions for this window in screen coordinates. | |
void | setDimensionsMaximum (const glm::uvec2 &dimensions) |
Sets the maximum allowable dimensions for this window, in screen coordinates. | |
void | setFullscreen (bool fullscreen, bool exclusive=false) |
Makes this window fullscreen. | |
void | maximize () |
Maximizes this window. | |
void | minimize () |
Minimizes this window. | |
void | restore () |
Restores this window (if it has been minimized). | |
Static Public Member Functions | |
static WindowContext & | getInstance () |
Gets this application's sole window instance. | |
static WindowContext & | initialize (const nlohmann::json &initialWindowConfiguration) |
Initializes this window context with the settings specified in this project's project.json file. | |
static void | clear () |
Loses reference to the singleton window context, initiating its destruction. | |
Public Attributes | |
Signal | mSigWindowResized { mSignalTracker, "WindowResized" } |
Signal emitted when this window's dimensions are changed. | |
Signal | mSigWindowMaximized { mSignalTracker, "WindowMaximized" } |
Signal emitted when this window is maximized. | |
Signal | mSigWindowMinimized { mSignalTracker, "WindowMinimized" } |
Signal emitted when this window is minimized. | |
Signal | mSigWindowMoved { mSignalTracker, "WindowMoved" } |
Signal emitted when this window is repositioned. | |
Signal | mSigWindowMouseEntered { mSignalTracker, "WindowMouseEntered" } |
Signal emitted when the mouse has entered this window. | |
Signal | mSigWindowMouseExited { mSignalTracker, "WindowMouseExited" } |
Signal emitted when the mouse leaves this window. | |
Signal | mSigWindowShown { mSignalTracker, "WindowShown" } |
Signal emitted when this window is shown. | |
Signal | mSigWindowHidden { mSignalTracker, "WindowHidden" } |
Signal emitted when this window is hidden. | |
Signal | mSigWindowExposed { mSignalTracker, "WindowExposed" } |
Signal emitted when this window is exposed. | |
Signal | mSigWindowSizeChanged { mSignalTracker, "WindowSizeChanged" } |
Signal emitted when this window is resized. | |
Signal | mSigWindowRestored { mSignalTracker, "WindowRestored" } |
Signal emitted when this window is restored (after being minimized). | |
Signal | mSigWindowKeyFocusGained { mSignalTracker, "WindowKeyFocusGained" } |
Signal emitted when this window receives keyboard focus. | |
Signal | mSigWindowKeyFocusLost { mSignalTracker, "WindowKeyFocusLost" } |
Signal emitted when this window loses keyboard focus. | |
Signal | mSigWindowCloseRequested { mSignalTracker, "WindowClosed" } |
Signal emitted when the user attempts to close this window (by the X button in the window border usually). | |
Signal | mSigWindowKeyFocusOffered { mSignalTracker, "WindowKeyFocusOffered" } |
Signal emitted when the application offers keyboard focus to the user. | |
Signal | mSigWindowICCProfileChanged { mSignalTracker, "WindowICCProfileChanged" } |
I don't know what this is quite honestly. | |
Signal | mSigWindowDisplayChanged { mSignalTracker, "WindowDisplayChanged" } |
Signal emitted when the window display changes. | |
Private Member Functions | |
void | refreshWindowProperties () |
Replaces currently cached window properties. | |
WindowContext (const nlohmann::json &initialWindowConfiguration) | |
Initializes SDL and OpenGL contexts, creates an SDL window and stores a reference to it. | |
WindowContext (const WindowContext &other)=delete | |
WindowContext (WindowContext &&other)=delete | |
WindowContext & | operator= (const WindowContext &other)=delete |
WindowContext & | operator= (WindowContext &&other)=delete |
Private Attributes | |
SignalTracker | mSignalTracker {} |
The signal tracker responsible for publishing window related signals and tracking their observers. | |
SDL_Window * | mpSDLWindow |
The SDL window handle this class is a wrapper over. | |
SDL_GLContext | mpGLContext |
The OpenGL context associated with this window. | |
Assimp::Importer * | mpAssetImporter |
The asset importer asset associated with this window (and therefore the whole project) | |
SDL_WindowFlags | mCachedWindowFlags {} |
A number whose bits represent different modes a window can be in. | |
glm::i16vec2 | mCachedWindowPosition {} |
The cached position of this window, in screen coordinates. | |
glm::u16vec2 | mCachedWindowDimensions {} |
The cached dimensions of this window, in pixels. | |
glm::u16vec2 | mCachedWindowMinimumDimensions {} |
The minimum allowed dimensions for this window, in screen coordinates. | |
glm::u16vec2 | mCachedWindowMaximumDimensions {} |
The maximum allowed dimensions for this window, in screen coordinates. | |
int | mCachedDisplayID {0} |
The ID of the display (or monitor) this window is rendered on. | |
std::string | mCachedTitle {} |
The cached title of this window. | |
Static Private Attributes | |
static std::unique_ptr< WindowContext > | s_windowContextManager { nullptr } |
A pointer to the single static instance of the WindowContext associated with the application. | |
A class providing access to various window management methods and window event Signals.
It is essentially a convenient wrapper over SDL_Window.
|
static |
Loses reference to the singleton window context, initiating its destruction.
Usually called as part of the application cleanup process.
const glm::uvec2 WindowContext::getDimensions | ( | ) | const |
Gets the dimensions of this window (in pixels).
const glm::uvec2 WindowContext::getDimensionsMaximum | ( | ) | const |
Gets the maximum dimensions allowed for this window (in screen coordinates).
const glm::uvec2 WindowContext::getDimensionsMinimum | ( | ) | const |
Gets the minimum dimensions allowed for this window (in screen coordinates).
int WindowContext::getDisplayID | ( | ) | const |
Gets the ID associated with the monitor this window is primarily being displayed on.
|
static |
Gets this application's sole window instance.
const glm::ivec2 WindowContext::getPosition | ( | ) | const |
Gets the position of this window (relative to the top left corner of the screen) in screen coordinates.
const std::string & WindowContext::getTitle | ( | ) | const |
Gets the title of this window.
void WindowContext::handleWindowEvent | ( | const SDL_WindowEvent & | windowEvent | ) |
Converts an SDL window event into its corresponding engine Signal equivalent, which it then broadcasts.
windowEvent | The SDL window event to be converted. |
bool WindowContext::hasCapturedMouse | ( | ) | const |
Tests whether this window has captured the mouse.
true | This window has captured the mouse. |
false | This window has not captured the mouse. |
bool WindowContext::hasKeyFocus | ( | ) | const |
Tests whether this window has keyboard focus.
true | This window has keyboard focus. |
false | This window does not have keyboard focus. |
bool WindowContext::hasMouseFocus | ( | ) | const |
Tests whether this window has mouse focus.
true | This window has mouse focus. |
false | This window does not have mouse focus. |
|
static |
Initializes this window context with the settings specified in this project's project.json
file.
initialWindowConfiguration | The window configuration for this application. |
bool WindowContext::isBorderless | ( | ) | const |
Tests whether this window is using windowed borderless fullscreen.
true | This window is using windowed borderless fullscreen. |
false | This window is using exclusive fullscreen, or isn't in fullscreen at all. |
bool WindowContext::isExclusiveFullscreen | ( | ) | const |
Tests whether a fullscreen window is using exclusive fullscreen.
true | This window is using exclusive fullscreen. |
false | This window is using borderless window fullscreen or isn't in fullscreen at all. |
bool WindowContext::isFullscreen | ( | ) | const |
Tests whether this window is in fullscreen.
true | This window is in full screen. |
false | This window is not in full screen. |
bool WindowContext::isHidden | ( | ) | const |
Tests whether this window is hidden (as in, there is another window on top of it, or it is minimized (I think)).
true | This window is hidden. |
false | This window is not hidden. |
bool WindowContext::isMaximized | ( | ) | const |
Tests whether this window is maximized.
true | This window is maximized. |
false | This window is not maximized. |
bool WindowContext::isMinimized | ( | ) | const |
Tests whether this window is minimized.
true | This window is minimized. |
false | This window is not minimized. |
bool WindowContext::isResizable | ( | ) | const |
Tests whether this window is resizable.
true | This window is resizable. |
false | This window is unresizable. |
bool WindowContext::isShown | ( | ) | const |
Tests whether this window is shown, inverse of hidden.
true | This window is shown. |
false | This window is not shown. |
void WindowContext::setBorder | ( | bool | state | ) |
Adds or removes the border around this window.
state | Whether the border is enabled or disabled. |
void WindowContext::setDimensions | ( | const glm::uvec2 & | dimensions | ) |
Sets the width and height of the window, in pixels (since SDL_WINDOW_ALLOW_HIGHDPI ought to have been called).
dimensions | The new dimensions for this window. |
void WindowContext::setDimensionsMaximum | ( | const glm::uvec2 & | dimensions | ) |
Sets the maximum allowable dimensions for this window, in screen coordinates.
dimensions | This window's new maximum allowable dimensions. |
void WindowContext::setDimensionsMinimum | ( | const glm::uvec2 & | dimensions | ) |
Sets the minimum allowable dimensions for this window in screen coordinates.
dimensions | This window's new minimum allowable dimensions. |
void WindowContext::setFullscreen | ( | bool | fullscreen, |
bool | exclusive = false ) |
Makes this window fullscreen.
fullscreen | Whether or not to enable fullscreen. |
exclusive | Use exclusive fullscreen, borderless windowed mode otherwise. |
void WindowContext::setHidden | ( | bool | hide | ) |
Sets this window's visibility.
hide | Whether to hide or show this window. |
void WindowContext::setPosition | ( | const glm::uvec2 & | position | ) |
Sets the position of this window relative to the top left corner of the screen, in screen coordinates.
position | The new position of this window. |
void WindowContext::setResizeAllowed | ( | bool | allowed | ) |
Enables or disables the resizing of this window.
allowed | Whether this window should be resizable. |
void WindowContext::setTitle | ( | const std::string & | newTitle | ) |
Sets the title for this window.
newTitle | This window's new title. |
|
private |
The maximum allowed dimensions for this window, in screen coordinates.
|
private |
The minimum allowed dimensions for this window, in screen coordinates.
|
private |
The cached position of this window, in screen coordinates.
|
private |
The asset importer asset associated with this window (and therefore the whole project)
|
private |
The OpenGL context associated with this window.
Signal ToyMaker::WindowContext::mSigWindowDisplayChanged { mSignalTracker, "WindowDisplayChanged" } |
Signal ToyMaker::WindowContext::mSigWindowICCProfileChanged { mSignalTracker, "WindowICCProfileChanged" } |
I don't know what this is quite honestly.
Signal ToyMaker::WindowContext::mSigWindowSizeChanged { mSignalTracker, "WindowSizeChanged" } |
Signal emitted when this window is resized.
|
inlinestaticprivate |
A pointer to the single static instance of the WindowContext associated with the application.