Added unit tests for groups and toggle groups, fixed comments and syntax
Signed-off-by: Jose <jotamkin@amazon.com>
This commit is contained in:
+2
-1
@@ -1112,7 +1112,8 @@ namespace AzToolsFramework
|
||||
const AZ::Edit::ElementData* groupData = nullptr;
|
||||
for (const AZ::Edit::ElementData& elementData : parentEditData->m_elements)
|
||||
{
|
||||
if ((node->m_elementEditData == &elementData) && (elementData.m_elementId != AZ::Edit::ClassElements::Group)) // this element matches this node
|
||||
// this element matches this node
|
||||
if ((node->m_elementEditData == &elementData) && (elementData.m_elementId != AZ::Edit::ClassElements::Group))
|
||||
{
|
||||
// Record the last found group data
|
||||
node->m_groupElementData = groupData;
|
||||
|
||||
+3
-3
@@ -1120,10 +1120,10 @@ namespace AzToolsFramework
|
||||
if (!m_toggleSwitch)
|
||||
{
|
||||
m_handlerName = AZ::Edit::UIHandlers::CheckBox;
|
||||
EBUS_EVENT_RESULT(m_handler, PropertyTypeRegistrationMessages::Bus, ResolvePropertyHandler, m_handlerName, azrtti_typeid<bool>());
|
||||
PropertyTypeRegistrationMessages::Bus::BroadcastResult(m_handler, &PropertyTypeRegistrationMessages::Bus::Events::ResolvePropertyHandler, m_handlerName, azrtti_typeid<bool>());
|
||||
m_toggleSwitch = m_handler->CreateGUI(this);
|
||||
m_middleLayout->insertWidget(0, m_toggleSwitch, 1);
|
||||
auto checkBoxCtrl = reinterpret_cast<AzToolsFramework::PropertyCheckBoxCtrl*>(m_toggleSwitch);
|
||||
auto checkBoxCtrl = static_cast<AzToolsFramework::PropertyCheckBoxCtrl*>(m_toggleSwitch);
|
||||
QObject::connect(checkBoxCtrl, &AzToolsFramework::PropertyCheckBoxCtrl::valueChanged, this, &PropertyRowWidget::OnClickedToggleButton);
|
||||
}
|
||||
}
|
||||
@@ -1138,7 +1138,7 @@ namespace AzToolsFramework
|
||||
|
||||
void PropertyRowWidget::OnClickedToggleButton(bool checked)
|
||||
{
|
||||
if ((m_expanded && !checked) || (!m_expanded && checked))
|
||||
if (m_expanded != checked)
|
||||
{
|
||||
DoExpandOrContract(!IsExpanded(), 0 != (QGuiApplication::keyboardModifiers() & Qt::ControlModifier));
|
||||
}
|
||||
|
||||
+1
@@ -143,6 +143,7 @@ namespace AzToolsFramework
|
||||
QToolButton* GetIndicatorButton() { return m_indicatorButton; }
|
||||
QLabel* GetNameLabel() { return m_nameLabel; }
|
||||
QWidget* GetToggle() { return m_toggleSwitch; }
|
||||
const QWidget* GetToggle() const { return m_toggleSwitch; }
|
||||
void SetIndentSize(int w);
|
||||
void SetAsCustom(bool custom) { m_custom = custom; }
|
||||
|
||||
|
||||
+10
-12
@@ -167,7 +167,7 @@ namespace AzToolsFramework
|
||||
InstanceDataHierarchyList m_instances; ///< List of instance sets to display, other one can aggregate other instances.
|
||||
InstanceDataHierarchy::ValueComparisonFunction m_valueComparisonFunction;
|
||||
ReflectedPropertyEditor::WidgetList m_widgets;
|
||||
ReflectedPropertyEditor::SpecialGroupWidgetList m_specialGroupWidgets;
|
||||
ReflectedPropertyEditor::WidgetList m_specialGroupWidgets;
|
||||
InstanceDataNode* groupSourceNode = nullptr;
|
||||
RowContainerType m_widgetsInDisplayOrder;
|
||||
UserWidgetToDataMap m_userWidgetsToData;
|
||||
@@ -626,7 +626,7 @@ namespace AzToolsFramework
|
||||
// creates and populates the GUI to edit the property if not already created
|
||||
void ReflectedPropertyEditor::Impl::CreateEditorWidget(PropertyRowWidget* pWidget)
|
||||
{
|
||||
if ((!pWidget->HasChildWidgetAlready()) && (!pWidget->GetToggle()))
|
||||
if (!pWidget->HasChildWidgetAlready() && !pWidget->GetToggle())
|
||||
{
|
||||
PropertyHandlerBase* pHandler = pWidget->GetHandler();
|
||||
if (pHandler)
|
||||
@@ -753,7 +753,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((!node->GetElementEditMetadata()) || (node->GetElementEditMetadata()->m_elementId != AZ::Edit::ClassElements::Group))
|
||||
if (!node->GetElementEditMetadata() || (node->GetElementEditMetadata()->m_elementId != AZ::Edit::ClassElements::Group))
|
||||
{
|
||||
pWidget = CreateOrPullFromPool();
|
||||
pWidget->show();
|
||||
@@ -787,7 +787,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
// Save the last InstanceDataNode that is a Group ClassElement so that we can use it as the source node for its widget.
|
||||
if ((node->GetElementEditMetadata()) && (node->GetElementEditMetadata()->m_elementId == AZ::Edit::ClassElements::Group))
|
||||
if (node->GetElementEditMetadata() && (node->GetElementEditMetadata()->m_elementId == AZ::Edit::ClassElements::Group))
|
||||
{
|
||||
groupSourceNode = node;
|
||||
}
|
||||
@@ -1382,16 +1382,14 @@ namespace AzToolsFramework
|
||||
return;
|
||||
}
|
||||
|
||||
// get the property editor
|
||||
// Get the property editor from either the widget map or the special toggle group widgets
|
||||
auto rowWidget = m_widgets.find(it->second);
|
||||
auto rowWidgetGroup = m_specialGroupWidgets.find(it->second);
|
||||
if (rowWidget != m_widgets.end() || rowWidgetGroup != m_specialGroupWidgets.end())
|
||||
if (rowWidget == m_widgets.end())
|
||||
{
|
||||
rowWidget = m_specialGroupWidgets.find(it->second);
|
||||
}
|
||||
if (rowWidget != m_widgets.end() || rowWidget != m_specialGroupWidgets.end())
|
||||
{
|
||||
if (rowWidget == m_widgets.end())
|
||||
{
|
||||
rowWidget = rowWidgetGroup;
|
||||
}
|
||||
|
||||
InstanceDataNode* node = rowWidget->first;
|
||||
PropertyRowWidget* widget = rowWidget->second;
|
||||
PropertyHandlerBase* handler = widget->GetHandler();
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ namespace AzToolsFramework
|
||||
|
||||
typedef AZStd::unordered_map<InstanceDataNode*, PropertyRowWidget*> WidgetList;
|
||||
|
||||
typedef AZStd::unordered_map<InstanceDataNode*, PropertyRowWidget*> SpecialGroupWidgetList;
|
||||
ReflectedPropertyEditor::WidgetList m_specialGroupWidgets;
|
||||
|
||||
ReflectedPropertyEditor(QWidget* pParent);
|
||||
virtual ~ReflectedPropertyEditor();
|
||||
|
||||
Reference in New Issue
Block a user