leocad/common/lc_propertieswidget.h

131 lines
4.3 KiB
C
Raw Normal View History

2023-12-31 21:55:35 +01:00
#pragma once
#include "lc_array.h"
#include "lc_objectproperty.h"
2023-12-31 21:55:35 +01:00
class lcCollapsibleWidgetButton;
2024-01-15 02:41:01 +01:00
class lcKeyFrameWidget;
2023-12-31 21:55:35 +01:00
class lcPropertiesWidget : public QWidget
{
Q_OBJECT;
public:
lcPropertiesWidget(QWidget* Parent);
void Update(const lcArray<lcObject*>& Selection, lcObject* Focus);
protected slots:
void CategoryStateChanged(bool Expanded);
2024-01-15 02:41:01 +01:00
void KeyFrameChanged();
2024-01-06 03:56:43 +01:00
void BoolChanged();
2023-12-31 21:55:35 +01:00
void FloatChanged();
2024-01-06 03:56:43 +01:00
void IntegerChanged();
2023-12-31 21:55:35 +01:00
void StepNumberChanged();
2024-01-02 03:57:54 +01:00
void StringChanged();
void StringListChanged(int Index);
2024-01-06 03:56:43 +01:00
void ColorButtonClicked();
2023-12-31 21:55:35 +01:00
void PieceColorButtonClicked();
void PieceColorChanged(int ColorIndex);
void PieceIdButtonClicked();
void PieceIdChanged(PieceInfo* Info);
protected:
enum class CategoryIndex
{
Piece,
Camera,
CameraTransform,
Light,
ObjectTransform,
Count
};
2023-12-31 21:55:35 +01:00
enum class PropertyType
{
Bool,
Float,
Integer,
StepNumber,
String,
StringList,
Color,
PieceColor,
PieceId
};
enum class LayoutMode
{
Empty,
Piece,
Camera,
Light,
Multiple,
Count
};
struct CategoryWidgets
{
lcCollapsibleWidgetButton* Button = nullptr;
std::vector<lcObjectPropertyId> Properties;
std::vector<int> SpacingRows;
};
struct PropertyWidgets
{
QLabel* Label = nullptr;
2024-01-15 02:41:01 +01:00
QWidget* Editor = nullptr;
lcKeyFrameWidget* KeyFrame = nullptr;
2023-12-31 21:55:35 +01:00
};
2024-01-15 02:41:01 +01:00
lcObjectPropertyId GetEditorWidgetPropertyId(QWidget* Widget) const;
lcObjectPropertyId GetKeyFrameWidgetPropertyId(QWidget* Widget) const;
2023-12-31 21:55:35 +01:00
void AddCategory(CategoryIndex Index, const QString& Title);
void AddSpacing();
void AddLabel(lcObjectPropertyId PropertyId, const QString& Text, const QString& ToolTip);
2024-01-15 02:41:01 +01:00
void AddKeyFrameWidget(lcObjectPropertyId PropertyId);
void AddBoolProperty(lcObjectPropertyId PropertyId, const QString& Text, const QString& ToolTip, bool SupportsKeyFrames);
void AddFloatProperty(lcObjectPropertyId PropertyId, const QString& Text, const QString& ToolTip, bool SupportsKeyFrames, float Min, float Max);
void AddIntegerProperty(lcObjectPropertyId PropertyId, const QString& Text, const QString& ToolTip, bool SupportsKeyFrames, int Min, int Max);
void AddStepNumberProperty(lcObjectPropertyId PropertyId, const QString& Text, const QString& ToolTip, bool SupportsKeyFrames);
void AddStringProperty(lcObjectPropertyId PropertyId, const QString& Text, const QString& ToolTip, bool SupportsKeyFrames);
void AddStringListProperty(lcObjectPropertyId PropertyId, const QString& Text, const QString& ToolTip, bool SupportsKeyFrames, const QStringList& Strings);
void AddColorProperty(lcObjectPropertyId PropertyId, const QString& Text, const QString& ToolTip, bool SupportsKeyFrames);
void AddPieceColorProperty(lcObjectPropertyId PropertyId, const QString& Text, const QString& ToolTip, bool SupportsKeyFrames);
void AddPieceIdProperty(lcObjectPropertyId PropertyId, const QString& Text, const QString& ToolTip, bool SupportsKeyFrames);
2024-01-15 02:41:01 +01:00
void UpdateKeyFrameWidget(lcObjectPropertyId PropertyId);
void UpdateBool(lcObjectPropertyId PropertyId, bool Value);
void UpdateFloat(lcObjectPropertyId PropertyId, float Value);
void UpdateInteger(lcObjectPropertyId PropertyId, int Value);
void UpdateStepNumber(lcObjectPropertyId PropertyId, lcStep Step, lcStep Min, lcStep Max);
void UpdateString(lcObjectPropertyId PropertyId, const QString& Text);
void UpdateStringList(lcObjectPropertyId PropertyId, int ListIndex);
void UpdateColor(lcObjectPropertyId PropertyId, QColor Color);
void UpdatePieceColor(lcObjectPropertyId PropertyId, int ColorIndex);
void UpdatePieceId(lcObjectPropertyId PropertyId, const QString& Name);
2023-12-31 21:55:35 +01:00
void SetEmpty();
void SetPiece(const lcArray<lcObject*>& Selection, lcObject* Focus);
void SetCamera(lcObject* Focus);
void SetLight(lcObject* Focus);
void CreateWidgets();
void SetLayoutMode(LayoutMode Mode);
void SetPropertyVisible(lcObjectPropertyId PropertyId, bool Visible);
void SetCategoryVisible(CategoryIndex Index, bool Visible);
void SetCategoryWidgetsVisible(CategoryWidgets& Category, bool Visible);
lcObject* mFocusObject = nullptr;
std::array<PropertyWidgets, static_cast<int>(lcObjectPropertyId::Count)> mPropertyWidgets = {};
std::array<CategoryWidgets, static_cast<int>(CategoryIndex::Count)> mCategoryWidgets = {};
CategoryWidgets* mCurrentCategory = nullptr;
QGridLayout* mLayout = nullptr;
int mLayoutRow = 0;
LayoutMode mLayoutMode = LayoutMode::Count;
2023-12-31 21:55:35 +01:00
};