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.
o3de/Gems/Blast/Code/Editor/SettingsWidget.cpp

78 lines
2.9 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 "StdAfx.h"
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzToolsFramework/UI/PropertyEditor/InstanceDataHierarchy.h>
#include <AzToolsFramework/UI/PropertyEditor/ReflectedPropertyEditor.hxx>
#include <Editor/SettingsWidget.h>
#include <QBoxLayout>
namespace Blast
{
namespace Editor
{
SettingsWidget::SettingsWidget(QWidget* parent)
: QWidget(parent)
{
CreatePropertyEditor(this);
}
void SettingsWidget::SetValue(const BlastGlobalConfiguration& configuration)
{
m_configuration = configuration;
blockSignals(true);
m_propertyEditor->ClearInstances();
m_propertyEditor->AddInstance(&m_configuration);
m_propertyEditor->InvalidateAll();
blockSignals(false);
}
void SettingsWidget::CreatePropertyEditor(QWidget* parent)
{
QVBoxLayout* verticalLayout = new QVBoxLayout(parent);
verticalLayout->setContentsMargins(0, 0, 0, 0);
verticalLayout->setSpacing(0);
AZ::SerializeContext* m_serializeContext;
AZ::ComponentApplicationBus::BroadcastResult(
m_serializeContext, &AZ::ComponentApplicationRequests::GetSerializeContext);
AZ_Assert(m_serializeContext, "Failed to retrieve serialize context.");
static const int propertyLabelWidth = 250;
m_propertyEditor = new AzToolsFramework::ReflectedPropertyEditor(parent);
m_propertyEditor->Setup(m_serializeContext, this, true, propertyLabelWidth);
m_propertyEditor->show();
m_propertyEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
verticalLayout->addWidget(m_propertyEditor);
}
void SettingsWidget::BeforePropertyModified(AzToolsFramework::InstanceDataNode* /*node*/) {}
void SettingsWidget::AfterPropertyModified(AzToolsFramework::InstanceDataNode* /*node*/)
{
emit onValueChanged(m_configuration);
}
void SettingsWidget::SetPropertyEditingActive(AzToolsFramework::InstanceDataNode* /*node*/) {}
void SettingsWidget::SetPropertyEditingComplete(AzToolsFramework::InstanceDataNode* /*node*/) {}
void SettingsWidget::SealUndoStack() {}
} // namespace Editor
} // namespace Blast
#include <Editor/moc_SettingsWidget.cpp>