Integrating github/staging through commit ab87ed9
This commit is contained in:
+5
@@ -56,6 +56,11 @@ namespace AzToolsFramework
|
||||
return QPixmap();
|
||||
}
|
||||
|
||||
bool EditorEntityUiHandlerBase::CanToggleLockVisibility(AZ::EntityId /*entityId*/) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void EditorEntityUiHandlerBase::PaintItemBackground(QPainter* /*painter*/, const QStyleOptionViewItem& /*option*/, const QModelIndex& /*index*/) const
|
||||
{
|
||||
}
|
||||
|
||||
+2
@@ -45,6 +45,8 @@ namespace AzToolsFramework
|
||||
virtual QString GenerateItemTooltip(AZ::EntityId entityId) const;
|
||||
//! Returns the item icon pixmap to display in the Outliner.
|
||||
virtual QPixmap GenerateItemIcon(AZ::EntityId entityId) const;
|
||||
//! Returns whether the element's lock and visibility state should be accessible in the Outliner
|
||||
virtual bool CanToggleLockVisibility(AZ::EntityId entityId) const;
|
||||
|
||||
//! Paints the background of the item in the Outliner.
|
||||
virtual void PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
|
||||
@@ -97,8 +97,6 @@ namespace AzToolsFramework
|
||||
AzToolsFramework::Layers::EditorLayerComponentRequestBus::EventResult(
|
||||
layerColor, entityId, &AzToolsFramework::Layers::EditorLayerComponentRequestBus::Events::GetLayerColor);
|
||||
|
||||
const QTreeView* outlinerTreeView(qobject_cast<const QTreeView*>(option.widget));
|
||||
int indentation = outlinerTreeView->indentation();
|
||||
|
||||
bool isFirstColumn = index.column() == EntityOutlinerListModel::ColumnName;
|
||||
bool hasVisibleChildren = index.data(EntityOutlinerListModel::ExpandedRole).value<bool>() && index.model()->hasChildren(index);
|
||||
|
||||
+1
-9
@@ -490,15 +490,7 @@ namespace LegacyFramework
|
||||
|
||||
AZ_Assert(!m_desc.m_enableProjectManager || m_desc.m_enableGUI, "Enabling the project manager in the application settings requires enabling the GUI as well.");
|
||||
|
||||
// if we're a GUI APP we need the UI Framework component:
|
||||
if (m_desc.m_enableGUI)
|
||||
{
|
||||
EnsureComponentCreated(AzToolsFramework::Framework::RTTI_Type());
|
||||
}
|
||||
else
|
||||
{
|
||||
EnsureComponentCreated(AzToolsFramework::Framework::RTTI_Type());
|
||||
}
|
||||
EnsureComponentCreated(AzToolsFramework::Framework::RTTI_Type());
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
|
||||
+54
-37
@@ -351,58 +351,68 @@ namespace AzToolsFramework
|
||||
|
||||
QVariant EntityOutlinerListModel::dataForVisibility(const QModelIndex& index, int role) const
|
||||
{
|
||||
auto id = GetEntityFromIndex(index);
|
||||
auto entityId = GetEntityFromIndex(index);
|
||||
auto entityUiHandler = m_editorEntityFrameworkInterface->GetHandler(entityId);
|
||||
|
||||
switch (role)
|
||||
if (!entityUiHandler || entityUiHandler->CanToggleLockVisibility(entityId))
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
case Qt::CheckStateRole:
|
||||
{
|
||||
return IsEntitySetToBeVisible(id) ? Qt::Checked : Qt::Unchecked;
|
||||
}
|
||||
{
|
||||
return IsEntitySetToBeVisible(entityId) ? Qt::Checked : Qt::Unchecked;
|
||||
}
|
||||
case Qt::ToolTipRole:
|
||||
{
|
||||
return QString("Show/Hide Entity");
|
||||
}
|
||||
{
|
||||
return QString("Show/Hide Entity");
|
||||
}
|
||||
case Qt::SizeHintRole:
|
||||
{
|
||||
return QSize(20, 20);
|
||||
{
|
||||
return QSize(20, 20);
|
||||
}
|
||||
}
|
||||
return dataForAll(index, role);
|
||||
}
|
||||
|
||||
return dataForAll(index, role);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant EntityOutlinerListModel::dataForLock(const QModelIndex& index, int role) const
|
||||
{
|
||||
auto id = GetEntityFromIndex(index);
|
||||
auto entityId = GetEntityFromIndex(index);
|
||||
auto entityUiHandler = m_editorEntityFrameworkInterface->GetHandler(entityId);
|
||||
|
||||
switch (role)
|
||||
if (!entityUiHandler || entityUiHandler->CanToggleLockVisibility(entityId))
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
case Qt::CheckStateRole:
|
||||
{
|
||||
bool isLocked = false;
|
||||
// Lock state is tracked in 3 places:
|
||||
// EditorLockComponent, EditorEntityModel, and ComponentEntityObject.
|
||||
// In addition to that, entities that are in layers can have the layer's lock state override their own.
|
||||
// Retrieving the lock state from the lock component is ideal for drawing the lock icon in the outliner because
|
||||
// the outliner needs to show that specific entity's lock state, and not the actual final lock state including the layer behavior.
|
||||
// The EditorLockComponent only knows about the specific entity's lock state and not the hierarchy.
|
||||
EditorLockComponentRequestBus::EventResult(
|
||||
isLocked, id, &EditorLockComponentRequests::GetLocked);
|
||||
{
|
||||
bool isLocked = false;
|
||||
// Lock state is tracked in 3 places:
|
||||
// EditorLockComponent, EditorEntityModel, and ComponentEntityObject.
|
||||
// In addition to that, entities that are in layers can have the layer's lock state override their own.
|
||||
// Retrieving the lock state from the lock component is ideal for drawing the lock icon in the outliner because
|
||||
// the outliner needs to show that specific entity's lock state, and not the actual final lock state including the layer
|
||||
// behavior. The EditorLockComponent only knows about the specific entity's lock state and not the hierarchy.
|
||||
EditorLockComponentRequestBus::EventResult(isLocked, entityId, &EditorLockComponentRequests::GetLocked);
|
||||
|
||||
return isLocked ? Qt::Checked : Qt::Unchecked;
|
||||
}
|
||||
return isLocked ? Qt::Checked : Qt::Unchecked;
|
||||
}
|
||||
case Qt::ToolTipRole:
|
||||
{
|
||||
return QString("Lock/Unlock Entity (Locked means the entity cannot be moved in the viewport)");
|
||||
}
|
||||
{
|
||||
return QString("Lock/Unlock Entity (Locked means the entity cannot be moved in the viewport)");
|
||||
}
|
||||
case Qt::SizeHintRole:
|
||||
{
|
||||
return QSize(20, 20);
|
||||
{
|
||||
return QSize(20, 20);
|
||||
}
|
||||
}
|
||||
|
||||
return dataForAll(index, role);
|
||||
}
|
||||
|
||||
return dataForAll(index, role);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant EntityOutlinerListModel::dataForSortIndex(const QModelIndex& index, int role) const
|
||||
@@ -429,8 +439,12 @@ namespace AzToolsFramework
|
||||
if (value.canConvert<Qt::CheckState>())
|
||||
{
|
||||
const auto entityId = GetEntityFromIndex(index);
|
||||
switch (index.column())
|
||||
auto entityUiHandler = m_editorEntityFrameworkInterface->GetHandler(entityId);
|
||||
|
||||
if (!entityUiHandler || entityUiHandler->CanToggleLockVisibility(entityId))
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case ColumnVisibilityToggle:
|
||||
ToggleEntityVisibility(entityId);
|
||||
break;
|
||||
@@ -438,6 +452,7 @@ namespace AzToolsFramework
|
||||
case ColumnLockToggle:
|
||||
ToggleEntityLockState(entityId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -826,7 +841,6 @@ namespace AzToolsFramework
|
||||
for (const ComponentAssetPair& pair : componentAssetPairs)
|
||||
{
|
||||
const AZ::TypeId& componentType = pair.first;
|
||||
const AZ::Data::AssetId& assetId = pair.second;
|
||||
|
||||
componentsToAdd.push_back(componentType);
|
||||
}
|
||||
@@ -853,7 +867,6 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
// Assign asset associated with each created component.
|
||||
const AZ::Entity::ComponentArrayType& componentsAdded = addComponentsOutcome.GetValue()[targetEntityId].m_componentsAdded;
|
||||
for (const ComponentAssetPair& pair : componentAssetPairs)
|
||||
{
|
||||
const AZ::TypeId& componentType = pair.first;
|
||||
@@ -1978,7 +1991,8 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
// Retrieve the Entity UI Handler
|
||||
AZ::EntityId entityId(index.data(EntityOutlinerListModel::EntityIdRole).value<AZ::u64>());
|
||||
auto firstColumnIndex = index.siblingAtColumn(0);
|
||||
AZ::EntityId entityId(firstColumnIndex.data(EntityOutlinerListModel::EntityIdRole).value<AZ::u64>());
|
||||
auto entityUiHandler = m_editorEntityFrameworkInterface->GetHandler(entityId);
|
||||
|
||||
const bool isSelected = (option.state & QStyle::State_Selected);
|
||||
@@ -2001,8 +2015,11 @@ namespace AzToolsFramework
|
||||
case EntityOutlinerListModel::ColumnVisibilityToggle:
|
||||
case EntityOutlinerListModel::ColumnLockToggle:
|
||||
{
|
||||
// Paint the Visibility and Lock state checkboxes
|
||||
PaintCheckboxes(painter, option, index, isHovered);
|
||||
if (!entityUiHandler || entityUiHandler->CanToggleLockVisibility(entityId))
|
||||
{
|
||||
// Paint the Visibility and Lock state checkboxes
|
||||
PaintCheckboxes(painter, option, index, isHovered);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EntityOutlinerListModel::ColumnName:
|
||||
|
||||
+9
-12
@@ -184,6 +184,7 @@ namespace AzToolsFramework
|
||||
m_gui->m_objectTree->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_gui->m_objectTree->setAutoScrollMargin(20);
|
||||
m_gui->m_objectTree->setIndentation(24);
|
||||
m_gui->m_objectTree->setRootIsDecorated(false);
|
||||
connect(m_gui->m_objectTree, &QTreeView::customContextMenuRequested, this, &EntityOutlinerWidget::OnOpenTreeContextMenu);
|
||||
|
||||
// custom item delegate
|
||||
@@ -804,10 +805,10 @@ namespace AzToolsFramework
|
||||
addAction(m_actionToDeleteSelectionAndDescendants);
|
||||
|
||||
m_actionToRenameSelection = new QAction(tr("Rename"), this);
|
||||
#ifdef Q_OS_MAC
|
||||
#if defined(Q_OS_MAC)
|
||||
// "Alt+Return" translates to Option+Return on macOS
|
||||
m_actionToRenameSelection->setShortcut(tr("Alt+Return"));
|
||||
#elseif Q_OS_WIN
|
||||
#elif defined(Q_OS_WIN)
|
||||
m_actionToRenameSelection->setShortcut(tr("F2"));
|
||||
#endif
|
||||
m_actionToRenameSelection->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
@@ -1089,16 +1090,6 @@ namespace AzToolsFramework
|
||||
setEnabled(true);
|
||||
SetEntityOutlinerState(m_gui, true);
|
||||
}
|
||||
|
||||
void EntityOutlinerWidget::SetRootEntity(AZ::EntityId rootEntityId)
|
||||
{
|
||||
// The proxy model needs a tick to initialize, else it will return an invalid index in mapFromSource.
|
||||
QTimer::singleShot(0, this, [rootEntityId, this]() {
|
||||
QModelIndex rootIndex = m_listModel->GetIndexFromEntity(rootEntityId);
|
||||
QModelIndex proxyIndex = m_proxyModel->mapFromSource(rootIndex);
|
||||
m_gui->m_objectTree->setRootIndex(proxyIndex);
|
||||
});
|
||||
}
|
||||
|
||||
void EntityOutlinerWidget::SetUpdatesEnabled(bool enable)
|
||||
{
|
||||
@@ -1114,6 +1105,12 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
void EntityOutlinerWidget::ExpandEntityChildren(AZ::EntityId entityId)
|
||||
{
|
||||
QModelIndex index = GetIndexFromEntityId(entityId);
|
||||
m_gui->m_objectTree->expand(index);
|
||||
}
|
||||
|
||||
void EntityOutlinerWidget::OnEntityInfoUpdatedAddChildEnd(AZ::EntityId /*parentId*/, AZ::EntityId childId)
|
||||
{
|
||||
QueueContentUpdateSort(childId);
|
||||
|
||||
+1
-1
@@ -106,8 +106,8 @@ namespace AzToolsFramework
|
||||
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
|
||||
|
||||
// EntityOutlinerWidgetInterface
|
||||
void SetRootEntity(AZ::EntityId rootEntityId) override;
|
||||
void SetUpdatesEnabled(bool enable) override;
|
||||
void ExpandEntityChildren(AZ::EntityId entityId) override;
|
||||
|
||||
// Build a selection object from the given entities. Entities already in the Widget's selection buffers are ignored.
|
||||
template <class EntityIdCollection>
|
||||
|
||||
+1
-1
@@ -22,8 +22,8 @@ namespace AzToolsFramework
|
||||
public:
|
||||
AZ_RTTI(EntityOutlinerWidgetInterface, "{30C0F252-EC84-4196-BF59-EB9E73B8ADCB}");
|
||||
|
||||
virtual void SetRootEntity(AZ::EntityId rootEntityId) = 0;
|
||||
virtual void SetUpdatesEnabled(bool enable) = 0;
|
||||
virtual void ExpandEntityChildren(AZ::EntityId entityId) = 0;
|
||||
};
|
||||
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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 <AzToolsFramework/UI/Prefab/LevelRootUiHandler.h>
|
||||
|
||||
#include <AzToolsFramework/UI/Prefab/PrefabEditInterface.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
|
||||
#include <AzToolsFramework/UI/Outliner/EntityOutlinerListModel.hxx>
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
const QColor LevelRootUiHandler::m_levelRootBorderColor = QColor("#656565");
|
||||
const QString LevelRootUiHandler::m_levelRootIconPath = QString(":/Level/level.svg");
|
||||
|
||||
LevelRootUiHandler::LevelRootUiHandler()
|
||||
{
|
||||
m_prefabEditInterface = AZ::Interface<Prefab::PrefabEditInterface>::Get();
|
||||
|
||||
if (m_prefabEditInterface == nullptr)
|
||||
{
|
||||
AZ_Assert(false, "LevelRootUiHandler - could not get PrefabEditInterface on LevelRootUiHandler construction.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_prefabPublicInterface = AZ::Interface<Prefab::PrefabPublicInterface>::Get();
|
||||
|
||||
if (m_prefabPublicInterface == nullptr)
|
||||
{
|
||||
AZ_Assert(false, "LevelRootUiHandler - could not get PrefabPublicInterface on LevelRootUiHandler construction.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap LevelRootUiHandler::GenerateItemIcon(AZ::EntityId /*entityId*/) const
|
||||
{
|
||||
return QPixmap(m_levelRootIconPath);
|
||||
}
|
||||
|
||||
bool LevelRootUiHandler::CanToggleLockVisibility(AZ::EntityId /*entityId*/) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void LevelRootUiHandler::PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& /*index*/) const
|
||||
{
|
||||
if (!painter)
|
||||
{
|
||||
AZ_Warning("LevelRootUiHandler", false, "LevelRootUiHandler - painter is nullptr, can't draw Prefab outliner background.");
|
||||
return;
|
||||
}
|
||||
|
||||
QPen borderLinePen(m_levelRootBorderColor, m_levelRootBorderThickness);
|
||||
|
||||
QRect rect = option.rect;
|
||||
rect.setLeft(rect.left() + (m_levelRootBorderThickness / 2));
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
painter->setPen(borderLinePen);
|
||||
|
||||
// Draw border at the bottom
|
||||
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#include <AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Prefab
|
||||
{
|
||||
class PrefabEditInterface;
|
||||
class PrefabPublicInterface;
|
||||
};
|
||||
|
||||
class LevelRootUiHandler
|
||||
: public EditorEntityUiHandlerBase
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(LevelRootUiHandler, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(AzToolsFramework::LevelRootUiHandler, "{B1D3B270-CD29-4033-873A-D78E76AB24A4}", EditorEntityUiHandlerBase);
|
||||
|
||||
LevelRootUiHandler();
|
||||
~LevelRootUiHandler() override = default;
|
||||
|
||||
// EditorEntityUiHandler...
|
||||
QPixmap GenerateItemIcon(AZ::EntityId entityId) const override;
|
||||
bool CanToggleLockVisibility(AZ::EntityId entityId) const override;
|
||||
void PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
||||
|
||||
private:
|
||||
Prefab::PrefabEditInterface* m_prefabEditInterface = nullptr;
|
||||
Prefab::PrefabPublicInterface* m_prefabPublicInterface = nullptr;
|
||||
|
||||
static constexpr int m_levelRootBorderThickness = 1;
|
||||
static const QColor m_levelRootBorderColor;
|
||||
static const QString m_levelRootIconPath;
|
||||
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
+30
-9
@@ -130,14 +130,14 @@ namespace AzToolsFramework
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(
|
||||
prefabWipFeaturesEnabled, &AzFramework::ApplicationRequests::ArePrefabWipFeaturesEnabled);
|
||||
|
||||
AzToolsFramework::EntityIdList selectedEntities;
|
||||
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
|
||||
selectedEntities, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
|
||||
|
||||
if (prefabWipFeaturesEnabled)
|
||||
{
|
||||
// Create Prefab
|
||||
{
|
||||
AzToolsFramework::EntityIdList selectedEntities;
|
||||
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
|
||||
selectedEntities, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
|
||||
|
||||
if (!selectedEntities.empty())
|
||||
{
|
||||
bool layerInSelection = false;
|
||||
@@ -186,10 +186,6 @@ namespace AzToolsFramework
|
||||
|
||||
// Edit/Save Prefab
|
||||
{
|
||||
AzToolsFramework::EntityIdList selectedEntities;
|
||||
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
|
||||
selectedEntities, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
|
||||
|
||||
if (selectedEntities.size() == 1)
|
||||
{
|
||||
AZ::EntityId selectedEntity = selectedEntities[0];
|
||||
@@ -237,6 +233,14 @@ namespace AzToolsFramework
|
||||
{
|
||||
menu->addSeparator();
|
||||
}
|
||||
|
||||
QAction* deleteAction = menu->addAction(QObject::tr("Delete"));
|
||||
QObject::connect(deleteAction, &QAction::triggered, deleteAction, [this] { ContextMenu_DeleteSelected(); });
|
||||
if (selectedEntities.size() == 0 ||
|
||||
(selectedEntities.size() == 1 && s_prefabPublicInterface->IsLevelInstanceContainerEntity(selectedEntities[0])))
|
||||
{
|
||||
deleteAction->setDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void PrefabIntegrationManager::HandleSourceFileType(AZStd::string_view sourceFilePath, AZ::EntityId parentId, AZ::Vector3 position) const
|
||||
@@ -369,6 +373,16 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
void PrefabIntegrationManager::ContextMenu_DeleteSelected()
|
||||
{
|
||||
AzToolsFramework::EntityIdList selectedEntityIds;
|
||||
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
|
||||
selectedEntityIds, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
|
||||
|
||||
AzToolsFramework::ToolsApplicationRequestBus::Broadcast(
|
||||
&AzToolsFramework::ToolsApplicationRequests::DeleteEntitiesAndAllDescendants, selectedEntityIds);
|
||||
}
|
||||
|
||||
void PrefabIntegrationManager::GenerateSuggestedFilenameFromEntities(const EntityIdList& entityIds, AZStd::string& outName)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
|
||||
@@ -972,7 +986,14 @@ namespace AzToolsFramework
|
||||
|
||||
void PrefabIntegrationManager::OnPrefabComponentActivate(AZ::EntityId entityId)
|
||||
{
|
||||
s_editorEntityUiInterface->RegisterEntity(entityId, m_prefabUiHandler.GetHandlerId());
|
||||
if (s_prefabPublicInterface->IsLevelInstanceContainerEntity(entityId))
|
||||
{
|
||||
s_editorEntityUiInterface->RegisterEntity(entityId, m_levelRootUiHandler.GetHandlerId());
|
||||
}
|
||||
else
|
||||
{
|
||||
s_editorEntityUiInterface->RegisterEntity(entityId, m_prefabUiHandler.GetHandlerId());
|
||||
}
|
||||
}
|
||||
|
||||
void PrefabIntegrationManager::OnPrefabComponentDeactivate(AZ::EntityId entityId)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserSourceDropBus.h>
|
||||
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
|
||||
#include <AzToolsFramework/UI/Prefab/LevelRootUiHandler.h>
|
||||
#include <AzToolsFramework/UI/Prefab/PrefabEditManager.h>
|
||||
#include <AzToolsFramework/UI/Prefab/PrefabIntegrationBus.h>
|
||||
#include <AzToolsFramework/UI/Prefab/PrefabIntegrationInterface.h>
|
||||
@@ -77,6 +78,9 @@ namespace AzToolsFramework
|
||||
// Manages the Edit Mode UI for prefabs
|
||||
PrefabEditManager m_prefabEditManager;
|
||||
|
||||
// Used to handle the UI for the level root
|
||||
LevelRootUiHandler m_levelRootUiHandler;
|
||||
|
||||
// Used to handle the UI for prefab entities
|
||||
PrefabUiHandler m_prefabUiHandler;
|
||||
|
||||
@@ -85,6 +89,7 @@ namespace AzToolsFramework
|
||||
static void ContextMenu_InstantiatePrefab();
|
||||
static void ContextMenu_EditPrefab(AZ::EntityId containerEntity);
|
||||
static void ContextMenu_SavePrefab(AZ::EntityId containerEntity);
|
||||
static void ContextMenu_DeleteSelected();
|
||||
|
||||
// Prompt and resolve dialogs
|
||||
static bool QueryUserForPrefabSaveLocation(
|
||||
|
||||
+43
-3
@@ -62,6 +62,7 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
#include <UI/PropertyEditor/Model/AssetCompleterModel.h>
|
||||
#include <UI/PropertyEditor/View/AssetCompleterListView.h>
|
||||
#include <UI/PropertyEditor/ThumbnailDropDown.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -95,6 +96,12 @@ namespace AzToolsFramework
|
||||
m_thumbnail->setFixedSize(QSize(24, 24));
|
||||
m_thumbnail->setVisible(false);
|
||||
|
||||
m_thumbnailDropDown = new ThumbnailDropDown(this);
|
||||
m_thumbnailDropDown->setFixedSize(QSize(40, 24));
|
||||
m_thumbnailDropDown->setVisible(false);
|
||||
|
||||
connect(m_thumbnailDropDown, &ThumbnailDropDown::clicked, this, &PropertyAssetCtrl::OnEditButtonClicked);
|
||||
|
||||
m_editButton = new QToolButton(this);
|
||||
m_editButton->setAutoRaise(true);
|
||||
m_editButton->setIcon(QIcon(":/stylesheet/img/UI20/open-in-internal-app.svg"));
|
||||
@@ -104,6 +111,7 @@ namespace AzToolsFramework
|
||||
connect(m_editButton, &QToolButton::clicked, this, &PropertyAssetCtrl::OnEditButtonClicked);
|
||||
|
||||
pLayout->addWidget(m_thumbnail);
|
||||
pLayout->addWidget(m_thumbnailDropDown);
|
||||
pLayout->addWidget(m_browseEdit);
|
||||
pLayout->addWidget(m_editButton);
|
||||
|
||||
@@ -1082,8 +1090,9 @@ namespace AzToolsFramework
|
||||
void PropertyAssetCtrl::UpdateThumbnail()
|
||||
{
|
||||
m_thumbnail->setVisible(m_showThumbnail);
|
||||
m_thumbnailDropDown->setVisible(m_showThumbnailDropDown);
|
||||
|
||||
if (m_showThumbnail)
|
||||
if (m_showThumbnail || m_showThumbnailDropDown)
|
||||
{
|
||||
const AZ::Data::AssetId assetID = GetCurrentAssetID();
|
||||
if (assetID.IsValid())
|
||||
@@ -1098,13 +1107,21 @@ namespace AzToolsFramework
|
||||
if (result)
|
||||
{
|
||||
SharedThumbnailKey thumbnailKey = MAKE_TKEY(AzToolsFramework::AssetBrowser::ProductThumbnailKey, assetID);
|
||||
m_thumbnail->SetThumbnailKey(thumbnailKey, Thumbnailer::ThumbnailContext::DefaultContext);
|
||||
if (m_showThumbnail)
|
||||
{
|
||||
m_thumbnail->SetThumbnailKey(thumbnailKey, Thumbnailer::ThumbnailContext::DefaultContext);
|
||||
}
|
||||
if (m_showThumbnailDropDown)
|
||||
{
|
||||
m_thumbnailDropDown->SetThumbnailKey(thumbnailKey, Thumbnailer::ThumbnailContext::DefaultContext);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_thumbnail->ClearThumbnail();
|
||||
m_thumbnailDropDown->ClearThumbnail();
|
||||
}
|
||||
|
||||
void PropertyAssetCtrl::SetClearButtonEnabled(bool enable)
|
||||
@@ -1138,6 +1155,16 @@ namespace AzToolsFramework
|
||||
return m_showThumbnail;
|
||||
}
|
||||
|
||||
void PropertyAssetCtrl::SetShowThumbnailDropDown(bool enable)
|
||||
{
|
||||
m_showThumbnailDropDown = enable;
|
||||
}
|
||||
|
||||
bool PropertyAssetCtrl::GetShowThumbnailDropDown() const
|
||||
{
|
||||
return m_showThumbnailDropDown;
|
||||
}
|
||||
|
||||
const AZ::Uuid& AssetPropertyHandlerDefault::GetHandledType() const
|
||||
{
|
||||
return AZ::GetAssetClassId();
|
||||
@@ -1248,7 +1275,7 @@ namespace AzToolsFramework
|
||||
GUI->SetBrowseButtonIcon(QIcon(iconPath.c_str()));
|
||||
}
|
||||
}
|
||||
else if (attrib == AZ_CRC_CE("ShowThumbnail"))
|
||||
else if (attrib == AZ_CRC_CE("Thumbnail"))
|
||||
{
|
||||
bool showThumbnail = false;
|
||||
if (attrValue->Read<bool>(showThumbnail))
|
||||
@@ -1256,6 +1283,19 @@ namespace AzToolsFramework
|
||||
GUI->SetShowThumbnail(showThumbnail);
|
||||
}
|
||||
}
|
||||
else if (attrib == AZ_CRC_CE("ThumbnailWithDropDown"))
|
||||
{
|
||||
PropertyAssetCtrl::EditCallbackType* func = azdynamic_cast<PropertyAssetCtrl::EditCallbackType*>(attrValue->GetAttribute());
|
||||
if (func)
|
||||
{
|
||||
GUI->SetShowThumbnailDropDown(true);
|
||||
GUI->SetEditNotifyCallback(func);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI->SetEditNotifyCallback(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AssetPropertyHandlerDefault::WriteGUIValuesIntoProperty(size_t index, PropertyAssetCtrl* GUI, property_t& instance, InstanceDataNode* node)
|
||||
|
||||
+6
@@ -45,6 +45,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
class AssetCompleterModel;
|
||||
class AssetCompleterListView;
|
||||
class ThumbnailDropDown;
|
||||
|
||||
namespace Thumbnailer
|
||||
{
|
||||
@@ -94,6 +95,7 @@ namespace AzToolsFramework
|
||||
void OnAssetIDChanged(AZ::Data::AssetId newAssetID);
|
||||
|
||||
protected:
|
||||
ThumbnailDropDown* m_thumbnailDropDown = nullptr;
|
||||
Thumbnailer::ThumbnailWidget* m_thumbnail = nullptr;
|
||||
QPushButton* m_errorButton = nullptr;
|
||||
QToolButton* m_editButton = nullptr;
|
||||
@@ -156,6 +158,8 @@ namespace AzToolsFramework
|
||||
|
||||
bool m_showThumbnail = false;
|
||||
|
||||
bool m_showThumbnailDropDown = false;
|
||||
|
||||
// ! Default suffix used in the field's placeholder text when a default value is set.
|
||||
const char* m_DefaultSuffix = " (default)";
|
||||
|
||||
@@ -205,6 +209,8 @@ namespace AzToolsFramework
|
||||
|
||||
void SetShowThumbnail(bool enable);
|
||||
bool GetShowThumbnail() const;
|
||||
void SetShowThumbnailDropDown(bool enable);
|
||||
bool GetShowThumbnailDropDown() const;
|
||||
|
||||
void SetSelectedAssetID(const AZ::Data::AssetId& newID);
|
||||
void SetCurrentAssetType(const AZ::Data::AssetType& newType);
|
||||
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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 <AzToolsFramework/Debug/TraceContext.h>
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // 4251: 'QRawFont::d': class 'QExplicitlySharedDataPointer<QRawFontPrivate>' needs to have dll-interface to be used by clients of class 'QRawFont'
|
||||
// 4800: 'QTextEngine *const ': forcing value to bool 'true' or 'false' (performance warning)
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QEvent>
|
||||
#include <QPainter>
|
||||
#include <UI/UICore/AspectRatioAwarePixmapWidget.hxx>
|
||||
#include <Thumbnails/ThumbnailWidget.h>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
#include "ThumbnailDropDown.h"
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
ThumbnailDropDown::ThumbnailDropDown(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QHBoxLayout* pLayout = new QHBoxLayout();
|
||||
pLayout->setContentsMargins(0, 0, 0, 0);
|
||||
pLayout->setSpacing(0);
|
||||
|
||||
m_thumbnail = new Thumbnailer::ThumbnailWidget(this);
|
||||
m_thumbnail->setFixedSize(QSize(24, 24));
|
||||
|
||||
m_dropDownArrow = new AspectRatioAwarePixmapWidget(this);
|
||||
m_dropDownArrow->setPixmap(QPixmap(":/stylesheet/img/triangle0.png"));
|
||||
m_dropDownArrow->setFixedSize(QSize(8, 24));
|
||||
|
||||
m_emptyThumbnail = new QLabel(this);
|
||||
m_emptyThumbnail->setPixmap(QPixmap(":/stylesheet/img/line.png"));
|
||||
m_emptyThumbnail->setFixedSize(QSize(24, 24));
|
||||
|
||||
pLayout->addWidget(m_emptyThumbnail);
|
||||
pLayout->addWidget(m_thumbnail);
|
||||
pLayout->addSpacing(4);
|
||||
pLayout->addWidget(m_dropDownArrow);
|
||||
pLayout->addSpacing(4);
|
||||
|
||||
setLayout(pLayout);
|
||||
}
|
||||
|
||||
void ThumbnailDropDown::SetThumbnailKey(Thumbnailer::SharedThumbnailKey key, const char* contextName)
|
||||
{
|
||||
m_emptyThumbnail->setVisible(false);
|
||||
m_thumbnail->SetThumbnailKey(key, contextName);
|
||||
}
|
||||
|
||||
void ThumbnailDropDown::ClearThumbnail()
|
||||
{
|
||||
m_emptyThumbnail->setVisible(true);
|
||||
m_thumbnail->ClearThumbnail();
|
||||
}
|
||||
|
||||
bool ThumbnailDropDown::event(QEvent* e)
|
||||
{
|
||||
if (isEnabled())
|
||||
{
|
||||
if (e->type() == QEvent::MouseButtonPress)
|
||||
{
|
||||
emit clicked();
|
||||
return true; //ignore
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::event(e);
|
||||
}
|
||||
|
||||
void ThumbnailDropDown::paintEvent(QPaintEvent* e)
|
||||
{
|
||||
QPainter p(this);
|
||||
QRect targetRect(QPoint(), QSize(40, 24));
|
||||
p.fillRect(targetRect, QColor(17, 17, 17)); // #111111
|
||||
QWidget::paintEvent(e);
|
||||
}
|
||||
|
||||
void ThumbnailDropDown::enterEvent(QEvent* e)
|
||||
{
|
||||
m_dropDownArrow->setPixmap(QPixmap(":/stylesheet/img/triangle0_highlighted.png"));
|
||||
QWidget::enterEvent(e);
|
||||
}
|
||||
|
||||
void ThumbnailDropDown::leaveEvent(QEvent* e)
|
||||
{
|
||||
m_dropDownArrow->setPixmap(QPixmap(":/stylesheet/img/triangle0.png"));
|
||||
QWidget::leaveEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
#include "UI/PropertyEditor/moc_ThumbnailDropDown.cpp"
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/PlatformDef.h>
|
||||
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // 4251: class '...' needs to have dll-interface to be used by clients of class '...'
|
||||
// 4800: 'uint': forcing value to bool 'true' or 'false' (performance warning)
|
||||
#include <QWidget>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
#endif
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
class AspectRatioAwarePixmapWidget;
|
||||
|
||||
namespace Thumbnailer
|
||||
{
|
||||
class ThumbnailWidget;
|
||||
}
|
||||
|
||||
class ThumbnailDropDown : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ThumbnailDropDown(QWidget* parent = nullptr);
|
||||
|
||||
//! Call this to set what thumbnail widget will display
|
||||
void SetThumbnailKey(Thumbnailer::SharedThumbnailKey key, const char* contextName = "Default");
|
||||
//! Remove current thumbnail
|
||||
void ClearThumbnail();
|
||||
|
||||
bool event(QEvent* e) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* e) override;
|
||||
void enterEvent(QEvent* e) override;
|
||||
void leaveEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
Thumbnailer::ThumbnailWidget* m_thumbnail = nullptr;
|
||||
QLabel* m_emptyThumbnail = nullptr;
|
||||
AspectRatioAwarePixmapWidget* m_dropDownArrow = nullptr;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user