Window class reference


The main Ange widget. "Window" instance can create a GLFW physical window or sub-window. Requires initialization using the Init() method.

Functions

Functions documentation

Window(
Window* parent = nullptr,
std::string windowName = "Ange Window",
const Widget2DProps& props = Widget2DProps({ 0,0 }, {720, 480}, WindowFlags::FifoDrawable)
) noexcept;

Default constructor.


Window(const Window & copy);

Copy constructor. Does NOT copy bindings, only position, dimension etc.


virtual ~Window() noexcept;

Destructor. Basicly it invokes Cleanup() method.


Window& operator=(Window rhs);

Assignment operator.


friend void swap(Window& first, Window& second) noexcept;

Swap function. Swaps only trivial data, such as position, dimension, m_Widget2DPorps, m_World, m_ResizableProps.


Window* Clone() const override;

Clone function. Does NOT copy bindings, only position, dimension etc.


bool Operate() noexcept;

Runs all the processes occurring in the window and allows it to operate properly. Based on the dimensions of the window, sets the view scissor and executes the function DispatchEvents() of the base class EventDispatcher. If the window is of the type "Parent", it automatically performs a buffer swap (glfwSwapBuffers()), and processes all events from the GLFW (glfwPollEvents()). Returns true if the window is open.


void Swap() noexcept;

Replaces the old image with a recently rendered one.


void ClearScene() noexcept;

It the window is of the "Parent" type, it clears previously rendered frame, and setups the background to background color.


void Init() noexcept;

Starts initialization processes for a specific window type.


bool IfOpen() const noexcept;

Returns value which describes if the window is closed (false) or open (true).


void Close() noexcept;

Sends a signal to the window to close. Attention, closure may not occur immediately. Because the sent event must be processed by the Operate() function.


void SetVSync(int value) const noexcept;

Sets vertical synchronization. Only for the "Parent" window.


void MakeCurrent() noexcept;

Sets the window to be active for rendering (for OpenGL). Only for the "Parent" window.


void SetClearColor(Color newColor) noexcept;

Sets the background color. Only for the "Parent" window.


const Dimension<size_t> GetPhysicalWindowDim() const noexcept;

Returns the actual size of the physical (top) window in pixels.


const Point<int> GetRealPosition() const noexcept;

Returns the actual position of the physical (top) window in pixels. Can be negative.


ShaderManager* GetShaderManager() const noexcept;

Returns pointer to the ShaderManager object from the physical (top) window. Do not delete the received object yourself.


bool GetFocusStatus() const noexcept;

Returns window focus status (eg. 0 -> no focus, 1 -> focused).


World* GetWorld() noexcept;

Returns pointer to the World object. Do not delete the received object yourself.


GLFWwindow* GetGLFWwindow() const noexcept;

Returns pointer to the top (physical) window GLFWwindow object. Do not delete the received object yourself.


void SetWindowSize(Dimension<size_t> newSize) noexcept;

Sets the new window size.


void SetPosition(Point<int> newPosition) noexcept override;

Sets the new window position.


void ChangePosition(Point<int> positionChange) noexcept override;

Changes the window position.


void SetMinMaxDimensions(int iMinWidth, int iMinHeight, int iMaxWidth, int iMaxHeight) noexcept override;

Sets the constraints of the window.


void SetVisibility(bool mode) noexcept override;

Sets the visibility of the window.


bool GetVisibility() const noexcept override;

Returns the value corresponding to the visibility of the window.


std::string GetWindowName();

Returns the window name.


void SetCallback(Callback callback) noexcept;

Sets callback function;


void ResetCallback() noexcept;

Resets callback.


void SetFlags(int newFlags) noexcept override;

Sets new flags for the window.


void EnableWidget() noexcept override;

Activates listening for upcoming events.


void DisableWidget() noexcept override;

Deactivates listening for upcoming events.


void Render() noexcept override;

Adds a widget rendering event to the event list.


void UnregisterEvent(EventType eventType) override;

Allows to unregister internal event hook.


void InitParent(const Widget2DProps& props) noexcept;

Initializes the window in "Parent" mode.


void InitChild(const Widget2DProps& props) noexcept;

Initializes the window in "Child" mode.


void Cleanup() noexcept;

Clears the memory of the window object. It also performs memory cleaning in sub windows. The function is secured against re-use.


bool OnWindowResize(Event* event) noexcept;

Event handling mehod. Performs automatic viewport change and changes in the world's matrices. Only for window of 'Parent' type.


bool OnWindowIconify(Event* event) noexcept;

Event handling mehod. Changes the internal state of "bIconify". Only for window of 'Parent' type.


bool OnWindowClose(Event* event) noexcept;

Event handling mehod. Invoking Cleanup() method. Only for window of 'Parent' type.


bool OnWindowMove(Event* event) noexcept;

Event handling mehod. Updates variables that store the position of the window. Only for window of 'Parent' type.


bool OnWindowFocusChange(Event* event) noexcept;

Event handling mehod. Changes the internal state of "bFocus". Only for window of 'Parent' type.


bool SubWindowAlterEvent(Event* event) noexcept;

Event handling mehod for window of "Child" type. Analyzes events and sends them to the child window to process (sometimes in an altered form).


Variables documentation

WindowProps m_WindowProps;

Stores data regarding window states.


WindowType m_WindowType;

Indicates the window type (Parent or Child).


ShaderManager* m_ShaderManager;

An pointer to the object that stores OpenGL shaders. Copied from the physical (top) window.


World* m_World;

An pointer to the object that stores VP matrices. Copied from the physical (top) window.


Callback m_Callback;

An pointer to the callback function.


std::list<BindListIterator> m_InternalBindings;

List of iterators after internal binding.


std::list<BindListIterator> m_ExternalBindings;

List of iterators after external binding (to the other windows/widgets).


GLFWwindow* m_GLFWWindow;

Pointer for the "GLFWwindow" object of the GLFW library.


static bool s_GLFWInitialized;

Static variable to secure the re-initialization of the GLFW library.