/* * 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 #include "MipmapSettingWidget.h" #include #include #include #include #include #include namespace ImageProcessingEditor { using namespace ImageProcessing; MipmapSettingWidget::MipmapSettingWidget(EditorTextureSetting& textureSetting, QWidget* parent /*= nullptr*/) : QWidget(parent) , m_ui(new Ui::MipmapSettingWidget) , m_textureSetting(&textureSetting) { m_ui->setupUi(this); AZ::SerializeContext* serializeContext = nullptr; EBUS_EVENT_RESULT(serializeContext, AZ::ComponentApplicationBus, GetSerializeContext); AZ_Assert(serializeContext, "Serialization context not available"); m_ui->propertyEditor->SetAutoResizeLabels(true); m_ui->propertyEditor->Setup(serializeContext, this, true, 250); m_ui->propertyEditor->ClearInstances(); TextureSettings* instance = &m_textureSetting->GetMultiplatformTextureSetting(); const AZ::Uuid& classId = AZ::SerializeTypeInfo::GetUuid(instance); m_ui->propertyEditor->AddInstance(instance, classId); m_ui->propertyEditor->InvalidateAll(); m_ui->propertyEditor->ExpandAll(); RefreshUI(); EditorInternalNotificationBus::Handler::BusConnect(); } MipmapSettingWidget::~MipmapSettingWidget() { EditorInternalNotificationBus::Handler::BusDisconnect(); } void MipmapSettingWidget::RefreshUI() { TextureSettings& texSetting = m_textureSetting->GetMultiplatformTextureSetting(); const PresetSettings* preset = BuilderSettingManager::Instance()->GetPreset(texSetting.m_preset); if (preset == nullptr || preset->m_mipmapSetting == nullptr) { m_ui->enableCheckBox->setCheckState(Qt::CheckState::Unchecked); m_ui->enableCheckBox->setEnabled(false); m_ui->propertyEditor->hide(); } else { bool showMipMap = texSetting.m_enableMipmap; m_ui->enableCheckBox->setEnabled(true); m_ui->enableCheckBox->setCheckState(showMipMap ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); QObject::connect(m_ui->enableCheckBox, &QCheckBox::clicked, this, &MipmapSettingWidget::OnCheckBoxStateChanged); if (showMipMap) { m_ui->propertyEditor->show(); this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } else { m_ui->propertyEditor->hide(); this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); } } m_ui->propertyEditor->InvalidateValues(); } void MipmapSettingWidget::OnCheckBoxStateChanged(bool checked) { bool finalChecked = m_textureSetting->RefreshMipSetting(checked); if (finalChecked) { m_ui->propertyEditor->show(); } else { m_ui->propertyEditor->hide(); } EditorInternalNotificationBus::Broadcast(&EditorInternalNotificationBus::Events::OnEditorSettingsChanged, false, BuilderSettingManager::s_defaultPlatform); } void MipmapSettingWidget::AfterPropertyModified(AzToolsFramework::InstanceDataNode* /*pNode*/) { //Only the first texture setting reflected is changed, we need to propagate the change to every texture settings. m_textureSetting->PropagateCommonSettings(); m_ui->propertyEditor->InvalidateValues(); EditorInternalNotificationBus::Broadcast(&EditorInternalNotificationBus::Events::OnEditorSettingsChanged, false, BuilderSettingManager::s_defaultPlatform); } void MipmapSettingWidget::OnEditorSettingsChanged(bool needRefresh, const AZStd::string& /*platform*/) { if (needRefresh) { RefreshUI(); } } }//namespace ImageProcessingEditor #include