leocad/common/lc_propertieswidget.h

140 lines
4.6 KiB
C
Raw Normal View History

2023-12-31 21:55:35 +01:00
#pragma once
#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);
2024-05-15 05:45:09 +02:00
void Update(const std::vector<lcObject*>& Selection, lcObject* Focus);
2023-12-31 21:55:35 +01:00
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();
void ColorChanged(QColor Color);
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,
LightBlender,
LightPOVRay,
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;
2024-04-28 01:01:51 +02:00
CategoryIndex Category;
};
struct PropertyWidgets
{
QLabel* Label = nullptr;
2024-01-15 02:41:01 +01:00
QWidget* Editor = nullptr;
lcKeyFrameWidget* KeyFrame = nullptr;
2024-04-28 01:01:51 +02:00
CategoryIndex Category;
bool Visible = true;
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-03-03 02:40:08 +01:00
std::pair<QVariant, bool> GetUpdateValue(lcObjectPropertyId PropertyId);
2024-01-15 02:41:01 +01:00
void UpdateKeyFrameWidget(lcObjectPropertyId PropertyId);
2024-02-20 01:45:14 +01:00
void UpdateBool(lcObjectPropertyId PropertyId);
void UpdateFloat(lcObjectPropertyId PropertyId, float Value);
2024-02-20 01:45:14 +01:00
void UpdateInteger(lcObjectPropertyId PropertyId);
void UpdateStepNumber(lcObjectPropertyId PropertyId, lcStep Step, lcStep Min, lcStep Max);
2024-02-20 02:38:04 +01:00
void UpdateString(lcObjectPropertyId PropertyId);
2024-02-20 01:45:14 +01:00
void UpdateStringList(lcObjectPropertyId PropertyId);
void UpdateColor(lcObjectPropertyId PropertyId);
void UpdatePieceColor(lcObjectPropertyId PropertyId);
void UpdatePieceId(lcObjectPropertyId PropertyId);
2023-12-31 21:55:35 +01:00
void SetEmpty();
2024-05-15 05:45:09 +02:00
void SetPiece(const std::vector<lcObject*>& Selection, lcObject* Focus);
void SetCamera(const std::vector<lcObject*>& Selection, lcObject* Focus);
void SetLight(const std::vector<lcObject*>& Selection, lcObject* Focus);
2023-12-31 21:55:35 +01:00
void CreateWidgets();
void SetLayoutMode(LayoutMode Mode);
void SetPropertyVisible(lcObjectPropertyId PropertyId, bool Visible);
void SetPropertyWidgetsVisible(lcObjectPropertyId PropertyId, bool Visible);
void SetCategoryVisible(CategoryIndex Index, bool Visible);
void SetCategoryWidgetsVisible(CategoryWidgets& Category, bool Visible);
2024-05-15 05:45:09 +02:00
std::vector<lcObject*> mSelection;
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
};