Removes GenericLineEditCtrl.h/inl/cpp from Gems/ScriptCanvas (which lead to removing a target)
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -137,32 +137,6 @@ ly_create_alias(NAME ScriptCanvas.Clients NAMESPACE Gem TARGETS Gem::ScriptCanv
|
||||
ly_create_alias(NAME ScriptCanvas.Servers NAMESPACE Gem TARGETS Gem::ScriptCanvas)
|
||||
|
||||
if(PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
ly_add_target(
|
||||
NAME ScriptCanvasEditor STATIC
|
||||
NAMESPACE Gem
|
||||
AUTOMOC
|
||||
FILES_CMAKE
|
||||
scriptcanvasgem_editor_static_files.cmake
|
||||
COMPILE_DEFINITIONS
|
||||
PUBLIC
|
||||
SCRIPTCANVAS_ERRORS_ENABLED
|
||||
PRIVATE
|
||||
SCRIPTCANVAS_EDITOR
|
||||
${SCRIPT_CANVAS_COMMON_DEFINES}
|
||||
INCLUDE_DIRECTORIES
|
||||
PUBLIC
|
||||
.
|
||||
Editor/Include
|
||||
Editor/Static/Include
|
||||
Editor/Assets
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzCore
|
||||
AZ::AzToolsFramework
|
||||
3rdParty::Qt::Widgets
|
||||
Gem::ScriptCanvas
|
||||
)
|
||||
|
||||
ly_add_target(
|
||||
NAME ScriptCanvas.Editor.Static STATIC
|
||||
NAMESPACE Gem
|
||||
@@ -181,11 +155,12 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
SCRIPTCANVAS_EDITOR
|
||||
${SCRIPT_CANVAS_COMMON_DEFINES}
|
||||
INCLUDE_DIRECTORIES
|
||||
PUBLIC
|
||||
Editor/Include
|
||||
PRIVATE
|
||||
.
|
||||
Editor
|
||||
Tools
|
||||
Editor/Include
|
||||
${SCRIPT_CANVAS_AUTOGEN_BUILD_DIR}
|
||||
BUILD_DEPENDENCIES
|
||||
PUBLIC
|
||||
@@ -194,7 +169,6 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
AZ::AssetBuilderSDK
|
||||
${additional_dependencies}
|
||||
Gem::ScriptCanvas
|
||||
Gem::ScriptCanvasEditor
|
||||
Gem::ScriptEvents.Static
|
||||
Gem::GraphCanvasWidgets
|
||||
Gem::ExpressionEvaluation.Static
|
||||
@@ -206,7 +180,6 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
|
||||
ly_add_target(
|
||||
NAME ScriptCanvas.Editor GEM_MODULE
|
||||
|
||||
NAMESPACE Gem
|
||||
FILES_CMAKE
|
||||
scriptcanvasgem_editor_shared_files.cmake
|
||||
@@ -217,10 +190,11 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
SCRIPTCANVAS_EDITOR
|
||||
${SCRIPT_CANVAS_COMMON_DEFINES}
|
||||
INCLUDE_DIRECTORIES
|
||||
PUBLIC
|
||||
Editor/Include
|
||||
PRIVATE
|
||||
.
|
||||
Editor
|
||||
Editor/Include
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzToolsFramework
|
||||
@@ -294,7 +268,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzTest
|
||||
Gem::ScriptCanvasEditor
|
||||
Gem::ScriptCanvas.Editor.Static
|
||||
)
|
||||
ly_add_googletest(
|
||||
|
||||
-133
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
|
||||
#include <ScriptCanvas/Core/Attributes.h>
|
||||
|
||||
#include <QValidator>
|
||||
#endif
|
||||
|
||||
class QLineEdit;
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
namespace EditCtrl
|
||||
{
|
||||
template<typename T> using PropertyToStringCB = AZStd::function<bool(AZStd::string&, const T&)>;
|
||||
template<typename T> using StringToPropertyCB = AZStd::function<bool(T&, AZStd::string_view)>;
|
||||
using StringValidatorCB = AZStd::function<QValidator::State(QString&, int&)>;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
class GenericLineEditHandler;
|
||||
|
||||
class GenericLineEditCtrlBase
|
||||
: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
template<typename T>
|
||||
friend class GenericLineEditHandler;
|
||||
AZ_RTTI(GenericLineEditCtrlBase, "{0EC84840-666F-424E-9443-D20D8FEF743B}");
|
||||
AZ_CLASS_ALLOCATOR(GenericLineEditCtrlBase, AZ::SystemAllocator, 0);
|
||||
|
||||
GenericLineEditCtrlBase(QWidget* pParent = nullptr);
|
||||
~GenericLineEditCtrlBase() override = default;
|
||||
|
||||
AZStd::string value() const;
|
||||
|
||||
QWidget* GetFirstInTabOrder();
|
||||
QWidget* GetLastInTabOrder();
|
||||
void UpdateTabOrder();
|
||||
|
||||
signals:
|
||||
void valueChanged(AZStd::string& newValue);
|
||||
|
||||
public:
|
||||
void setValue(AZStd::string_view val);
|
||||
void setMaxLen(int maxLen);
|
||||
void onChildLineEditValueChange(const QString& value);
|
||||
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent* e) override;
|
||||
|
||||
private:
|
||||
QLineEdit* m_pLineEdit;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class GenericLineEditCtrl
|
||||
: public GenericLineEditCtrlBase
|
||||
{
|
||||
public:
|
||||
friend class GenericLineEditHandler<T>;
|
||||
AZ_RTTI(((GenericLineEditCtrl<T>), "{4A094311-8956-40C9-95B5-7D50C2574B45}", T), GenericLineEditCtrlBase);
|
||||
AZ_CLASS_ALLOCATOR(GenericLineEditCtrl, AZ::SystemAllocator, 0);
|
||||
|
||||
GenericLineEditCtrl(QWidget* pParent = nullptr)
|
||||
: GenericLineEditCtrlBase(pParent)
|
||||
{}
|
||||
~GenericLineEditCtrl() override = default;
|
||||
|
||||
private:
|
||||
// Stores per ctrl instance string <-> T conversion functions
|
||||
EditCtrl::PropertyToStringCB<T> m_propertyToStringCB;
|
||||
EditCtrl::StringToPropertyCB<T> m_stringToPropertyCB;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class GenericLineEditHandler
|
||||
: QObject
|
||||
, public AzToolsFramework::PropertyHandler<T, GenericLineEditCtrlBase>
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(GenericLineEditHandler, AZ::SystemAllocator, 0);
|
||||
|
||||
GenericLineEditHandler(const EditCtrl::PropertyToStringCB<T>& propertyToStringCB, const EditCtrl::StringToPropertyCB<T>& stringToPropertyCB,
|
||||
const EditCtrl::StringValidatorCB& stringValidatorCB = {});
|
||||
|
||||
AZ::u32 GetHandlerName(void) const override { return ScriptCanvas::Attributes::UIHandlers::GenericLineEdit; }
|
||||
QWidget* GetFirstInTabOrder(GenericLineEditCtrlBase* widget) override { return widget->GetFirstInTabOrder(); }
|
||||
QWidget* GetLastInTabOrder(GenericLineEditCtrlBase* widget) override { return widget->GetLastInTabOrder(); }
|
||||
void UpdateWidgetInternalTabbing(GenericLineEditCtrlBase* widget) override { widget->UpdateTabOrder(); }
|
||||
|
||||
QWidget* CreateGUI(QWidget* pParent) override;
|
||||
void ConsumeAttribute(GenericLineEditCtrlBase* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
|
||||
void WriteGUIValuesIntoProperty(size_t index, GenericLineEditCtrlBase* GUI, typename GenericLineEditHandler::property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
bool ReadValuesIntoGUI(size_t index, GenericLineEditCtrlBase* GUI, const typename GenericLineEditHandler::property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
|
||||
bool AutoDelete() const override { return false; }
|
||||
|
||||
private:
|
||||
// Stores per handler string <-> T conversion functions
|
||||
// There is only 1 handler per instantiated T
|
||||
EditCtrl::PropertyToStringCB<T> m_propertyToStringCB;
|
||||
EditCtrl::StringToPropertyCB<T> m_stringToPropertyCB;
|
||||
EditCtrl::StringValidatorCB m_stringValidatorCB;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
AzToolsFramework::PropertyHandlerBase* RegisterGenericLineEditHandler(const EditCtrl::PropertyToStringCB<T>& propertyToStringCB, const EditCtrl::StringToPropertyCB<T>& stringToPropertyCB)
|
||||
{
|
||||
if (!AzToolsFramework::PropertyTypeRegistrationMessages::Bus::FindFirstHandler())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto propertyHandler(aznew GenericLineEditHandler<T>(propertyToStringCB, stringToPropertyCB));
|
||||
AzToolsFramework::PropertyTypeRegistrationMessages::Bus::Broadcast(&AzToolsFramework::PropertyTypeRegistrationMessages::RegisterPropertyType, propertyHandler);
|
||||
return propertyHandler;
|
||||
}
|
||||
}
|
||||
|
||||
#include <ScriptCanvas/View/EditCtrls/GenericLineEditCtrl.inl>
|
||||
-123
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QtWidgets/QLineEdit>
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
class GenericStringValidator
|
||||
: public QValidator
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(GenericStringValidator, AZ::SystemAllocator, 0);
|
||||
GenericStringValidator(const EditCtrl::StringValidatorCB& stringValidatorCB)
|
||||
: m_stringValidatorCB(stringValidatorCB)
|
||||
{}
|
||||
|
||||
QValidator::State validate(QString& input, int& pos) const override
|
||||
{
|
||||
return m_stringValidatorCB ? m_stringValidatorCB(input, pos) : QValidator::State::Acceptable;
|
||||
}
|
||||
|
||||
private:
|
||||
EditCtrl::StringValidatorCB m_stringValidatorCB;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
GenericLineEditHandler<T>::GenericLineEditHandler(const EditCtrl::PropertyToStringCB<T>& propertyToStringCB, const EditCtrl::StringToPropertyCB<T>& stringToPropertyCB,
|
||||
const EditCtrl::StringValidatorCB& stringValidatorCB)
|
||||
: m_propertyToStringCB(propertyToStringCB)
|
||||
, m_stringToPropertyCB(stringToPropertyCB)
|
||||
, m_stringValidatorCB(stringValidatorCB)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
QWidget* GenericLineEditHandler<T>::CreateGUI(QWidget* pParent)
|
||||
{
|
||||
auto newCtrl = aznew GenericLineEditCtrl<T>(pParent);
|
||||
if (m_stringValidatorCB)
|
||||
{
|
||||
newCtrl->m_pLineEdit->setValidator(aznew GenericStringValidator(m_stringValidatorCB));
|
||||
}
|
||||
connect(newCtrl, &GenericLineEditCtrl<T>::valueChanged, this, [newCtrl]()
|
||||
{
|
||||
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(&AzToolsFramework::PropertyEditorGUIMessages::RequestWrite, newCtrl);
|
||||
});
|
||||
return newCtrl;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void GenericLineEditHandler<T>::ConsumeAttribute(GenericLineEditCtrlBase* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrReader, const char* debugName)
|
||||
{
|
||||
(void)debugName;
|
||||
if (attrib == ScriptCanvas::Attributes::StringToProperty)
|
||||
{
|
||||
EditCtrl::StringToPropertyCB<T> value;
|
||||
if (attrReader->Read<EditCtrl::StringToPropertyCB<T>>(value))
|
||||
{
|
||||
auto genericGUI = azrtti_cast<GenericLineEditCtrl<T>*>(GUI);
|
||||
genericGUI->m_stringToPropertyCB = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_WarningOnce("Script Canvas", false, "Failed to read 'StringToProperty' attribute from property '%s'. Expected a function<bool(string&, const %s&)>.", debugName, AZ::AzTypeInfo<typename GenericLineEditHandler::property_t>::Name());
|
||||
}
|
||||
}
|
||||
else if (attrib == ScriptCanvas::Attributes::PropertyToString)
|
||||
{
|
||||
EditCtrl::PropertyToStringCB<T> value;
|
||||
if (attrReader->Read<EditCtrl::PropertyToStringCB<T>>(value))
|
||||
{
|
||||
auto genericGUI = azrtti_cast<GenericLineEditCtrl<T>*>(GUI);
|
||||
genericGUI->m_propertyToStringCB = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_WarningOnce("Script Canvas", false, "Failed to read 'PropertyToString' attribute from property '%s'. Expected a function<bool(%s&, string_view)>.", debugName, AZ::AzTypeInfo<typename GenericLineEditHandler::property_t>::Name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void GenericLineEditHandler<T>::WriteGUIValuesIntoProperty(size_t, GenericLineEditCtrlBase* GUI, typename GenericLineEditHandler::property_t& instance, AzToolsFramework::InstanceDataNode*)
|
||||
{
|
||||
// Invoke the ctrl string -> T override if it exist otherwise attempt to invoke the handler string -> T override
|
||||
auto genericGUI = azrtti_cast<GenericLineEditCtrl<T>*>(GUI);
|
||||
if (genericGUI->m_stringToPropertyCB)
|
||||
{
|
||||
genericGUI->m_stringToPropertyCB(instance, genericGUI->value());
|
||||
}
|
||||
else if (m_stringToPropertyCB)
|
||||
{
|
||||
m_stringToPropertyCB(instance, GUI->value());
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool GenericLineEditHandler<T>::ReadValuesIntoGUI(size_t, GenericLineEditCtrlBase* GUI, const typename GenericLineEditHandler::property_t& instance, AzToolsFramework::InstanceDataNode*)
|
||||
{
|
||||
// Invoke the ctrl T -> string override if it exist otherwise attempt to invoke the handler T -> string override
|
||||
auto genericGUI = azrtti_cast<GenericLineEditCtrl<T>*>(GUI);
|
||||
if (genericGUI->m_propertyToStringCB)
|
||||
{
|
||||
AZStd::string val;
|
||||
genericGUI->m_propertyToStringCB(val, instance);
|
||||
genericGUI->setValue(val);
|
||||
return true;
|
||||
}
|
||||
else if (m_propertyToStringCB)
|
||||
{
|
||||
AZStd::string val;
|
||||
m_propertyToStringCB(val, instance);
|
||||
GUI->setValue(val);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include <ScriptCanvas/View/EditCtrls/GenericLineEditCtrl.h>
|
||||
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyQTConstants.h>
|
||||
#include <QtWidgets/QHBoxLayout>
|
||||
|
||||
#include <QFocusEvent>
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
GenericLineEditCtrlBase::GenericLineEditCtrlBase(QWidget* pParent)
|
||||
: QWidget(pParent)
|
||||
{
|
||||
// create the gui, it consists of a layout, and in that layout, a text field for the value
|
||||
// and then a slider for the value.
|
||||
QHBoxLayout* pLayout = new QHBoxLayout(this);
|
||||
m_pLineEdit = new QLineEdit(this);
|
||||
|
||||
pLayout->setSpacing(4);
|
||||
pLayout->setContentsMargins(1, 0, 1, 0);
|
||||
|
||||
pLayout->addWidget(m_pLineEdit);
|
||||
|
||||
m_pLineEdit->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||
m_pLineEdit->setMinimumWidth(AzToolsFramework::PropertyQTConstant_MinimumWidth);
|
||||
m_pLineEdit->setFixedHeight(AzToolsFramework::PropertyQTConstant_DefaultHeight);
|
||||
|
||||
m_pLineEdit->setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
setLayout(pLayout);
|
||||
setFocusProxy(m_pLineEdit);
|
||||
setFocusPolicy(m_pLineEdit->focusPolicy());
|
||||
|
||||
connect(m_pLineEdit, &QLineEdit::textChanged, this, &GenericLineEditCtrlBase::onChildLineEditValueChange);
|
||||
connect(m_pLineEdit, &QLineEdit::editingFinished, this, [this]()
|
||||
{
|
||||
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(&AzToolsFramework::PropertyEditorGUIMessages::OnEditingFinished, this);
|
||||
});
|
||||
}
|
||||
|
||||
void GenericLineEditCtrlBase::setValue(AZStd::string_view value)
|
||||
{
|
||||
QSignalBlocker signalBlocker(m_pLineEdit);
|
||||
m_pLineEdit->setText(value.data());
|
||||
}
|
||||
|
||||
void GenericLineEditCtrlBase::focusInEvent(QFocusEvent* e)
|
||||
{
|
||||
m_pLineEdit->event(e);
|
||||
m_pLineEdit->selectAll();
|
||||
}
|
||||
|
||||
AZStd::string GenericLineEditCtrlBase::value() const
|
||||
{
|
||||
return AZStd::string(m_pLineEdit->text().toUtf8().data());
|
||||
}
|
||||
|
||||
void GenericLineEditCtrlBase::setMaxLen(int maxLen)
|
||||
{
|
||||
QSignalBlocker signalBlocker(m_pLineEdit);
|
||||
m_pLineEdit->setMaxLength(maxLen);
|
||||
}
|
||||
|
||||
void GenericLineEditCtrlBase::onChildLineEditValueChange(const QString& newValue)
|
||||
{
|
||||
AZStd::string changedVal(newValue.toUtf8().data());
|
||||
emit valueChanged(changedVal);
|
||||
}
|
||||
|
||||
QWidget* GenericLineEditCtrlBase::GetFirstInTabOrder()
|
||||
{
|
||||
return m_pLineEdit;
|
||||
}
|
||||
QWidget* GenericLineEditCtrlBase::GetLastInTabOrder()
|
||||
{
|
||||
return m_pLineEdit;
|
||||
}
|
||||
|
||||
void GenericLineEditCtrlBase::UpdateTabOrder()
|
||||
{
|
||||
// There's only one QT widget on this property.
|
||||
}
|
||||
}
|
||||
|
||||
#include <Editor/Static/Include/ScriptCanvas/View/EditCtrls/moc_GenericLineEditCtrl.cpp>
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <ScriptCanvas/Libraries/Libraries.h>
|
||||
#include <ScriptCanvas/PerformanceStatisticsBus.h>
|
||||
#include <ScriptCanvas/Variable/VariableCore.h>
|
||||
#include <ScriptCanvas/View/EditCtrls/GenericLineEditCtrl.h>
|
||||
#include <Editor/Assets/ScriptCanvasAssetHelpers.h>
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Editor/Static/Include/ScriptCanvas/View/EditCtrls/GenericLineEditCtrl.h
|
||||
Editor/Static/Source/View/EditCtrls/GenericLineEditCtrl.cpp
|
||||
)
|
||||
@@ -29,7 +29,7 @@ ly_add_target(
|
||||
BUILD_DEPENDENCIES
|
||||
PUBLIC
|
||||
Gem::ScriptCanvas
|
||||
Gem::ScriptCanvasEditor
|
||||
Gem::ScriptCanvas.Editor
|
||||
Gem::GraphCanvasWidgets
|
||||
Gem::ScriptEvents.Editor
|
||||
PRIVATE
|
||||
@@ -44,7 +44,6 @@ ly_add_target(
|
||||
*.ScriptCanvasNodeable.xml,ScriptCanvasNodeable_Source.jinja,$path/$fileprefix.generated.cpp
|
||||
RUNTIME_DEPENDENCIES
|
||||
Gem::ScriptCanvas.Editor
|
||||
Gem::ScriptCanvasEditor
|
||||
Gem::GraphCanvasWidgets
|
||||
Gem::ScriptEvents
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user