Cleaning up and making the debugger resize well

This commit is contained in:
Anonymus Raccoon
2020-02-16 22:54:43 +01:00
parent 2f1c53a92d
commit 74045c0d99
7 changed files with 141 additions and 214 deletions
+8 -5
View File
@@ -16,14 +16,17 @@
namespace ComSquare::Renderer
{
QtSFML::QtSFML(unsigned int h, unsigned int w) :
QtWindow(h, w), _sfWidget(nullptr)
{ }
_window(), _sfWidget(nullptr)
{
this->_window.resize(w, h);
}
void QtSFML::createWindow(SNES &snes, int maxFPS)
{
this->setWindowName(snes.cartridge->header.gameName);
this->_sfWidget = std::make_unique<QtFullSFML>(snes, &_frame, QPoint(0, 0), QSize(this->_width, this->_height), maxFPS);
this->_sfWidget->show();
this->_sfWidget = std::make_unique<QtFullSFML>(snes, &_window, QPoint(0, 0), QSize(this->_window.width(), this->_window.height()), maxFPS);
this->_sfWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
this->_window.show();
}
void QtSFML::putPixel(unsigned y, unsigned x, uint32_t rgba)
@@ -35,7 +38,7 @@ namespace ComSquare::Renderer
void QtSFML::setWindowName(std::string &newWindowName)
{
QtWindow::setWindowName(newWindowName);
this->_window.setWindowTitle((newWindowName + " - ComSquare").c_str());
}
QtFullSFML::QtFullSFML(SNES &snes, QWidget *parent, const QPoint &position, const QSize &size, int frameRate) :
+4 -2
View File
@@ -8,10 +8,10 @@
#include <QtWidgets/QWidget>
#include <SFML/Graphics/RenderWindow.hpp>
#include <QtCore/QTimer>
#include <QtWidgets/QMainWindow>
#include "../IRenderer.hpp"
#include "../SFRenderer.hpp"
#include "QtWidgetSFML.hpp"
#include "QtWindow.hpp"
namespace ComSquare::Renderer
{
@@ -29,8 +29,10 @@ namespace ComSquare::Renderer
};
//! @brief A SFML renderer inside a QT window.
class QtSFML : public IRenderer, public QtWindow {
class QtSFML : public IRenderer {
private:
//! @brief The main window that the app reside on.
QMainWindow _window;
//! @brief The SFML widget.
std::unique_ptr<QtFullSFML> _sfWidget = nullptr;
public:
-21
View File
@@ -1,21 +0,0 @@
//
// Created by anonymus-raccoon on 2/16/20.
//
#include "QtWindow.hpp"
#include <QIcon>
namespace ComSquare::Renderer
{
QtWindow::QtWindow(unsigned int height, unsigned int width) :
_frame(), _width(width), _height(height)
{
this->_frame.setWindowIcon(QIcon(":/resources/Logo.png"));
this->_frame.show();
}
void QtWindow::setWindowName(std::string &newWindowName)
{
this->_frame.setWindowTitle((newWindowName + " - ComSquare").c_str());
}
}
-35
View File
@@ -1,35 +0,0 @@
//
// Created by anonymus-raccoon on 2/16/20.
//
#ifndef COMSQUARE_QTWINDOW_HPP
#define COMSQUARE_QTWINDOW_HPP
#include <QtWidgets/QFrame>
namespace ComSquare::Renderer
{
class QtWindow {
protected:
//! @brief The SFML frame.
QFrame _frame;
//! @brief The _width of the window.
unsigned int _width;
//! @brief The _height of the window.
unsigned int _height;
public:
//! @brief Set a new name to the window, if there is already a name it will be overwrite.
//! @param newWindowName new title for the window.
void setWindowName(std::string &newWindowName);
//! @brief Constructor that return a SFML renderer inside a QT window.
//! @param height _height of the window.
//! @param width _width of the window.
QtWindow(unsigned int height, unsigned int width);
QtWindow(const QtWindow &) = delete;
QtWindow &operator=(const QtWindow &) = delete;
~QtWindow() = default;
};
}
#endif //COMSQUARE_QTWINDOW_HPP