Integrating latest from github/staging
Integrating up through commit 5e1bdae
This commit is contained in:
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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 <Atom/Feature/Utils/LightingPreset.h>
|
||||
#include <Atom/Viewport/MaterialViewportRequestBus.h>
|
||||
#include <AtomToolsFramework/Util/Util.h>
|
||||
#include <AzFramework/Application/Application.h>
|
||||
#include <Window/PresetBrowserDialogs/LightingPresetBrowserDialog.h>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
LightingPresetBrowserDialog::LightingPresetBrowserDialog(QWidget* parent)
|
||||
: PresetBrowserDialog(parent)
|
||||
{
|
||||
QSignalBlocker signalBlocker(this);
|
||||
|
||||
setWindowTitle("Lighting Preset Browser");
|
||||
|
||||
MaterialViewportRequestBus::BroadcastResult(m_initialPreset, &MaterialViewportRequestBus::Events::GetLightingPresetSelection);
|
||||
|
||||
AZ::Render::LightingPresetPtrVector presets;
|
||||
MaterialViewportRequestBus::BroadcastResult(presets, &MaterialViewportRequestBus::Events::GetLightingPresets);
|
||||
AZStd::sort(presets.begin(), presets.end(), [](const auto& a, const auto& b) { return a->m_displayName < b->m_displayName; });
|
||||
|
||||
QListWidgetItem* selectedItem = nullptr;
|
||||
for (const auto& preset : presets)
|
||||
{
|
||||
QImage image;
|
||||
MaterialViewportRequestBus::BroadcastResult(image, &MaterialViewportRequestBus::Events::GetLightingPresetPreview, preset);
|
||||
|
||||
QListWidgetItem* item = CreateListItem(preset->m_displayName.c_str(), image);
|
||||
|
||||
m_listItemToPresetMap[item] = preset;
|
||||
|
||||
if (m_initialPreset == preset)
|
||||
{
|
||||
selectedItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedItem)
|
||||
{
|
||||
m_ui->m_presetList->setCurrentItem(selectedItem);
|
||||
m_ui->m_presetList->scrollToItem(selectedItem);
|
||||
}
|
||||
}
|
||||
|
||||
void LightingPresetBrowserDialog::SelectCurrentPreset()
|
||||
{
|
||||
auto presetItr = m_listItemToPresetMap.find(m_ui->m_presetList->currentItem());
|
||||
if (presetItr != m_listItemToPresetMap.end())
|
||||
{
|
||||
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SelectLightingPreset, presetItr->second);
|
||||
}
|
||||
}
|
||||
|
||||
void LightingPresetBrowserDialog::SelectInitialPreset()
|
||||
{
|
||||
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SelectLightingPreset, m_initialPreset);
|
||||
}
|
||||
|
||||
} // namespace MaterialEditor
|
||||
|
||||
#include <Window/PresetBrowserDialogs/moc_LightingPresetBrowserDialog.cpp>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <Atom/Feature/Utils/LightingPreset.h>
|
||||
#include <Atom/Viewport/MaterialViewportNotificationBus.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#endif
|
||||
|
||||
#include <Window/PresetBrowserDialogs/PresetBrowserDialog.h>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
//! Widget for managing and selecting from a library of preset assets
|
||||
class LightingPresetBrowserDialog : public PresetBrowserDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LightingPresetBrowserDialog(QWidget* parent = nullptr);
|
||||
~LightingPresetBrowserDialog() = default;
|
||||
|
||||
private:
|
||||
void SelectCurrentPreset() override;
|
||||
void SelectInitialPreset() override;
|
||||
|
||||
AZ::Render::LightingPresetPtr m_initialPreset;
|
||||
AZStd::unordered_map<QListWidgetItem*, AZ::Render::LightingPresetPtr> m_listItemToPresetMap;
|
||||
};
|
||||
} // namespace MaterialEditor
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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 <Atom/Feature/Utils/ModelPreset.h>
|
||||
#include <Atom/Viewport/MaterialViewportRequestBus.h>
|
||||
#include <AtomToolsFramework/Util/Util.h>
|
||||
#include <AzFramework/Application/Application.h>
|
||||
#include <Window/PresetBrowserDialogs/ModelPresetBrowserDialog.h>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
ModelPresetBrowserDialog::ModelPresetBrowserDialog(QWidget* parent)
|
||||
: PresetBrowserDialog(parent)
|
||||
{
|
||||
QSignalBlocker signalBlocker(this);
|
||||
|
||||
setWindowTitle("Model Preset Browser");
|
||||
|
||||
MaterialViewportRequestBus::BroadcastResult(m_initialPreset, &MaterialViewportRequestBus::Events::GetModelPresetSelection);
|
||||
|
||||
AZ::Render::ModelPresetPtrVector presets;
|
||||
MaterialViewportRequestBus::BroadcastResult(presets, &MaterialViewportRequestBus::Events::GetModelPresets);
|
||||
AZStd::sort(presets.begin(), presets.end(), [](const auto& a, const auto& b) { return a->m_displayName < b->m_displayName; });
|
||||
|
||||
QListWidgetItem* selectedItem = nullptr;
|
||||
for (const auto& preset : presets)
|
||||
{
|
||||
QImage image;
|
||||
MaterialViewportRequestBus::BroadcastResult(image, &MaterialViewportRequestBus::Events::GetModelPresetPreview, preset);
|
||||
|
||||
QListWidgetItem* item = CreateListItem(preset->m_displayName.c_str(), image);
|
||||
|
||||
m_listItemToPresetMap[item] = preset;
|
||||
|
||||
if (m_initialPreset == preset)
|
||||
{
|
||||
selectedItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedItem)
|
||||
{
|
||||
m_ui->m_presetList->setCurrentItem(selectedItem);
|
||||
m_ui->m_presetList->scrollToItem(selectedItem);
|
||||
}
|
||||
}
|
||||
|
||||
void ModelPresetBrowserDialog::SelectCurrentPreset()
|
||||
{
|
||||
auto presetItr = m_listItemToPresetMap.find(m_ui->m_presetList->currentItem());
|
||||
if (presetItr != m_listItemToPresetMap.end())
|
||||
{
|
||||
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SelectModelPreset, presetItr->second);
|
||||
}
|
||||
}
|
||||
|
||||
void ModelPresetBrowserDialog::SelectInitialPreset()
|
||||
{
|
||||
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SelectModelPreset, m_initialPreset);
|
||||
}
|
||||
|
||||
} // namespace MaterialEditor
|
||||
|
||||
#include <Window/PresetBrowserDialogs/moc_ModelPresetBrowserDialog.cpp>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <Atom/Feature/Utils/ModelPreset.h>
|
||||
#include <Atom/Viewport/MaterialViewportNotificationBus.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#endif
|
||||
|
||||
#include <Window/PresetBrowserDialogs/PresetBrowserDialog.h>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
//! Widget for managing and selecting from a library of preset assets
|
||||
class ModelPresetBrowserDialog : public PresetBrowserDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ModelPresetBrowserDialog(QWidget* parent = nullptr);
|
||||
~ModelPresetBrowserDialog() = default;
|
||||
|
||||
private:
|
||||
void SelectCurrentPreset() override;
|
||||
void SelectInitialPreset() override;
|
||||
|
||||
AZ::Render::ModelPresetPtr m_initialPreset;
|
||||
AZStd::unordered_map<QListWidgetItem*, AZ::Render::ModelPresetPtr> m_listItemToPresetMap;
|
||||
};
|
||||
} // namespace MaterialEditor
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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 <AtomToolsFramework/Util/Util.h>
|
||||
#include <AzFramework/Application/Application.h>
|
||||
#include <AzQtComponents/Components/StyleManager.h>
|
||||
#include <AzQtComponents/Components/Widgets/ElidingLabel.h>
|
||||
#include <AzQtComponents/Components/Widgets/LineEdit.h>
|
||||
#include <AzQtComponents/Components/Widgets/Text.h>
|
||||
#include <Window/PresetBrowserDialogs/PresetBrowserDialog.h>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
PresetBrowserDialog::PresetBrowserDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::PresetBrowserDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
QSignalBlocker signalBlocker(this);
|
||||
|
||||
SetupPresetList();
|
||||
SetupSearchWidget();
|
||||
SetupDialogButtons();
|
||||
}
|
||||
|
||||
void PresetBrowserDialog::SetupPresetList()
|
||||
{
|
||||
m_ui->m_presetList->setFlow(QListView::LeftToRight);
|
||||
m_ui->m_presetList->setResizeMode(QListView::Adjust);
|
||||
m_ui->m_presetList->setGridSize(QSize(0, 0));
|
||||
m_ui->m_presetList->setWrapping(true);
|
||||
|
||||
QObject::connect(m_ui->m_presetList, &QListWidget::currentItemChanged, [this]() { SelectCurrentPreset(); });
|
||||
}
|
||||
|
||||
QListWidgetItem* PresetBrowserDialog::CreateListItem(const QString& title, const QImage& image)
|
||||
{
|
||||
const QSize gridSize = m_ui->m_presetList->gridSize();
|
||||
m_ui->m_presetList->setGridSize(
|
||||
QSize(AZStd::max(gridSize.width(), image.width() + 10), AZStd::max(gridSize.height(), image.height() + 10)));
|
||||
|
||||
QListWidgetItem* item = new QListWidgetItem(m_ui->m_presetList);
|
||||
item->setData(Qt::UserRole, title);
|
||||
item->setSizeHint(image.size() + QSize(4, 4));
|
||||
m_ui->m_presetList->addItem(item);
|
||||
|
||||
QLabel* previewImage = new QLabel(m_ui->m_presetList);
|
||||
previewImage->setFixedSize(image.size());
|
||||
previewImage->setMargin(0);
|
||||
previewImage->setPixmap(QPixmap::fromImage(image));
|
||||
previewImage->updateGeometry();
|
||||
|
||||
AzQtComponents::ElidingLabel* previewLabel = new AzQtComponents::ElidingLabel(previewImage);
|
||||
previewLabel->setText(title);
|
||||
previewLabel->setFixedSize(QSize(image.width(), 15));
|
||||
previewLabel->setMargin(0);
|
||||
previewLabel->setStyleSheet("background-color: rgb(35, 35, 35)");
|
||||
AzQtComponents::Text::addPrimaryStyle(previewLabel);
|
||||
AzQtComponents::Text::addLabelStyle(previewLabel);
|
||||
|
||||
m_ui->m_presetList->setItemWidget(item, previewImage);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
void PresetBrowserDialog::SetupSearchWidget()
|
||||
{
|
||||
m_ui->m_searchWidget->setReadOnly(false);
|
||||
m_ui->m_searchWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
AzQtComponents::LineEdit::applySearchStyle(m_ui->m_searchWidget);
|
||||
connect(m_ui->m_searchWidget, &QLineEdit::textChanged, this, [this]() { ApplySearchFilter(); });
|
||||
connect(m_ui->m_searchWidget, &QWidget::customContextMenuRequested, this, [this](const QPoint& pos) { ShowSearchMenu(pos); });
|
||||
}
|
||||
|
||||
void PresetBrowserDialog::SetupDialogButtons()
|
||||
{
|
||||
connect(m_ui->m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(m_ui->m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
connect(this, &QDialog::rejected, this, [this]() { SelectInitialPreset(); });
|
||||
}
|
||||
|
||||
void PresetBrowserDialog::ApplySearchFilter()
|
||||
{
|
||||
for (int index = 0; index < m_ui->m_presetList->count(); ++index)
|
||||
{
|
||||
QListWidgetItem* item = m_ui->m_presetList->item(index);
|
||||
const QString& title = item->data(Qt::UserRole).toString();
|
||||
const QString filter = m_ui->m_searchWidget->text();
|
||||
item->setHidden(!filter.isEmpty() && !title.contains(filter, Qt::CaseInsensitive));
|
||||
}
|
||||
}
|
||||
|
||||
void PresetBrowserDialog::ShowSearchMenu(const QPoint& pos)
|
||||
{
|
||||
QScopedPointer<QMenu> menu(m_ui->m_searchWidget->createStandardContextMenu());
|
||||
menu->setStyleSheet("background-color: #333333");
|
||||
menu->exec(m_ui->m_searchWidget->mapToGlobal(pos));
|
||||
}
|
||||
} // namespace MaterialEditor
|
||||
|
||||
#include <Window/PresetBrowserDialogs/moc_PresetBrowserDialog.cpp>
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
#include <QDialog>
|
||||
#endif
|
||||
|
||||
#include <Window/PresetBrowserDialogs/ui_PresetBrowserDialog.h>
|
||||
|
||||
class QImage;
|
||||
class QListWidgetItem;
|
||||
class QString;
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
//! Widget for managing and selecting from a library of preset assets
|
||||
class PresetBrowserDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PresetBrowserDialog(QWidget* parent = nullptr);
|
||||
~PresetBrowserDialog() = default;
|
||||
|
||||
protected:
|
||||
void SetupPresetList();
|
||||
QListWidgetItem* CreateListItem(const QString& title, const QImage& image);
|
||||
|
||||
void SetupSearchWidget();
|
||||
void SetupDialogButtons();
|
||||
void ApplySearchFilter();
|
||||
void ShowSearchMenu(const QPoint& pos);
|
||||
virtual void SelectCurrentPreset() = 0;
|
||||
virtual void SelectInitialPreset() = 0;
|
||||
|
||||
QScopedPointer<Ui::PresetBrowserDialog> m_ui;
|
||||
};
|
||||
} // namespace MaterialEditor
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PresetBrowserDialog</class>
|
||||
<widget class="QWidget" name="PresetBrowserDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Preset Browser</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_searchWidget"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="m_presetList"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user