feat: implement type-safe ReferenceProperty for SmartPointer fields and add UI support for object selection via context-aware dropdowns

This commit is contained in:
AndreaRigoni
2026-04-17 13:20:21 +00:00
parent ec2d437819
commit 506b8f037f
12 changed files with 265 additions and 12 deletions

View File

@@ -4,6 +4,7 @@
#include <QWidget>
class QPushButton;
class QSlider;
class QComboBox;
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
@@ -21,6 +22,8 @@ class QSlider;
#include "Math/Dense.h"
#include "Settings.h"
namespace uLib { class ObjectsContext; }
namespace uLib {
namespace Qt {
@@ -211,12 +214,28 @@ private:
QPushButton* m_Button;
};
class ReferencePropertyWidget : public PropertyWidgetBase {
Q_OBJECT
public:
ReferencePropertyWidget(ReferencePropertyBase* prop, ::uLib::ObjectsContext* context, QWidget* parent = nullptr);
virtual ~ReferencePropertyWidget();
private slots:
void onComboChanged(int index);
private:
void refreshCombo();
ReferencePropertyBase* m_RefProp;
::uLib::ObjectsContext* m_Context;
QComboBox* m_Combo;
Connection m_ContextConnection;
};
class PropertyEditor : public QWidget {
Q_OBJECT
public:
PropertyEditor(QWidget* parent = nullptr);
virtual ~PropertyEditor();
void setObject(uLib::Object* obj, bool displayOnly = false);
void setContext(uLib::ObjectsContext* context) { m_Context = context; }
template<typename T>
void registerFactory(std::function<QWidget*(PropertyBase*, QWidget*)> factory) {
m_Factories[std::type_index(typeid(T))] = factory;
@@ -228,6 +247,7 @@ signals:
private:
void clear();
uLib::Object* m_Object;
uLib::ObjectsContext* m_Context;
QVBoxLayout* m_MainLayout;
QScrollArea* m_ScrollArea;
QWidget* m_Container;