75 lines
2.1 KiB
C
75 lines
2.1 KiB
C
|
#pragma once
|
||
|
|
||
|
#include <QFrame>
|
||
|
#include <QGridLayout>
|
||
|
#include <QPushButton>
|
||
|
#include <entity.hpp>
|
||
|
#include <QLabel>
|
||
|
#include <objectselectiondialog.h>
|
||
|
|
||
|
class Component;
|
||
|
class Asset;
|
||
|
|
||
|
class InspectorBase : public QFrame
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
public:
|
||
|
InspectorBase(QWidget* parent) : QFrame(parent) {}
|
||
|
|
||
|
//TODO: make this more consolidated (maybe templates?)
|
||
|
void Setup(Component* component, bool showRemoveButton = true)
|
||
|
{
|
||
|
m_layout = new QGridLayout(this);
|
||
|
m_layout->setAlignment(Qt::AlignTop);
|
||
|
m_layout->setSpacing(0);
|
||
|
|
||
|
if(showRemoveButton)
|
||
|
{
|
||
|
QLabel* label = new QLabel(Utility::GetTypeName(GetEntPool().GetType(component)).c_str());
|
||
|
m_layout->addWidget(label, 0, 0);
|
||
|
|
||
|
m_componentHandle = component;
|
||
|
|
||
|
QPushButton* duplicateButton = new QPushButton("Duplicate Component");
|
||
|
connect(duplicateButton, &QPushButton::clicked, this, &InspectorBase::DuplicateButtonClicked);
|
||
|
m_layout->addWidget(duplicateButton, 0, 1, Qt::AlignRight);
|
||
|
|
||
|
QPushButton* removeButton = new QPushButton("Remove Component");
|
||
|
connect(removeButton, &QPushButton::clicked, this, &InspectorBase::RemoveButtonClicked);
|
||
|
m_layout->addWidget(removeButton, 0, 2);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void AddProperty(QString name, glm::vec3& ref);
|
||
|
void AddProperty(QString name, glm::quat& ref);
|
||
|
void AddProperty(QString name, float& ref, float rate = 1.0f);
|
||
|
void AddProperty(QString name, ObjectSelectionType type, int& ref);
|
||
|
void AddProperty(QString name, bool& ref);
|
||
|
void AddProperty(QString name, std::string& ref);
|
||
|
|
||
|
void AddColorProperty(QString name, glm::vec3& ref);
|
||
|
|
||
|
void AddCustomProperty(QString name, QWidget* widget);
|
||
|
|
||
|
virtual InspectorBase* Clone(Component*)
|
||
|
{
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
virtual InspectorBase* Clone(Asset*)
|
||
|
{
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
signals:
|
||
|
void onChange();
|
||
|
|
||
|
protected:
|
||
|
QGridLayout* m_layout;
|
||
|
Component* m_componentHandle;
|
||
|
|
||
|
private:
|
||
|
void RemoveButtonClicked(bool checked);
|
||
|
void DuplicateButtonClicked(bool checked);
|
||
|
};
|