Newer
Older
GameEngine / src / Framework / Window.cpp
@John Ryland John Ryland on 22 Aug 1 KB save more of the WIP
/*
	ApplicationFramework
	by John Ryland
	Copyright (c) 2023
*/

////////////////////////////////////////////////////////////////////////////////////
//	Window

#include "Window.h"
#include "IApplication.h"
#include "IWindowSystem.h"
#include "IRenderSystem.h"

namespace ApplicationFramework {

Window::Window(IApplication& app, int width, int height, const char* title)
    : m_application(app)
{
    m_handle = m_application.WindowSystem()->CreateWindow(this, width, height, title);
    m_application.RenderSystem()->CreateWindow(this);
}

// virtual
Window::~Window()
{
    m_application.RenderSystem()->DestroyWindow(this);
    m_application.WindowSystem()->DestroyWindow(m_handle);
}

void Window::Show()
{
    m_application.WindowSystem()->ShowWindow(m_handle);
}

void Window::SetPosition(uint32_t x, uint32_t y)
{
    m_application.WindowSystem()->SetWindowPosition(m_handle, x, y);
}

void Window::Position(uint32_t& x, uint32_t& y)
{
    m_application.WindowSystem()->GetWindowPosition(m_handle, x, y);
}

void Window::SetSize(uint32_t width, uint32_t height)
{
    m_application.WindowSystem()->SetWindowSize(m_handle, width, height);
}

void Window::Size(uint32_t& width, uint32_t& height)
{
    m_application.WindowSystem()->GetWindowSize(m_handle, width, height);
}

void Window::SetFocused()
{
    m_application.WindowSystem()->SetWindowFocus(m_handle);
}

bool Window::HasFocus()
{
    return m_application.WindowSystem()->GetWindowFocus(m_handle);
}

bool Window::IsMinimized()
{
    return m_application.WindowSystem()->GetWindowMinimized(m_handle);
}

void Window::SetTitle(const char* str)
{
    m_application.WindowSystem()->SetWindowTitle(m_handle, str);
}

void Window::SetAlpha(float alpha)
{
    m_application.WindowSystem()->SetWindowAlpha(m_handle, alpha);
}

bool Window::IsKeyPressed(int key)
{
    return m_application.WindowSystem()->IsKeyPressed(m_handle, key);
}

} // ApplicationFramework namespace