Support editing string properties.
This commit is contained in:
+12
-4
@@ -115,9 +115,14 @@ void lcCamera::Initialize()
|
||||
mState = 0;
|
||||
}
|
||||
|
||||
void lcCamera::SetName(const QString& Name)
|
||||
bool lcCamera::SetName(const QString& Name)
|
||||
{
|
||||
if (mName == Name)
|
||||
return false;
|
||||
|
||||
mName = Name;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void lcCamera::CreateName(const lcArray<lcCamera*>& Cameras)
|
||||
@@ -614,9 +619,11 @@ QVariant lcCamera::GetPropertyValue(lcObjectPropertyId PropertyId) const
|
||||
case lcObjectPropertyId::PieceColor:
|
||||
case lcObjectPropertyId::PieceStepShow:
|
||||
case lcObjectPropertyId::PieceStepHide:
|
||||
case lcObjectPropertyId::CameraName:
|
||||
break;
|
||||
|
||||
case lcObjectPropertyId::CameraName:
|
||||
return GetName();
|
||||
|
||||
case lcObjectPropertyId::CameraType:
|
||||
return static_cast<int>(GetCameraType());
|
||||
|
||||
@@ -668,7 +675,6 @@ bool lcCamera::SetPropertyValue(lcObjectPropertyId PropertyId, lcStep Step, bool
|
||||
{
|
||||
Q_UNUSED(Step);
|
||||
Q_UNUSED(AddKey);
|
||||
Q_UNUSED(Value);
|
||||
|
||||
switch (PropertyId)
|
||||
{
|
||||
@@ -676,9 +682,11 @@ bool lcCamera::SetPropertyValue(lcObjectPropertyId PropertyId, lcStep Step, bool
|
||||
case lcObjectPropertyId::PieceColor:
|
||||
case lcObjectPropertyId::PieceStepShow:
|
||||
case lcObjectPropertyId::PieceStepHide:
|
||||
case lcObjectPropertyId::CameraName:
|
||||
break;
|
||||
|
||||
case lcObjectPropertyId::CameraName:
|
||||
return SetName(Value.toString());
|
||||
|
||||
case lcObjectPropertyId::CameraType:
|
||||
return SetCameraType(static_cast<lcCameraType>(Value.toInt()));
|
||||
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public:
|
||||
return mName;
|
||||
}
|
||||
|
||||
void SetName(const QString& Name);
|
||||
bool SetName(const QString& Name);
|
||||
void CreateName(const lcArray<lcCamera*>& Cameras);
|
||||
|
||||
bool IsSimple() const
|
||||
|
||||
+3
-25
@@ -3159,19 +3159,6 @@ void lcModel::SetCameraZFar(lcCamera* Camera, float ZFar)
|
||||
UpdateAllViews();
|
||||
}
|
||||
|
||||
void lcModel::SetCameraName(lcCamera* Camera, const QString& Name)
|
||||
{
|
||||
if (Camera->GetName() == Name)
|
||||
return;
|
||||
|
||||
Camera->SetName(Name);
|
||||
|
||||
SaveCheckpoint(tr("Renaming Camera"));
|
||||
gMainWindow->UpdateSelectedObjects(false);
|
||||
UpdateAllViews();
|
||||
gMainWindow->UpdateCameraMenu();
|
||||
}
|
||||
|
||||
void lcModel::SetLightAttenuationDistance(lcLight* Light, float Distance)
|
||||
{
|
||||
Light->SetAttenuationDistance(Distance, mCurrentStep, gMainWindow->GetAddKeys());
|
||||
@@ -3263,19 +3250,10 @@ void lcModel::SetObjectsProperty(const lcArray<lcObject*>& Objects, lcObjectProp
|
||||
SaveCheckpoint(lcObject::GetCheckpointString(PropertyId));
|
||||
gMainWindow->UpdateSelectedObjects(false);
|
||||
UpdateAllViews();
|
||||
}
|
||||
|
||||
void lcModel::SetLightName(lcLight* Light, const QString &Name)
|
||||
{
|
||||
if (Light->GetName() == Name)
|
||||
return;
|
||||
|
||||
Light->SetName(Name);
|
||||
|
||||
SaveCheckpoint(tr("Renaming Light"));
|
||||
gMainWindow->UpdateSelectedObjects(false);
|
||||
UpdateAllViews();
|
||||
gMainWindow->UpdateCameraMenu();
|
||||
// todo: fix hacky camera menu update
|
||||
if (PropertyId == lcObjectPropertyId::CameraName)
|
||||
gMainWindow->UpdateCameraMenu();
|
||||
}
|
||||
|
||||
bool lcModel::AnyPiecesSelected() const
|
||||
|
||||
@@ -371,7 +371,6 @@ public:
|
||||
void SetCameraFOV(lcCamera* Camera, float FOV);
|
||||
void SetCameraZNear(lcCamera* Camera, float ZNear);
|
||||
void SetCameraZFar(lcCamera* Camera, float ZFar);
|
||||
void SetCameraName(lcCamera* Camera, const QString& Name);
|
||||
|
||||
void SetLightAttenuationDistance(lcLight* Light, float Distance);
|
||||
void SetLightAttenuationPower(lcLight* Light, float Power);
|
||||
@@ -380,7 +379,6 @@ public:
|
||||
void SetSpotLightTightness(lcLight* Light, float Tightness);
|
||||
void SetLightSize(lcLight* Light, lcVector2 LightAreaSize);
|
||||
void SetLightPower(lcLight* Light, float Power);
|
||||
void SetLightName(lcLight* Light, const QString& Name);
|
||||
|
||||
void ShowPropertiesDialog();
|
||||
void ShowSelectByNameDialog();
|
||||
|
||||
@@ -583,8 +583,8 @@ void lcPropertiesWidget::AddStepNumberProperty(lcObjectPropertyId PropertyId, co
|
||||
|
||||
void lcPropertiesWidget::StringChanged()
|
||||
{
|
||||
QLineEdit* Widget = qobject_cast<QLineEdit*>(sender());
|
||||
lcObjectPropertyId PropertyId = GetEditorWidgetPropertyId(Widget);
|
||||
QLineEdit* LineEdit = qobject_cast<QLineEdit*>(sender());
|
||||
lcObjectPropertyId PropertyId = GetEditorWidgetPropertyId(LineEdit);
|
||||
|
||||
if (PropertyId == lcObjectPropertyId::Count)
|
||||
return;
|
||||
@@ -594,35 +594,32 @@ void lcPropertiesWidget::StringChanged()
|
||||
if (!Model)
|
||||
return;
|
||||
|
||||
lcCamera* Camera = dynamic_cast<lcCamera*>(mFocusObject);
|
||||
lcLight* Light = dynamic_cast<lcLight*>(mFocusObject);
|
||||
QString Text = Widget->text();
|
||||
|
||||
if (Camera)
|
||||
{
|
||||
if (PropertyId == lcObjectPropertyId::CameraName)
|
||||
{
|
||||
Model->SetCameraName(Camera, Text);
|
||||
}
|
||||
}
|
||||
else if (Light)
|
||||
{
|
||||
if (PropertyId == lcObjectPropertyId::LightName)
|
||||
{
|
||||
Model->SetLightName(Light, Text);
|
||||
}
|
||||
}
|
||||
QString Value = LineEdit->text();
|
||||
Model->SetObjectsProperty(mFocusObject ? lcArray<lcObject*>{ mFocusObject } : mSelection, PropertyId, Value);
|
||||
}
|
||||
|
||||
void lcPropertiesWidget::UpdateString(lcObjectPropertyId PropertyId, const QString& Text)
|
||||
void lcPropertiesWidget::UpdateString(lcObjectPropertyId PropertyId)
|
||||
{
|
||||
QLineEdit* Widget = qobject_cast<QLineEdit*>(mPropertyWidgets[static_cast<int>(PropertyId)].Editor);
|
||||
QLineEdit* LineEdit = qobject_cast<QLineEdit*>(mPropertyWidgets[static_cast<int>(PropertyId)].Editor);
|
||||
|
||||
if (Widget)
|
||||
if (!LineEdit)
|
||||
return;
|
||||
|
||||
QSignalBlocker Blocker(LineEdit);
|
||||
QVariant Value;
|
||||
bool Partial;
|
||||
|
||||
std::tie(Value, Partial) = GetUpdateValue(PropertyId, QString());
|
||||
|
||||
if (Partial)
|
||||
{
|
||||
QSignalBlocker Blocker(Widget);
|
||||
|
||||
Widget->setText(Text);
|
||||
LineEdit->clear();
|
||||
LineEdit->setPlaceholderText(tr("Multiple Values"));
|
||||
}
|
||||
else
|
||||
{
|
||||
LineEdit->setText(Value.toString());
|
||||
LineEdit->setPlaceholderText(QString());
|
||||
}
|
||||
|
||||
UpdateKeyFrameWidget(PropertyId);
|
||||
@@ -1199,7 +1196,6 @@ void lcPropertiesWidget::SetCamera(const lcArray<lcObject*>& Selection, lcObject
|
||||
float FoV = 60.0f;
|
||||
float ZNear = 1.0f;
|
||||
float ZFar = 100.0f;
|
||||
QString Name;
|
||||
|
||||
if (Camera)
|
||||
{
|
||||
@@ -1210,10 +1206,9 @@ void lcPropertiesWidget::SetCamera(const lcArray<lcObject*>& Selection, lcObject
|
||||
FoV = Camera->m_fovy;
|
||||
ZNear = Camera->m_zNear;
|
||||
ZFar = Camera->m_zFar;
|
||||
Name = Camera->GetName();
|
||||
}
|
||||
|
||||
UpdateString(lcObjectPropertyId::CameraName, Name);
|
||||
UpdateString(lcObjectPropertyId::CameraName);
|
||||
UpdateStringList(lcObjectPropertyId::CameraType);
|
||||
|
||||
UpdateFloat(lcObjectPropertyId::CameraFOV, FoV);
|
||||
@@ -1241,7 +1236,6 @@ void lcPropertiesWidget::SetLight(const lcArray<lcObject*>& Selection, lcObject*
|
||||
mSelection = Selection;
|
||||
mFocusObject = Light;
|
||||
|
||||
QString Name;
|
||||
lcLightType LightType = lcLightType::Count;
|
||||
lcLightAreaShape LightAreaShape = lcLightAreaShape::Count;
|
||||
lcVector2 LightSize(0.0f, 0.0f);
|
||||
@@ -1254,7 +1248,6 @@ void lcPropertiesWidget::SetLight(const lcArray<lcObject*>& Selection, lcObject*
|
||||
|
||||
if (Light)
|
||||
{
|
||||
Name = Light->GetName();
|
||||
LightType = Light->GetLightType();
|
||||
LightAreaShape = Light->GetAreaShape();
|
||||
|
||||
@@ -1303,7 +1296,7 @@ void lcPropertiesWidget::SetLight(const lcArray<lcObject*>& Selection, lcObject*
|
||||
LightAreaShape = lcLightAreaShape::Count;
|
||||
}
|
||||
|
||||
UpdateString(lcObjectPropertyId::LightName, Name);
|
||||
UpdateString(lcObjectPropertyId::LightName);
|
||||
UpdateStringList(lcObjectPropertyId::LightType);
|
||||
UpdateColor(lcObjectPropertyId::LightColor);
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ protected:
|
||||
void UpdateFloat(lcObjectPropertyId PropertyId, float Value);
|
||||
void UpdateInteger(lcObjectPropertyId PropertyId);
|
||||
void UpdateStepNumber(lcObjectPropertyId PropertyId, lcStep Step, lcStep Min, lcStep Max);
|
||||
void UpdateString(lcObjectPropertyId PropertyId, const QString& Text);
|
||||
void UpdateString(lcObjectPropertyId PropertyId);
|
||||
void UpdateStringList(lcObjectPropertyId PropertyId);
|
||||
void UpdateColor(lcObjectPropertyId PropertyId);
|
||||
void UpdatePieceColor(lcObjectPropertyId PropertyId, int ColorIndex);
|
||||
|
||||
+16
-2
@@ -484,6 +484,16 @@ void lcLight::Rotate(lcStep Step, bool AddKey, const lcMatrix33& RotationMatrix,
|
||||
SetRotation(NewLocalToWorldMatrix, Step, AddKey);
|
||||
}
|
||||
|
||||
bool lcLight::SetName(const QString& Name)
|
||||
{
|
||||
if (mName == Name)
|
||||
return false;
|
||||
|
||||
mName = Name;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool lcLight::SetLightType(lcLightType LightType)
|
||||
{
|
||||
if (static_cast<int>(LightType) < 0 || LightType >= lcLightType::Count)
|
||||
@@ -1060,9 +1070,11 @@ QVariant lcLight::GetPropertyValue(lcObjectPropertyId PropertyId) const
|
||||
case lcObjectPropertyId::CameraUpX:
|
||||
case lcObjectPropertyId::CameraUpY:
|
||||
case lcObjectPropertyId::CameraUpZ:
|
||||
case lcObjectPropertyId::LightName:
|
||||
break;
|
||||
|
||||
case lcObjectPropertyId::LightName:
|
||||
return GetName();
|
||||
|
||||
case lcObjectPropertyId::LightType:
|
||||
return static_cast<int>(GetLightType());
|
||||
|
||||
@@ -1132,9 +1144,11 @@ bool lcLight::SetPropertyValue(lcObjectPropertyId PropertyId, lcStep Step, bool
|
||||
case lcObjectPropertyId::CameraUpX:
|
||||
case lcObjectPropertyId::CameraUpY:
|
||||
case lcObjectPropertyId::CameraUpZ:
|
||||
case lcObjectPropertyId::LightName:
|
||||
break;
|
||||
|
||||
case lcObjectPropertyId::LightName:
|
||||
return SetName(Value.toString());
|
||||
|
||||
case lcObjectPropertyId::LightType:
|
||||
return SetLightType(static_cast<lcLightType>(Value.toInt()));
|
||||
|
||||
|
||||
+1
-4
@@ -304,10 +304,7 @@ public:
|
||||
return mCastShadow;
|
||||
}
|
||||
|
||||
void SetName(const QString& Name)
|
||||
{
|
||||
mName = Name;
|
||||
}
|
||||
bool SetName(const QString& Name);
|
||||
|
||||
QString GetName() const override
|
||||
{
|
||||
|
||||
+6
-2
@@ -18,9 +18,11 @@ QString lcObject::GetCheckpointString(lcObjectPropertyId PropertyId)
|
||||
case lcObjectPropertyId::PieceColor:
|
||||
case lcObjectPropertyId::PieceStepShow:
|
||||
case lcObjectPropertyId::PieceStepHide:
|
||||
case lcObjectPropertyId::CameraName:
|
||||
break;
|
||||
|
||||
case lcObjectPropertyId::CameraName:
|
||||
return QT_TRANSLATE_NOOP("Checkpoint", "Renaming Camera");
|
||||
|
||||
case lcObjectPropertyId::CameraType:
|
||||
return QT_TRANSLATE_NOOP("Checkpoint", "Changing Camera Type");
|
||||
|
||||
@@ -36,9 +38,11 @@ QString lcObject::GetCheckpointString(lcObjectPropertyId PropertyId)
|
||||
case lcObjectPropertyId::CameraUpX:
|
||||
case lcObjectPropertyId::CameraUpY:
|
||||
case lcObjectPropertyId::CameraUpZ:
|
||||
case lcObjectPropertyId::LightName:
|
||||
break;
|
||||
|
||||
case lcObjectPropertyId::LightName:
|
||||
return QT_TRANSLATE_NOOP("Checkpoint", "Renaming Light");
|
||||
|
||||
case lcObjectPropertyId::LightType:
|
||||
return QT_TRANSLATE_NOOP("Checkpoint", "Changing Light Type");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user