You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
4.1 KiB
C++
112 lines
4.1 KiB
C++
/*
|
|
* 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 <AzCore/EBus/EBus.h>
|
|
#include <AzToolsFramework/Debug/TraceContext.h>
|
|
#include <AzToolsFramework/UI/PropertyEditor/PropertyVectorCtrl.hxx>
|
|
#include <SceneAPI/SceneUI/RowWidgets/TransformRowHandler.h>
|
|
|
|
namespace AZ
|
|
{
|
|
namespace SceneAPI
|
|
{
|
|
namespace SceneUI
|
|
{
|
|
AZ_CLASS_ALLOCATOR_IMPL(TranformRowHandler, SystemAllocator, 0)
|
|
|
|
TranformRowHandler* TranformRowHandler::s_instance = nullptr;
|
|
|
|
QWidget* TranformRowHandler::CreateGUI(QWidget* parent)
|
|
{
|
|
return aznew TransformRowWidget(parent);
|
|
}
|
|
|
|
u32 TranformRowHandler::GetHandlerName() const
|
|
{
|
|
return AZ_CRC("TranformRow", 0x795295be);
|
|
}
|
|
|
|
bool TranformRowHandler::AutoDelete() const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool TranformRowHandler::IsDefaultHandler() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
void TranformRowHandler::ConsumeAttribute(TransformRowWidget* widget, u32 attrib,
|
|
AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName)
|
|
{
|
|
if (attrib == AZ::Edit::Attributes::ReadOnly)
|
|
{
|
|
bool value;
|
|
if (attrValue->Read<bool>(value))
|
|
{
|
|
widget->SetEnableEdit(!value);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AzToolsFramework::Vector3PropertyHandler handler;
|
|
handler.ConsumeAttribute(widget->GetTranslationWidget(), attrib, attrValue, debugName);
|
|
handler.ConsumeAttribute(widget->GetRotationWidget(), attrib, attrValue, debugName);
|
|
handler.ConsumeAttribute(widget->GetScaleWidget(), attrib, attrValue, debugName);
|
|
}
|
|
}
|
|
|
|
void TranformRowHandler::WriteGUIValuesIntoProperty(size_t /*index*/, TransformRowWidget* GUI,
|
|
property_t& instance, AzToolsFramework::InstanceDataNode* /*node*/)
|
|
{
|
|
GUI->GetTransform(instance);
|
|
}
|
|
|
|
bool TranformRowHandler::ReadValuesIntoGUI(size_t /*index*/, TransformRowWidget* GUI, const property_t& instance,
|
|
AzToolsFramework::InstanceDataNode* /*node*/)
|
|
{
|
|
GUI->SetTransform(instance);
|
|
return false;
|
|
}
|
|
|
|
void TranformRowHandler::Register()
|
|
{
|
|
using namespace AzToolsFramework;
|
|
|
|
if (!s_instance)
|
|
{
|
|
s_instance = aznew TranformRowHandler();
|
|
PropertyTypeRegistrationMessages::Bus::Broadcast(&PropertyTypeRegistrationMessages::Bus::Events::RegisterPropertyType, s_instance);
|
|
}
|
|
}
|
|
|
|
void TranformRowHandler::Unregister()
|
|
{
|
|
using namespace AzToolsFramework;
|
|
|
|
if (s_instance)
|
|
{
|
|
PropertyTypeRegistrationMessages::Bus::Broadcast(&PropertyTypeRegistrationMessages::Bus::Events::UnregisterPropertyType, s_instance);
|
|
delete s_instance;
|
|
s_instance = nullptr;
|
|
}
|
|
}
|
|
|
|
void TranformRowHandler::ConsumeFilterTypeAttribute(TransformRowWidget* /*widget*/,
|
|
AzToolsFramework::PropertyAttributeReader* /*attrValue*/)
|
|
{
|
|
}
|
|
} // namespace SceneUI
|
|
} // namespace SceneAPI
|
|
} // namespace AZ
|
|
|
|
#include <RowWidgets/moc_TransformRowHandler.cpp> |