remove custom transform scale UI handler
This commit is contained in:
-1
@@ -32,7 +32,6 @@
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformComponentBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformScalePropertyHandler.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorInspectorComponentBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorPendingCompositionBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
|
||||
-82
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "AzToolsFramework_precompiled.h"
|
||||
#include <ToolsComponents/TransformScalePropertyHandler.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
void RegisterTransformScaleHandler()
|
||||
{
|
||||
PropertyTypeRegistrationMessages::Bus::Broadcast(&PropertyTypeRegistrationMessages::RegisterPropertyType, aznew Components::TransformScalePropertyHandler());
|
||||
}
|
||||
|
||||
namespace Components
|
||||
{
|
||||
AZ::u32 TransformScalePropertyHandler::GetHandlerName(void) const
|
||||
{
|
||||
return TransformScaleHandler;
|
||||
}
|
||||
|
||||
QWidget* TransformScalePropertyHandler::CreateGUI(QWidget* parent)
|
||||
{
|
||||
AzQtComponents::DoubleSpinBox* newCtrl = new AzQtComponents::DoubleSpinBox(parent);
|
||||
connect(newCtrl, QOverload<double>::of(&AzQtComponents::DoubleSpinBox::valueChanged), newCtrl, [newCtrl]()
|
||||
{
|
||||
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(&AzToolsFramework::PropertyEditorGUIMessages::RequestWrite, newCtrl);
|
||||
});
|
||||
|
||||
newCtrl->setMinimum(AZ::MinTransformScale);
|
||||
newCtrl->setMaximum(AZ::MaxTransformScale);
|
||||
|
||||
return newCtrl;
|
||||
}
|
||||
|
||||
void TransformScalePropertyHandler::ConsumeAttribute(AzQtComponents::DoubleSpinBox* GUI, AZ::u32 attrib,
|
||||
AzToolsFramework::PropertyAttributeReader* attrValue, [[maybe_unused]] const char* debugName)
|
||||
{
|
||||
if (attrib == AZ::Edit::Attributes::Suffix)
|
||||
{
|
||||
AZStd::string label;
|
||||
if (attrValue->Read<AZStd::string>(label))
|
||||
{
|
||||
GUI->setSuffix(label.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TransformScalePropertyHandler::WriteGUIValuesIntoProperty([[maybe_unused]] size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
AZ::Vector3& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
|
||||
{
|
||||
const float value = aznumeric_cast<float>(GUI->value());
|
||||
const float currentMaxElement = instance.GetMaxElement();
|
||||
if (currentMaxElement != 0.0f)
|
||||
{
|
||||
instance *= value / currentMaxElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
instance = AZ::Vector3(value);
|
||||
}
|
||||
}
|
||||
|
||||
bool TransformScalePropertyHandler::ReadValuesIntoGUI([[maybe_unused]] size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
const AZ::Vector3& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
|
||||
{
|
||||
QSignalBlocker signalBlocker(GUI);
|
||||
GUI->setValue(instance.GetMaxElement());
|
||||
return true;
|
||||
}
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzQtComponents/Components/Widgets/SpinBox.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#endif
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
static const AZ::Crc32 TransformScaleHandler = AZ_CRC_CE("TransformScale");
|
||||
|
||||
//! Handler to allow the scale field inside the Transform Component to be represented as a single value in
|
||||
//! the editor, but stored internally as a Vector3.
|
||||
//! The purpose for this is to prevent any new entities being created with non-uniform scale on the Transform
|
||||
//! Component, but preserve the data required for migrating any existing entities to use the Non-Uniform Scale
|
||||
//! Component, until all migration work is completed.
|
||||
//! The value shown in the editor will be the maximum value from the scale vector, and changing the value in
|
||||
//! the editor will update the vector so that its maximum value matches the newly edited value, but its
|
||||
//! components retain their existing proportion.
|
||||
//! For example, if the current vector scale is (2, 3, 4), the value in the editor will appear as 4. If the value
|
||||
//! in the editor is updated to 2, then the vector scale will update to (1, 1.5, 2), keeping the same proportion
|
||||
//! between the x, y and z components.
|
||||
class TransformScalePropertyHandler
|
||||
: public QObject
|
||||
, public AzToolsFramework::PropertyHandler<AZ::Vector3, AzQtComponents::DoubleSpinBox>
|
||||
{
|
||||
Q_OBJECT //AUTOMOC
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(TransformScalePropertyHandler, AZ::SystemAllocator, 0);
|
||||
|
||||
AZ::u32 GetHandlerName(void) const override;
|
||||
QWidget* CreateGUI(QWidget* parent) override;
|
||||
void ConsumeAttribute(AzQtComponents::DoubleSpinBox* GUI, AZ::u32 attrib,
|
||||
AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
|
||||
void WriteGUIValuesIntoProperty(size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
AZ::Vector3& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
bool ReadValuesIntoGUI(size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
const AZ::Vector3& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
};
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
-2
@@ -16,7 +16,6 @@
|
||||
#include <AzToolsFramework/ToolsComponents/EditorEntityIdContainer.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyAudioCtrlTypes.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/GenericComboBoxCtrl.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformScalePropertyHandler.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -38,7 +37,6 @@ namespace AzToolsFramework
|
||||
void RegisterButtonPropertyHandlers();
|
||||
void RegisterMultiLineEditHandler();
|
||||
void RegisterCrcHandler();
|
||||
void RegisterTransformScaleHandler();
|
||||
void ReflectPropertyEditor(AZ::ReflectContext* context);
|
||||
|
||||
namespace Components
|
||||
|
||||
@@ -293,8 +293,6 @@ set(FILES
|
||||
ToolsComponents/TransformComponent.h
|
||||
ToolsComponents/TransformComponent.cpp
|
||||
ToolsComponents/TransformComponentBus.h
|
||||
ToolsComponents/TransformScalePropertyHandler.cpp
|
||||
ToolsComponents/TransformScalePropertyHandler.h
|
||||
ToolsComponents/ScriptEditorComponent.cpp
|
||||
ToolsComponents/ScriptEditorComponent.h
|
||||
ToolsComponents/ToolsAssetCatalogComponent.cpp
|
||||
|
||||
Reference in New Issue
Block a user