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
-2
View File
@@ -131,8 +131,6 @@ add_executable(ComSquare
sources/Renderer/QtRenderer/QtWidgetSFML.hpp sources/Renderer/QtRenderer/QtWidgetSFML.hpp
ui/cpu.ui ui/cpu.ui
resources/appResources.qrc resources/appResources.qrc
sources/Renderer/QtRenderer/QtWindow.cpp
sources/Renderer/QtRenderer/QtWindow.hpp
sources/Utility/Utility.hpp) sources/Utility/Utility.hpp)
target_compile_definitions(ComSquare PUBLIC DEBUGGER_ENABLED) target_compile_definitions(ComSquare PUBLIC DEBUGGER_ENABLED)
-1
View File
@@ -8,7 +8,6 @@
#include "../CPU/CPU.hpp" #include "../CPU/CPU.hpp"
#include "../Renderer/SFRenderer.hpp" #include "../Renderer/SFRenderer.hpp"
#include "../SNES.hpp" #include "../SNES.hpp"
#include "../Renderer/QtRenderer/QtWindow.hpp"
#include "../../ui/ui_cpu.h" #include "../../ui/ui_cpu.h"
namespace ComSquare::Debugger namespace ComSquare::Debugger
+8 -5
View File
@@ -16,14 +16,17 @@
namespace ComSquare::Renderer namespace ComSquare::Renderer
{ {
QtSFML::QtSFML(unsigned int h, unsigned int w) : 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) void QtSFML::createWindow(SNES &snes, int maxFPS)
{ {
this->setWindowName(snes.cartridge->header.gameName); 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 = std::make_unique<QtFullSFML>(snes, &_window, QPoint(0, 0), QSize(this->_window.width(), this->_window.height()), maxFPS);
this->_sfWidget->show(); this->_sfWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
this->_window.show();
} }
void QtSFML::putPixel(unsigned y, unsigned x, uint32_t rgba) void QtSFML::putPixel(unsigned y, unsigned x, uint32_t rgba)
@@ -35,7 +38,7 @@ namespace ComSquare::Renderer
void QtSFML::setWindowName(std::string &newWindowName) 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) : 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 <QtWidgets/QWidget>
#include <SFML/Graphics/RenderWindow.hpp> #include <SFML/Graphics/RenderWindow.hpp>
#include <QtCore/QTimer> #include <QtCore/QTimer>
#include <QtWidgets/QMainWindow>
#include "../IRenderer.hpp" #include "../IRenderer.hpp"
#include "../SFRenderer.hpp" #include "../SFRenderer.hpp"
#include "QtWidgetSFML.hpp" #include "QtWidgetSFML.hpp"
#include "QtWindow.hpp"
namespace ComSquare::Renderer namespace ComSquare::Renderer
{ {
@@ -29,8 +29,10 @@ namespace ComSquare::Renderer
}; };
//! @brief A SFML renderer inside a QT window. //! @brief A SFML renderer inside a QT window.
class QtSFML : public IRenderer, public QtWindow { class QtSFML : public IRenderer {
private: private:
//! @brief The main window that the app reside on.
QMainWindow _window;
//! @brief The SFML widget. //! @brief The SFML widget.
std::unique_ptr<QtFullSFML> _sfWidget = nullptr; std::unique_ptr<QtFullSFML> _sfWidget = nullptr;
public: 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
+129 -148
View File
@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>422</width> <width>420</width>
<height>399</height> <height>405</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -21,152 +21,133 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<widget class="QTextBrowser" name="logger"> <layout class="QGridLayout" name="gridLayout">
<property name="geometry"> <item row="0" column="0" rowspan="2">
<rect> <layout class="QFormLayout" name="formLayout">
<x>220</x> <item row="0" column="0">
<y>30</y> <widget class="QLabel" name="accumulatorLabel">
<width>200</width> <property name="text">
<height>305</height> <string>Accumulator</string>
</rect> </property>
</property> </widget>
</widget> </item>
<widget class="QLabel" name="loggerLabel"> <item row="0" column="1">
<property name="geometry"> <widget class="QLineEdit" name="accumulatorLineEdit">
<rect> <property name="text">
<x>220</x> <string/>
<y>0</y> </property>
<width>200</width> </widget>
<height>25</height> </item>
</rect> <item row="1" column="0">
</property> <widget class="QLabel" name="programBankRegisterLabel">
<property name="text"> <property name="text">
<string>Instructions History</string> <string>Program Bank</string>
</property> </property>
<property name="alignment"> </widget>
<set>Qt::AlignCenter</set> </item>
</property> <item row="1" column="1">
</widget> <widget class="QLineEdit" name="programBankRegisterLineEdit"/>
<widget class="QWidget" name="formLayoutWidget"> </item>
<property name="geometry"> <item row="2" column="0">
<rect> <widget class="QLabel" name="programCounterLabel">
<x>0</x> <property name="text">
<y>0</y> <string>Program Counter</string>
<width>211</width> </property>
<height>361</height> </widget>
</rect> </item>
</property> <item row="2" column="1">
<layout class="QFormLayout" name="formLayout"> <widget class="QLineEdit" name="programCounterLineEdit"/>
<item row="0" column="0"> </item>
<widget class="QLabel" name="accumulatorLabel"> <item row="3" column="0">
<property name="text"> <widget class="QLabel" name="directBankLabel">
<string>Accumulator</string> <property name="text">
</property> <string>Direct Bank</string>
</widget> </property>
</item> </widget>
<item row="0" column="1"> </item>
<widget class="QLineEdit" name="accumulatorLineEdit"> <item row="3" column="1">
<property name="text"> <widget class="QLineEdit" name="directBankLineEdit"/>
<string/> </item>
</property> <item row="4" column="0">
</widget> <widget class="QLabel" name="directPageLabel">
</item> <property name="text">
<item row="1" column="0"> <string>Direct Page</string>
<widget class="QLabel" name="programBankRegisterLabel"> </property>
<property name="text"> </widget>
<string>Program Bank</string> </item>
</property> <item row="4" column="1">
</widget> <widget class="QLineEdit" name="directPageLineEdit"/>
</item> </item>
<item row="1" column="1"> <item row="5" column="0">
<widget class="QLineEdit" name="programBankRegisterLineEdit"/> <widget class="QLabel" name="stackPointerLabel">
</item> <property name="text">
<item row="2" column="0"> <string>Stack Pointer</string>
<widget class="QLabel" name="programCounterLabel"> </property>
<property name="text"> </widget>
<string>Program Counter</string> </item>
</property> <item row="5" column="1">
</widget> <widget class="QLineEdit" name="stackPointerLineEdit"/>
</item> </item>
<item row="2" column="1"> <item row="6" column="0">
<widget class="QLineEdit" name="programCounterLineEdit"/> <widget class="QLabel" name="xIndexLabel">
</item> <property name="text">
<item row="3" column="0"> <string>X Index</string>
<widget class="QLabel" name="directBankLabel"> </property>
<property name="text"> </widget>
<string>Direct Bank</string> </item>
</property> <item row="6" column="1">
</widget> <widget class="QLineEdit" name="xIndexLineEdit"/>
</item> </item>
<item row="3" column="1"> <item row="7" column="0">
<widget class="QLineEdit" name="directBankLineEdit"/> <widget class="QLabel" name="yIndexLabel">
</item> <property name="text">
<item row="4" column="0"> <string>Y Index</string>
<widget class="QLabel" name="directPageLabel"> </property>
<property name="text"> </widget>
<string>Direct Page</string> </item>
</property> <item row="7" column="1">
</widget> <widget class="QLineEdit" name="yIndexLineEdit"/>
</item> </item>
<item row="4" column="1"> <item row="8" column="0">
<widget class="QLineEdit" name="directPageLineEdit"/> <widget class="QLabel" name="flagsLabel">
</item> <property name="text">
<item row="5" column="0"> <string>Flags</string>
<widget class="QLabel" name="stackPointerLabel"> </property>
<property name="text"> </widget>
<string>Stack Pointer</string> </item>
</property> <item row="8" column="1">
</widget> <widget class="QLineEdit" name="flagsLineEdit"/>
</item> </item>
<item row="5" column="1"> <item row="9" column="0">
<widget class="QLineEdit" name="stackPointerLineEdit"/> <widget class="QLabel" name="emulationModeLabel">
</item> <property name="text">
<item row="6" column="0"> <string>Emulation mode</string>
<widget class="QLabel" name="xIndexLabel"> </property>
<property name="text"> </widget>
<string>X Index</string> </item>
</property> <item row="9" column="1">
</widget> <widget class="QCheckBox" name="emulationModeCheckBox">
</item> <property name="layoutDirection">
<item row="6" column="1"> <enum>Qt::RightToLeft</enum>
<widget class="QLineEdit" name="xIndexLineEdit"/> </property>
</item> </widget>
<item row="7" column="0"> </item>
<widget class="QLabel" name="yIndexLabel"> </layout>
<property name="text"> </item>
<string>Y Index</string> <item row="0" column="1">
</property> <widget class="QLabel" name="loggerLabel">
</widget> <property name="text">
</item> <string>Instructions History</string>
<item row="7" column="1"> </property>
<widget class="QLineEdit" name="yIndexLineEdit"/> <property name="alignment">
</item> <set>Qt::AlignCenter</set>
<item row="8" column="0"> </property>
<widget class="QLabel" name="flagsLabel"> </widget>
<property name="text"> </item>
<string>Flags</string> <item row="1" column="1">
</property> <widget class="QTextBrowser" name="logger"/>
</widget> </item>
</item> </layout>
<item row="8" column="1">
<widget class="QLineEdit" name="flagsLineEdit"/>
</item>
<item row="9" column="0">
<widget class="QLabel" name="emulationModeLabel">
<property name="text">
<string>Emulation mode</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QCheckBox" name="emulationModeCheckBox">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
<widget class="QToolBar" name="toolBar"> <widget class="QToolBar" name="toolBar">
<property name="minimumSize"> <property name="minimumSize">