Archived
1
Fork 0

Add light inspector

This commit is contained in:
Joshua Goins 2018-12-25 22:51:26 -05:00
parent 815910ac90
commit b5bbd15bd8
2 changed files with 37 additions and 0 deletions

View file

@ -7,6 +7,7 @@ struct Context;
struct InfoComponent;
struct TransformComponent;
struct MeshComponent;
struct LightComponent;
class Inspector : public QWidget {
Q_OBJECT
@ -19,6 +20,7 @@ private:
void addInfoInspector(InfoComponent* info);
void addTransformInspector(TransformComponent* transform);
void addMeshInspector(MeshComponent* mesh);
void addLightInspector(LightComponent* light);
QVBoxLayout* layout = nullptr;

View file

@ -3,12 +3,14 @@
#include <QIcon>
#include <QLabel>
#include <QLineEdit>
#include <QComboBox>
#include "context.h"
#include "ecs.h"
#include "worldmanager.h"
#include "vec3edit.h"
#include "collapsesection.h"
#include "coloredit.h"
Inspector::Inspector(Context& context, QWidget* parent) : QWidget(parent), context(context) {
setWindowTitle("Inspector");
@ -49,6 +51,10 @@ void Inspector::rebuild() {
MeshComponent* mesh = ECS::getComponent<MeshComponent>(entity);
if(mesh)
addMeshInspector(mesh);
LightComponent* light = ECS::getComponent<LightComponent>(entity);
if(light)
addLightInspector(light);
}
void Inspector::addInfoInspector(InfoComponent* info) {
@ -94,3 +100,32 @@ void Inspector::addMeshInspector(MeshComponent* mesh) {
QGridLayout* layout = new QGridLayout();
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);
}