Add light inspector
This commit is contained in:
parent
815910ac90
commit
b5bbd15bd8
2 changed files with 37 additions and 0 deletions
|
@ -7,6 +7,7 @@ struct Context;
|
||||||
struct InfoComponent;
|
struct InfoComponent;
|
||||||
struct TransformComponent;
|
struct TransformComponent;
|
||||||
struct MeshComponent;
|
struct MeshComponent;
|
||||||
|
struct LightComponent;
|
||||||
|
|
||||||
class Inspector : public QWidget {
|
class Inspector : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -19,6 +20,7 @@ private:
|
||||||
void addInfoInspector(InfoComponent* info);
|
void addInfoInspector(InfoComponent* info);
|
||||||
void addTransformInspector(TransformComponent* transform);
|
void addTransformInspector(TransformComponent* transform);
|
||||||
void addMeshInspector(MeshComponent* mesh);
|
void addMeshInspector(MeshComponent* mesh);
|
||||||
|
void addLightInspector(LightComponent* light);
|
||||||
|
|
||||||
QVBoxLayout* layout = nullptr;
|
QVBoxLayout* layout = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,14 @@
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "ecs.h"
|
#include "ecs.h"
|
||||||
#include "worldmanager.h"
|
#include "worldmanager.h"
|
||||||
#include "vec3edit.h"
|
#include "vec3edit.h"
|
||||||
#include "collapsesection.h"
|
#include "collapsesection.h"
|
||||||
|
#include "coloredit.h"
|
||||||
|
|
||||||
Inspector::Inspector(Context& context, QWidget* parent) : QWidget(parent), context(context) {
|
Inspector::Inspector(Context& context, QWidget* parent) : QWidget(parent), context(context) {
|
||||||
setWindowTitle("Inspector");
|
setWindowTitle("Inspector");
|
||||||
|
@ -49,6 +51,10 @@ void Inspector::rebuild() {
|
||||||
MeshComponent* mesh = ECS::getComponent<MeshComponent>(entity);
|
MeshComponent* mesh = ECS::getComponent<MeshComponent>(entity);
|
||||||
if(mesh)
|
if(mesh)
|
||||||
addMeshInspector(mesh);
|
addMeshInspector(mesh);
|
||||||
|
|
||||||
|
LightComponent* light = ECS::getComponent<LightComponent>(entity);
|
||||||
|
if(light)
|
||||||
|
addLightInspector(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inspector::addInfoInspector(InfoComponent* info) {
|
void Inspector::addInfoInspector(InfoComponent* info) {
|
||||||
|
@ -94,3 +100,32 @@ void Inspector::addMeshInspector(MeshComponent* mesh) {
|
||||||
QGridLayout* layout = new QGridLayout();
|
QGridLayout* layout = new QGridLayout();
|
||||||
section->setLayout(layout);
|
section->setLayout(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Inspector::addLightInspector(LightComponent* light) {
|
||||||
|
CollapseSection* section = new CollapseSection("Light", true);
|
||||||
|
layout->addWidget(section);
|
||||||
|
sections.push_back(section);
|
||||||
|
|
||||||
|
QGridLayout* layout = new QGridLayout();
|
||||||
|
section->setLayout(layout);
|
||||||
|
|
||||||
|
QLabel* typeLabel = new QLabel("Type");
|
||||||
|
layout->addWidget(typeLabel);
|
||||||
|
|
||||||
|
QComboBox* typeCombo = new QComboBox();
|
||||||
|
typeCombo->addItem("Point");
|
||||||
|
typeCombo->addItem("Directional");
|
||||||
|
typeCombo->setCurrentIndex((int)light->type);
|
||||||
|
|
||||||
|
connect(typeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), [light](int index) {
|
||||||
|
light->type = (LightType)index;
|
||||||
|
});
|
||||||
|
|
||||||
|
layout->addWidget(typeCombo, 0, 1);
|
||||||
|
|
||||||
|
QLabel* colorLabel = new QLabel("Color");
|
||||||
|
layout->addWidget(colorLabel, 1, 0);
|
||||||
|
|
||||||
|
ColorEdit* colorEdit = new ColorEdit(light->color);
|
||||||
|
layout->addWidget(colorEdit, 1, 1);
|
||||||
|
}
|
||||||
|
|
Reference in a new issue