Files
o3de/Code/Editor/Controls/ReflectedPropertyControl/PropertyMiscCtrl.h
T
Artur K a322d9e2b8 Small Code/Editor cleanup pass (#4909)
* Clean-up in ConfigGroup

Removed unused templated AddVar and related code.
Replaced legacy types with `AZ::` ones.
Cleaned up cpp file.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Add a few missing Q_OBJECT macros, remove some unused variables.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Apply some of clazy suggestions + simplifications

* removed `emit` from non-signal function calls.
* replaced `QStringLiteral("")` with a constexpr friendly
`QLatin1String()`

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Fix a CNewLevelDialog focus bug

Fixed an incorrect QTimer::singleShot invocation.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* match lambda to `messageChanged` signature

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* vs compilation fix + applied review

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* apply reviewer recommendation

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>
2021-10-29 09:59:18 +01:00

83 lines
3.0 KiB
C++

/*
* 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/base.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
#include "ReflectedVar.h"
#include "Util/VariablePropertyType.h"
#include "Controls/SplineCtrl.h"
#include <QWidget>
#endif
class QLabel;
class QLineEdit;
class UserPropertyEditor : public QWidget
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(UserPropertyEditor, AZ::SystemAllocator, 0);
UserPropertyEditor(QWidget *pParent = nullptr);
void SetValue(const QString &value, bool notify = true);
QString GetValue() const { return m_value; }
void SetData(bool canEdit, bool useTree, const QString &treeSeparator, const QString &dialogTitle, const std::vector<IVariable::IGetCustomItems::SItem>& items);
void onEditClicked();
signals:
void ValueChanged(const QString &value);
void RefreshItems();
private:
QLabel *m_valueLabel;
QString m_value;
bool m_canEdit;
bool m_useTree;
QString m_treeSeparator;
QString m_dialogTitle;
std::vector<IVariable::IGetCustomItems::SItem> m_items;
};
class UserPopupWidgetHandler : public QObject, public AzToolsFramework::PropertyHandler < CReflectedVarUser, UserPropertyEditor>
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(UserPopupWidgetHandler, AZ::SystemAllocator, 0);
bool IsDefaultHandler() const override { return false; }
QWidget* CreateGUI(QWidget *pParent) override;
AZ::u32 GetHandlerName(void) const override {return AZ_CRC("ePropertyUser", 0x65b972c0); }
void ConsumeAttribute(UserPropertyEditor* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
void WriteGUIValuesIntoProperty(size_t index, UserPropertyEditor* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
bool ReadValuesIntoGUI(size_t index, UserPropertyEditor* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
};
class FloatCurveHandler : public QObject, public AzToolsFramework::PropertyHandler < CReflectedVarSpline, CSplineCtrl>
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(FloatCurveHandler, AZ::SystemAllocator, 0);
bool IsDefaultHandler() const override { return false; }
QWidget* CreateGUI(QWidget *pParent) override;
AZ::u32 GetHandlerName(void) const override { return AZ_CRC("ePropertyFloatCurve", 0x7440ccce); }
void ConsumeAttribute(CSplineCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
void WriteGUIValuesIntoProperty(size_t index, CSplineCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
bool ReadValuesIntoGUI(size_t index, CSplineCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
void OnSplineChange(CSplineCtrl*);
};