Merge remote-tracking branch 'upstream/development' into nvsickle/DomPatch

This commit is contained in:
Nicholas Van Sickle
2022-02-07 10:51:43 -08:00
2456 changed files with 259183 additions and 105897 deletions
@@ -1,73 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "AzAssetBrowserWindow.h"
#include "AzAssetBrowser/ui_AssetBrowserWindow.h"
#include <AzToolsFramework/AssetBrowser/UI/AssetTreeView.h>
#include <AzToolsFramework/AssetBrowser/UI/SortFilterProxyModel.hxx>
#include <AzToolsFramework/AssetBrowser/UI/AssetBrowserModel.h>
#include <AzToolsFramework/AssetBrowser/AssetCache/AssetCacheBus.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserRequestBus.h>
const char* ASSET_BROWSER_PREVIEW_NAME = "Asset Browser (PREVIEW)";
AzAssetBrowserWindow::AzAssetBrowserWindow(const QString& name, QWidget* parent)
: QDialog(parent)
, m_ui(new Ui::AssetBrowserWindowClass())
, m_assetDatabaseSortFilterProxyModel(new AssetBrowser::UI::SortFilterProxyModel(parent))
, m_name(name)
, m_assetBrowser(new AssetBrowser::UI::AssetTreeView(name, this))
{
EBUS_EVENT_RESULT(m_assetBrowserModel, AssetBrowser::AssetCache::AssetCacheRequestsBus, GetAssetBrowserModel);
AZ_Assert(m_assetBrowserModel, "Failed to get filebrowser model");
m_assetDatabaseSortFilterProxyModel->setSourceModel(m_assetBrowserModel);
m_ui->setupUi(this);
connect(m_ui->searchCriteriaWidget,
&AzToolsFramework::SearchCriteriaWidget::SearchCriteriaChanged,
m_assetDatabaseSortFilterProxyModel.data(),
&AssetBrowser::UI::SortFilterProxyModel::OnSearchCriteriaChanged);
connect(m_assetBrowser, &QTreeView::customContextMenuRequested, this, &AzAssetBrowserWindow::OnContextMenu);
}
AzAssetBrowserWindow::~AzAssetBrowserWindow()
{
m_assetBrowser->SaveState();
}
//////////////////////////////////////////////////////////////////////////
const AZ::Uuid& AzAssetBrowserWindow::GetClassID()
{
return AZ::AzTypeInfo<AzAssetBrowserWindow>::Uuid();
}
void AzAssetBrowserWindow::OnContextMenu(const QPoint& point)
{
(void)point;
//get the selected entries
QModelIndexList sourceIndexes;
for (const auto& index : m_assetBrowser->selectedIndexes())
{
sourceIndexes.push_back(m_assetDatabaseSortFilterProxyModel->mapToSource(index));
}
AZStd::vector<AssetBrowser::UI::Entry*> entries;
m_assetBrowserModel->SourceIndexesToAssetDatabaseEntries(sourceIndexes, entries);
if (entries.empty() || entries.size() > 1)
{
return;
}
auto entry = entries.front();
EBUS_EVENT(AssetBrowser::AssetBrowserRequestBus::Bus, OnItemContextMenu, this, entry);
}
#include <AzAssetBrowser/moc_AzAssetBrowserWindow.cpp>
@@ -1,57 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Math/Uuid.h>
#include <QDialog>
#endif
namespace Ui
{
class AssetBrowserWindowClass;
}
namespace AssetBrowser
{
namespace UI
{
class AssetTreeView;
class SortFilterProxyModel;
class AssetBrowserModel;
}
}
class AzAssetBrowserWindow
: public QDialog
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(AzAssetBrowserWindow, AZ::SystemAllocator, 0);
AZ_TYPE_INFO(AzAssetBrowserWindow, "{20238D23-2670-44BC-9110-A51374C18B5A}");
explicit AzAssetBrowserWindow(const QString& name = "default", QWidget* parent = nullptr);
virtual ~AzAssetBrowserWindow();
static const AZ::Uuid& GetClassID();
protected Q_SLOTS:
void OnContextMenu(const QPoint& point);
private:
QScopedPointer<Ui::AssetBrowserWindowClass> m_ui;
QScopedPointer<AssetBrowser::UI::AssetBrowserModel> m_assetDatabaseModel;
QScopedPointer<AssetBrowser::UI::SortFilterProxyModel> m_assetDatabaseSortFilterProxyModel;
QString m_name;
AssetBrowser::UI::AssetTreeView* m_assetBrowser;
AssetBrowser::UI::AssetBrowserModel* m_assetBrowserModel;
};
extern const char* ASSET_BROWSER_PREVIEW_NAME;
@@ -78,10 +78,7 @@
<enum>Qt::ClickFocus</enum>
</property>
<property name="toolTip">
<string extracomment="Collapse All"/>
</property>
<property name="toolTipDuration">
<number>3</number>
<string extracomment="Collapse All">Collapse All</string>
</property>
<property name="text">
<string/>
-3
View File
@@ -104,13 +104,11 @@ ly_add_target(
3rdParty::Qt::Concurrent
3rdParty::TIFF
3rdParty::squish-ccr
3rdParty::AWSNativeSDK::STS
Legacy::CryCommon
Legacy::EditorCommon
AZ::AzCore
AZ::AzToolsFramework
Gem::LmbrCentral.Static
AZ::AWSNativeSDKInit
AZ::AtomCore
Gem::Atom_RPI.Edit
Gem::Atom_RPI.Public
@@ -119,7 +117,6 @@ ly_add_target(
Gem::AtomViewportDisplayInfo
${additional_dependencies}
PUBLIC
3rdParty::AWSNativeSDK::Core
3rdParty::Qt::Network
Legacy::EditorCore
RUNTIME_DEPENDENCIES
-186
View File
@@ -1,186 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "CVarMenu.h"
CVarMenu::CVarMenu(QWidget* parent)
: QMenu(parent)
{
}
void CVarMenu::AddCVarToggleItem(CVarToggle cVarToggle)
{
// Add CVar toggle action
QAction* action = addAction(cVarToggle.m_displayName);
connect(action, &QAction::triggered, [this, cVarToggle](bool checked)
{
// Update the CVar's value based on the action's new checked state
ICVar* cVar = gEnv->pConsole->GetCVar(cVarToggle.m_cVarName.toUtf8().data());
if (cVar)
{
SetCVar(cVar, checked ? cVarToggle.m_onValue : cVarToggle.m_offValue);
}
});
action->setCheckable(true);
// Initialize the action's checked state based on the associated CVar's value
ICVar* cVar = gEnv->pConsole->GetCVar(cVarToggle.m_cVarName.toUtf8().data());
bool checked = (cVar && cVar->GetFVal() == cVarToggle.m_onValue);
action->setChecked(checked);
}
void CVarMenu::AddCVarValuesItem(QString cVarName,
QString displayName,
CVarDisplayNameValuePairs availableCVarValues,
float offValue)
{
// Add a submenu offering multiple values for one CVar
QMenu* menu = addMenu(displayName);
QActionGroup* group = new QActionGroup(menu);
group->setExclusive(true);
ICVar* cVar = gEnv->pConsole->GetCVar(cVarName.toUtf8().data());
float cVarValue = cVar ? cVar->GetFVal() : 0.0f;
for (const auto& availableCVarValue : availableCVarValues)
{
QAction* action = menu->addAction(availableCVarValue.first);
action->setCheckable(true);
group->addAction(action);
float availableOnValue = availableCVarValue.second;
connect(action, &QAction::triggered, [this, action, cVarName, availableOnValue, offValue](bool checked)
{
ICVar* cVar = gEnv->pConsole->GetCVar(cVarName.toUtf8().data());
if (cVar)
{
if (!checked)
{
SetCVar(cVar, offValue);
}
else
{
// Toggle the CVar and update the action's checked state to
// allow none of the items to be checked in the exclusive group.
// Otherwise we could have just used the action's currently checked
// state and updated the CVar's value only
bool cVarOn = (cVar->GetFVal() == availableOnValue);
checked = !cVarOn;
SetCVar(cVar, checked ? availableOnValue : offValue);
action->setChecked(checked);
}
}
});
// Initialize the action's checked state based on the CVar's current value
bool checked = (cVarValue == availableOnValue);
action->setChecked(checked);
}
}
void CVarMenu::AddUniqueCVarsItem(QString displayName,
AZStd::vector<CVarToggle> availableCVars)
{
// Add a submenu of actions offering values for unique CVars
QMenu* menu = addMenu(displayName);
QActionGroup* group = new QActionGroup(menu);
group->setExclusive(true);
for (const CVarToggle& availableCVar : availableCVars)
{
QAction* action = menu->addAction(availableCVar.m_displayName);
action->setCheckable(true);
group->addAction(action);
connect(action, &QAction::triggered, [this, action, availableCVar, availableCVars](bool checked)
{
ICVar* cVar = gEnv->pConsole->GetCVar(availableCVar.m_cVarName.toUtf8().data());
if (cVar)
{
if (!checked)
{
SetCVar(cVar, availableCVar.m_offValue);
}
else
{
// Toggle the CVar and update the action's checked state to
// allow none of the items to be checked in the exclusive group.
// Otherwise we could have just used the action's currently checked
// state and updated the CVar's value only
bool cVarOn = (cVar->GetFVal() == availableCVar.m_onValue);
bool cVarChecked = !cVarOn;
SetCVar(cVar, cVarChecked ? availableCVar.m_onValue : availableCVar.m_offValue);
action->setChecked(cVarChecked);
if (cVarChecked)
{
// Set the rest of the CVars in the group to their off values
SetCVarsToOffValue(availableCVars, availableCVar);
}
}
}
});
// Initialize the action's checked state based on its associated CVar's current value
ICVar* cVar = gEnv->pConsole->GetCVar(availableCVar.m_cVarName.toUtf8().data());
bool cVarChecked = (cVar && cVar->GetFVal() == availableCVar.m_onValue);
action->setChecked(cVarChecked);
if (cVarChecked)
{
// Set the rest of the CVars in the group to their off values
SetCVarsToOffValue(availableCVars, availableCVar);
}
}
}
void CVarMenu::AddResetCVarsItem()
{
QAction* action = addAction(tr("Reset to Default"));
connect(action, &QAction::triggered, this, [this]()
{
for (auto it : m_originalCVarValues)
{
ICVar* cVar = gEnv->pConsole->GetCVar(it.first.c_str());
if (cVar)
{
cVar->Set(it.second);
}
}
});
}
void CVarMenu::SetCVarsToOffValue(const AZStd::vector<CVarToggle>& cVarToggles, const CVarToggle& excludeCVarToggle)
{
// Set all but the specified CVars to their off values
for (const CVarToggle& cVarToggle : cVarToggles)
{
if (cVarToggle.m_cVarName != excludeCVarToggle.m_cVarName
|| cVarToggle.m_onValue != excludeCVarToggle.m_onValue)
{
ICVar* cVar = gEnv->pConsole->GetCVar(cVarToggle.m_cVarName.toUtf8().data());
if (cVar)
{
SetCVar(cVar, cVarToggle.m_offValue);
}
}
}
}
void CVarMenu::SetCVar(ICVar* cVar, float newValue)
{
float oldValue = cVar->GetFVal();
cVar->Set(newValue);
// Store original value for CVar if not already in the list
m_originalCVarValues.emplace(AZStd::string(cVar->GetName()), oldValue);
}
void CVarMenu::AddSeparator()
{
addSeparator();
}
-65
View File
@@ -1,65 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <QMenu>
#include <QString>
#include <AzCore/std/string/string.h>
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/utils.h>
struct ICVar;
class CVarMenu
: public QMenu
{
Q_OBJECT
public:
// CVar that can be toggled on and off
struct CVarToggle
{
QString m_cVarName;
QString m_displayName;
float m_onValue;
float m_offValue;
};
// List of a CVar's available values and their descriptions
using CVarDisplayNameValuePairs = AZStd::vector<AZStd::pair<QString, float>>;
CVarMenu(QWidget* parent = nullptr);
// Add an action that turns a CVar on/off
void AddCVarToggleItem(CVarToggle cVarToggle);
// Add a submenu of actions for a CVar that offers multiple values for exclusive selection
void AddCVarValuesItem(QString cVarName,
QString displayName,
CVarDisplayNameValuePairs availableCVarValues,
float offValue);
// Add a submenu of actions for exclusively turning unique CVars on/off
void AddUniqueCVarsItem(QString displayName,
AZStd::vector<CVarToggle> availableCVars);
// Add an action to reset all CVars to their original values before they
// were modified by this menu
void AddResetCVarsItem();
void AddSeparator();
private:
void SetCVarsToOffValue(const AZStd::vector<CVarToggle>& cVarToggles, const CVarToggle& excludeCVarToggle);
void SetCVar(ICVar* cVar, float newValue);
// Original CVar values before they were modified by this menu
AZStd::unordered_map<AZStd::string, float> m_originalCVarValues;
};
-30
View File
@@ -1,30 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
class CommandManagerRequests : public AZ::EBusTraits
{
public:
struct CommandDetails
{
AZStd::string m_name;
AZStd::vector<AZStd::string> m_arguments;
};
virtual AZStd::vector<AZStd::string> GetCommands() const = 0;
virtual void ExecuteCommand(const AZStd::string& commandLine) {}
virtual void GetCommandDetails(AZStd::string commandName, CommandDetails& outArguments) const = 0;
};
using CommandManagerRequestBus = AZ::EBus<CommandManagerRequests>;
-195
View File
@@ -1,195 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "ConfigGroup.h"
namespace Config
{
CConfigGroup::CConfigGroup()
{
}
CConfigGroup::~CConfigGroup()
{
for (IConfigVar* var : m_vars)
{
delete var;
}
}
void CConfigGroup::AddVar(IConfigVar* var)
{
m_vars.push_back(var);
}
AZ::u32 CConfigGroup::GetVarCount()
{
return aznumeric_cast<AZ::u32>(m_vars.size());
}
IConfigVar* CConfigGroup::GetVar(const char* szName)
{
for (IConfigVar* var : m_vars)
{
if (0 == _stricmp(szName, var->GetName().c_str()))
{
return var;
}
}
return nullptr;
}
const IConfigVar* CConfigGroup::GetVar(const char* szName) const
{
for (const IConfigVar* var : m_vars)
{
if (0 == _stricmp(szName, var->GetName().c_str()))
{
return var;
}
}
return nullptr;
}
IConfigVar* CConfigGroup::GetVar(AZ::u32 index)
{
if (index < m_vars.size())
{
return m_vars[index];
}
return nullptr;
}
const IConfigVar* CConfigGroup::GetVar(AZ::u32 index) const
{
if (index < m_vars.size())
{
return m_vars[index];
}
return nullptr;
}
void CConfigGroup::SaveToXML(XmlNodeRef node)
{
// save only values that don't have default values
for (const IConfigVar* var : m_vars)
{
if (var->IsFlagSet(IConfigVar::eFlag_DoNotSave) || var->IsDefault())
{
continue;
}
const char* szName = var->GetName().c_str();
switch (var->GetType())
{
case IConfigVar::eType_BOOL:
{
bool currentValue = false;
var->Get(&currentValue);
node->setAttr(szName, currentValue);
break;
}
case IConfigVar::eType_INT:
{
int currentValue = 0;
var->Get(&currentValue);
node->setAttr(szName, currentValue);
break;
}
case IConfigVar::eType_FLOAT:
{
float currentValue = 0;
var->Get(&currentValue);
node->setAttr(szName, currentValue);
break;
}
case IConfigVar::eType_STRING:
{
AZStd::string currentValue;
var->Get(&currentValue);
node->setAttr(szName, currentValue.c_str());
break;
}
}
}
}
void CConfigGroup::LoadFromXML(XmlNodeRef node)
{
// load values that are save-able
for (IConfigVar* var : m_vars)
{
if (var->IsFlagSet(IConfigVar::eFlag_DoNotSave))
{
continue;
}
const char* szName = var->GetName().c_str();
switch (var->GetType())
{
case IConfigVar::eType_BOOL:
{
bool currentValue = false;
var->GetDefault(&currentValue);
if (node->getAttr(szName, currentValue))
{
var->Set(&currentValue);
}
break;
}
case IConfigVar::eType_INT:
{
int currentValue = 0;
var->GetDefault(&currentValue);
if (node->getAttr(szName, currentValue))
{
var->Set(&currentValue);
}
break;
}
case IConfigVar::eType_FLOAT:
{
float currentValue = 0;
var->GetDefault(&currentValue);
if (node->getAttr(szName, currentValue))
{
var->Set(&currentValue);
}
break;
}
case IConfigVar::eType_STRING:
{
AZStd::string currentValue;
var->GetDefault(&currentValue);
QString readValue(currentValue.c_str());
if (node->getAttr(szName, readValue))
{
currentValue = readValue.toUtf8().data();
var->Set(&currentValue);
}
break;
}
}
}
}
}
-113
View File
@@ -1,113 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/base.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/string/string.h>
struct ICVar;
class XmlNodeRef;
namespace Config
{
// Abstract configurable variable
struct IConfigVar
{
public:
enum EType
{
eType_BOOL,
eType_INT,
eType_FLOAT,
eType_STRING,
};
enum EFlags
{
eFlag_NoUI = 1 << 0,
eFlag_NoCVar = 1 << 1,
eFlag_DoNotSave = 1 << 2,
};
IConfigVar(const char* szName, const char* szDescription, EType varType, AZ::u8 flags)
: m_name(szName)
, m_description(szDescription)
, m_type(varType)
, m_flags(flags)
, m_ptr(nullptr)
{};
virtual ~IConfigVar() = default;
AZ_FORCE_INLINE EType GetType() const
{
return m_type;
}
AZ_FORCE_INLINE const AZStd::string& GetName() const
{
return m_name;
}
AZ_FORCE_INLINE const AZStd::string& GetDescription() const
{
return m_description;
}
AZ_FORCE_INLINE bool IsFlagSet(EFlags flag) const
{
return 0 != (m_flags & flag);
}
virtual void Get(void* outPtr) const = 0;
virtual void Set(const void* ptr) = 0;
virtual bool IsDefault() const = 0;
virtual void GetDefault(void* outPtr) const = 0;
virtual void Reset() = 0;
static constexpr EType TranslateType(const bool&) { return eType_BOOL; }
static constexpr EType TranslateType(const int&) { return eType_INT; }
static constexpr EType TranslateType(const float&) { return eType_FLOAT; }
static constexpr EType TranslateType(const AZStd::string&) { return eType_STRING; }
protected:
EType m_type;
AZ::u8 m_flags;
AZStd::string m_name;
AZStd::string m_description;
void* m_ptr;
ICVar* m_pCVar;
};
// Group of configuration variables with optional mapping to CVars
class CConfigGroup
{
private:
using TConfigVariables = AZStd::vector<IConfigVar*> ;
TConfigVariables m_vars;
using TConsoleVariables = AZStd::vector<ICVar*>;
TConsoleVariables m_consoleVars;
public:
CConfigGroup();
virtual ~CConfigGroup();
void AddVar(IConfigVar* var);
AZ::u32 GetVarCount();
IConfigVar* GetVar(const char* szName);
IConfigVar* GetVar(AZ::u32 index);
const IConfigVar* GetVar(const char* szName) const;
const IConfigVar* GetVar(AZ::u32 index) const;
void SaveToXML(XmlNodeRef node);
void LoadFromXML(XmlNodeRef node);
};
};
-369
View File
@@ -1,369 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Tooltip that displays bitmap.
#include "EditorDefs.h"
#include "BitmapToolTip.h"
// Qt
#include <QVBoxLayout>
// Editor
#include "Util/Image.h"
#include "Util/ImageUtil.h"
static const int STATIC_TEXT_C_HEIGHT = 42;
static const int HISTOGRAM_C_HEIGHT = 130;
/////////////////////////////////////////////////////////////////////////////
// CBitmapToolTip
CBitmapToolTip::CBitmapToolTip(QWidget* parent)
: QWidget(parent, Qt::ToolTip)
, m_staticBitmap(new QLabel(this))
, m_staticText(new QLabel(this))
, m_rgbaHistogram(new CImageHistogramCtrl(this))
, m_alphaChannelHistogram(new CImageHistogramCtrl(this))
{
m_nTimer = 0;
m_hToolWnd = nullptr;
m_bShowHistogram = true;
m_bShowFullsize = false;
m_eShowMode = ESHOW_RGB;
connect(&m_timer, &QTimer::timeout, this, &CBitmapToolTip::OnTimer);
auto* layout = new QVBoxLayout(this);
layout->setSizeConstraint(QLayout::SetFixedSize);
layout->addWidget(m_staticBitmap);
layout->addWidget(m_staticText);
auto* histogramLayout = new QHBoxLayout();
histogramLayout->addWidget(m_rgbaHistogram);
histogramLayout->addWidget(m_alphaChannelHistogram);
m_alphaChannelHistogram->setVisible(false);
layout->addLayout(histogramLayout);
setLayout(layout);
}
CBitmapToolTip::~CBitmapToolTip()
{
}
//////////////////////////////////////////////////////////////////////////
void CBitmapToolTip::GetShowMode(EShowMode& eShowMode, bool& bShowInOriginalSize) const
{
bShowInOriginalSize = CheckVirtualKey(Qt::Key_Space);
eShowMode = ESHOW_RGB;
if (m_bHasAlpha)
{
if (CheckVirtualKey(Qt::Key_Control))
{
eShowMode = ESHOW_RGB_ALPHA;
}
else if (CheckVirtualKey(Qt::Key_Alt))
{
eShowMode = ESHOW_ALPHA;
}
else if (CheckVirtualKey(Qt::Key_Shift))
{
eShowMode = ESHOW_RGBA;
}
}
else if (m_bIsLimitedHDR)
{
if (CheckVirtualKey(Qt::Key_Shift))
{
eShowMode = ESHOW_RGBE;
}
}
}
const char* CBitmapToolTip::GetShowModeDescription(EShowMode eShowMode, [[maybe_unused]] bool bShowInOriginalSize) const
{
switch (eShowMode)
{
case ESHOW_RGB:
return "RGB";
case ESHOW_RGB_ALPHA:
return "RGB+A";
case ESHOW_ALPHA:
return "Alpha";
case ESHOW_RGBA:
return "RGBA";
case ESHOW_RGBE:
return "RGBExp";
}
return "";
}
void CBitmapToolTip::RefreshViewmode()
{
LoadImage(m_filename);
if (m_eShowMode == ESHOW_RGB_ALPHA || m_eShowMode == ESHOW_RGBA)
{
m_rgbaHistogram->setVisible(true);
m_alphaChannelHistogram->setVisible(true);
}
else if (m_eShowMode == ESHOW_ALPHA)
{
m_rgbaHistogram->setVisible(false);
m_alphaChannelHistogram->setVisible(true);
}
else
{
m_rgbaHistogram->setVisible(true);
m_alphaChannelHistogram->setVisible(false);
}
}
bool CBitmapToolTip::LoadImage(const QString& imageFilename)
{
EShowMode eShowMode = ESHOW_RGB;
const char* pShowModeDescription = "RGB";
bool bShowInOriginalSize = false;
GetShowMode(eShowMode, bShowInOriginalSize);
pShowModeDescription = GetShowModeDescription(eShowMode, bShowInOriginalSize);
QString convertedFileName = Path::GamePathToFullPath(Path::ReplaceExtension(imageFilename, ".dds"));
// We need to check against both the image filename and the converted filename as it is possible that the
// converted file existed but failed to load previously and we reverted to loading the source asset.
bool alreadyLoadedImage = ((m_filename == convertedFileName) || (m_filename == imageFilename));
if (alreadyLoadedImage && (m_eShowMode == eShowMode) && (m_bShowFullsize == bShowInOriginalSize))
{
return true;
}
CCryFile fileCheck;
if (!fileCheck.Open(convertedFileName.toUtf8().data(), "rb"))
{
// if we didn't find it, then default back to just using what we can find (if any)
convertedFileName = imageFilename;
}
else
{
fileCheck.Close();
}
m_eShowMode = eShowMode;
m_bShowFullsize = bShowInOriginalSize;
CImageEx image;
image.SetHistogramEqualization(CheckVirtualKey(Qt::Key_Shift));
bool loadedRequestedAsset = true;
if (!CImageUtil::LoadImage(convertedFileName, image))
{
//Failed to load the requested asset, let's try loading the source asset if available.
loadedRequestedAsset = false;
if (!CImageUtil::LoadImage(imageFilename, image))
{
m_staticBitmap->clear();
return false;
}
}
QString imginfo;
m_filename = loadedRequestedAsset ? convertedFileName : imageFilename;
m_bHasAlpha = image.HasAlphaChannel();
m_bIsLimitedHDR = image.IsLimitedHDR();
GetShowMode(eShowMode, bShowInOriginalSize);
pShowModeDescription = GetShowModeDescription(eShowMode, bShowInOriginalSize);
if (m_bHasAlpha)
{
imginfo = tr("%1x%2 %3\nShowing %4 (ALT=Alpha, SHIFT=RGBA, CTRL=RGB+A, SPACE=see in original size)");
}
else if (m_bIsLimitedHDR)
{
imginfo = tr("%1x%2 %3\nShowing %4 (SHIFT=see hist.-equalized, SPACE=see in original size)");
}
else
{
imginfo = tr("%1x%2 %3\nShowing %4 (SPACE=see in original size)");
}
imginfo = imginfo.arg(image.GetWidth()).arg(image.GetHeight()).arg(image.GetFormatDescription()).arg(pShowModeDescription);
m_staticText->setText(imginfo);
int w = image.GetWidth();
int h = image.GetHeight();
int multiplier = (m_eShowMode == ESHOW_RGB_ALPHA ? 2 : 1);
int originalW = w * multiplier;
int originalH = h;
if (!bShowInOriginalSize || (w == 0))
{
w = 256;
}
if (!bShowInOriginalSize || (h == 0))
{
h = 256;
}
w *= multiplier;
resize(w + 4, h + 4 + STATIC_TEXT_C_HEIGHT + HISTOGRAM_C_HEIGHT);
setVisible(true);
CImageEx scaledImage;
if (bShowInOriginalSize && (originalW < w))
{
w = originalW;
}
if (bShowInOriginalSize && (originalH < h))
{
h = originalH;
}
scaledImage.Allocate(w, h);
if (m_eShowMode == ESHOW_RGB_ALPHA)
{
CImageUtil::ScaleToDoubleFit(image, scaledImage);
}
else
{
CImageUtil::ScaleToFit(image, scaledImage);
}
if (m_eShowMode == ESHOW_RGB || m_eShowMode == ESHOW_RGBE)
{
scaledImage.SwapRedAndBlue();
scaledImage.FillAlpha();
}
else if (m_eShowMode == ESHOW_ALPHA)
{
for (int hh = 0; hh < scaledImage.GetHeight(); hh++)
{
for (int ww = 0; ww < scaledImage.GetWidth(); ww++)
{
int a = scaledImage.ValueAt(ww, hh) >> 24;
scaledImage.ValueAt(ww, hh) = RGB(a, a, a);
}
}
}
else if (m_eShowMode == ESHOW_RGB_ALPHA)
{
int halfWidth = scaledImage.GetWidth() / 2;
for (int hh = 0; hh < scaledImage.GetHeight(); hh++)
{
for (int ww = 0; ww < halfWidth; ww++)
{
int r = GetRValue(scaledImage.ValueAt(ww, hh));
int g = GetGValue(scaledImage.ValueAt(ww, hh));
int b = GetBValue(scaledImage.ValueAt(ww, hh));
int a = scaledImage.ValueAt(ww, hh) >> 24;
scaledImage.ValueAt(ww, hh) = RGB(b, g, r);
scaledImage.ValueAt(ww + halfWidth, hh) = RGB(a, a, a);
}
}
}
else //if (m_showMode == ESHOW_RGBA)
{
scaledImage.SwapRedAndBlue();
}
QImage qImage(scaledImage.GetWidth(), scaledImage.GetHeight(), QImage::Format_RGB32);
memcpy(qImage.bits(), scaledImage.GetData(), qImage.sizeInBytes());
m_staticBitmap->setPixmap(QPixmap::fromImage(qImage));
if (m_bShowHistogram && scaledImage.GetData())
{
m_rgbaHistogram->ComputeHistogram(image, CImageHistogram::eImageFormat_32BPP_BGRA);
m_rgbaHistogram->setDrawMode(EHistogramDrawMode::OverlappedRGB);
m_alphaChannelHistogram->histogramDisplay()->CopyComputedDataFrom(m_rgbaHistogram->histogramDisplay());
m_alphaChannelHistogram->setDrawMode(EHistogramDrawMode::AlphaChannel);
}
return true;
}
void CBitmapToolTip::OnTimer()
{
/*
if (IsWindowVisible())
{
if (m_bHaveAnythingToRender)
Invalidate();
}
*/
if (m_hToolWnd)
{
QRect toolRc(m_toolRect);
QRect rc = geometry();
QPoint cursorPos = QCursor::pos();
toolRc.moveTopLeft(m_hToolWnd->mapToGlobal(toolRc.topLeft()));
if (!toolRc.contains(cursorPos) && !rc.contains(cursorPos))
{
setVisible(false);
}
else
{
RefreshViewmode();
}
}
}
//////////////////////////////////////////////////////////////////////////
void CBitmapToolTip::showEvent([[maybe_unused]] QShowEvent* event)
{
QPoint cursorPos = QCursor::pos();
move(cursorPos);
m_timer.start(500);
}
//////////////////////////////////////////////////////////////////////////
void CBitmapToolTip::hideEvent([[maybe_unused]] QHideEvent* event)
{
m_timer.stop();
}
//////////////////////////////////////////////////////////////////////////
void CBitmapToolTip::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Control || event->key() == Qt::Key_Alt || event->key() == Qt::Key_Shift)
{
RefreshViewmode();
}
}
void CBitmapToolTip::keyReleaseEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Control || event->key() == Qt::Key_Alt || event->key() == Qt::Key_Shift)
{
RefreshViewmode();
}
}
//////////////////////////////////////////////////////////////////////////
void CBitmapToolTip::SetTool(QWidget* pWnd, const QRect& rect)
{
assert(pWnd);
m_hToolWnd = pWnd;
m_toolRect = rect;
}
#include <Controls/moc_BitmapToolTip.cpp>
-88
View File
@@ -1,88 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Tooltip that displays bitmap.
#ifndef CRYINCLUDE_EDITOR_CONTROLS_BITMAPTOOLTIP_H
#define CRYINCLUDE_EDITOR_CONTROLS_BITMAPTOOLTIP_H
#pragma once
#if !defined(Q_MOC_RUN)
#include "Controls/ImageHistogramCtrl.h"
#include <QLabel>
#include <QTimer>
#endif
//////////////////////////////////////////////////////////////////////////
class CBitmapToolTip
: public QWidget
{
Q_OBJECT
// Construction
public:
enum EShowMode
{
ESHOW_RGB = 0,
ESHOW_ALPHA,
ESHOW_RGBA,
ESHOW_RGB_ALPHA,
ESHOW_RGBE
};
CBitmapToolTip(QWidget* parent = nullptr);
virtual ~CBitmapToolTip();
bool Create(const RECT& rect);
// Attributes
public:
// Operations
public:
void RefreshViewmode();
bool LoadImage(const QString& imageFilename);
void SetTool(QWidget* pWnd, const QRect& rect);
// Generated message map functions
protected:
void OnTimer();
void keyPressEvent(QKeyEvent* event) override;
void keyReleaseEvent(QKeyEvent* event) override;
void showEvent(QShowEvent* event) override;
void hideEvent(QHideEvent* event) override;
private:
void GetShowMode(EShowMode& showMode, bool& showInOriginalSize) const;
const char* GetShowModeDescription(EShowMode showMode, bool showInOriginalSize) const;
QLabel* m_staticBitmap;
QLabel* m_staticText;
QString m_filename;
bool m_bShowHistogram;
EShowMode m_eShowMode;
bool m_bShowFullsize;
bool m_bHasAlpha;
bool m_bIsLimitedHDR;
CImageHistogramCtrl* m_rgbaHistogram;
CImageHistogramCtrl* m_alphaChannelHistogram;
int m_nTimer;
QWidget* m_hToolWnd;
QRect m_toolRect;
QTimer m_timer;
};
#endif // CRYINCLUDE_EDITOR_CONTROLS_BITMAPTOOLTIP_H
@@ -1,172 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "QBitmapPreviewDialog.h"
#include <Controls/ui_QBitmapPreviewDialog.h>
#include <QApplication>
#include <QDesktopWidget>
#include <QPainter>
#include <QScreen>
void QBitmapPreviewDialog::ImageData::setRgba8888(const void* buffer, const int& w, const int& h)
{
const unsigned long bytes = w * h * 4;
m_buffer.resize(bytes);
memcpy(m_buffer.data(), buffer, bytes);
m_image = QImage((uchar*)m_buffer.constData(), w, h, QImage::Format::Format_RGBA8888);
}
static void fillChecker(int w, int h, unsigned int* dst)
{
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
dst[y * w + x] = 0xFF000000 | (((x >> 2) + (y >> 2)) % 2 == 0 ? 0x007F7F7F : 0x00000000);
}
}
}
QBitmapPreviewDialog::QBitmapPreviewDialog(QWidget* parent)
: QWidget(parent)
, ui(new Ui::QBitmapTooltip)
{
ui->setupUi(this);
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_ShowWithoutActivating);
// Clear label text
ui->m_placeholderBitmap->setText("");
ui->m_placeholderHistogram->setText("");
ui->m_bitmapSize->setProperty("tableRow", "Odd");
ui->m_Mips->setProperty("tableRow", "Even");
ui->m_Mean->setProperty("tableRow", "Odd");
ui->m_StdDev->setProperty("tableRow", "Even");
ui->m_Median->setProperty("tableRow", "Odd");
ui->m_labelForBitmapSize->setProperty("tooltipLabel", "content");
ui->m_labelForMean->setProperty("tooltipLabel", "content");
ui->m_labelForMedian->setProperty("tooltipLabel", "content");
ui->m_labelForMips->setProperty("tooltipLabel", "content");
ui->m_labelForStdDev->setProperty("tooltipLabel", "content");
ui->m_vBitmapSize->setProperty("tooltipLabel", "content");
ui->m_vMean->setProperty("tooltipLabel", "content");
ui->m_vMedian->setProperty("tooltipLabel", "content");
ui->m_vMips->setProperty("tooltipLabel", "content");
ui->m_vStdDev->setProperty("tooltipLabel", "content");
// Initialize placeholder images
const int w = 64;
const int h = 64;
QByteArray buffer;
buffer.resize(w * h * 4);
unsigned int* dst = (unsigned int*)buffer.data();
fillChecker(w, h, dst);
m_checker.setRgba8888(buffer.constData(), w, h);
m_initialSize = window()->window()->geometry().size();
}
QBitmapPreviewDialog::~QBitmapPreviewDialog()
{
delete ui;
}
void QBitmapPreviewDialog::setImageRgba8888(const void* buffer, const int& w, const int& h, [[maybe_unused]] const QString& info)
{
m_imageMain.setRgba8888(buffer, w, h);
}
QRect QBitmapPreviewDialog::getHistogramArea()
{
return QRect(ui->m_placeholderHistogram->pos(), ui->m_placeholderHistogram->size());
}
void QBitmapPreviewDialog::setFullSize(const bool& fullSize)
{
if (fullSize)
{
QSize desktop = QApplication::screenAt(ui->m_placeholderBitmap->pos())->availableGeometry().size();
QSize image = m_imageMain.m_image.size();
QPoint location = mapToGlobal(ui->m_placeholderBitmap->pos());
QSize finalSize;
finalSize.setWidth((image.width() < (desktop.width() - location.x())) ? image.width() : (desktop.width() - location.x()));
finalSize.setHeight((image.height() < (desktop.height() - location.y())) ? image.height() : (desktop.height() - location.y()));
float scale = (finalSize.width() < finalSize.height()) ? finalSize.width() / float(m_imageMain.m_image.width()) : finalSize.height() / float(m_imageMain.m_image.height());
ui->m_placeholderBitmap->setFixedSize(scale * m_imageMain.m_image.size());
}
else
{
ui->m_placeholderBitmap->setFixedSize(256, 256);
}
adjustSize();
update();
}
void QBitmapPreviewDialog::paintEvent(QPaintEvent* e)
{
QWidget::paintEvent(e);
QRect rect(ui->m_placeholderBitmap->pos(), ui->m_placeholderBitmap->size());
drawImageData(rect, m_imageMain);
}
void QBitmapPreviewDialog::drawImageData(const QRect& rect, const ImageData& imgData)
{
// Draw the
QPainter p(this);
p.drawImage(rect.topLeft(), m_checker.m_image.scaled(rect.size()));
p.drawImage(rect.topLeft(), imgData.m_image.scaled(rect.size()));
// Draw border
QPen pen;
pen.setColor(QColor(0, 0, 0));
p.drawRect(rect.top(), rect.left(), rect.width() - 1, rect.height());
}
void QBitmapPreviewDialog::setSize(QString _value)
{
ui->m_vBitmapSize->setText(_value);
}
void QBitmapPreviewDialog::setMips(QString _value)
{
ui->m_vMips->setText(_value);
}
void QBitmapPreviewDialog::setMean(QString _value)
{
ui->m_vMean->setText(_value);
}
void QBitmapPreviewDialog::setMedian(QString _value)
{
ui->m_vMedian->setText(_value);
}
void QBitmapPreviewDialog::setStdDev(QString _value)
{
ui->m_vStdDev->setText(_value);
}
QSize QBitmapPreviewDialog::GetCurrentBitmapSize()
{
return ui->m_placeholderBitmap->size();
}
QSize QBitmapPreviewDialog::GetOriginalImageSize()
{
return m_imageMain.m_image.size();
}
#include <Controls/moc_QBitmapPreviewDialog.cpp>
@@ -1,64 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef QBITMAPPREVIEWDIALOG_H
#define QBITMAPPREVIEWDIALOG_H
#if !defined(Q_MOC_RUN)
#include <QWidget>
#include <QPixmap>
#include <QImage>
#endif
class QLabel;
namespace Ui {
class QBitmapTooltip;
}
class QBitmapPreviewDialog
: public QWidget
{
Q_OBJECT
struct ImageData
{
QByteArray m_buffer;
QImage m_image;
void setRgba8888(const void* buffer, const int& w, const int& h);
};
public:
explicit QBitmapPreviewDialog(QWidget* parent = 0);
virtual ~QBitmapPreviewDialog();
QSize GetCurrentBitmapSize();
QSize GetOriginalImageSize();
protected:
void setImageRgba8888(const void* buffer, const int& w, const int& h, const QString& info);
void setSize(QString _value);
void setMips(QString _value);
void setMean(QString _value);
void setMedian(QString _value);
void setStdDev(QString _value);
QRect getHistogramArea();
void setFullSize(const bool& fullSize);
void paintEvent(QPaintEvent* e) override;
private:
void drawImageData(const QRect& rect, const ImageData& imgData);
protected:
Ui::QBitmapTooltip* ui;
QSize m_initialSize;
ImageData m_checker;
ImageData m_imageMain;
};
#endif // QBITMAPPREVIEWDIALOG_H
@@ -1,390 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QBitmapTooltip</class>
<widget class="QWidget" name="QBitmapTooltip">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>256</width>
<height>510</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>256</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="m_placeholderBitmap">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>256</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string>Bitmap Area</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_placeholderHistogram">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>128</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string>Histogram Area</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="m_bitmapSize" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="m_labelForBitmapSize">
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_vBitmapSize">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Size Value</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="m_Mips" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="m_labelForMips">
<property name="text">
<string>DXT5 Mips:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_vMips">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Size Value</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="m_Mean" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="m_labelForMean">
<property name="text">
<string>Mean:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_vMean">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Size Value</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="m_StdDev" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="m_labelForStdDev">
<property name="text">
<string>StdDev:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_vStdDev">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Size Value</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="m_Median" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="m_labelForMedian">
<property name="text">
<string>Median:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_vMedian">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Size Value</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -1,528 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "QBitmapPreviewDialogImp.h"
// Cry
#include <ITexture.h>
// EditorCore
#include <Util/Image.h>
#include <Include/IImageUtil.h>
// QT
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: class '...' needs to have dll-interface to be used by clients of class '...'
#include <QEvent>
#include <QKeyEvent>
#include <QPainter>
#include <QPainterPath>
#include <qmath.h>
AZ_POP_DISABLE_WARNING
#include <Controls/ui_QBitmapPreviewDialog.h>
static const int kDefaultWidth = 256;
static const int kDefaultHeight = 256;
QBitmapPreviewDialogImp::QBitmapPreviewDialogImp(QWidget* parent)
: QBitmapPreviewDialog(parent)
, m_image(new CImageEx())
, m_showOriginalSize(false)
, m_showMode(ESHOW_RGB)
, m_histrogramMode(eHistogramMode_OverlappedRGB)
{
setMouseTracking(true);
setImage("");
ui->m_placeholderBitmap->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
ui->m_placeholderHistogram->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
ui->m_labelForBitmapSize->setProperty("tooltipLabel", "Content");
ui->m_labelForMean->setProperty("tooltipLabel", "Content");
ui->m_labelForMedian->setProperty("tooltipLabel", "Content");
ui->m_labelForMips->setProperty("tooltipLabel", "Content");
ui->m_labelForStdDev->setProperty("tooltipLabel", "Content");
ui->m_vBitmapSize->setProperty("tooltipLabel", "Content");
ui->m_vMean->setProperty("tooltipLabel", "Content");
ui->m_vMedian->setProperty("tooltipLabel", "Content");
ui->m_vMips->setProperty("tooltipLabel", "Content");
ui->m_vStdDev->setProperty("tooltipLabel", "Content");
setUIStyleMode(EUISTYLE_IMAGE_ONLY);
}
QBitmapPreviewDialogImp::~QBitmapPreviewDialogImp()
{
SAFE_DELETE(m_image);
}
void QBitmapPreviewDialogImp::setImage(const QString path)
{
if (path.isEmpty()
|| m_path == path
|| !GetIEditor()->GetImageUtil()->LoadImage(path.toUtf8().data(), *m_image))
{
return;
}
m_showOriginalSize = isSizeSmallerThanDefault();
m_path = path;
refreshData();
}
void QBitmapPreviewDialogImp::setShowMode(EShowMode mode)
{
if (mode == ESHOW_NumModes)
{
return;
}
m_showMode = mode;
refreshData();
update();
}
void QBitmapPreviewDialogImp::toggleShowMode()
{
m_showMode = (EShowMode)(((int)m_showMode + 1) % ESHOW_NumModes);
refreshData();
update();
}
void QBitmapPreviewDialogImp::setUIStyleMode(EUIStyle mode)
{
if (mode >= EUISTYLE_NumModes)
{
return;
}
m_uiStyle = mode;
if (m_uiStyle == EUISTYLE_IMAGE_ONLY)
{
ui->m_placeholderHistogram->hide();
ui->m_labelForBitmapSize->hide();
ui->m_labelForMean->hide();
ui->m_labelForMedian->hide();
ui->m_labelForMips->hide();
ui->m_labelForStdDev->hide();
ui->m_vBitmapSize->hide();
ui->m_vMean->hide();
ui->m_vMedian->hide();
ui->m_vMips->hide();
ui->m_vStdDev->hide();
}
else
{
ui->m_placeholderHistogram->show();
ui->m_labelForBitmapSize->show();
ui->m_labelForMean->show();
ui->m_labelForMedian->show();
ui->m_labelForMips->show();
ui->m_labelForStdDev->show();
ui->m_vBitmapSize->show();
ui->m_vMean->show();
ui->m_vMedian->show();
ui->m_vMips->show();
ui->m_vStdDev->show();
}
}
const QBitmapPreviewDialogImp::EShowMode& QBitmapPreviewDialogImp::getShowMode() const
{
return m_showMode;
}
void QBitmapPreviewDialogImp::setHistogramMode(EHistogramMode mode)
{
if (mode == eHistogramMode_NumModes)
{
return;
}
m_histrogramMode = mode;
}
void QBitmapPreviewDialogImp::toggleHistrogramMode()
{
m_histrogramMode = (EHistogramMode)(((int)m_histrogramMode + 1) % eHistogramMode_NumModes);
update();
}
const QBitmapPreviewDialogImp::EHistogramMode& QBitmapPreviewDialogImp::getHistogramMode() const
{
return m_histrogramMode;
}
void QBitmapPreviewDialogImp::toggleOriginalSize()
{
m_showOriginalSize = !m_showOriginalSize;
refreshData();
update();
}
bool QBitmapPreviewDialogImp::isSizeSmallerThanDefault()
{
return m_image->GetWidth() < kDefaultWidth && m_image->GetHeight() < kDefaultHeight;
}
void QBitmapPreviewDialogImp::setOriginalSize(bool value)
{
m_showOriginalSize = value;
refreshData();
update();
}
const char* QBitmapPreviewDialogImp::GetShowModeDescription(EShowMode eShowMode, [[maybe_unused]] bool bShowInOriginalSize) const
{
switch (eShowMode)
{
case ESHOW_RGB:
return "RGB";
case ESHOW_RGB_ALPHA:
return "RGB+A";
case ESHOW_ALPHA:
return "Alpha";
case ESHOW_RGBA:
return "RGBA";
case ESHOW_RGBE:
return "RGBExp";
}
return "";
}
const char* getHistrogramModeStr(QBitmapPreviewDialogImp::EHistogramMode mode, bool shortName)
{
switch (mode)
{
case QBitmapPreviewDialogImp::eHistogramMode_Luminosity:
return shortName ? "Lum" : "Luminosity";
case QBitmapPreviewDialogImp::eHistogramMode_OverlappedRGB:
return shortName ? "Overlap" : "Overlapped RGBA";
case QBitmapPreviewDialogImp::eHistogramMode_SplitRGB:
return shortName ? "R|G|B" : "Split RGB";
case QBitmapPreviewDialogImp::eHistogramMode_RedChannel:
return shortName ? "Red" : "Red Channel";
case QBitmapPreviewDialogImp::eHistogramMode_GreenChannel:
return shortName ? "Green" : "Green Channel";
case QBitmapPreviewDialogImp::eHistogramMode_BlueChannel:
return shortName ? "Blue" : "Blue Channel";
case QBitmapPreviewDialogImp::eHistogramMode_AlphaChannel:
return shortName ? "Alpha" : "Alpha Channel";
default:
break;
}
return "";
}
void QBitmapPreviewDialogImp::refreshData()
{
// Check if we have some usefull data loaded
if (m_image->GetWidth() * m_image->GetHeight() == 0)
{
return;
}
int w = m_image->GetWidth();
int h = m_image->GetHeight();
int multiplier = (m_showMode == ESHOW_RGB_ALPHA ? 2 : 1);
int originalW = w * multiplier;
int originalH = h;
if (!m_showOriginalSize || (w == 0))
{
w = kDefaultWidth;
}
if (!m_showOriginalSize || (h == 0))
{
h = kDefaultHeight;
}
w *= multiplier;
CImageEx scaledImage;
if (m_showOriginalSize && (originalW < w))
{
w = originalW;
}
if (m_showOriginalSize && (originalH < h))
{
h = originalH;
}
scaledImage.Allocate(w, h);
if (m_showMode == ESHOW_RGB_ALPHA)
{
GetIEditor()->GetImageUtil()->ScaleToDoubleFit(*m_image, scaledImage);
}
else
{
GetIEditor()->GetImageUtil()->ScaleToFit(*m_image, scaledImage);
}
if (m_showMode == ESHOW_RGB || m_showMode == ESHOW_RGBE)
{
scaledImage.FillAlpha();
}
else if (m_showMode == ESHOW_ALPHA)
{
for (int h2 = 0; h2 < scaledImage.GetHeight(); h2++)
{
for (int w2 = 0; w2 < scaledImage.GetWidth(); w2++)
{
int a = scaledImage.ValueAt(w2, h2) >> 24;
scaledImage.ValueAt(w2, h2) = RGB(a, a, a) | (a << 24);
}
}
}
else if (m_showMode == ESHOW_RGB_ALPHA)
{
int halfWidth = scaledImage.GetWidth() / 2;
for (int h2 = 0; h2 < scaledImage.GetHeight(); h2++)
{
for (int w2 = 0; w2 < halfWidth; w2++)
{
int r = GetRValue(scaledImage.ValueAt(w2, h2));
int g = GetGValue(scaledImage.ValueAt(w2, h2));
int b = GetBValue(scaledImage.ValueAt(w2, h2));
int a = scaledImage.ValueAt(w2, h2) >> 24;
scaledImage.ValueAt(w2, h2) = RGB(r, g, b) | (a << 24);
scaledImage.ValueAt(w2 + halfWidth, h2) = RGB(a, a, a) | (a << 24);
}
}
}
setImageRgba8888(scaledImage.GetData(), w, h, "");
setSize(QString().asprintf("%d x %d", m_image->GetWidth(), m_image->GetHeight()));
setMips(QString().asprintf("%d", m_image->GetNumberOfMipMaps()));
setFullSize(m_showOriginalSize);
// Compute histogram
m_histogram.ComputeHistogram((BYTE*)scaledImage.GetData(), w, h, CImageHistogram::eImageFormat_32BPP_RGBA);
}
void QBitmapPreviewDialogImp::paintEvent(QPaintEvent* e)
{
QBitmapPreviewDialog::paintEvent(e);
//if showing original size hide other information so it's easier to see
if (m_showOriginalSize)
{
return;
}
if (m_uiStyle == EUISTYLE_IMAGE_ONLY)
{
return;
}
QPainter p(this);
QPen pen;
QPainterPath path[4];
// Fill background color
QRect histogramRect = getHistogramArea();
p.fillRect(histogramRect, QColor(255, 255, 255));
// Draw borders
pen.setColor(QColor(0, 0, 0));
p.setPen(pen);
p.drawRect(histogramRect);
// Draw histogram
QVector<int> drawChannels;
switch (m_histrogramMode)
{
case eHistogramMode_Luminosity:
drawChannels.push_back(3);
break;
case eHistogramMode_SplitRGB:
drawChannels.push_back(0);
drawChannels.push_back(1);
drawChannels.push_back(2);
break;
case eHistogramMode_OverlappedRGB:
drawChannels.push_back(0);
drawChannels.push_back(1);
drawChannels.push_back(2);
break;
case eHistogramMode_RedChannel:
drawChannels.push_back(0);
break;
case eHistogramMode_GreenChannel:
drawChannels.push_back(1);
break;
case eHistogramMode_BlueChannel:
drawChannels.push_back(2);
break;
case eHistogramMode_AlphaChannel:
drawChannels.push_back(3);
break;
}
int graphWidth = qMax(histogramRect.width(), 1);
int graphHeight = qMax(histogramRect.height() - 2, 0);
int graphBottom = histogramRect.bottom() + 1;
int currX[4] = {0, 0, 0, 0};
int prevX[4] = {0, 0, 0, 0};
float scale = 0.0f;
static const int numSubGraphs = 3;
const int subGraph = qCeil(graphWidth / numSubGraphs);
// Fill background for Split RGB histogram
if (m_histrogramMode == eHistogramMode_SplitRGB)
{
const static QColor backgroundColor[numSubGraphs] =
{
QColor(255, 220, 220),
QColor(220, 255, 220),
QColor(220, 220, 255)
};
for (int i = 0; i < numSubGraphs; i++)
{
p.fillRect(histogramRect.left() + subGraph * i,
histogramRect.top(),
subGraph + (i == numSubGraphs - 1 ? 1 : 0),
histogramRect.height(), backgroundColor[i]);
}
}
int lastHeight[CImageHistogram::kNumChannels] = { INT_MAX, INT_MAX, INT_MAX, INT_MAX };
for (int x = 0; x < graphWidth; ++x)
{
for (int j = 0; j < drawChannels.size(); j++)
{
const int c = drawChannels[j];
int& curr_x = currX[c];
int& prev_x = prevX[c];
int& last_height = lastHeight[c];
QPainterPath& curr_path = path[c];
curr_x = histogramRect.left() + x + 1;
int i = static_cast<int>(((float)x / (graphWidth - 1)) * (CImageHistogram::kNumColorLevels - 1));
if (m_histrogramMode == eHistogramMode_SplitRGB)
{
// Filter out to area which we are interested
const int k = x / subGraph;
if (k != c)
{
continue;
}
i = qCeil((i - (subGraph * c)) * numSubGraphs);
i = qMin(i, CImageHistogram::kNumColorLevels - 1);
i = qMax(i, 0);
}
if (m_histrogramMode == eHistogramMode_Luminosity)
{
scale = (float)m_histogram.m_lumCount[i] / m_histogram.m_maxLumCount;
}
else if (m_histogram.m_maxCount[c])
{
scale = (float)m_histogram.m_count[c][i] / m_histogram.m_maxCount[c];
}
int height = static_cast<int>(graphBottom - graphHeight * scale);
if (last_height == INT_MAX)
{
last_height = height;
}
curr_path.moveTo(prev_x, last_height);
curr_path.lineTo(curr_x, height);
last_height = height;
if (prev_x == INT_MAX)
{
prev_x = curr_x;
}
prev_x = curr_x;
}
}
static const QColor kChannelColor[4] =
{
QColor(255, 0, 0),
QColor(0, 255, 0),
QColor(0, 0, 255),
QColor(120, 120, 120)
};
for (int i = 0; i < drawChannels.size(); i++)
{
const int c = drawChannels[i];
pen.setColor(kChannelColor[c]);
p.setPen(pen);
p.drawPath(path[c]);
}
// Update histogram info
{
float mean = 0, stdDev = 0, median = 0;
switch (m_histrogramMode)
{
case eHistogramMode_Luminosity:
case eHistogramMode_SplitRGB:
case eHistogramMode_OverlappedRGB:
mean = m_histogram.m_meanAvg;
stdDev = m_histogram.m_stdDevAvg;
median = m_histogram.m_medianAvg;
break;
case eHistogramMode_RedChannel:
mean = m_histogram.m_mean[0];
stdDev = m_histogram.m_stdDev[0];
median = m_histogram.m_median[0];
break;
case eHistogramMode_GreenChannel:
mean = m_histogram.m_mean[1];
stdDev = m_histogram.m_stdDev[1];
median = m_histogram.m_median[1];
break;
case eHistogramMode_BlueChannel:
mean = m_histogram.m_mean[2];
stdDev = m_histogram.m_stdDev[2];
median = m_histogram.m_median[2];
break;
case eHistogramMode_AlphaChannel:
mean = m_histogram.m_mean[3];
stdDev = m_histogram.m_stdDev[3];
median = m_histogram.m_median[3];
break;
}
QString val;
val.setNum(mean);
setMean(val);
val.setNum(stdDev);
setStdDev(val);
val.setNum(median);
setMedian(val);
}
}
#include <Controls/moc_QBitmapPreviewDialogImp.cpp>
@@ -1,89 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef QBITMAPPREVIEWDIALOG_IMP_H
#define QBITMAPPREVIEWDIALOG_IMP_H
#if !defined(Q_MOC_RUN)
#include "QBitmapPreviewDialog.h"
#include <Util/ImageHistogram.h>
#endif
class CImageEx;
class QBitmapPreviewDialogImp
: public QBitmapPreviewDialog
{
Q_OBJECT;
public:
enum EUIStyle
{
EUISTYLE_IMAGE_ONLY,
EUISTYLE_IMAGE_HISTOGRAM,
EUISTYLE_NumModes
};
enum EShowMode
{
ESHOW_RGB = 0,
ESHOW_ALPHA,
ESHOW_RGBA,
ESHOW_RGB_ALPHA,
ESHOW_RGBE,
ESHOW_NumModes,
};
enum EHistogramMode
{
eHistogramMode_Luminosity,
eHistogramMode_OverlappedRGB,
eHistogramMode_SplitRGB,
eHistogramMode_RedChannel,
eHistogramMode_GreenChannel,
eHistogramMode_BlueChannel,
eHistogramMode_AlphaChannel,
eHistogramMode_NumModes,
};
explicit QBitmapPreviewDialogImp(QWidget* parent = 0);
virtual ~QBitmapPreviewDialogImp();
void setImage(const QString path);
void setShowMode(EShowMode mode);
void toggleShowMode();
void setUIStyleMode(EUIStyle mode);
const EShowMode& getShowMode() const;
void setHistogramMode(EHistogramMode mode);
void toggleHistrogramMode();
const EHistogramMode& getHistogramMode() const;
void setOriginalSize(bool value);
void toggleOriginalSize();
bool isSizeSmallerThanDefault();
void paintEvent(QPaintEvent* e) override;
protected:
void refreshData();
private:
const char* GetShowModeDescription(EShowMode eShowMode, bool bShowInOriginalSize) const;
private:
CImageEx* m_image;
QString m_path;
CImageHistogram m_histogram;
bool m_showOriginalSize;
EShowMode m_showMode;
EHistogramMode m_histrogramMode;
EUIStyle m_uiStyle;
};
#endif // QBITMAPPREVIEWDIALOG_IMP_H
-642
View File
@@ -1,642 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include <Controls/QToolTipWidget.h>
#include "QBitmapPreviewDialogImp.h"
#include "qcoreapplication.h"
#include "qguiapplication.h"
#include "qapplication.h"
#include <QDesktopWidget>
#include <QPainter>
#include <QtGlobal>
#include <qgraphicseffect.h>
void QToolTipWidget::RebuildLayout()
{
if (m_title != nullptr)
{
m_title->hide();
}
if (m_content != nullptr)
{
m_content->hide();
}
if (m_specialContent != nullptr)
{
m_specialContent->hide();
}
//empty layout
while (m_layout->count() > 0)
{
m_layout->takeAt(0);
}
qDeleteAll(m_currentShortcuts);
m_currentShortcuts.clear();
if (m_includeTextureShortcuts)
{
m_currentShortcuts.append(new QLabel(tr("Alt - Alpha"), this));
m_currentShortcuts.back()->setProperty("tooltipLabel", "Shortcut");
m_currentShortcuts.append(new QLabel(tr("Shift - RGBA"), this));
m_currentShortcuts.back()->setProperty("tooltipLabel", "Shortcut");
}
if (m_title != nullptr && !m_title->text().isEmpty())
{
m_layout->addWidget(m_title);
m_title->show();
}
for (QLabel* var : m_currentShortcuts)
{
if (var != nullptr)
{
m_layout->addWidget(var);
var->show();
}
}
if (m_specialContent != nullptr)
{
m_layout->addWidget(m_specialContent);
m_specialContent->show();
}
if (m_content != nullptr && !m_content->text().isEmpty())
{
m_layout->addWidget(m_content);
m_content->show();
}
m_background->adjustSize();
adjustSize();
}
void QToolTipWidget::Hide()
{
m_currentShortcuts.clear();
hide();
}
void QToolTipWidget::Show(QPoint pos, ArrowDirection dir)
{
if (!IsValid())
{
return;
}
m_arrow->m_direction = dir;
pos = AdjustTipPosByArrowSize(pos, dir);
m_normalPos = pos;
move(pos);
RebuildLayout();
show();
m_arrow->show();
}
void QToolTipWidget::Display(QRect targetRect, ArrowDirection preferredArrowDir)
{
if (!IsValid())
{
return;
}
KeepTipOnScreen(targetRect, preferredArrowDir);
RebuildLayout();
show();
m_arrow->show();
}
void QToolTipWidget::TryDisplay(QPoint mousePos, const QRect& rect, [[maybe_unused]] ArrowDirection preferredArrowDir)
{
if (rect.contains(mousePos))
{
Display(rect, QToolTipWidget::ArrowDirection::ARROW_RIGHT);
}
else
{
hide();
}
}
void QToolTipWidget::TryDisplay(QPoint mousePos, const QWidget* widget, ArrowDirection preferredArrowDir)
{
const QRect rect(widget->mapToGlobal(QPoint(0,0)), widget->size());
TryDisplay(mousePos, rect, preferredArrowDir);
}
void QToolTipWidget::SetTitle(QString title)
{
if (!title.isEmpty())
{
m_title->setText(title);
}
m_title->setProperty("tooltipLabel", "Title");
setWindowTitle("ToolTip - " + title);
}
void QToolTipWidget::SetContent(QString content)
{
m_content->setWordWrap(true);
m_content->setProperty("tooltipLabel", "Content");
//line-height is not supported via stylesheet so we use the html rich-text subset in QT for it.
m_content->setText(QString("<span style=\"line-height: 14px;\">%1</span>").arg(content));
}
void QToolTipWidget::AppendContent(QString content)
{
m_content->setText(m_content->text() + "\n\n" + content);
update();
RebuildLayout();
m_content->update();
m_content->repaint();
}
QToolTipWidget::QToolTipWidget(QWidget* parent)
: QWidget(parent)
{
m_background = new QWidget(this);
m_background->setProperty("tooltip", "Background");
m_background->stackUnder(this);
m_title = new QLabel(this);
m_currentShortcuts = QVector<QLabel*>();
m_content = new QLabel(this);
m_specialContent = nullptr;
setWindowTitle("ToolTip");
setObjectName("ToolTip");
m_layout = new QVBoxLayout(this);
m_normalPos = QPoint(0, 0);
m_arrow = new QArrow(m_background);
setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint);
m_arrow->setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint);
m_arrow->setAttribute(Qt::WA_TranslucentBackground, true);
m_background->setLayout(m_layout);
m_arrow->setObjectName("ToolTipArrow");
m_background->setObjectName("ToolTipBackground");
//we need a drop shadow for the background
QGraphicsDropShadowEffect* dropShadow = new QGraphicsDropShadowEffect(this);
dropShadow->setBlurRadius(m_shadowRadius);
dropShadow->setColor(Qt::black);
dropShadow->setOffset(0);
dropShadow->setEnabled(true);
m_background->setGraphicsEffect(dropShadow);
//we need a second drop shadow effect for the arrow
dropShadow = new QGraphicsDropShadowEffect(m_arrow);
dropShadow->setBlurRadius(m_shadowRadius);
dropShadow->setColor(Qt::black);
dropShadow->setOffset(0);
dropShadow->setEnabled(true);
m_arrow->setGraphicsEffect(dropShadow);
}
QToolTipWidget::~QToolTipWidget()
{
}
void QToolTipWidget::AddSpecialContent(QString type, QString dataStream)
{
if (type.isEmpty())
{
m_includeTextureShortcuts = false;
if (m_specialContent != nullptr)
{
delete m_specialContent;
m_specialContent = nullptr;
}
return;
}
if (type == "TEXTURE")
{
if (m_specialContent == nullptr)
{
QCoreApplication::instance()->installEventFilter(this); //grab the event filter while displaying the advanced texture tooltip
m_specialContent = new QBitmapPreviewDialogImp(this);
}
QString path(dataStream);
qobject_cast<QBitmapPreviewDialogImp*>(m_specialContent)->setImage(path);
// set default showmode to RGB
qobject_cast<QBitmapPreviewDialogImp*>(m_specialContent)->setShowMode(QBitmapPreviewDialogImp::EShowMode::ESHOW_RGB);
QString dir = (path.split("/").count() > path.split("\\").count()) ? path.split("/").back() : path.split("\\").back();
SetTitle(dir);
//always use default size but not image size
qobject_cast<QBitmapPreviewDialogImp*>(m_specialContent)->setOriginalSize(false);
m_includeTextureShortcuts = true;
}
else if (type == "ADD TO CONTENT")
{
AppendContent(dataStream);
m_includeTextureShortcuts = false;
if (m_specialContent != nullptr)
{
delete m_specialContent;
m_specialContent = nullptr;
}
}
else if (type == "REPLACE TITLE")
{
SetTitle(dataStream);
m_includeTextureShortcuts = false;
if (m_specialContent != nullptr)
{
delete m_specialContent;
m_specialContent = nullptr;
}
}
else if (type == "REPLACE CONTENT")
{
SetContent(dataStream);
m_includeTextureShortcuts = false;
if (m_specialContent != nullptr)
{
delete m_specialContent;
m_specialContent = nullptr;
}
}
else
{
m_includeTextureShortcuts = false;
if (m_specialContent != nullptr)
{
delete m_specialContent;
m_specialContent = nullptr;
}
return;
}
m_special = type;
}
bool QToolTipWidget::eventFilter(QObject* obj, QEvent* event)
{
if (event->type() == QEvent::KeyPress)
{
if (m_special == "TEXTURE" && m_specialContent != nullptr)
{
const QKeyEvent* ke = static_cast<QKeyEvent*>(event);
Qt::KeyboardModifiers mods = ke->modifiers();
if (mods & Qt::KeyboardModifier::AltModifier)
{
((QBitmapPreviewDialogImp*)m_specialContent)->setShowMode(QBitmapPreviewDialogImp::ESHOW_ALPHA);
}
else if (mods & Qt::KeyboardModifier::ShiftModifier && !(mods & Qt::KeyboardModifier::ControlModifier))
{
((QBitmapPreviewDialogImp*)m_specialContent)->setShowMode(QBitmapPreviewDialogImp::ESHOW_RGBA);
}
}
}
if (event->type() == QEvent::KeyRelease)
{
if (m_special == "TEXTURE" && m_specialContent != nullptr)
{
const QKeyEvent* ke = static_cast<QKeyEvent*>(event);
Qt::KeyboardModifiers mods = ke->modifiers();
if (!(mods& Qt::KeyboardModifier::AltModifier) && !(mods & Qt::KeyboardModifier::ShiftModifier))
{
((QBitmapPreviewDialogImp*)m_specialContent)->setShowMode(QBitmapPreviewDialogImp::ESHOW_RGB);
}
}
}
return QWidget::eventFilter(obj, event);
}
void QToolTipWidget::hideEvent(QHideEvent* event)
{
QWidget::hideEvent(event);
m_arrow->hide();
}
void QToolTipWidget::UpdateOptionalData(QString optionalData)
{
AddSpecialContent(m_special, optionalData);
}
QPoint QToolTipWidget::AdjustTipPosByArrowSize(QPoint pos, ArrowDirection dir)
{
switch (dir)
{
case QToolTipWidget::ArrowDirection::ARROW_UP:
{
m_arrow->move(pos);
pos.setY(pos.y() + 10);
m_arrow->setFixedSize(20, 10);
pos -= QPoint(m_shadowRadius, m_shadowRadius);
break;
}
case QToolTipWidget::ArrowDirection::ARROW_LEFT:
{
m_arrow->move(pos);
pos.setX(pos.x() + 10);
m_arrow->setFixedSize(10, 20);
pos -= QPoint(m_shadowRadius, m_shadowRadius);
break;
}
case QToolTipWidget::ArrowDirection::ARROW_RIGHT:
{
pos.setX(pos.x() - 10);
m_arrow->move(QPoint(pos.x() + width(), pos.y()));
m_arrow->setFixedSize(10, 20);
pos -= QPoint(-m_shadowRadius, m_shadowRadius);
break;
}
case QToolTipWidget::ArrowDirection::ARROW_DOWN:
{
pos.setY(pos.y() - 10);
m_arrow->move(QPoint(pos.x(), pos.y() + height()));
m_arrow->setFixedSize(20, 10);
pos -= QPoint(m_shadowRadius, -m_shadowRadius);
break;
}
default:
m_arrow->move(-10, -10);
break;
}
return pos;
}
bool QToolTipWidget::IsValid()
{
if (m_title->text().isEmpty() ||
(m_content->text().isEmpty() && m_specialContent == nullptr))
{
return false;
}
return true;
}
void QToolTipWidget::KeepTipOnScreen(QRect targetRect, ArrowDirection preferredArrowDir)
{
QRect desktop = QApplication::desktop()->availableGeometry(this);
if (this->isHidden())
{
setAttribute(Qt::WA_DontShowOnScreen, true);
Show(QPoint(0, 0), preferredArrowDir);
hide();
setAttribute(Qt::WA_DontShowOnScreen, false);
}
//else assume the size is right
//calculate initial rect
QRect tipRect = QRect(0, 0, 0, 0);
switch (preferredArrowDir)
{
case QToolTipWidget::ArrowDirection::ARROW_UP:
{
//tip is below the widget with a left alignment
tipRect.setTopLeft(AdjustTipPosByArrowSize(targetRect.bottomLeft(), preferredArrowDir));
break;
}
case QToolTipWidget::ArrowDirection::ARROW_LEFT:
{
//tip is on the right with the top being even
tipRect.setTopLeft(AdjustTipPosByArrowSize(targetRect.topRight(), preferredArrowDir));
break;
}
case QToolTipWidget::ArrowDirection::ARROW_RIGHT:
{
//tip is on the left with the top being even
tipRect.setY(targetRect.top());
tipRect.setX(targetRect.left() - width());
tipRect.setTopLeft(AdjustTipPosByArrowSize(tipRect.topLeft(), preferredArrowDir));
break;
}
case QToolTipWidget::ArrowDirection::ARROW_DOWN:
{
//tip is above the widget with a left alignment
tipRect.setX(targetRect.left());
tipRect.setY(targetRect.top() - height());
tipRect.setTopLeft(AdjustTipPosByArrowSize(tipRect.topLeft(), preferredArrowDir));
break;
}
default:
{
//tip is on the right with the top being even
preferredArrowDir = QToolTipWidget::ArrowDirection::ARROW_LEFT;
tipRect.setTopLeft(AdjustTipPosByArrowSize(targetRect.topRight(), QToolTipWidget::ArrowDirection::ARROW_LEFT));
break;
}
}
tipRect.setSize(size());
//FixPositioning
if (preferredArrowDir == ArrowDirection::ARROW_LEFT || preferredArrowDir == ArrowDirection::ARROW_RIGHT)
{
if (tipRect.left() <= desktop.left())
{
m_arrow->m_direction = ArrowDirection::ARROW_LEFT;
tipRect.setTopLeft(AdjustTipPosByArrowSize(targetRect.topRight(), m_arrow->m_direction));
}
else if (tipRect.right() >= desktop.right())
{
m_arrow->m_direction = ArrowDirection::ARROW_RIGHT;
tipRect.setLeft(targetRect.left() - width());
tipRect.setTopLeft(AdjustTipPosByArrowSize(tipRect.topLeft(), m_arrow->m_direction));
}
}
else if (preferredArrowDir == ArrowDirection::ARROW_UP || preferredArrowDir == ArrowDirection::ARROW_DOWN)
{
if (tipRect.top() <= desktop.top())
{
m_arrow->m_direction = ArrowDirection::ARROW_UP;
tipRect.setTopLeft(AdjustTipPosByArrowSize(targetRect.bottomLeft(), m_arrow->m_direction));
}
else if (tipRect.bottom() >= desktop.bottom())
{
m_arrow->m_direction = ArrowDirection::ARROW_DOWN;
tipRect.setY(targetRect.top() - height());
tipRect.setTopLeft(AdjustTipPosByArrowSize(tipRect.topLeft(), m_arrow->m_direction));
}
}
//Nudge tip without arrow
if (preferredArrowDir == ArrowDirection::ARROW_UP || preferredArrowDir == ArrowDirection::ARROW_DOWN)
{
if (tipRect.left() <= desktop.left())
{
tipRect.setLeft(desktop.left());
}
else if (tipRect.right() >= desktop.right())
{
tipRect.setLeft(desktop.right() - width());
}
}
else if (preferredArrowDir == ArrowDirection::ARROW_RIGHT || preferredArrowDir == ArrowDirection::ARROW_LEFT)
{
if (tipRect.top() <= desktop.top())
{
tipRect.setTop(desktop.top());
}
else if (tipRect.bottom() >= desktop.bottom())
{
tipRect.setTop(desktop.bottom() - height());
}
}
m_normalPos = tipRect.topLeft();
move(m_normalPos);
}
QPolygonF QToolTipWidget::QArrow::CreateArrow()
{
QVector<QPointF> vertex;
//3 points in triangle
vertex.reserve(3);
//all magic number below are given in order to draw smooth transitions between tooltip and arrow
if (m_direction == ArrowDirection::ARROW_UP)
{
vertex.push_back(QPointF(10, 1));
vertex.push_back(QPointF(19, 10));
vertex.push_back(QPointF(0, 10));
}
else if (m_direction == ArrowDirection::ARROW_RIGHT)
{
vertex.push_back(QPointF(9, 10));
vertex.push_back(QPointF(0, 19));
vertex.push_back(QPointF(0, 1));
}
else if (m_direction == ArrowDirection::ARROW_LEFT)
{
vertex.push_back(QPointF(1, 10));
vertex.push_back(QPointF(10, 19));
vertex.push_back(QPointF(10, 0));
}
else //ArrowDirection::ARROW_DOWN
{
vertex.push_back(QPointF(10, 10));
vertex.push_back(QPointF(19, 0));
vertex.push_back(QPointF(0, 0));
}
return QPolygonF(vertex);
}
void QToolTipWidget::QArrow::paintEvent([[maybe_unused]] QPaintEvent* event)
{
QColor color(255, 255, 255, 255);
QPainter painter(this);
painter.fillRect(rect(), Qt::transparent); //force transparency
painter.setRenderHint(QPainter::Antialiasing, false);
painter.setBrush(color);
painter.setPen(Qt::NoPen);
painter.drawPolygon(CreateArrow());
//painter.setRenderHint(QPainter::Antialiasing, false);
}
QToolTipWrapper::QToolTipWrapper(QWidget* parent)
: QObject(parent)
{
}
void QToolTipWrapper::SetTitle(QString title)
{
m_title = title;
}
void QToolTipWrapper::SetContent(QString content)
{
AddSpecialContent("REPLACE CONTENT", content);
}
void QToolTipWrapper::AppendContent(QString content)
{
AddSpecialContent("ADD TO CONTENT", content);
}
void QToolTipWrapper::AddSpecialContent(QString type, QString dataStream)
{
if (type == "REPLACE CONTENT")
{
m_contentOperations.clear();
}
m_contentOperations.push_back({type, dataStream});
}
void QToolTipWrapper::UpdateOptionalData(QString optionalData)
{
m_contentOperations.push_back({"UPDATE OPTIONAL", optionalData});
}
void QToolTipWrapper::Display(QRect targetRect, QToolTipWidget::ArrowDirection preferredArrowDir)
{
GetOrCreateToolTip()->Display(targetRect, preferredArrowDir);
}
void QToolTipWrapper::TryDisplay(QPoint mousePos, const QWidget * widget, QToolTipWidget::ArrowDirection preferredArrowDir)
{
GetOrCreateToolTip()->TryDisplay(mousePos, widget, preferredArrowDir);
}
void QToolTipWrapper::TryDisplay(QPoint mousePos, const QRect & widget, QToolTipWidget::ArrowDirection preferredArrowDir)
{
GetOrCreateToolTip()->TryDisplay(mousePos, widget, preferredArrowDir);
}
void QToolTipWrapper::hide()
{
DestroyToolTip();
}
void QToolTipWrapper::show()
{
GetOrCreateToolTip()->show();
}
bool QToolTipWrapper::isVisible() const
{
return m_actualTooltip && m_actualTooltip->isVisible();
}
void QToolTipWrapper::update()
{
if (m_actualTooltip)
{
m_actualTooltip->update();
}
}
void QToolTipWrapper::ReplayContentOperations(QToolTipWidget* tooltipWidget)
{
tooltipWidget->SetTitle(m_title);
for (const auto& operation : m_contentOperations)
{
if (operation.first == "UPDATE OPTIONAL")
{
tooltipWidget->UpdateOptionalData(operation.second);
}
else
{
tooltipWidget->AddSpecialContent(operation.first, operation.second);
}
}
}
QToolTipWidget * QToolTipWrapper::GetOrCreateToolTip()
{
if (!m_actualTooltip)
{
QToolTipWidget* tooltipWidget = new QToolTipWidget(static_cast<QWidget*>(parent()));
tooltipWidget->setAttribute(Qt::WA_DeleteOnClose);
ReplayContentOperations(tooltipWidget);
m_actualTooltip = tooltipWidget;
}
return m_actualTooltip.data();
}
void QToolTipWrapper::DestroyToolTip()
{
if (m_actualTooltip)
{
m_actualTooltip->deleteLater();
}
}
-148
View File
@@ -1,148 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef QToolTipWidget_h__
#define QToolTipWidget_h__
#include "EditorCoreAPI.h"
#include <QPointer>
#include <QWidget>
#include <QLabel>
#include <QString>
#include <QMap>
#include <QMapIterator>
#include <QVector>
#include <QVBoxLayout>
#include <memory>
class IQToolTip
{
public:
virtual void SetTitle(QString title) = 0;
virtual void SetContent(QString content) = 0;
virtual void AppendContent(QString content) = 0;
virtual void AddSpecialContent(QString type, QString dataStream) = 0;
virtual void UpdateOptionalData(QString optionalData) = 0;
};
class EDITOR_CORE_API QToolTipWidget
: public QWidget
, public IQToolTip
{
public:
enum class ArrowDirection
{
ARROW_UP,
ARROW_LEFT,
ARROW_RIGHT,
ARROW_DOWN
};
class QArrow
: public QWidget
{
public:
ArrowDirection m_direction;
QPoint m_pos;
QArrow(QWidget* parent)
: QWidget(parent){ setWindowFlags(Qt::ToolTip); }
virtual ~QArrow(){}
QPolygonF CreateArrow();
virtual void paintEvent(QPaintEvent*) override;
};
QToolTipWidget(QWidget* parent);
~QToolTipWidget();
void SetTitle(QString title) override;
void SetContent(QString content) override;
void AppendContent(QString content) override;
void AddSpecialContent(QString type, QString dataStream) override;
void UpdateOptionalData(QString optionalData) override;
void Display(QRect targetRect, ArrowDirection preferredArrowDir);
//! Displays the tooltip on the given widget, only if the mouse is over it.
void TryDisplay(QPoint mousePos, const QWidget* widget, ArrowDirection preferredArrowDir);
//! Displays the tooltip on the given rect, only if the mouse is over it.
void TryDisplay(QPoint mousePos, const QRect& widget, ArrowDirection preferredArrowDir);
void Hide();
protected:
void Show(QPoint pos, ArrowDirection dir);
bool IsValid();
void KeepTipOnScreen(QRect targetRect, ArrowDirection preferredArrowDir);
QPoint AdjustTipPosByArrowSize(QPoint pos, ArrowDirection dir);
virtual bool eventFilter(QObject* obj, QEvent* event) override;
void RebuildLayout();
virtual void hideEvent(QHideEvent*) override;
QLabel* m_title;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
QVector<QLabel*> m_currentShortcuts;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
//can be anything from QLabel to QBitMapPreviewDialog
//must allow movement, and show/hide calls
QLabel* m_content;
QWidget* m_specialContent;
QWidget* m_background;
QVBoxLayout* m_layout;
QString m_special;
QPoint m_normalPos;
QArrow* m_arrow;
const int m_shadowRadius = 5;
bool m_includeTextureShortcuts; //added since Qt does not support modifier only shortcuts
};
// HACK: The EditorUI_QT classes all were keeping persistent references to QToolTipWidgets around
// This led to many, many top-level widget creations, which led to many platform-side window allocations
// which led to crashes in Qt5.15. As this is legacy code, this is a drop-in replacement that only
// allocates the actual QToolTipWidget (and thus platform window) while the tooltip is visible
class EDITOR_CORE_API QToolTipWrapper
: public QObject
, public IQToolTip
{
public:
QToolTipWrapper(QWidget* parent);
void SetTitle(QString title) override;
void SetContent(QString content) override;
void AppendContent(QString content) override;
void AddSpecialContent(QString type, QString dataStream) override;
void UpdateOptionalData(QString optionalData) override;
void Display(QRect targetRect, QToolTipWidget::ArrowDirection preferredArrowDir);
void TryDisplay(QPoint mousePos, const QWidget* widget, QToolTipWidget::ArrowDirection preferredArrowDir);
void TryDisplay(QPoint mousePos, const QRect& widget, QToolTipWidget::ArrowDirection preferredArrowDir);
void hide();
void show();
bool isVisible() const;
void update();
void repaint(){update();} //Things really shouldn't be calling repaint on these...
void Hide(){hide();}
void close(){hide();}
private:
void ReplayContentOperations(QToolTipWidget* tooltipWidget);
QToolTipWidget* GetOrCreateToolTip();
void DestroyToolTip();
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // conditional expression is constant, needs to have dll-interface to be used by clients of class 'AzQtComponents::FilteredSearchWidget'
QPointer<QToolTipWidget> m_actualTooltip;
AZ_POP_DISABLE_WARNING
QString m_title;
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // conditional expression is constant, needs to have dll-interface to be used by clients of class 'AzQtComponents::FilteredSearchWidget'
QVector<QPair<QString, QString>> m_contentOperations;
AZ_POP_DISABLE_WARNING
};
#endif // QToolTipWidget_h__
@@ -1,131 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "PropertyAnimationCtrl.h"
// Qt
#include <QHBoxLayout>
#include <QLabel>
#include <QToolButton>
// Editor
#include "Util/UIEnumerations.h"
#include "IResourceSelectorHost.h"
AnimationPropertyCtrl::AnimationPropertyCtrl(QWidget *pParent)
: QWidget(pParent)
{
m_animationLabel = new QLabel;
m_pApplyButton = new QToolButton;
m_pApplyButton->setIcon(QIcon(":/reflectedPropertyCtrl/img/apply.png"));
m_pApplyButton->setFocusPolicy(Qt::StrongFocus);
QHBoxLayout *pLayout = new QHBoxLayout(this);
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->addWidget(m_animationLabel, 1);
pLayout->addWidget(m_pApplyButton);
connect(m_pApplyButton, &QAbstractButton::clicked, this, &AnimationPropertyCtrl::OnApplyClicked);
};
AnimationPropertyCtrl::~AnimationPropertyCtrl()
{
}
void AnimationPropertyCtrl::SetValue(const CReflectedVarAnimation &animation)
{
m_animation = animation;
m_animationLabel->setText(animation.m_animation.c_str());
}
CReflectedVarAnimation AnimationPropertyCtrl::value() const
{
return m_animation;
}
void AnimationPropertyCtrl::OnApplyClicked()
{
QStringList cSelectedAnimations;
int nTotalAnimations(0);
int nCurrentAnimation(0);
QString combinedString = GetIEditor()->GetResourceSelectorHost()->GetGlobalSelection("animation");
SplitString(combinedString, cSelectedAnimations, ',');
nTotalAnimations = cSelectedAnimations.size();
for (nCurrentAnimation = 0; nCurrentAnimation < nTotalAnimations; ++nCurrentAnimation)
{
QString& rstrCurrentAnimAction = cSelectedAnimations[nCurrentAnimation];
if (!rstrCurrentAnimAction.isEmpty())
{
m_animation.m_animation = rstrCurrentAnimAction.toUtf8().data();
m_animationLabel->setText(m_animation.m_animation.c_str());
emit ValueChanged(m_animation);
}
}
}
QWidget* AnimationPropertyCtrl::GetFirstInTabOrder()
{
return m_pApplyButton;
}
QWidget* AnimationPropertyCtrl::GetLastInTabOrder()
{
return m_pApplyButton;
}
void AnimationPropertyCtrl::UpdateTabOrder()
{
setTabOrder(m_pApplyButton, m_pApplyButton);
}
QWidget* AnimationPropertyWidgetHandler::CreateGUI(QWidget *pParent)
{
AnimationPropertyCtrl* newCtrl = aznew AnimationPropertyCtrl(pParent);
connect(newCtrl, &AnimationPropertyCtrl::ValueChanged, newCtrl, [newCtrl]()
{
EBUS_EVENT(AzToolsFramework::PropertyEditorGUIMessages::Bus, RequestWrite, newCtrl);
});
return newCtrl;
}
void AnimationPropertyWidgetHandler::ConsumeAttribute(AnimationPropertyCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName)
{
Q_UNUSED(GUI);
Q_UNUSED(attrib);
Q_UNUSED(attrValue);
Q_UNUSED(debugName);
}
void AnimationPropertyWidgetHandler::WriteGUIValuesIntoProperty(size_t index, AnimationPropertyCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node)
{
Q_UNUSED(index);
Q_UNUSED(node);
CReflectedVarAnimation val = GUI->value();
instance = static_cast<property_t>(val);
}
bool AnimationPropertyWidgetHandler::ReadValuesIntoGUI(size_t index, AnimationPropertyCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node)
{
Q_UNUSED(index);
Q_UNUSED(node);
CReflectedVarAnimation val = instance;
GUI->SetValue(val);
return false;
}
#include <Controls/ReflectedPropertyControl/moc_PropertyAnimationCtrl.cpp>
@@ -1,78 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_UTILS_PROPERTYANIMATIONCTRL_H
#define CRYINCLUDE_EDITOR_UTILS_PROPERTYANIMATIONCTRL_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <AzCore/base.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
#include "ReflectedVar.h"
#include <QWidget>
#include <QPointer>
#endif
class QToolButton;
class QLabel;
class QHBoxLayout;
class AnimationPropertyCtrl
: public QWidget
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(AnimationPropertyCtrl, AZ::SystemAllocator, 0);
AnimationPropertyCtrl(QWidget* pParent = nullptr);
virtual ~AnimationPropertyCtrl();
CReflectedVarAnimation value() const;
QWidget* GetFirstInTabOrder();
QWidget* GetLastInTabOrder();
void UpdateTabOrder();
signals:
void ValueChanged(CReflectedVarAnimation value);
public slots:
void SetValue(const CReflectedVarAnimation& animation);
protected slots:
void OnApplyClicked();
private:
QToolButton* m_pApplyButton;
QLabel* m_animationLabel;
CReflectedVarAnimation m_animation;
};
class AnimationPropertyWidgetHandler
: QObject
, public AzToolsFramework::PropertyHandler < CReflectedVarAnimation, AnimationPropertyCtrl >
{
public:
AZ_CLASS_ALLOCATOR(AnimationPropertyWidgetHandler, AZ::SystemAllocator, 0);
virtual AZ::u32 GetHandlerName(void) const override { return AZ_CRC("Animation", 0x8d5284dc); }
virtual bool IsDefaultHandler() const override { return true; }
virtual QWidget* GetFirstInTabOrder(AnimationPropertyCtrl* widget) override { return widget->GetFirstInTabOrder(); }
virtual QWidget* GetLastInTabOrder(AnimationPropertyCtrl* widget) override { return widget->GetLastInTabOrder(); }
virtual void UpdateWidgetInternalTabbing(AnimationPropertyCtrl* widget) override { widget->UpdateTabOrder(); }
virtual QWidget* CreateGUI(QWidget* pParent) override;
virtual void ConsumeAttribute(AnimationPropertyCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
virtual void WriteGUIValuesIntoProperty(size_t index, AnimationPropertyCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
virtual bool ReadValuesIntoGUI(size_t index, AnimationPropertyCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
};
#endif // CRYINCLUDE_EDITOR_UTILS_PROPERTYANIMATIONCTRL_H
@@ -10,7 +10,6 @@
// Editor
#include "PropertyCtrl.h"
#include "PropertyResourceCtrl.h"
#include "PropertyGenericCtrl.h"
#include "PropertyMiscCtrl.h"
#include "PropertyMotionCtrl.h"
@@ -21,7 +20,6 @@ void RegisterReflectedVarHandlers()
if (!registered)
{
registered = true;
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew FileResourceSelectorWidgetHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew SequencePropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew SequenceIdPropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew LocalStringPropertyHandler());
@@ -1,383 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "PropertyResourceCtrl.h"
// Qt
#include <QHBoxLayout>
#include <QLineEdit>
// AzToolsFramework
#include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyAudioCtrl.h>
// Editor
#include "Controls/QToolTipWidget.h"
#include "Controls/BitmapToolTip.h"
BrowseButton::BrowseButton(PropertyType type, QWidget* parent /*= nullptr*/)
: QToolButton(parent)
, m_propertyType(type)
{
setAutoRaise(true);
setIcon(QIcon(QStringLiteral(":/stylesheet/img/UI20/browse-edit.svg")));
connect(this, &QAbstractButton::clicked, this, &BrowseButton::OnClicked);
}
void BrowseButton::SetPathAndEmit(const QString& path)
{
//only emit if path changes. Old property control
if (path != m_path)
{
m_path = path;
emit PathChanged(m_path);
}
}
class FileBrowseButton
: public BrowseButton
{
public:
AZ_CLASS_ALLOCATOR(FileBrowseButton, AZ::SystemAllocator, 0);
FileBrowseButton(PropertyType type, QWidget* pParent = nullptr)
: BrowseButton(type, pParent)
{
setToolTip("Browse...");
}
private:
void OnClicked() override
{
QString tempValue("");
if (!m_path.isEmpty() && !Path::GetExt(m_path).isEmpty())
{
tempValue = m_path;
}
AssetSelectionModel selection;
if (m_propertyType == ePropertyTexture)
{
// Filters for texture.
selection = AssetSelectionModel::AssetGroupSelection("Texture");
}
else
{
return;
}
AzToolsFramework::EditorRequests::Bus::Broadcast(&AzToolsFramework::EditorRequests::BrowseForAssets, selection);
if (selection.IsValid())
{
QString newPath = Path::FullPathToGamePath(selection.GetResult()->GetFullPath().c_str()).c_str();
switch (m_propertyType)
{
case ePropertyTexture:
newPath.replace("\\\\", "/");
if (newPath.size() > MAX_PATH)
{
newPath.resize(MAX_PATH);
}
}
SetPathAndEmit(newPath);
}
}
};
class AudioControlSelectorButton
: public BrowseButton
{
public:
AZ_CLASS_ALLOCATOR(AudioControlSelectorButton, AZ::SystemAllocator, 0);
AudioControlSelectorButton(PropertyType type, QWidget* pParent = nullptr)
: BrowseButton(type, pParent)
{
setToolTip(tr("Select Audio Control"));
}
private:
void OnClicked() override
{
AZStd::string resourceResult;
auto ConvertLegacyAudioPropertyType = [](const PropertyType type) -> AzToolsFramework::AudioPropertyType
{
switch (type)
{
case ePropertyAudioTrigger:
return AzToolsFramework::AudioPropertyType::Trigger;
case ePropertyAudioRTPC:
return AzToolsFramework::AudioPropertyType::Rtpc;
case ePropertyAudioSwitch:
return AzToolsFramework::AudioPropertyType::Switch;
case ePropertyAudioSwitchState:
return AzToolsFramework::AudioPropertyType::SwitchState;
case ePropertyAudioEnvironment:
return AzToolsFramework::AudioPropertyType::Environment;
case ePropertyAudioPreloadRequest:
return AzToolsFramework::AudioPropertyType::Preload;
default:
return AzToolsFramework::AudioPropertyType::NumTypes;
}
};
auto propType = ConvertLegacyAudioPropertyType(m_propertyType);
if (propType != AzToolsFramework::AudioPropertyType::NumTypes)
{
AzToolsFramework::AudioControlSelectorRequestBus::EventResult(
resourceResult, propType, &AzToolsFramework::AudioControlSelectorRequestBus::Events::SelectResource,
AZStd::string_view{ m_path.toUtf8().constData() });
SetPathAndEmit(QString{ resourceResult.c_str() });
}
}
};
class TextureEditButton
: public BrowseButton
{
public:
AZ_CLASS_ALLOCATOR(TextureEditButton, AZ::SystemAllocator, 0);
TextureEditButton(QWidget* pParent = nullptr)
: BrowseButton(ePropertyTexture, pParent)
{
setIcon(QIcon(QStringLiteral(":/stylesheet/img/UI20/open-in-internal-app.svg")));
setToolTip(tr("Launch default editor"));
}
private:
void OnClicked() override
{
CFileUtil::EditTextureFile(m_path.toUtf8().data(), true);
}
};
FileResourceSelectorWidget::FileResourceSelectorWidget(QWidget* pParent /*= nullptr*/)
: QWidget(pParent)
, m_propertyType(ePropertyInvalid)
, m_tooltip(nullptr)
{
m_pathEdit = new QLineEdit;
m_mainLayout = new QHBoxLayout(this);
m_mainLayout->addWidget(m_pathEdit, 1);
m_mainLayout->setContentsMargins(0, 0, 0, 0);
// KDAB just ported the MFC texture preview tooltip, but looks like Amazon added their own. Not sure which to use.
// To switch to Amazon QToolTipWidget, remove FileResourceSelectorWidget::event and m_previewTooltip
#ifdef USE_QTOOLTIPWIDGET
m_tooltip = new QToolTipWidget(this);
installEventFilter(this);
#endif
connect(m_pathEdit, &QLineEdit::editingFinished, this, [this]() { OnPathChanged(m_pathEdit->text()); });
}
bool FileResourceSelectorWidget::eventFilter([[maybe_unused]] QObject* obj, QEvent* event)
{
if (m_propertyType == ePropertyTexture)
{
if (event->type() == QEvent::ToolTip)
{
QHelpEvent* e = (QHelpEvent*)event;
m_tooltip->AddSpecialContent("TEXTURE", m_path);
m_tooltip->TryDisplay(e->globalPos(), m_pathEdit, QToolTipWidget::ArrowDirection::ARROW_RIGHT);
return true;
}
if (event->type() == QEvent::Leave)
{
m_tooltip->hide();
}
}
return false;
}
void FileResourceSelectorWidget::SetPropertyType(PropertyType type)
{
if (m_propertyType == type)
{
return;
}
//if the property type changed for some reason, delete all the existing widgets
if (!m_buttons.isEmpty())
{
qDeleteAll(m_buttons.begin(), m_buttons.end());
m_buttons.clear();
}
m_previewToolTip.reset();
m_propertyType = type;
switch (type)
{
case ePropertyTexture:
AddButton(new FileBrowseButton(type));
AddButton(new TextureEditButton);
m_previewToolTip.reset(new CBitmapToolTip);
break;
case ePropertyAudioTrigger:
case ePropertyAudioSwitch:
case ePropertyAudioSwitchState:
case ePropertyAudioRTPC:
case ePropertyAudioEnvironment:
case ePropertyAudioPreloadRequest:
AddButton(new AudioControlSelectorButton(type));
break;
default:
break;
}
m_mainLayout->invalidate();
}
void FileResourceSelectorWidget::AddButton(BrowseButton* button)
{
m_mainLayout->addWidget(button);
m_buttons.push_back(button);
connect(button, &BrowseButton::PathChanged, this, &FileResourceSelectorWidget::OnPathChanged);
}
void FileResourceSelectorWidget::OnPathChanged(const QString& path)
{
bool changed = SetPath(path);
if (changed)
{
emit PathChanged(m_path);
}
}
bool FileResourceSelectorWidget::SetPath(const QString& path)
{
bool changed = false;
const QString newPath = path.toLower();
if (m_path != newPath)
{
m_path = newPath;
UpdateWidgets();
changed = true;
}
return changed;
}
void FileResourceSelectorWidget::UpdateWidgets()
{
m_pathEdit->setText(m_path);
foreach(BrowseButton * button, m_buttons)
{
button->SetPath(m_path);
}
if (m_previewToolTip)
{
m_previewToolTip->SetTool(this, rect());
}
}
QString FileResourceSelectorWidget::GetPath() const
{
return m_path;
}
QWidget* FileResourceSelectorWidget::GetLastInTabOrder()
{
return m_buttons.empty() ? nullptr : m_buttons.last();
}
QWidget* FileResourceSelectorWidget::GetFirstInTabOrder()
{
return m_buttons.empty() ? nullptr : m_buttons.first();
}
void FileResourceSelectorWidget::UpdateTabOrder()
{
if (m_buttons.count() >= 2)
{
for (int i = 0; i < m_buttons.count() - 1; ++i)
{
setTabOrder(m_buttons[i], m_buttons[i + 1]);
}
}
}
bool FileResourceSelectorWidget::event(QEvent* event)
{
if (event->type() == QEvent::ToolTip && m_previewToolTip && !m_previewToolTip->isVisible())
{
if (!m_path.isEmpty())
{
m_previewToolTip->LoadImage(m_path);
m_previewToolTip->setVisible(true);
}
event->accept();
return true;
}
if (event->type() == QEvent::Resize && m_previewToolTip)
{
m_previewToolTip->SetTool(this, rect());
}
return QWidget::event(event);
}
QWidget* FileResourceSelectorWidgetHandler::CreateGUI(QWidget* pParent)
{
FileResourceSelectorWidget* newCtrl = aznew FileResourceSelectorWidget(pParent);
connect(newCtrl, &FileResourceSelectorWidget::PathChanged, newCtrl, [newCtrl]()
{
EBUS_EVENT(AzToolsFramework::PropertyEditorGUIMessages::Bus, RequestWrite, newCtrl);
});
return newCtrl;
}
void FileResourceSelectorWidgetHandler::ConsumeAttribute(FileResourceSelectorWidget* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName)
{
Q_UNUSED(GUI);
Q_UNUSED(attrib);
Q_UNUSED(attrValue);
Q_UNUSED(debugName);
}
void FileResourceSelectorWidgetHandler::WriteGUIValuesIntoProperty(size_t index, FileResourceSelectorWidget* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node)
{
Q_UNUSED(index);
Q_UNUSED(node);
CReflectedVarResource val = instance;
val.m_propertyType = GUI->GetPropertyType();
val.m_path = GUI->GetPath().toUtf8().data();
instance = static_cast<property_t>(val);
}
bool FileResourceSelectorWidgetHandler::ReadValuesIntoGUI(size_t index, FileResourceSelectorWidget* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node)
{
Q_UNUSED(index);
Q_UNUSED(node);
CReflectedVarResource val = instance;
GUI->SetPropertyType(val.m_propertyType);
GUI->SetPath(val.m_path.c_str());
return false;
}
#include <Controls/ReflectedPropertyControl/moc_PropertyResourceCtrl.cpp>
@@ -1,118 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_UTILS_PROPERTYRESOURCECTRL_H
#define CRYINCLUDE_EDITOR_UTILS_PROPERTYRESOURCECTRL_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <AzCore/base.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
#include "ReflectedVar.h"
#include "Util/VariablePropertyType.h"
#include <QWidget>
#include <QtWidgets/QToolButton>
#include <QtCore/QVector>
#endif
class QLineEdit;
class QHBoxLayout;
class CBitmapToolTip;
class QToolTipWidget;
class BrowseButton
: public QToolButton
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(BrowseButton, AZ::SystemAllocator, 0);
BrowseButton(PropertyType type, QWidget* parent = nullptr);
void SetPath(const QString& path) { m_path = path; }
QString GetPath() const { return m_path; }
PropertyType GetPropertyType() const {return m_propertyType; }
signals:
void PathChanged(const QString& path);
protected:
void SetPathAndEmit(const QString& path);
virtual void OnClicked() = 0;
PropertyType m_propertyType;
QString m_path;
};
class FileResourceSelectorWidget
: public QWidget
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(FileResourceSelectorWidget, AZ::SystemAllocator, 0);
FileResourceSelectorWidget(QWidget* pParent = nullptr);
bool SetPath(const QString& path);
QString GetPath() const;
void SetPropertyType(PropertyType type);
PropertyType GetPropertyType() const { return m_propertyType; }
QWidget* GetFirstInTabOrder();
QWidget* GetLastInTabOrder();
void UpdateTabOrder();
bool eventFilter(QObject* obj, QEvent* event) override;
signals:
void PathChanged(const QString& path);
protected:
bool event(QEvent* event) override;
private:
void OnAssignClicked();
void OnMaterialClicked();
void UpdateWidgets();
void AddButton(BrowseButton* button);
void OnPathChanged(const QString& path);
private:
QLineEdit* m_pathEdit;
PropertyType m_propertyType;
QString m_path;
QHBoxLayout* m_mainLayout;
QVector<BrowseButton*> m_buttons;
QScopedPointer<CBitmapToolTip> m_previewToolTip;
QToolTipWidget* m_tooltip;
};
class FileResourceSelectorWidgetHandler
: QObject
, public AzToolsFramework::PropertyHandler < CReflectedVarResource, FileResourceSelectorWidget >
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(FileResourceSelectorWidgetHandler, AZ::SystemAllocator, 0);
virtual AZ::u32 GetHandlerName(void) const override { return AZ_CRC("Resource", 0xbc91f416); }
virtual bool IsDefaultHandler() const override { return true; }
virtual QWidget* GetFirstInTabOrder(FileResourceSelectorWidget* widget) override { return widget->GetFirstInTabOrder(); }
virtual QWidget* GetLastInTabOrder(FileResourceSelectorWidget* widget) override { return widget->GetLastInTabOrder(); }
virtual void UpdateWidgetInternalTabbing(FileResourceSelectorWidget* widget) override { widget->UpdateTabOrder(); }
virtual QWidget* CreateGUI(QWidget* pParent) override;
virtual void ConsumeAttribute(FileResourceSelectorWidget* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
virtual void WriteGUIValuesIntoProperty(size_t index, FileResourceSelectorWidget* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
virtual bool ReadValuesIntoGUI(size_t index, FileResourceSelectorWidget* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
};
#endif // CRYINCLUDE_EDITOR_UTILS_PROPERTYRESOURCECTRL_H
@@ -229,28 +229,16 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
break;
case ePropertyFloat:
case ePropertyAngle:
//if the Description has a valid global enumDB lookup, edit as an enum, otherwise use normal float editor
if (desc.m_pEnumDBItem)
m_reflectedVarAdapter = new ReflectedVarDBEnumAdapter;
else
m_reflectedVarAdapter = new ReflectedVarFloatAdapter;
m_reflectedVarAdapter = new ReflectedVarFloatAdapter;
break;
case ePropertyInt:
//if the Description has a valid global enumDB lookup, edit as an enum, otherwise use normal int editor
if (desc.m_pEnumDBItem)
m_reflectedVarAdapter = new ReflectedVarDBEnumAdapter;
else
m_reflectedVarAdapter = new ReflectedVarIntAdapter;
m_reflectedVarAdapter = new ReflectedVarIntAdapter;
break;
case ePropertyBool:
m_reflectedVarAdapter = new ReflectedVarBoolAdapter;
break;
case ePropertyString:
//if the Description has a valid global enumDB lookup, edit as an enum, otherwise use normal string editor
if (desc.m_pEnumDBItem)
m_reflectedVarAdapter = new ReflectedVarDBEnumAdapter;
else
m_reflectedVarAdapter = new ReflectedVarStringAdapter;
m_reflectedVarAdapter = new ReflectedVarStringAdapter;
break;
case ePropertySelection:
m_reflectedVarAdapter = new ReflectedVarEnumAdapter;
@@ -70,12 +70,6 @@ void ReflectedVarInit::setupReflection(AZ::SerializeContext* serializeContext)
AZ::EditContext* ec = serializeContext->GetEditContext();
if (ec)
{
ec->Class< CReflectedVarResource >("VarResource", "Resource")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::NameLabelOverride, &CReflectedVarResource::varName)
->Attribute(AZ::Edit::Attributes::DescriptionTextOverride, &CReflectedVarResource::description)
;
ec->Class< CReflectedVarUser >("VarUser", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::NameLabelOverride, &CReflectedVarUser::varName)
@@ -15,7 +15,6 @@
// Editor
#include "ReflectedPropertyCtrl.h"
#include "UIEnumsDatabase.h"
namespace {
@@ -254,41 +253,6 @@ void ReflectedVarEnumAdapter::OnVariableChange([[maybe_unused]] IVariable* pVari
}
}
void ReflectedVarDBEnumAdapter::SetVariable(IVariable *pVariable)
{
Prop::Description desc(pVariable);
m_pEnumDBItem = desc.m_pEnumDBItem;
m_reflectedVar.reset(new CReflectedVarEnum<AZStd::string>(pVariable->GetHumanName().toUtf8().data()));
if (m_pEnumDBItem)
{
for (int i = 0; i < m_pEnumDBItem->strings.size(); i++)
{
QString name = m_pEnumDBItem->strings[i];
m_reflectedVar->addEnum( m_pEnumDBItem->NameToValue(name).toUtf8().data(), name.toUtf8().data() );
}
}
}
void ReflectedVarDBEnumAdapter::SyncReflectedVarToIVar(IVariable *pVariable)
{
const AZStd::string valueStr = pVariable->GetDisplayValue().toUtf8().data();
const AZStd::string value = m_pEnumDBItem ? AZStd::string(m_pEnumDBItem->ValueToName(valueStr.c_str()).toUtf8().data()) : valueStr;
m_reflectedVar->setEnumByName(value);
}
void ReflectedVarDBEnumAdapter::SyncIVarToReflectedVar(IVariable *pVariable)
{
QString iVarVal = m_reflectedVar->m_selectedEnumName.c_str();
if (m_pEnumDBItem)
{
iVarVal = m_pEnumDBItem->NameToValue(iVarVal);
}
pVariable->SetDisplayValue(iVarVal);
}
void ReflectedVarVector2Adapter::SetVariable(IVariable *pVariable)
{
m_reflectedVar.reset(new CReflectedVarVector2(pVariable->GetHumanName().toUtf8().data()));
@@ -16,7 +16,6 @@
#include <QScopedPointer>
struct CUIEnumsDatabase_SEnum;
class ReflectedPropertyItem;
// Class to wrap the CReflectedVars and sync them with corresponding IVariable.
@@ -145,22 +144,6 @@ AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
bool m_updatingEnums;
};
class EDITOR_CORE_API ReflectedVarDBEnumAdapter
: public ReflectedVarAdapter
{
public:
void SetVariable(IVariable* pVariable) override;
void SyncReflectedVarToIVar(IVariable* pVariable) override;
void SyncIVarToReflectedVar(IVariable* pVariable) override;
CReflectedVar* GetReflectedVar() override { return m_reflectedVar.data(); }
private:
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
QScopedPointer<CReflectedVarEnum<AZStd::string> > m_reflectedVar;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
CUIEnumsDatabase_SEnum* m_pEnumDBItem;
};
class EDITOR_CORE_API ReflectedVarVector2Adapter
: public ReflectedVarAdapter
{
+1 -1
View File
@@ -588,7 +588,7 @@ QMenu* LevelEditorMenuHandler::CreateGameMenu()
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (!usePrefabSystemForLevels)
{
// Export to Engine
-1
View File
@@ -13,7 +13,6 @@
#include <QMap>
#include <QTranslator>
#include <QSet>
#include "IEventLoopHook.h"
#include <unordered_map>
#include <AzCore/PlatformDef.h>
+20 -51
View File
@@ -36,14 +36,6 @@ AZ_POP_DISABLE_WARNING
#include <QMessageBox>
#include <QDialogButtonBox>
// Aws Native SDK
#include <aws/sts/STSClient.h>
#include <aws/core/auth/AWSCredentialsProvider.h>
#include <aws/sts/model/GetFederationTokenRequest.h>
#include <aws/core/http/HttpClient.h>
#include <aws/core/http/HttpResponse.h>
#include <aws/core/utils/json/JsonSerializer.h>
// AzCore
#include <AzCore/Casting/numeric_cast.h>
#include <AzCore/Component/ComponentApplicationLifecycle.h>
@@ -144,9 +136,7 @@ AZ_POP_DISABLE_WARNING
#include "Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h"
// AWSNativeSDK
#include <AzToolsFramework/Undo/UndoSystem.h>
#include <AWSNativeSDKInit/AWSNativeSDKInit.h>
#if defined(AZ_PLATFORM_WINDOWS)
@@ -716,7 +706,7 @@ void CCryEditApp::OnFileSave()
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (!usePrefabSystemForLevels)
{
@@ -1719,7 +1709,6 @@ bool CCryEditApp::InitInstance()
mainWindow->Initialize();
GetIEditor()->GetCommandManager()->RegisterAutoCommands();
GetIEditor()->AddUIEnums();
mainWindowWrapper->enableSaveRestoreGeometry("O3DE", "O3DE", "mainWindowGeometry");
m_pDocManager->OnFileNew();
@@ -1830,10 +1819,7 @@ bool CCryEditApp::InitInstance()
if (GetIEditor()->GetCommandManager()->IsRegistered("editor.open_lnm_editor"))
{
CCommand0::SUIInfo uiInfo;
#if !defined(NDEBUG)
bool ok =
#endif
GetIEditor()->GetCommandManager()->GetUIInfo("editor.open_lnm_editor", uiInfo);
[[maybe_unused]] bool ok = GetIEditor()->GetCommandManager()->GetUIInfo("editor.open_lnm_editor", uiInfo);
assert(ok);
}
@@ -1842,34 +1828,6 @@ bool CCryEditApp::InitInstance()
return true;
}
void CCryEditApp::RegisterEventLoopHook(IEventLoopHook* pHook)
{
pHook->pNextHook = m_pEventLoopHook;
m_pEventLoopHook = pHook;
}
void CCryEditApp::UnregisterEventLoopHook(IEventLoopHook* pHookToRemove)
{
IEventLoopHook* pPrevious = nullptr;
for (IEventLoopHook* pHook = m_pEventLoopHook; pHook != nullptr; pHook = pHook->pNextHook)
{
if (pHook == pHookToRemove)
{
if (pPrevious)
{
pPrevious->pNextHook = pHookToRemove->pNextHook;
}
else
{
m_pEventLoopHook = pHookToRemove->pNextHook;
}
pHookToRemove->pNextHook = nullptr;
return;
}
}
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::LoadFile(QString fileName)
{
@@ -2125,8 +2083,6 @@ bool CCryEditApp::FixDanglingSharedMemory(const QString& sharedMemName) const
int CCryEditApp::ExitInstance(int exitCode)
{
AZ_TracePrintf("Exit", "Called ExitInstance() with exit code: 0x%x", exitCode);
if (m_pEditor)
{
m_pEditor->OnBeginShutdownSequence();
@@ -2408,7 +2364,7 @@ void CCryEditApp::ExportLevel(bool bExportToGame, bool bExportTexture, bool bAut
{
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (usePrefabSystemForLevels)
{
AZ_Assert(false, "Prefab system doesn't require level exports.");
@@ -2449,7 +2405,7 @@ bool CCryEditApp::UserExportToGame(bool bNoMsgBox)
{
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (usePrefabSystemForLevels)
{
AZ_Assert(false, "Export Level should no longer exist.");
@@ -2497,7 +2453,7 @@ void CCryEditApp::ExportToGame(bool bNoMsgBox)
{
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (usePrefabSystemForLevels)
{
AZ_Assert(false, "Prefab system no longer exports levels.");
@@ -3005,7 +2961,7 @@ CCryEditApp::ECreateLevelResult CCryEditApp::CreateLevel(const QString& levelNam
{
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
// If we are creating a new level and we're in simulate mode, then switch it off before we do anything else
if (GetIEditor()->GetGameEngine() && GetIEditor()->GetGameEngine()->GetSimulationMode())
@@ -3151,7 +3107,7 @@ bool CCryEditApp::CreateLevel(bool& wasCreateLevelOperationCancelled)
{
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (!usePrefabSystemForLevels)
{
QString str = QObject::tr("Level %1 has been changed. Save Level?").arg(GetIEditor()->GetGameEngine()->GetLevelName());
@@ -3363,6 +3319,10 @@ CCryEditDoc* CCryEditApp::OpenDocumentFile(const char* filename, bool addToMostR
return GetIEditor()->GetDocument();
}
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
// If we are loading and we're in simulate mode, then switch it off before we do anything else
if (GetIEditor()->GetGameEngine() && GetIEditor()->GetGameEngine()->GetSimulationMode())
{
@@ -3370,6 +3330,15 @@ CCryEditDoc* CCryEditApp::OpenDocumentFile(const char* filename, bool addToMostR
bool bIsDocModified = GetIEditor()->GetDocument()->IsModified();
OnSwitchPhysics();
GetIEditor()->GetDocument()->SetModifiedFlag(bIsDocModified);
if (usePrefabSystemForLevels)
{
auto* rootSpawnableInterface = AzFramework::RootSpawnableInterface::Get();
if (rootSpawnableInterface)
{
rootSpawnableInterface->ProcessSpawnableQueue();
}
}
}
// We're about to start loading a level, so start recording errors to display at the end.
-4
View File
@@ -30,7 +30,6 @@ class CConsoleDialog;
struct mg_connection;
struct mg_request_info;
struct mg_context;
struct IEventLoopHook;
class QAction;
class MainWindow;
class QSharedMemory;
@@ -153,8 +152,6 @@ public:
int IdleProcessing(bool bBackground);
bool IsWindowInForeground();
void RunInitPythonScript(CEditCommandLineInfo& cmdInfo);
void RegisterEventLoopHook(IEventLoopHook* pHook);
void UnregisterEventLoopHook(IEventLoopHook* pHook);
void DisableIdleProcessing() override;
void EnableIdleProcessing() override;
@@ -344,7 +341,6 @@ private:
QString m_lastOpenLevelPath;
CQuickAccessBar* m_pQuickAccessBar = nullptr;
IEventLoopHook* m_pEventLoopHook = nullptr;
QString m_rootEnginePath;
int m_disableIdleProcessingCounter = 0; //!< Counts requests to disable idle processing. When non-zero, idle processing will be disabled.
+6 -46
View File
@@ -57,7 +57,6 @@
// LmbrCentral
#include <LmbrCentral/Audio/AudioSystemComponentBus.h>
#include <LmbrCentral/Rendering/EditorLightComponentBus.h> // for LmbrCentral::EditorLightComponentRequestBus
static const char* kAutoBackupFolder = "_autobackup";
static const char* kHoldFolder = "$tmp_hold"; // conform to the ignored file types $tmp[0-9]*_ regex
@@ -372,7 +371,7 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (!usePrefabSystemForLevels)
{
@@ -637,7 +636,7 @@ bool CCryEditDoc::SaveModified()
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (!usePrefabSystemForLevels)
{
QMessageBox saveModifiedMessageBox(AzToolsFramework::GetActiveWindow());
@@ -700,7 +699,7 @@ void CCryEditDoc::OnFileSaveAs()
CCryEditApp::instance()->AddToRecentFileList(levelFileDialog.GetFileName());
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (usePrefabSystemForLevels)
{
AzToolsFramework::Prefab::TemplateId rootPrefabTemplateId =
@@ -729,7 +728,7 @@ bool CCryEditDoc::BeforeOpenDocument(const QString& lpszPathName, TOpenDocContex
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (!usePrefabSystemForLevels)
{
@@ -2130,52 +2129,13 @@ void CCryEditDoc::ReleaseXmlArchiveArray(TDocMultiArchive& arrXmlAr)
//////////////////////////////////////////////////////////////////////////
// AzToolsFramework::EditorEntityContextNotificationBus interface implementation
void CCryEditDoc::OnSliceInstantiated(const AZ::Data::AssetId& sliceAssetId, AZ::SliceComponent::SliceInstanceAddress& sliceAddress, const AzFramework::SliceInstantiationTicket& /*ticket*/)
void CCryEditDoc::OnSliceInstantiated([[maybe_unused]] const AZ::Data::AssetId& sliceAssetId, [[maybe_unused]] AZ::SliceComponent::SliceInstanceAddress& sliceAddress, [[maybe_unused]] const AzFramework::SliceInstantiationTicket& ticket)
{
if (m_envProbeSliceAssetId == sliceAssetId)
{
const AZ::SliceComponent::EntityList& entities = sliceAddress.GetInstance()->GetInstantiated()->m_entities;
const AZ::Uuid editorEnvProbeComponentId("{8DBD6035-583E-409F-AFD9-F36829A0655D}");
AzToolsFramework::EntityIdList entityIds;
entityIds.reserve(entities.size());
for (const AZ::Entity* entity : entities)
{
if (entity->FindComponent(editorEnvProbeComponentId))
{
// Update Probe Area size to cover the whole terrain
LmbrCentral::EditorLightComponentRequestBus::Event(entity->GetId(), &LmbrCentral::EditorLightComponentRequests::SetProbeAreaDimensions, AZ::Vector3(m_terrainSize, m_terrainSize, m_envProbeHeight));
// Force update the light to apply cubemap
LmbrCentral::EditorLightComponentRequestBus::Event(entity->GetId(), &LmbrCentral::EditorLightComponentRequests::RefreshLight);
}
entityIds.push_back(entity->GetId());
}
//Detach instantiated env probe entities from engine slice
AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Broadcast(
&AzToolsFramework::SliceEditorEntityOwnershipServiceRequests::DetachSliceEntities, entityIds);
sliceAddress.SetInstance(nullptr);
sliceAddress.SetReference(nullptr);
SetModifiedFlag(true);
SetModifiedModules(eModifiedEntities);
AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusDisconnect();
//save after level default slice fully instantiated
Save();
}
GetIEditor()->ResumeUndo();
}
void CCryEditDoc::OnSliceInstantiationFailed(const AZ::Data::AssetId& sliceAssetId, const AzFramework::SliceInstantiationTicket& /*ticket*/)
void CCryEditDoc::OnSliceInstantiationFailed([[maybe_unused]] const AZ::Data::AssetId& sliceAssetId, [[maybe_unused]] const AzFramework::SliceInstantiationTicket& ticket)
{
if (m_envProbeSliceAssetId == sliceAssetId)
{
AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusDisconnect();
AZ_Warning("Editor", false, "Failed to instantiate default environment probe slice.");
}
GetIEditor()->ResumeUndo();
}
//////////////////////////////////////////////////////////////////////////
-1
View File
@@ -200,7 +200,6 @@ protected:
QString m_pathName;
QString m_slicePathName;
QString m_title;
AZ::Data::AssetId m_envProbeSliceAssetId;
float m_terrainSize;
const char* m_envProbeSliceRelativePath = "EngineAssets/Slices/DefaultLevelSetup.slice";
const float m_envProbeHeight = 200.0f;
-29
View File
@@ -26,7 +26,6 @@
#include "Core/QtEditorApplication.h"
#include "CheckOutDialog.h"
#include "GameEngine.h"
#include "UndoConfigSpec.h"
#include "ViewManager.h"
#include "EditorViewportCamera.h"
@@ -369,21 +368,6 @@ namespace
inline namespace Commands
{
void PySetConfigSpec(int spec, int platform)
{
CUndo undo("Set Config Spec");
if (CUndo::IsRecording())
{
CUndo::Record(new CUndoConficSpec());
}
GetIEditor()->SetEditorConfigSpec((ESystemConfigSpec)spec, (ESystemConfigPlatform)platform);
}
int PyGetConfigSpec()
{
return static_cast<int>(GetIEditor()->GetEditorConfigSpec());
}
int PyGetConfigPlatform()
{
return static_cast<int>(GetIEditor()->GetEditorConfigPlatform());
@@ -434,9 +418,7 @@ namespace AzToolsFramework
addLegacyGeneral(behaviorContext->Method("set_current_view_rotation", PySetCurrentViewRotation, nullptr, "Sets the rotation of the current view as given x, y, z Euler angles in degrees."));
addLegacyGeneral(behaviorContext->Method("export_to_engine", CCryEditApp::Command_ExportToEngine, nullptr, "Exports the current level to the engine."));
addLegacyGeneral(behaviorContext->Method("set_config_spec", PySetConfigSpec, nullptr, "Sets the system config spec and platform."));
addLegacyGeneral(behaviorContext->Method("get_config_platform", PyGetConfigPlatform, nullptr, "Gets the system config platform."));
addLegacyGeneral(behaviorContext->Method("get_config_spec", PyGetConfigSpec, nullptr, "Gets the system config spec."));
addLegacyGeneral(behaviorContext->Method("set_result_to_success", PySetResultToSuccess, nullptr, "Sets the result of a script execution to success. Used only for Sandbox AutoTests."));
addLegacyGeneral(behaviorContext->Method("set_result_to_failure", PySetResultToFailure, nullptr, "Sets the result of a script execution to failure. Used only for Sandbox AutoTests."));
@@ -464,17 +446,6 @@ namespace AzToolsFramework
};
addCheckoutDialog(behaviorContext->Method("enable_for_all", PyCheckOutDialogEnableForAll, nullptr, "Enables the 'Apply to all' button in the checkout dialog; useful for allowing the user to apply a decision to check out files to multiple, related operations."));
behaviorContext->EnumProperty<ESystemConfigSpec::CONFIG_AUTO_SPEC>("SystemConfigSpec_Auto")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigSpec::CONFIG_LOW_SPEC>("SystemConfigSpec_Low")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigSpec::CONFIG_MEDIUM_SPEC>("SystemConfigSpec_Medium")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigSpec::CONFIG_HIGH_SPEC>("SystemConfigSpec_High")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigSpec::CONFIG_VERYHIGH_SPEC>("SystemConfigSpec_VeryHigh")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigPlatform::CONFIG_INVALID_PLATFORM>("SystemConfigPlatform_InvalidPlatform")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigPlatform::CONFIG_PC>("SystemConfigPlatform_Pc")
-17
View File
@@ -123,9 +123,7 @@
#include "Util/XmlTemplate.h"
// Utility classes.
#include "Util/bitarray.h"
#include "Util/RefCountBase.h"
#include "Util/TRefCountBase.h"
#include "Util/MemoryBlock.h"
#include "Util/PathUtil.h"
@@ -168,18 +166,3 @@
#ifdef LoadCursor
#undef LoadCursor
#endif
#ifdef _DEBUG
#if !defined(AZ_PLATFORM_LINUX)
#ifdef assert
#undef assert
#if defined(USE_AZ_ASSERT)
#define assert(condition) AZ_Assert(condition, "")
#else
#define assert CRY_ASSERT
#endif
#endif // !defined(AZ_PLATFORM_LINUX)
#endif
#endif
-24
View File
@@ -1,24 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
//! Allows handlers to be notified when settings are changed to refresh accordingly
class EditorPreferencesNotifications
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
//! Notifies about changes in the Editor Preferences
virtual void OnEditorPreferencesChanged() {}
};
using EditorPreferencesNotificationBus = AZ::EBus<EditorPreferencesNotifications>;
+1 -1
View File
@@ -101,7 +101,7 @@ void CEditorPreferencesPage_AWS::SaveSettingsRegistryFile()
return;
}
bool saved{};
[[maybe_unused]] bool saved = false;
constexpr auto configurationMode =
AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY;
if (AZ::IO::SystemFile outputFile; outputFile.Open(resolvedPath.data(), configurationMode))
@@ -30,7 +30,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
serialize.Class<GeneralSettings>()
->Version(3)
->Field("PreviewPanel", &GeneralSettings::m_previewPanel)
->Field("ApplyConfigSpec", &GeneralSettings::m_applyConfigSpec)
->Field("EnableSourceControl", &GeneralSettings::m_enableSourceControl)
->Field("ClearConsole", &GeneralSettings::m_clearConsoleOnGameModeStart)
->Field("ConsoleBackgroundColorTheme", &GeneralSettings::m_consoleBackgroundColorTheme)
@@ -81,7 +80,6 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
{
editContext->Class<GeneralSettings>("General Settings", "General Editor Preferences")
->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_previewPanel, "Show Geometry Preview Panel", "Show Geometry Preview Panel")
->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_applyConfigSpec, "Hide objects by config spec", "Hide objects by config spec")
->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_enableSourceControl, "Enable Source Control", "Enable Source Control")
->DataElement(
AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_clearConsoleOnGameModeStart, "Clear Console at game startup", "Clear Console when game mode starts")
@@ -157,7 +155,6 @@ void CEditorPreferencesPage_General::OnApply()
{
//general settings
gSettings.bPreviewGeometryWindow = m_generalSettings.m_previewPanel;
gSettings.bApplyConfigSpecInEditor = m_generalSettings.m_applyConfigSpec;
gSettings.enableSourceControl = m_generalSettings.m_enableSourceControl;
gSettings.clearConsoleOnGameModeStart = m_generalSettings.m_clearConsoleOnGameModeStart;
gSettings.consoleBackgroundColorTheme = m_generalSettings.m_consoleBackgroundColorTheme;
@@ -195,7 +192,6 @@ void CEditorPreferencesPage_General::InitializeSettings()
{
//general settings
m_generalSettings.m_previewPanel = gSettings.bPreviewGeometryWindow;
m_generalSettings.m_applyConfigSpec = gSettings.bApplyConfigSpecInEditor;
m_generalSettings.m_enableSourceControl = gSettings.enableSourceControl;
m_generalSettings.m_clearConsoleOnGameModeStart = gSettings.clearConsoleOnGameModeStart;
m_generalSettings.m_consoleBackgroundColorTheme = gSettings.consoleBackgroundColorTheme;
@@ -45,7 +45,6 @@ private:
AZ_TYPE_INFO(GeneralSettings, "{C2AE8F6D-7AA6-499E-A3E8-ECCD0AC6F3D2}")
bool m_previewPanel;
bool m_applyConfigSpec;
bool m_enableSourceControl;
bool m_clearConsoleOnGameModeStart;
AzToolsFramework::ConsoleColorTheme m_consoleBackgroundColorTheme;
+23 -2
View File
@@ -89,6 +89,7 @@
#include <LmbrCentral/Rendering/EditorCameraCorrectionBus.h>
// Atom
#include <Atom/RPI.Public/RenderPipeline.h>
#include <Atom/RPI.Public/View.h>
#include <Atom/RPI.Public/ViewportContextManager.h>
#include <Atom/RPI.Public/ViewProviderBus.h>
@@ -584,7 +585,8 @@ void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event)
m_renderViewport->SetScene(nullptr);
break;
case eNotify_OnEndSceneOpen:
case eNotify_OnEndLoad:
case eNotify_OnEndCreate:
UpdateScene();
SetDefaultCamera();
break;
@@ -2324,7 +2326,26 @@ void EditorViewportWidget::UpdateScene()
{
AZ::RPI::SceneNotificationBus::Handler::BusDisconnect();
m_renderViewport->SetScene(mainScene);
AZ::RPI::SceneNotificationBus::Handler::BusConnect(m_renderViewport->GetViewportContext()->GetRenderScene()->GetId());
auto viewportContext = m_renderViewport->GetViewportContext();
AZ::RPI::SceneNotificationBus::Handler::BusConnect(viewportContext->GetRenderScene()->GetId());
// Don't enable the render pipeline until a level has been loaded
// Also show/hide the RenderViewportWidget accordingly so that we get the
// expected gradient background when no level is loaded
auto renderPipeline = viewportContext->GetCurrentPipeline();
if (renderPipeline)
{
if (GetIEditor()->IsLevelLoaded())
{
m_renderViewport->show();
renderPipeline->AddToRenderTick();
}
else
{
m_renderViewport->hide();
renderPipeline->RemoveFromRenderTick();
}
}
}
}
}
+1 -1
View File
@@ -14,7 +14,7 @@
#define CRYINCLUDE_EDITOR_CORE_ERRORRECORDER_H
#pragma once
#include "Include/EditorCoreAPI.h"
#include <EditorCoreAPI.h>
//////////////////////////////////////////////////////////////////////////
//! Automatic class to record and display error.
-3
View File
@@ -17,9 +17,6 @@
// forward declarations.
class CParticleItem;
#include <CryCommon/IValidator.h>
#include <CryCommon/smartptr.h>
#include "Objects/BaseObject.h"
#include "Include/EditorCoreAPI.h"
#include "Include/IErrorReport.h"
+2 -1
View File
@@ -18,6 +18,7 @@
// AzCore
#include <AzCore/Component/ComponentApplication.h>
#include <AzCore/IO/IStreamer.h>
#include <AzCore/IO/Streamer/FileRequest.h>
#include <AzCore/std/parallel/binary_semaphore.h>
#include <AzCore/Console/IConsole.h>
@@ -488,7 +489,7 @@ bool CGameEngine::LoadLevel(
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (!usePrefabSystemForLevels)
{
+3 -3
View File
@@ -100,7 +100,7 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (usePrefabSystemForLevels)
{
@@ -317,8 +317,8 @@ void CGameExporter::ExportLevelInfo(const QString& path)
root->setAttr("Name", levelName.toUtf8().data());
auto terrain = AzFramework::Terrain::TerrainDataRequestBus::FindFirstHandler();
const AZ::Aabb terrainAabb = terrain ? terrain->GetTerrainAabb() : AZ::Aabb::CreateFromPoint(AZ::Vector3::CreateZero());
const AZ::Vector2 terrainGridResolution = terrain ? terrain->GetTerrainHeightQueryResolution() : AZ::Vector2::CreateOne();
const int compiledHeightmapSize = static_cast<int>(terrainAabb.GetXExtent() / terrainGridResolution.GetX());
const float terrainGridResolution = terrain ? terrain->GetTerrainHeightQueryResolution() : 1.0f;
const int compiledHeightmapSize = static_cast<int>(terrainAabb.GetXExtent() / terrainGridResolution);
root->setAttr("HeightmapSize", compiledHeightmapSize);
//////////////////////////////////////////////////////////////////////////
+1 -1
View File
@@ -70,7 +70,7 @@ private:
{
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (usePrefabSystemForLevels)
{
AZ_Assert(false, "Level.pak should no longer be used when prefabs are used for levels.");
-34
View File
@@ -19,8 +19,6 @@
#include "Util/UndoUtil.h"
#include <CryVersion.h>
#include <WinWidgetId.h>
#include <AzCore/Component/EntityId.h>
#include <AzCore/Debug/Budget.h>
@@ -48,7 +46,6 @@ class ICommandManager;
class CEditorCommandManager;
class CHyperGraphManager;
class CConsoleSynchronization;
class CUIEnumsDatabase;
struct ISourceControl;
struct IEditorClassFactory;
struct ITransformManipulator;
@@ -66,15 +63,9 @@ struct SEditorSettings;
class CGameExporter;
class IAWSResourceManager;
namespace WinWidget
{
class WinWidgetManager;
}
struct ISystem;
struct IRenderer;
struct AABB;
struct IEventLoopHook;
struct IErrorReport; // Vladimir@conffx
struct IFileUtil; // Vladimir@conffx
struct IEditorLog; // Vladimir@conffx
@@ -323,17 +314,6 @@ enum MouseCallbackFlags
MK_CALLBACK_FLAGS = 0x100
};
//! Types of database items
enum EDataBaseItemType
{
EDB_TYPE_MATERIAL,
EDB_TYPE_PARTICLE,
EDB_TYPE_MUSIC,
EDB_TYPE_EAXPRESET,
EDB_TYPE_SOUNDMOOD,
EDB_TYPE_FLARE
};
enum EEditorPathName
{
EDITOR_PATH_OBJECTS,
@@ -528,11 +508,6 @@ struct IEditor
virtual void SetActiveView(CViewport* viewport) = 0;
virtual struct IEditorFileMonitor* GetFileMonitor() = 0;
// These are needed for Qt integration:
virtual void RegisterEventLoopHook(IEventLoopHook* pHook) = 0;
virtual void UnregisterEventLoopHook(IEventLoopHook* pHook) = 0;
// ^^^
//! QMimeData is used by the Qt clipboard.
//! IMPORTANT: Any QMimeData allocated for the clipboard will be deleted
//! when the editor exists. If a QMimeData is allocated by a different
@@ -597,10 +572,6 @@ struct IEditor
virtual bool SetViewFocus(const char* sViewClassName) = 0;
virtual void CloseView(const GUID& classId) = 0; // close ALL panels related to classId, used when unloading plugins.
// We want to open a view object but not wrap it in a view pane)
virtual QWidget* OpenWinWidget(WinWidgetId openId) = 0;
virtual WinWidget::WinWidgetManager* GetWinWidgetManager() const = 0;
//! Opens standard color selection dialog.
//! Initialized with the color specified in color parameter.
//! Returns true if selection is made and false if selection is canceled.
@@ -682,15 +653,10 @@ struct IEditor
//! Only returns true if source control is both available AND currently connected and functioning
virtual bool IsSourceControlConnected() = 0;
virtual CUIEnumsDatabase* GetUIEnumsDatabase() = 0;
virtual void AddUIEnums() = 0;
virtual void ReduceMemory() = 0;
//! Export manager for exporting objects and a terrain from the game to DCC tools
virtual IExportManager* GetExportManager() = 0;
//! Set current configuration spec of the editor.
virtual void SetEditorConfigSpec(ESystemConfigSpec spec, ESystemConfigPlatform platform) = 0;
virtual ESystemConfigSpec GetEditorConfigSpec() const = 0;
virtual ESystemConfigPlatform GetEditorConfigPlatform() const = 0;
virtual void ReloadTemplates() = 0;
virtual void ShowStatusText(bool bEnable) = 0;
+1 -85
View File
@@ -12,16 +12,11 @@
#include "EditorDefs.h"
#include "IEditorImpl.h"
#include <EditorCommonAPI.h>
// Qt
#include <QByteArray>
// AWS Native SDK
AZ_PUSH_DISABLE_WARNING(4251 4355 4996, "-Wunknown-warning-option")
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/platform/FileSystem.h>
AZ_POP_DISABLE_WARNING
// AzCore
#include <AzCore/IO/Path/Path.h>
#include <AzCore/JSON/document.h>
@@ -56,7 +51,6 @@ AZ_POP_DISABLE_WARNING
#include "GameEngine.h"
#include "ToolBox.h"
#include "MainWindow.h"
#include "UIEnumsDatabase.h"
#include "RenderHelpers/AxisHelper.h"
#include "Settings.h"
#include "Include/IObjectManager.h"
@@ -75,12 +69,6 @@ AZ_POP_DISABLE_WARNING
#include "Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.h"
#include "Editor/AssetEditor/AssetEditorRequestsHandler.h"
// EditorCommon
#include <WinWidget/WinWidgetManager.h>
// AWSNativeSDK
#include <AWSNativeSDKInit/AWSNativeSDKInit.h>
#include "Core/QtEditorApplication.h" // for Editor::EditorQtApplication
static CCryEditDoc * theDocument;
@@ -127,12 +115,10 @@ CEditorImpl::CEditorImpl()
, m_pErrorsDlg(nullptr)
, m_pSourceControl(nullptr)
, m_pSelectionTreeManager(nullptr)
, m_pUIEnumsDatabase(nullptr)
, m_pConsoleSync(nullptr)
, m_pSettingsManager(nullptr)
, m_pLevelIndependentFileMan(nullptr)
, m_pExportManager(nullptr)
, m_awsResourceManager(nullptr)
, m_bMatEditMode(false)
, m_bShowStatusText(true)
, m_bInitialized(false)
@@ -158,7 +144,6 @@ CEditorImpl::CEditorImpl()
regCtx.pCommandManager = m_pCommandManager;
regCtx.pClassFactory = m_pClassFactory;
m_pEditorFileMonitor.reset(new CEditorFileMonitor());
m_pUIEnumsDatabase = new CUIEnumsDatabase;
m_pDisplaySettings = new CDisplaySettings;
m_pDisplaySettings->LoadRegistry();
m_pPluginManager = new CPluginManager;
@@ -177,8 +162,6 @@ CEditorImpl::CEditorImpl()
DetectVersion();
RegisterTools();
m_winWidgetManager.reset(new WinWidget::WinWidgetManager);
m_pAssetDatabaseLocationListener = nullptr;
m_pAssetBrowserRequestHandler = nullptr;
m_assetEditorRequestsHandler = nullptr;
@@ -312,7 +295,6 @@ CEditorImpl::~CEditorImpl()
SAFE_DELETE(m_pCommandManager)
SAFE_DELETE(m_pClassFactory)
SAFE_DELETE(m_pLasLoadedLevelErrorReport)
SAFE_DELETE(m_pUIEnumsDatabase)
SAFE_DELETE(m_pSettingsManager);
@@ -807,16 +789,6 @@ IEditorFileMonitor* CEditorImpl::GetFileMonitor()
return m_pEditorFileMonitor.get();
}
void CEditorImpl::RegisterEventLoopHook(IEventLoopHook* pHook)
{
CCryEditApp::instance()->RegisterEventLoopHook(pHook);
}
void CEditorImpl::UnregisterEventLoopHook(IEventLoopHook* pHook)
{
CCryEditApp::instance()->UnregisterEventLoopHook(pHook);
}
float CEditorImpl::GetTerrainElevation(float x, float y)
{
float terrainElevation = AzFramework::Terrain::TerrainDataRequests::GetDefaultTerrainHeight();
@@ -847,20 +819,6 @@ const QtViewPane* CEditorImpl::OpenView(QString sViewClassName, bool reuseOpened
return QtViewPaneManager::instance()->OpenPane(sViewClassName, openMode);
}
QWidget* CEditorImpl::OpenWinWidget(WinWidgetId openId)
{
if (m_winWidgetManager)
{
return m_winWidgetManager->OpenWinWidget(openId);
}
return nullptr;
}
WinWidget::WinWidgetManager* CEditorImpl::GetWinWidgetManager() const
{
return m_winWidgetManager.get();
}
QWidget* CEditorImpl::FindView(QString viewClassName)
{
return QtViewPaneManager::instance()->GetView(viewClassName);
@@ -1501,48 +1459,6 @@ IExportManager* CEditorImpl::GetExportManager()
return m_pExportManager;
}
void CEditorImpl::AddUIEnums()
{
// Spec settings for shadow casting lights
AZStd::string SpecString[4];
QStringList types;
types.push_back("Never=0");
SpecString[0] = AZStd::string::format("VeryHigh Spec=%d", CONFIG_VERYHIGH_SPEC);
types.push_back(SpecString[0].c_str());
SpecString[1] = AZStd::string::format("High Spec=%d", CONFIG_HIGH_SPEC);
types.push_back(SpecString[1].c_str());
SpecString[2] = AZStd::string::format("Medium Spec=%d", CONFIG_MEDIUM_SPEC);
types.push_back(SpecString[2].c_str());
SpecString[3] = AZStd::string::format("Low Spec=%d", CONFIG_LOW_SPEC);
types.push_back(SpecString[3].c_str());
m_pUIEnumsDatabase->SetEnumStrings("CastShadows", types);
// Power-of-two percentages
AZStd::string percentStringPOT[5];
types.clear();
percentStringPOT[0] = AZStd::string::format("Default=%d", 0);
types.push_back(percentStringPOT[0].c_str());
percentStringPOT[1] = AZStd::string::format("12.5=%d", 1);
types.push_back(percentStringPOT[1].c_str());
percentStringPOT[2] = AZStd::string::format("25=%d", 2);
types.push_back(percentStringPOT[2].c_str());
percentStringPOT[3] = AZStd::string::format("50=%d", 3);
types.push_back(percentStringPOT[3].c_str());
percentStringPOT[4] = AZStd::string::format("100=%d", 4);
types.push_back(percentStringPOT[4].c_str());
m_pUIEnumsDatabase->SetEnumStrings("ShadowMinResPercent", types);
}
void CEditorImpl::SetEditorConfigSpec(ESystemConfigSpec spec, [[maybe_unused]]ESystemConfigPlatform platform)
{
gSettings.editorConfigSpec = spec;
}
ESystemConfigSpec CEditorImpl::GetEditorConfigSpec() const
{
return (ESystemConfigSpec)gSettings.editorConfigSpec;
}
ESystemConfigPlatform CEditorImpl::GetEditorConfigPlatform() const
{
return m_pSystem->GetConfigPlatform();
-18
View File
@@ -53,11 +53,6 @@ namespace Editor
class EditorQtApplication;
}
namespace WinWidget
{
class WinWidgetManager;
}
namespace AssetDatabase
{
class AssetDatabaseLocationListener;
@@ -160,8 +155,6 @@ public:
CMusicManager* GetMusicManager() override { return m_pMusicManager; };
IEditorFileMonitor* GetFileMonitor() override;
void RegisterEventLoopHook(IEventLoopHook* pHook) override;
void UnregisterEventLoopHook(IEventLoopHook* pHook) override;
IIconManager* GetIconManager() override;
float GetTerrainElevation(float x, float y) override;
Editor::EditorQtApplication* GetEditorQtApplication() override { return m_QtApplication; }
@@ -221,9 +214,6 @@ public:
bool CloseView(const char* sViewClassName) override;
bool SetViewFocus(const char* sViewClassName) override;
QWidget* OpenWinWidget(WinWidgetId openId) override;
WinWidget::WinWidgetManager* GetWinWidgetManager() const override;
// close ALL panels related to classId, used when unloading plugins.
void CloseView(const GUID& classId) override;
bool SelectColor(QColor &color, QWidget *parent = 0) override;
@@ -276,14 +266,9 @@ public:
bool IsSourceControlConnected() override;
//! Setup Material Editor mode
void SetMatEditMode(bool bIsMatEditMode);
CUIEnumsDatabase* GetUIEnumsDatabase() override { return m_pUIEnumsDatabase; };
void AddUIEnums() override;
void ReduceMemory() override;
// Get Export manager
IExportManager* GetExportManager() override;
// Set current configuration spec of the editor.
void SetEditorConfigSpec(ESystemConfigSpec spec, ESystemConfigPlatform platform) override;
ESystemConfigSpec GetEditorConfigSpec() const override;
ESystemConfigPlatform GetEditorConfigPlatform() const override;
void ReloadTemplates() override;
void AddErrorMessage(const QString& text, const QString& caption);
@@ -355,7 +340,6 @@ protected:
CSelectionTreeManager* m_pSelectionTreeManager;
CUIEnumsDatabase* m_pUIEnumsDatabase;
//! CConsole Synchronization
CConsoleSynchronization* m_pConsoleSync;
//! Editor Settings Manager
@@ -369,8 +353,6 @@ protected:
QString m_selectFileBuffer;
QString m_levelNameBuffer;
IAWSResourceManager* m_awsResourceManager;
std::unique_ptr<WinWidget::WinWidgetManager> m_winWidgetManager;
//! True if the editor is in material edit mode. Fast preview of materials.
//! In this mode only very limited functionality is available.
-20
View File
@@ -1,20 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_IOBSERVABLE_H
#define CRYINCLUDE_EDITOR_IOBSERVABLE_H
#pragma once
//! Observable macro to be used in pure interfaces
#define DEFINE_OBSERVABLE_PURE_METHODS(observerClassName) \
virtual bool RegisterObserver(observerClassName * pObserver) = 0; \
virtual bool UnregisterObserver(observerClassName * pObserver) = 0; \
virtual void UnregisterAllObservers() = 0;
#endif // CRYINCLUDE_EDITOR_IOBSERVABLE_H
@@ -135,9 +135,6 @@ struct IClassDesc
//////////////////////////////////////////////////////////////////////////
};
struct IViewPaneClass;
struct CRYEDIT_API IEditorClassFactory
{
public:
@@ -149,7 +146,6 @@ public:
virtual IClassDesc* FindClass(const char* pClassName) const = 0;
//! Find class in the factory by class id
virtual IClassDesc* FindClass(const GUID& rClassID) const = 0;
virtual IViewPaneClass* FindViewPaneClassByTitle(const char* pPaneTitle) const = 0;
virtual void UnregisterClass(const char* pClassName) = 0;
virtual void UnregisterClass(const GUID& rClassID) = 0;
//! Get classes that matching specific requirements.
-24
View File
@@ -1,24 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IEVENTLOOPHOOK_H
#define CRYINCLUDE_EDITOR_INCLUDE_IEVENTLOOPHOOK_H
#pragma once
struct IEventLoopHook
{
IEventLoopHook* pNextHook;
IEventLoopHook()
: pNextHook(0) {}
virtual bool PrePumpMessage() { return false; }
};
#endif // CRYINCLUDE_EDITOR_INCLUDE_IEVENTLOOPHOOK_H
-74
View File
@@ -1,74 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IVIEWPANE_H
#define CRYINCLUDE_EDITOR_INCLUDE_IVIEWPANE_H
#pragma once
#include "IEditorClassFactory.h"
#include <QSize>
class QWidget;
class QRect;
struct IViewPaneClass
: public IClassDesc
{
DEFINE_UUID(0x7E13EC7C, 0xF621, 0x4aeb, 0xB6, 0x42, 0x67, 0xD7, 0x8E, 0xD4, 0x68, 0xF8)
enum EDockingDirection
{
DOCK_TOP,
DOCK_LEFT,
DOCK_RIGHT,
DOCK_BOTTOM,
DOCK_FLOAT,
};
virtual ~IViewPaneClass() = default;
// Return text for view pane title.
virtual QString GetPaneTitle() = 0;
// Return the string resource ID for the title's text.
virtual unsigned int GetPaneTitleID() const = 0;
// Return preferable initial docking position for pane.
virtual EDockingDirection GetDockingDirection() = 0;
// Initial pane size.
virtual QRect GetPaneRect() = 0;
// Get Minimal view size
virtual QSize GetMinSize() { return QSize(0, 0); }
// Return true if only one pane at a time of time view class can be created.
virtual bool SinglePane() = 0;
// Return true if the view window wants to get ID_IDLE_UPDATE commands.
virtual bool WantIdleUpdate() = 0;
//////////////////////////////////////////////////////////////////////////
// IUnknown
//////////////////////////////////////////////////////////////////////////
HRESULT STDMETHODCALLTYPE QueryInterface(const IID& riid, void** ppvObj)
{
if (riid == __az_uuidof(IViewPaneClass))
{
*ppvObj = this;
return S_OK;
}
return E_NOINTERFACE;
}
//////////////////////////////////////////////////////////////////////////
};
#endif // CRYINCLUDE_EDITOR_INCLUDE_IVIEWPANE_H
-2
View File
@@ -1,2 +0,0 @@
IDI_ICON1 ICON DISCARDABLE "..\\res\\lyeditor.ico"
-8
View File
@@ -97,8 +97,6 @@ public:
MOCK_METHOD0(GetActiveView, class CViewport* ());
MOCK_METHOD1(SetActiveView, void(CViewport*));
MOCK_METHOD0(GetFileMonitor, struct IEditorFileMonitor* ());
MOCK_METHOD1(RegisterEventLoopHook, void(IEventLoopHook* ));
MOCK_METHOD1(UnregisterEventLoopHook, void(IEventLoopHook* ));
MOCK_CONST_METHOD0(CreateQMimeData, QMimeData* ());
MOCK_CONST_METHOD1(DestroyQMimeData, void(QMimeData*));
MOCK_METHOD0(GetLevelIndependentFileMan, class CLevelIndependentFileMan* ());
@@ -128,8 +126,6 @@ public:
MOCK_METHOD1(CloseView, bool(const char* ));
MOCK_METHOD1(SetViewFocus, bool(const char* ));
MOCK_METHOD1(CloseView, void(const GUID& ));
MOCK_METHOD1(OpenWinWidget, QWidget* (WinWidgetId ));
MOCK_CONST_METHOD0(GetWinWidgetManager, WinWidget::WinWidgetManager* ());
MOCK_METHOD2(SelectColor, bool(QColor &, QWidget *));
MOCK_METHOD0(GetUndoManager, class CUndoManager* ());
MOCK_METHOD0(BeginUndo, void());
@@ -167,12 +163,8 @@ public:
MOCK_METHOD0(GetSourceControl, ISourceControl* ());
MOCK_METHOD0(IsSourceControlAvailable, bool());
MOCK_METHOD0(IsSourceControlConnected, bool());
MOCK_METHOD0(GetUIEnumsDatabase, CUIEnumsDatabase* ());
MOCK_METHOD0(AddUIEnums, void());
MOCK_METHOD0(ReduceMemory, void());
MOCK_METHOD0(GetExportManager, IExportManager* ());
MOCK_METHOD2(SetEditorConfigSpec, void(ESystemConfigSpec , ESystemConfigPlatform ));
MOCK_CONST_METHOD0(GetEditorConfigSpec, ESystemConfigSpec());
MOCK_CONST_METHOD0(GetEditorConfigPlatform, ESystemConfigPlatform());
MOCK_METHOD0(ReloadTemplates, void());
MOCK_METHOD1(ShowStatusText, void(bool ));
@@ -66,9 +66,7 @@ namespace CryEditPythonBindingsUnitTests
EXPECT_TRUE(behaviorContext->m_methods.find("set_current_view_position") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("set_current_view_rotation") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("export_to_engine") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("set_config_spec") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("get_config_platform") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("get_config_spec") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("set_result_to_success") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("set_result_to_failure") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("idle_enable") != behaviorContext->m_methods.end());
@@ -25,7 +25,6 @@
#include <Mocks/ICVarMock.h>
#include <Mocks/ISystemMock.h>
#include <Mocks/IConsoleMock.h>
#include <Mocks/ILogMock.h>
#include <Mocks/IConsoleMock.h>
#include "IEditorMock.h"
@@ -47,12 +47,12 @@ namespace UnitTest
void ViewportMouseCursorRequestImpl::BeginCursorCapture()
{
m_inputChannelMapper->SetCursorCaptureEnabled(true);
m_inputChannelMapper->SetCursorMode(AzToolsFramework::CursorInputMode::CursorModeCaptured);
}
void ViewportMouseCursorRequestImpl::EndCursorCapture()
{
m_inputChannelMapper->SetCursorCaptureEnabled(false);
m_inputChannelMapper->SetCursorMode(AzToolsFramework::CursorInputMode::CursorModeNone);
}
bool ViewportMouseCursorRequestImpl::IsMouseOver() const
+1 -7
View File
@@ -11,11 +11,6 @@
#include <algorithm>
// AWs Native SDK
AZ_PUSH_DISABLE_WARNING(4251 4355 4996, "-Wunknown-warning-option")
#include <aws/core/auth/AWSCredentialsProvider.h>
AZ_POP_DISABLE_WARNING
// Qt
#include <QMenuBar>
#include <QDebug>
@@ -77,7 +72,6 @@ AZ_POP_DISABLE_WARNING
#include "ToolbarManager.h"
#include "Core/QtEditorApplication.h"
#include "UndoDropDown.h"
#include "CVarMenu.h"
#include "EditorViewportSettings.h"
#include "KeyboardCustomizationSettings.h"
@@ -665,7 +659,7 @@ void MainWindow::InitActions()
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
if (!usePrefabSystemForLevels)
{
am->AddAction(ID_FILE_EXPORTTOGAMENOSURFACETEXTURE, tr("&Export to Engine"))
+5 -6
View File
@@ -49,7 +49,6 @@ class ToolbarCustomizationDialog;
class QWidgetAction;
class ActionManager;
class ShortcutDispatcher;
class CVarMenu;
namespace AzQtComponents
{
@@ -64,11 +63,11 @@ namespace AzToolsFramework
//! @name Reverse URLs.
//! Used to identify common actions and override them when necessary.
//@{
constexpr inline AZ::Crc32 EditModeMove = AZ_CRC_CE("com.o3de.action.editor.editmode.move");
constexpr inline AZ::Crc32 EditModeRotate = AZ_CRC_CE("com.o3de.action.editor.editmode.rotate");
constexpr inline AZ::Crc32 EditModeScale = AZ_CRC_CE("com.o3de.action.editor.editmode.scale");
constexpr inline AZ::Crc32 SnapToGrid = AZ_CRC_CE("com.o3de.action.editor.snaptogrid");
constexpr inline AZ::Crc32 SnapAngle = AZ_CRC_CE("com.o3de.action.editor.snapangle");
constexpr inline AZ::Crc32 EditModeMove = AZ_CRC_CE("org.o3de.action.editor.editmode.move");
constexpr inline AZ::Crc32 EditModeRotate = AZ_CRC_CE("org.o3de.action.editor.editmode.rotate");
constexpr inline AZ::Crc32 EditModeScale = AZ_CRC_CE("org.o3de.action.editor.editmode.scale");
constexpr inline AZ::Crc32 SnapToGrid = AZ_CRC_CE("org.o3de.action.editor.snaptogrid");
constexpr inline AZ::Crc32 SnapAngle = AZ_CRC_CE("org.o3de.action.editor.snapangle");
//@}
}
+1 -52
View File
@@ -62,7 +62,7 @@ protected:
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//! Undo object for CBaseObject that only stores its transform, color, area and minSpec
//! Undo object for CBaseObject that only stores its transform, color, area
class CUndoBaseObjectMinimal
: public IUndoObject
{
@@ -84,7 +84,6 @@ private:
Vec3 scale;
QColor color;
float area;
int minSpec;
};
void SetTransformsFromState(CBaseObject* pObject, const StateStruct& state, bool bUndo);
@@ -253,7 +252,6 @@ CUndoBaseObjectMinimal::CUndoBaseObjectMinimal(CBaseObject* pObj, [[maybe_unused
m_undoState.scale = pObj->GetScale();
m_undoState.color = pObj->GetColor();
m_undoState.area = pObj->GetArea();
m_undoState.minSpec = pObj->GetMinSpec();
}
//////////////////////////////////////////////////////////////////////////
@@ -284,14 +282,12 @@ void CUndoBaseObjectMinimal::Undo(bool bUndo)
m_redoState.rotate = pObject->GetRotation();
m_redoState.color = pObject->GetColor();
m_redoState.area = pObject->GetArea();
m_redoState.minSpec = pObject->GetMinSpec();
}
SetTransformsFromState(pObject, m_undoState, bUndo);
pObject->ChangeColor(m_undoState.color);
pObject->SetArea(m_undoState.area);
pObject->SetMinSpec(m_undoState.minSpec, false);
using namespace AzToolsFramework;
ComponentEntityObjectRequestBus::Event(pObject, &ComponentEntityObjectRequestBus::Events::UpdatePreemptiveUndoCache);
@@ -310,7 +306,6 @@ void CUndoBaseObjectMinimal::Redo()
pObject->ChangeColor(m_redoState.color);
pObject->SetArea(m_redoState.area);
pObject->SetMinSpec(m_redoState.minSpec, false);
using namespace AzToolsFramework;
ComponentEntityObjectRequestBus::Event(pObject, &ComponentEntityObjectRequestBus::Events::UpdatePreemptiveUndoCache);
@@ -382,7 +377,6 @@ CBaseObject::CBaseObject()
, m_bMatrixInWorldSpace(false)
, m_bMatrixValid(false)
, m_bWorldBoxValid(false)
, m_nMinSpec(0)
, m_vDrawIconPos(0, 0, 0)
, m_nIconFlags(0)
{
@@ -413,7 +407,6 @@ bool CBaseObject::Init([[maybe_unused]] IEditor* ie, CBaseObject* prev, [[maybe_
SetLocalTM(prev->GetPos(), prev->GetRotation(), prev->GetScale());
SetArea(prev->GetArea());
SetColor(prev->GetColor());
SetMinSpec(prev->GetMinSpec(), false);
// Copy all basic variables.
EnableUpdateCallbacks(false);
@@ -1053,17 +1046,6 @@ void CBaseObject::SetSelected(bool bSelect)
}
}
//////////////////////////////////////////////////////////////////////////
bool CBaseObject::IsHiddenBySpec() const
{
if (!gSettings.bApplyConfigSpecInEditor)
{
return false;
}
return (m_nMinSpec != 0 && gSettings.editorConfigSpec != 0 && m_nMinSpec > static_cast<uint32>(gSettings.editorConfigSpec));
}
//////////////////////////////////////////////////////////////////////////
//! Returns true if object hidden.
bool CBaseObject::IsHidden() const
@@ -1107,7 +1089,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
Vec3 scale = m_scale;
Quat quat = m_rotate;
Ang3 angles(0, 0, 0);
uint32 nMinSpec = m_nMinSpec;
QColor color = m_color;
float flattenArea = m_flattenArea;
@@ -1135,12 +1116,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
xmlNode->getAttr("Parent", parentId);
xmlNode->getAttr("LookAt", lookatId);
xmlNode->getAttr("Material", mtlName);
xmlNode->getAttr("MinSpec", nMinSpec);
if (nMinSpec <= CONFIG_VERYHIGH_SPEC) // Ignore invalid values.
{
m_nMinSpec = nMinSpec;
}
bool bHidden = flags & OBJFLAG_HIDDEN;
bool bFrozen = flags & OBJFLAG_FROZEN;
@@ -1245,11 +1220,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
{
xmlNode->setAttr("Flags", flags);
}
if (m_nMinSpec != 0)
{
xmlNode->setAttr("MinSpec", (uint32)m_nMinSpec);
}
}
// Serialize variables after default entity parameters.
@@ -1300,11 +1270,6 @@ XmlNodeRef CBaseObject::Export([[maybe_unused]] const QString& levelPath, XmlNod
objNode->setAttr("Scale", scale);
}
if (m_nMinSpec != 0)
{
objNode->setAttr("MinSpec", (uint32)m_nMinSpec);
}
// Save variables.
CVarObject::Serialize(objNode, false);
@@ -2134,22 +2099,6 @@ bool CBaseObject::IsSimilarObject(CBaseObject* pObject)
return false;
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::SetMinSpec(uint32 nSpec, bool bSetChildren)
{
m_nMinSpec = nSpec;
UpdateVisibility(!IsHidden());
// Set min spec for all childs.
if (bSetChildren)
{
for (int i = static_cast<int>(m_childs.size()) - 1; i >= 0; --i)
{
m_childs[i]->SetMinSpec(nSpec, true);
}
}
}
//////////////////////////////////////////////////////////////////////////
EScaleWarningLevel CBaseObject::GetScaleWarningLevel() const
{
-10
View File
@@ -31,7 +31,6 @@ class CUndoBaseObject;
class CObjectManager;
class CGizmo;
class CObjectArchive;
struct SSubObjSelectionModifyContext;
struct SRayHitInfo;
class CPopupMenuItem;
class QMenu;
@@ -257,8 +256,6 @@ public:
//! Returns true if object hidden.
bool IsHidden() const;
//! Check against min spec.
bool IsHiddenBySpec() const;
//! Returns true if object frozen.
virtual bool IsFrozen() const;
//! Returns true if object is shared between missions.
@@ -466,12 +463,6 @@ public:
//! Check if specified object is very similar to this one.
virtual bool IsSimilarObject(CBaseObject* pObject);
//////////////////////////////////////////////////////////////////////////
// Object minimal usage spec (All/Low/Medium/High)
//////////////////////////////////////////////////////////////////////////
uint32 GetMinSpec() const { return m_nMinSpec; }
virtual void SetMinSpec(uint32 nSpec, bool bSetChildren = true);
//! In This function variables of the object must be initialized.
virtual void InitVariables() {};
@@ -669,7 +660,6 @@ private:
mutable uint32 m_bMatrixValid : 1;
mutable uint32 m_bWorldBoxValid : 1;
uint32 m_bInSelectionBox : 1;
uint32 m_nMinSpec : 8;
Vec3 m_vDrawIconPos;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
+1 -42
View File
@@ -200,7 +200,6 @@ CEntityObject::CEntityObject()
// Init Variables.
mv_castShadow = true;
mv_castShadowMinSpec = CONFIG_LOW_SPEC;
mv_outdoor = false;
mv_recvWind = false;
mv_renderNearest = false;
@@ -249,18 +248,10 @@ CEntityObject::~CEntityObject()
//////////////////////////////////////////////////////////////////////////
void CEntityObject::InitVariables()
{
mv_castShadowMinSpec.AddEnumItem("Never", END_CONFIG_SPEC_ENUM);
mv_castShadowMinSpec.AddEnumItem("Low", CONFIG_LOW_SPEC);
mv_castShadowMinSpec.AddEnumItem("Medium", CONFIG_MEDIUM_SPEC);
mv_castShadowMinSpec.AddEnumItem("High", CONFIG_HIGH_SPEC);
mv_castShadowMinSpec.AddEnumItem("VeryHigh", CONFIG_VERYHIGH_SPEC);
mv_castShadow.SetFlags(mv_castShadow.GetFlags() | IVariable::UI_INVISIBLE);
mv_castShadowMinSpec->SetFlags(mv_castShadowMinSpec->GetFlags() | IVariable::UI_UNSORTED);
AddVariable(mv_outdoor, "OutdoorOnly", tr("Outdoor Only"));
AddVariable(mv_castShadow, "CastShadow", tr("Cast Shadow"));
AddVariable(mv_castShadowMinSpec, "CastShadowMinspec", tr("Cast Shadow MinSpec"));
AddVariable(mv_ratioLOD, "LodRatio");
AddVariable(mv_viewDistanceMultiplier, "ViewDistanceMultiplier");
@@ -361,7 +352,6 @@ bool CEntityObject::ConvertFromObject(CBaseObject* object)
CEntityObject* pObject = ( CEntityObject* )object;
mv_outdoor = pObject->mv_outdoor;
mv_castShadowMinSpec = pObject->mv_castShadowMinSpec;
mv_ratioLOD = pObject->mv_ratioLOD;
mv_viewDistanceMultiplier = pObject->mv_viewDistanceMultiplier;
mv_hiddenInGame = pObject->mv_hiddenInGame;
@@ -509,34 +499,16 @@ void CEntityObject::AdjustLightProperties(CVarBlockPtr& properties, const char*
pAreaLight->SetHumanName("PlanarLight");
}
bool bCastShadowLegacy = false; // Backward compatibility for existing shadow casting lights
if (IVariable* pCastShadowVarLegacy = FindVariableInSubBlock(properties, pSubBlockVar, "bCastShadow"))
{
pCastShadowVarLegacy->SetFlags(pCastShadowVarLegacy->GetFlags() | IVariable::UI_INVISIBLE);
const QString zeroPrefix("0");
if (!pCastShadowVarLegacy->GetDisplayValue().startsWith(zeroPrefix))
{
bCastShadowLegacy = true;
pCastShadowVarLegacy->SetDisplayValue(zeroPrefix);
}
}
if (IVariable* pCastShadowVar = FindVariableInSubBlock(properties, pSubBlockVar, "nCastShadows"))
{
if (bCastShadowLegacy)
{
pCastShadowVar->SetDisplayValue("1");
}
pCastShadowVar->SetDataType(IVariable::DT_UIENUM);
pCastShadowVar->SetFlags(pCastShadowVar->GetFlags() | IVariable::UI_UNSORTED);
}
if (IVariable* pShadowMinRes = FindVariableInSubBlock(properties, pSubBlockVar, "nShadowMinResPercent"))
{
pShadowMinRes->SetDataType(IVariable::DT_UIENUM);
pShadowMinRes->SetFlags(pShadowMinRes->GetFlags() | IVariable::UI_UNSORTED);
}
if (IVariable* pFade = FindVariableInSubBlock(properties, pSubBlockVar, "vFadeDimensionsLeft"))
{
pFade->SetFlags(pFade->GetFlags() | IVariable::UI_INVISIBLE);
@@ -873,12 +845,6 @@ void CEntityObject::Serialize(CObjectArchive& ar)
RemoveAllEntityLinks();
PostLoad(ar);
}
if ((mv_castShadowMinSpec == CONFIG_LOW_SPEC) && !mv_castShadow) // backwards compatibility check
{
mv_castShadowMinSpec = END_CONFIG_SPEC_ENUM;
mv_castShadow = true;
}
}
else
{
@@ -1033,8 +999,6 @@ XmlNodeRef CEntityObject::Export([[maybe_unused]] const QString& levelPath, XmlN
objNode->setAttr("ViewDistanceMultiplier", mv_viewDistanceMultiplier);
}
objNode->setAttr("CastShadowMinSpec", mv_castShadowMinSpec);
if (mv_recvWind)
{
objNode->setAttr("RecvWind", true);
@@ -1050,11 +1014,6 @@ XmlNodeRef CEntityObject::Export([[maybe_unused]] const QString& levelPath, XmlN
objNode->setAttr("OutdoorOnly", true);
}
if (GetMinSpec() != 0)
{
objNode->setAttr("MinSpec", ( uint32 )GetMinSpec());
}
if (mv_hiddenInGame)
{
objNode->setAttr("HiddenInGame", true);
@@ -1163,7 +1122,7 @@ void CEntityObject::UpdateVisibility(bool bVisible)
{
CBaseObject::UpdateVisibility(bVisible);
bool bVisibleWithSpec = bVisible && !IsHiddenBySpec();
bool bVisibleWithSpec = bVisible;
if (bVisibleWithSpec != static_cast<bool>(m_bVisible))
{
m_bVisible = bVisibleWithSpec;
-3
View File
@@ -174,8 +174,6 @@ public:
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
int GetCastShadowMinSpec() const { return mv_castShadowMinSpec; }
float GetRatioLod() const { return static_cast<float>(mv_ratioLOD); };
float GetViewDistanceMultiplier() const { return mv_viewDistanceMultiplier; }
@@ -306,7 +304,6 @@ protected:
//////////////////////////////////////////////////////////////////////////
CVariable<bool> mv_outdoor;
CVariable<bool> mv_castShadow; // Legacy, required for backwards compatibility
CSmartVariableEnum<int> mv_castShadowMinSpec;
CVariable<int> mv_ratioLOD;
CVariable<float> mv_viewDistanceMultiplier;
CVariable<bool> mv_hiddenInGame; // Entity is hidden in game (on start).
-62
View File
@@ -1,62 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorDefs.h"
#include "SubObjSelection.h"
SSubObjSelOptions g_SubObjSelOptions;
/*
//////////////////////////////////////////////////////////////////////////
bool CSubObjSelContext::IsEmpty() const
{
if (GetCount() == 0)
return false;
for (int i = 0; i < GetCount(); i++)
{
CSubObjectSelection *pSel = GetSelection(i);
if (!pSel->IsEmpty())
return true;
}
return false;
}
//////////////////////////////////////////////////////////////////////////
void CSubObjSelContext::ModifySelection( SSubObjSelectionModifyContext &modCtx )
{
for (int n = 0; n < GetCount(); n++)
{
CSubObjectSelection *pSel = GetSelection(n);
if (pSel->IsEmpty())
continue;
modCtx.pSubObjSelection = pSel;
pSel->pGeometry->SubObjSelectionModify( modCtx );
}
if (modCtx.type == SO_MODIFY_MOVE)
{
OnSelectionChange();
}
}
//////////////////////////////////////////////////////////////////////////
void CSubObjSelContext::AcceptModifySelection()
{
for (int n = 0; n < GetCount(); n++)
{
CSubObjectSelection *pSel = GetSelection(n);
if (pSel->IsEmpty())
continue;
if (pSel->pGeometry)
pSel->pGeometry->Update();
}
}
*/
-91
View File
@@ -1,91 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_OBJECTS_SUBOBJSELECTION_H
#define CRYINCLUDE_EDITOR_OBJECTS_SUBOBJSELECTION_H
#pragma once
//////////////////////////////////////////////////////////////////////////
// Sub Object element type.
//////////////////////////////////////////////////////////////////////////
enum ESubObjElementType
{
SO_ELEM_NONE = 0,
SO_ELEM_VERTEX,
SO_ELEM_EDGE,
SO_ELEM_FACE,
SO_ELEM_POLYGON,
SO_ELEM_UV,
};
//////////////////////////////////////////////////////////////////////////
enum ESubObjDisplayType
{
SO_DISPLAY_WIREFRAME,
SO_DISPLAY_FLAT,
SO_DISPLAY_GEOMETRY,
};
//////////////////////////////////////////////////////////////////////////
// Options for sub-object selection.
//////////////////////////////////////////////////////////////////////////
struct SSubObjSelOptions
{
bool bSelectByVertex;
bool bIgnoreBackfacing;
int nMatID;
bool bSoftSelection;
float fSoftSelFalloff;
// Display options.
bool bDisplayBackfacing;
bool bDisplayNormals;
float fNormalsLength;
ESubObjDisplayType displayType;
SSubObjSelOptions()
{
bSelectByVertex = false;
bIgnoreBackfacing = false;
bSoftSelection = false;
nMatID = 0;
fSoftSelFalloff = 1;
bDisplayBackfacing = true;
bDisplayNormals = false;
displayType = SO_DISPLAY_FLAT;
fNormalsLength = 0.4f;
}
};
extern SSubObjSelOptions g_SubObjSelOptions;
//////////////////////////////////////////////////////////////////////////
enum ESubObjSelectionModifyType
{
SO_MODIFY_UNSELECT,
SO_MODIFY_MOVE,
SO_MODIFY_ROTATE,
SO_MODIFY_SCALE,
};
//////////////////////////////////////////////////////////////////////////
// This structure is passed when user is dragging sub object selection.
//////////////////////////////////////////////////////////////////////////
struct SSubObjSelectionModifyContext
{
CViewport* view;
ESubObjSelectionModifyType type;
Vec3 vValue;
Matrix34 worldRefFrame;
};
#endif // CRYINCLUDE_EDITOR_OBJECTS_SUBOBJSELECTION_H
-20
View File
@@ -11,9 +11,6 @@
#include "Plugin.h"
// Editor
#include "Include/IViewPane.h"
#include <QMessageBox>
CClassFactory* CClassFactory::s_pInstance = nullptr;
@@ -149,23 +146,6 @@ IClassDesc* CClassFactory::FindClass(const GUID& rClassID) const
return pClassDesc;
}
IViewPaneClass* CClassFactory::FindViewPaneClassByTitle(const char* pPaneTitle) const
{
for (size_t i = 0; i < m_classes.size(); i++)
{
IViewPaneClass* viewPane = nullptr;
IClassDesc* desc = m_classes[i];
if (SUCCEEDED(desc->QueryInterface(__az_uuidof(IViewPaneClass), (void**)&viewPane)))
{
if (QString::compare(viewPane->GetPaneTitle(), pPaneTitle) == 0)
{
return viewPane;
}
}
}
return nullptr;
}
void CClassFactory::UnregisterClass(const char* pClassName)
{
IClassDesc* pClassDesc = FindClass(pClassName);
-47
View File
@@ -15,45 +15,6 @@
#include "Util/GuidUtil.h"
#include <map>
//! Derive from this class to decrease the amount of work for creating a new class description
//! Provides standard reference counter implementation for IUnknown
class CRefCountClassDesc
: public IClassDesc
{
public:
virtual ~CRefCountClassDesc() { }
HRESULT STDMETHODCALLTYPE QueryInterface([[maybe_unused]] const IID& riid, [[maybe_unused]] void** ppvObj)
{
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE AddRef()
{
++m_nRefCount;
return m_nRefCount;
}
ULONG STDMETHODCALLTYPE Release()
{
int refs = m_nRefCount;
if (--m_nRefCount <= 0)
{
delete this;
}
return refs;
}
private:
int m_nRefCount;
};
// Use this for debugging unregistration problems.
//#define DEBUG_CLASS_NAME_REGISTRATION
//! Class factory is a common repository of all registered plugin classes,
//! Classes here can found by their class ID or all classes of given system class retrieved
class CRYEDIT_API CClassFactory
@@ -71,8 +32,6 @@ public:
IClassDesc* FindClass(const char* className) const;
//! Find class in the factory by class ID
IClassDesc* FindClass(const GUID& rClassID) const;
//! Find View Pane Class in the factory by pane title
IViewPaneClass* FindViewPaneClassByTitle(const char* pPaneTitle) const;
void UnregisterClass(const char* pClassName);
void UnregisterClass(const GUID& rClassID);
//! Get classes matching specific requirements ordered alphabetically by name.
@@ -135,10 +94,4 @@ public:
#define REGISTER_CLASS_DESC(ClassDesc) \
CAutoRegisterClassHelper g_AutoRegHelper##ClassDesc(new ClassDesc);
#define REGISTER_QT_CLASS_DESC(ClassDesc, name, category) \
CAutoRegisterClassHelper g_AutoRegHelper##ClassDesc(new CQtViewClass<ClassDesc>(name, category));
#define REGISTER_QT_CLASS_DESC_SYSTEM_ID(ClassDesc, name, category, systemid) \
CAutoRegisterClassHelper g_AutoRegHelper##ClassDesc(new CQtViewClass<ClassDesc>(name, category, systemid));
#endif // CRYINCLUDE_EDITOR_PLUGIN_H
@@ -14,7 +14,6 @@
#include "UI/QComponentEntityEditorOutlinerWindow.h"
#include "UI/QComponentLevelEntityEditorMainWindow.h"
#include "UI/ComponentPalette/ComponentPaletteSettings.h"
#include "UI/ComponentPalette/ComponentPaletteWindow.h"
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/Component/EntityUtils.h>
@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Manifest>
</Manifest>
@@ -69,7 +69,6 @@
#include "ISourceControl.h"
#include "UI/QComponentEntityEditorMainWindow.h"
#include <LmbrCentral/Rendering/EditorLightComponentBus.h>
#include <LmbrCentral/Scripting/TagComponentBus.h>
#include <LmbrCentral/Scripting/EditorTagComponentBus.h>
@@ -16,7 +16,6 @@
#include <qevent.h>
#include <qmimedata.h>
#include <LmbrCentral/Rendering/LensFlareAsset.h>
#include <LmbrCentral/Rendering/MeshAsset.h>
#include <AzCore/Memory/Memory.h>
@@ -1,97 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "CategoriesList.h"
ComponentCategoryList::ComponentCategoryList(QWidget* parent /*= nullptr*/)
: QTreeWidget(parent)
{
}
void ComponentCategoryList::Init()
{
setColumnCount(1);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setDragDropMode(QAbstractItemView::DragDropMode::DragOnly);
setDragEnabled(true);
setSelectionMode(QAbstractItemView::ExtendedSelection);
setAllColumnsShowFocus(true);
setStyleSheet("QTreeWidget { selection-background-color: rgba(255,255,255,0.2); }");
QStringList headers;
headers << tr("Categories");
setHeaderLabels(headers);
const QString parentCategoryIconPath = QString("Icons/PropertyEditor/Browse_on.png");
const QString categoryIconPath = QString("Icons/PropertyEditor/Browse.png");
QTreeWidgetItem* allCategory = new QTreeWidgetItem(this);
allCategory->setText(0, "All");
allCategory->setIcon(0, QIcon(categoryIconPath));
// Need this briefly to collect the list of available categories.
ComponentDataModel dataModel(this);
for (const auto& cat : dataModel.GetCategories())
{
QString categoryString = QString(cat.c_str());
QStringList categories = categoryString.split('/', Qt::SkipEmptyParts);
QTreeWidgetItem* parent = nullptr;
QTreeWidgetItem* categoryWidget = nullptr;
for (const auto& categoryName : categories)
{
if (parent)
{
categoryWidget = new QTreeWidgetItem(parent);
categoryWidget->setIcon(0, QIcon(categoryIconPath));
// Store the full category path in a user role because we'll need it to locate the actual category
categoryWidget->setData(0, Qt::UserRole, QVariant::fromValue(categoryString));
}
else
{
auto existingCategory = findItems(categoryName, Qt::MatchExactly);
if (existingCategory.empty())
{
categoryWidget = new QTreeWidgetItem(this);
categoryWidget->setIcon(0, QIcon(parentCategoryIconPath));
}
else
{
categoryWidget = static_cast<QTreeWidgetItem*>(existingCategory.first());
categoryWidget->setIcon(0, QIcon(parentCategoryIconPath));
}
}
parent = categoryWidget;
categoryWidget->setText(0, categoryName);
}
}
expandAll();
connect(this, &QTreeWidget::itemClicked, this, &ComponentCategoryList::OnItemClicked);
}
void ComponentCategoryList::OnItemClicked(QTreeWidgetItem* item, int /*column*/)
{
QVariant userData = item->data(0, Qt::UserRole);
if (userData.isValid())
{
// Send in the full category path, not just the child category name
emit OnCategoryChange(userData.value<QString>().toStdString().c_str());
}
else
{
emit OnCategoryChange(item->text(0).toStdString().c_str());
}
}
#include <UI/ComponentPalette/moc_CategoriesList.cpp>
@@ -1,39 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include "ComponentDataModel.h"
#include <QTreeWidget>
#endif
//! ComponentCategoryList
//! Provides a list of all reflected categories that users can select for quick
//! filtering the filtered component list.
class ComponentCategoryList : public QTreeWidget
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(ComponentCategoryList, AZ::SystemAllocator, 0);
explicit ComponentCategoryList(QWidget* parent = nullptr);
void Init();
Q_SIGNALS:
void OnCategoryChange(const char* category);
protected:
// Will emit OnCategoryChange signal
void OnItemClicked(QTreeWidgetItem* item, int column);
};
@@ -1,547 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "ComponentDataModel.h"
#include "Include/IObjectManager.h"
#include "Objects/SelectionGroup.h"
#include <AzCore/Component/Entity.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/ToolsComponents/ComponentMimeData.h>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#include <AzToolsFramework/Commands/EntityStateCommand.h>
#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
#include <AzToolsFramework/API/EntityCompositionRequestBus.h>
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
#include <Editor/IEditor.h>
#include <Editor/Viewport.h>
#include <Editor/ViewManager.h>
#include <CryCommon/MathConversion.h>
#include <AzQtComponents/DragAndDrop/ViewportDragAndDrop.h>
#include <QMimeData>
namespace
{
// This is a helper function that given an object that derives from QAbstractItemModel,
// it will request the model's "ClassDataRole" class data for an entry and use that
// information to create a new entity with the selected components.
AZ::EntityId CreateEntityFromSelection(const QModelIndexList& selection, QAbstractItemModel* model)
{
AZ::Vector3 position = AZ::Vector3::CreateZero();
CViewport *view = GetIEditor()->GetViewManager()->GetGameViewport();
int width, height;
view->GetDimensions(&width, &height);
position = LYVec3ToAZVec3(view->ViewToWorld(QPoint(width / 2, height / 2)));
AZ::EntityId newEntityId;
EBUS_EVENT_RESULT(newEntityId, AzToolsFramework::EditorRequests::Bus, CreateNewEntityAtPosition, position, AZ::EntityId());
if (newEntityId.IsValid())
{
// Add all the selected components.
AZ::ComponentTypeList componentsToAdd;
for (auto index : selection)
{
// We only need to consider the first column, it's important that the data() function that
// returns ComponentDataModel::ClassDataRole also does so for the first column.
if (index.column() != 0)
{
continue;
}
QVariant classDataVariant = model->data(index, ComponentDataModel::ClassDataRole);
if (classDataVariant.isValid())
{
const AZ::SerializeContext::ClassData* classData = reinterpret_cast<const AZ::SerializeContext::ClassData*>(classDataVariant.value<void*>());
componentsToAdd.push_back(classData->m_typeId);
}
}
AzToolsFramework::EntityCompositionRequestBus::Broadcast(&AzToolsFramework::EntityCompositionRequests::AddComponentsToEntities, AzToolsFramework::EntityIdList{ newEntityId }, componentsToAdd);
return newEntityId;
}
return AZ::EntityId();
}
}
namespace ComponentDataUtilities
{
// This is a helper function to add the specified components to the selected entities, it relies on the provided
// QAbstractItemModel to determine the appropriate ClassData to use to create the components (given that some widgets
// may provide proxy models that alter the order).
void AddComponentsToSelectedEntities(const QModelIndexList& selectedComponents, QAbstractItemModel* model)
{
AzToolsFramework::EntityIdList selectedEntities;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(selectedEntities, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
if (selectedEntities.empty())
{
return;
}
// Add all the selected components.
AZ::ComponentTypeList componentsToAdd;
for (auto index : selectedComponents)
{
// We only need to consider the first column, it's important that the data() function that
// returns ComponentDataModel::ClassDataRole also does so for the first column.
if (index.column() != 0)
{
continue;
}
QVariant classDataVariant = model->data(index, ComponentDataModel::ClassDataRole);
if (classDataVariant.isValid())
{
const AZ::SerializeContext::ClassData* classData = reinterpret_cast<const AZ::SerializeContext::ClassData*>(classDataVariant.value<void*>());
componentsToAdd.push_back(classData->m_typeId);
}
}
AzToolsFramework::EntityCompositionRequestBus::Broadcast(&AzToolsFramework::EntityCompositionRequests::AddComponentsToEntities, selectedEntities, componentsToAdd);
}
}
// ComponentDataModel
//////////////////////////////////////////////////////////////////////////
ComponentDataModel::ComponentDataModel(QObject* parent)
: QAbstractTableModel(parent)
{
AZ::SerializeContext* serializeContext = nullptr;
EBUS_EVENT_RESULT(serializeContext, AZ::ComponentApplicationBus, GetSerializeContext);
AZ_Assert(serializeContext, "Failed to acquire application serialize context.");
serializeContext->EnumerateDerived<AZ::Component>([this](const AZ::SerializeContext::ClassData* classData, const AZ::Uuid&) -> bool
{
bool allowed = false;
bool hidden = false;
AZStd::string category = "Miscellaneous";
if (classData->m_editData)
{
for (const AZ::Edit::ElementData& element : classData->m_editData->m_elements)
{
if (element.m_elementId == AZ::Edit::ClassElements::EditorData)
{
AZStd::string iconPath;
AzToolsFramework::EditorRequestBus::BroadcastResult(iconPath, &AzToolsFramework::EditorRequests::GetComponentTypeEditorIcon, classData->m_typeId);
if (!iconPath.empty())
{
m_componentIcons[classData->m_typeId] = QIcon(iconPath.c_str());
}
for (const AZ::Edit::AttributePair& attribPair : element.m_attributes)
{
if (attribPair.first == AZ::Edit::Attributes::AppearsInAddComponentMenu)
{
if (auto data = azdynamic_cast<AZ::Edit::AttributeData<AZ::Crc32>*>(attribPair.second))
{
if (data->Get(nullptr) == AZ_CRC("Game"))
{
allowed = true;
}
}
}
else if (attribPair.first == AZ::Edit::Attributes::AddableByUser)
{
// skip this component if user is not allowed to add it directly
if (auto data = azdynamic_cast<AZ::Edit::AttributeData<bool>*>(attribPair.second))
{
if (!data->Get(nullptr))
{
hidden = true;
}
}
}
else if (attribPair.first == AZ::Edit::Attributes::Category)
{
if (auto data = azdynamic_cast<AZ::Edit::AttributeData<const char*>*>(attribPair.second))
{
category = data->Get(nullptr);
}
}
}
break;
}
}
}
if (allowed && !hidden)
{
m_componentList.push_back(classData);
m_componentMap[category].push_back(classData);
m_categories.insert(category);
}
return true;
});
// we'd like viewport events
AzQtComponents::DragAndDropEventsBus::Handler::BusConnect(AzQtComponents::DragAndDropContexts::EditorViewport);
}
ComponentDataModel::~ComponentDataModel()
{
AzQtComponents::DragAndDropEventsBus::Handler::BusDisconnect();
}
Qt::ItemFlags ComponentDataModel::flags([[maybe_unused]] const QModelIndex &index) const
{
return Qt::ItemFlags(
Qt::ItemIsEnabled |
Qt::ItemIsDragEnabled |
Qt::ItemIsDropEnabled |
Qt::ItemIsSelectable);
}
const AZ::SerializeContext::ClassData* ComponentDataModel::GetClassData(const QModelIndex& index) const
{
int row = index.row();
if (row < 0 || row >= m_componentList.size())
{
return nullptr;
}
return m_componentList[row];
}
const char* ComponentDataModel::GetCategory(const AZ::SerializeContext::ClassData* classData)
{
if (classData)
{
if (auto editorDataElement = classData->m_editData->FindElementData(AZ::Edit::ClassElements::EditorData))
{
if (auto categoryAttribute = editorDataElement->FindAttribute(AZ::Edit::Attributes::Category))
{
if (auto categoryData = azdynamic_cast<AZ::Edit::AttributeData<const char*>*>(categoryAttribute))
{
const char* result = categoryData->Get(nullptr);
if (result)
{
return result;
}
}
}
}
}
return "";
}
QModelIndex ComponentDataModel::index(int row, int column, const QModelIndex &parent /*= QModelIndex()*/) const
{
if (row >= rowCount(parent) || column >= columnCount(parent))
{
return QModelIndex();
}
return createIndex(row, column, (void*)(m_componentList[row]));
}
QModelIndex ComponentDataModel::parent([[maybe_unused]] const QModelIndex &child) const
{
return QModelIndex();
}
int ComponentDataModel::rowCount([[maybe_unused]] const QModelIndex &parent /*= QModelIndex()*/) const
{
return static_cast<int>(m_componentList.size());
}
int ComponentDataModel::columnCount([[maybe_unused]] const QModelIndex &parent /*= QModelIndex()*/) const
{
return ColumnIndex::Count;
}
QVariant ComponentDataModel::data(const QModelIndex &index, int role /*= Qt::DisplayRole*/) const
{
if (index.isValid())
{
const AZ::SerializeContext::ClassData* classData = m_componentList[index.row()];
if (!classData)
{
return QVariant();
}
switch (role)
{
case ClassDataRole:
if (index.column() == 0) // Only get data for one column
{
return QVariant::fromValue<void*>(reinterpret_cast<void*>(const_cast<AZ::SerializeContext::ClassData*>(classData)));
}
break;
case Qt::DisplayRole:
{
if (index.column() == ColumnIndex::Name)
{
return QVariant(classData->m_editData->m_name);
}
else
if (index.column() == ColumnIndex::Category)
{
if (auto editorDataElement = classData->m_editData->FindElementData(AZ::Edit::ClassElements::EditorData))
{
if (auto categoryAttribute = editorDataElement->FindAttribute(AZ::Edit::Attributes::Category))
{
if (auto categoryData = azdynamic_cast<const AZ::Edit::AttributeData<const char*>*>(categoryAttribute))
{
return QVariant(categoryData->Get(nullptr));
}
}
}
}
}
break;
case Qt::ToolTipRole:
{
return QVariant(classData->m_editData->m_description);
}
case Qt::DecorationRole:
{
if (index.column() == ColumnIndex::Icon)
{
auto iconIterator = m_componentIcons.find(classData->m_typeId);
if (iconIterator != m_componentIcons.end())
{
return iconIterator->second;
}
}
}
break;
default:
break;
}
}
return QVariant();
}
QMimeData* ComponentDataModel::mimeData(const QModelIndexList& indices) const
{
QModelIndexList list;
// Filter out columns we are not interested in.
for (const QModelIndex& index : indices)
{
if (index.column() == 0)
{
list.push_back(index);
}
}
AZStd::vector<const AZ::SerializeContext::ClassData*> sortedList;
for (QModelIndex index : list)
{
QVariant classDataVariant = index.data(ComponentDataModel::ClassDataRole);
if (classDataVariant.isValid())
{
const AZ::SerializeContext::ClassData* classData = reinterpret_cast<const AZ::SerializeContext::ClassData*>(classDataVariant.value<void*>());
sortedList.push_back(classData);
}
}
QMimeData* mimeData = nullptr;
if (!sortedList.empty())
{
mimeData = AzToolsFramework::ComponentTypeMimeData::Create(sortedList).release();
}
return mimeData;
}
bool ComponentDataModel::CanAcceptDragAndDropEvent(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context) const
{
using namespace AzToolsFramework;
using namespace AzQtComponents;
// if a listener with a higher priority already claimed this event, do not touch it.
if ((!event) || (event->isAccepted()) || (!event->mimeData()))
{
return false;
}
ViewportDragContext* contextVP = azrtti_cast<ViewportDragContext*>(&context);
if (!contextVP)
{
// not a viewport event. This is for some other GUI such as the main window itself.
return false;
}
AZStd::vector<const AZ::SerializeContext::ClassData*> componentClassDataList;
return AzToolsFramework::ComponentTypeMimeData::Get(event->mimeData(), componentClassDataList);
}
void ComponentDataModel::DragEnter(QDragEnterEvent* event, AzQtComponents::DragAndDropContextBase& context)
{
if (CanAcceptDragAndDropEvent(event, context))
{
event->setDropAction(Qt::CopyAction);
event->setAccepted(true);
// opportunities to show special highlights, or ghosted entities or previews here.
}
}
void ComponentDataModel::DragMove(QDragMoveEvent* event, AzQtComponents::DragAndDropContextBase& context)
{
if (CanAcceptDragAndDropEvent(event, context))
{
event->setDropAction(Qt::CopyAction);
event->setAccepted(true);
// opportunities to update special highlights, or ghosted entities or previews here.
}
}
void ComponentDataModel::DragLeave(QDragLeaveEvent* /*event*/)
{
// opportunities to remove ghosted entities or previews here.
}
void ComponentDataModel::Drop(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context)
{
using namespace AzToolsFramework;
using namespace AzQtComponents;
// ALWAYS CHECK - you are not the only one connected to this bus, and someone else may have already
// handled the event or accepted the drop - it might not contain types relevant to you.
// you still get informed about the drop event in case you did some stuff in your gui and need to clean it up.
if (!CanAcceptDragAndDropEvent(event, context))
{
return;
}
// note that the above call already checks all the pointers such as event, or whether context is a VP context, mimetype, etc
ViewportDragContext* contextVP = azrtti_cast<ViewportDragContext*>(&context);
// we don't get given this action by Qt unless we already returned accepted from one of the other ones (such as drag move of drag enter)
event->setDropAction(Qt::CopyAction);
event->setAccepted(true);
AzToolsFramework::ScopedUndoBatch undo("Create entity from components");
const AZStd::string name = AZStd::string::format("Entity%d", GetIEditor()->GetObjectManager()->GetObjectCount());
AZ::Entity* newEntity = aznew AZ::Entity(name.c_str());
if (newEntity)
{
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(&AzToolsFramework::EditorEntityContextRequests::AddRequiredComponents, *newEntity);
auto* transformComponent = newEntity->FindComponent<AzToolsFramework::Components::TransformComponent>();
if (transformComponent)
{
transformComponent->SetWorldTM(AZ::Transform::CreateTranslation(contextVP->m_hitLocation));
}
// Add the entity to the editor context, which activates it and creates the sandbox object.
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(&AzToolsFramework::EditorEntityContextRequests::AddEditorEntity, newEntity);
// Prepare undo command last so it captures the final state of the entity.
AzToolsFramework::EntityCreateCommand* command = aznew AzToolsFramework::EntityCreateCommand(static_cast<AZ::u64>(newEntity->GetId()));
command->Capture(newEntity);
command->SetParent(undo.GetUndoBatch());
// Only need to add components to the new entity
AzToolsFramework::EntityIdList entities = { newEntity->GetId() };
AZStd::vector<const AZ::SerializeContext::ClassData*> componentClassDataList;
AzToolsFramework::ComponentTypeMimeData::Get(event->mimeData(), componentClassDataList);
AZ::ComponentTypeList componentsToAdd;
for (auto classData : componentClassDataList)
{
if (!classData)
{
continue;
}
componentsToAdd.push_back(classData->m_typeId);
}
AzToolsFramework::EntityCompositionRequests::AddComponentsOutcome addedComponentsResult = AZ::Failure(AZStd::string("Failed to call AddComponentsToEntities on EntityCompositionRequestBus"));
AzToolsFramework::EntityCompositionRequestBus::BroadcastResult(addedComponentsResult, &AzToolsFramework::EntityCompositionRequests::AddComponentsToEntities, entities, componentsToAdd);
ToolsApplicationRequests::Bus::Broadcast(&ToolsApplicationRequests::AddDirtyEntity, newEntity->GetId());
AzToolsFramework::ToolsApplicationRequestBus::Broadcast(&AzToolsFramework::ToolsApplicationRequests::SetSelectedEntities, entities);
}
}
AZ::EntityId ComponentDataProxyModel::NewEntityFromSelection(const QModelIndexList& selection)
{
return CreateEntityFromSelection(selection, this);
}
AZ::EntityId ComponentDataModel::NewEntityFromSelection(const QModelIndexList& selection)
{
return CreateEntityFromSelection(selection, this);
}
bool ComponentDataProxyModel::filterAcceptsRow(int sourceRow, [[maybe_unused]] const QModelIndex &sourceParent) const
{
if (m_selectedCategory.empty() && !filterRegExp().isValid())
return true;
ComponentDataModel* dataModel = static_cast<ComponentDataModel*>(sourceModel());
if (sourceRow < 0 || sourceRow >= dataModel->GetComponents().size())
{
return false;
}
const AZ::SerializeContext::ClassData* classData = dataModel->GetComponents()[sourceRow];
if (!classData)
{
return false;
}
// Get Category
if (!m_selectedCategory.empty())
{
AZStd::string currentCateogry = ComponentDataModel::GetCategory(classData);
if (AzFramework::StringFunc::Find(currentCateogry.c_str(), m_selectedCategory.c_str()))
{
return false;
}
}
if (filterRegExp().isValid())
{
QString componentName = QString::fromUtf8(classData->m_editData->m_name);
return componentName.contains(filterRegExp());
}
return true;
}
void ComponentDataProxyModel::SetSelectedCategory(const AZStd::string& category)
{
m_selectedCategory = category;
invalidate();
}
void ComponentDataProxyModel::ClearSelectedCategory()
{
m_selectedCategory.clear();
invalidate();
}
#include "UI/ComponentPalette/moc_ComponentDataModel.cpp"
@@ -1,128 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
#include <AzCore/EBus/EBus.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Component/EntityId.h>
#include <AzCore/std/containers/set.h>
#include <AzCore/std/containers/vector.h>
#include <AzQtComponents/Buses/DragAndDrop.h>
#endif
namespace ComponentDataUtilities
{
// Given a list of selected components, use the provided model to get the components to add to any selected entities.
void AddComponentsToSelectedEntities(const QModelIndexList& selectedComponents, QAbstractItemModel* model);
}
class CViewport;
//! ComponentDataModel
//! Holds the data required to display components in a table, this includes component name, categories, icons.
class ComponentDataModel
: public QAbstractTableModel
, protected AzQtComponents::DragAndDropEventsBus::Handler // its okay if more than one of these is installed, the first one gets it.
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(ComponentDataModel, AZ::SystemAllocator, 0);
using ComponentClassList = AZStd::vector<const AZ::SerializeContext::ClassData*>;
using ComponentCategorySet = AZStd::set<AZStd::string>;
using ComponentClassMap = AZStd::unordered_map<AZStd::string, AZStd::vector<const AZ::SerializeContext::ClassData*>>;
using ComponentIconMap = AZStd::unordered_map<AZ::Uuid, QIcon>;
enum ColumnIndex
{
Icon,
Category,
Name,
Count
};
enum CustomRoles
{
ClassDataRole = Qt::UserRole + 1
};
ComponentDataModel(QObject* parent = nullptr);
~ComponentDataModel() override;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &child) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QMimeData* mimeData(const QModelIndexList& indexes) const override;
const AZ::SerializeContext::ClassData* GetClassData(const QModelIndex&) const;
AZ::EntityId NewEntityFromSelection(const QModelIndexList& selection);
static const char* GetCategory(const AZ::SerializeContext::ClassData* classData);
ComponentClassList& GetComponents() { return m_componentList; }
ComponentCategorySet& GetCategories() { return m_categories; }
protected:
//////////////////////////////////////////////////////////////////////////
// AzQtComponents::DragAndDropEventsBus::Handler
//////////////////////////////////////////////////////////////////////////
void DragEnter(QDragEnterEvent* event, AzQtComponents::DragAndDropContextBase& context) override;
void DragMove(QDragMoveEvent* event, AzQtComponents::DragAndDropContextBase& context) override;
void DragLeave(QDragLeaveEvent* event) override;
void Drop(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context) override;
bool CanAcceptDragAndDropEvent(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context) const;
ComponentClassList m_componentList;
ComponentClassMap m_componentMap;
ComponentIconMap m_componentIcons;
ComponentCategorySet m_categories;
};
//! ComponentDataProxyModel
//! FilterProxy for the ComponentDataModel is used along with the search criteria to filter the
//! list of components based on tags and/or selected category.
class ComponentDataProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(ComponentDataProxyModel, AZ::SystemAllocator, 0);
ComponentDataProxyModel(QObject* parent = nullptr)
: QSortFilterProxyModel(parent)
{}
// Creates a new entity and adds the selected components to it.
// It is specialized here to ensure it uses the correct indices according to the sorted data.
AZ::EntityId NewEntityFromSelection(const QModelIndexList& selection);
// Filters rows according to the specifed tags and/or selected category
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
// Set the category to filter by.
void SetSelectedCategory(const AZStd::string& category);
void ClearSelectedCategory();
protected:
AZStd::string m_selectedCategory;
};
@@ -1,116 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "ComponentPaletteWindow.h"
#include "ComponentDataModel.h"
#include "FavoriteComponentList.h"
#include "FilteredComponentList.h"
#include "CategoriesList.h"
#include <LyViewPaneNames.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzToolsFramework/UI/SearchWidget/SearchCriteriaWidget.hxx>
#include <AzToolsFramework/ToolsComponents/ComponentMimeData.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/API/ViewPaneOptions.h>
#include <QLabel>
#include <QKeyEvent>
ComponentPaletteWindow::ComponentPaletteWindow(QWidget* parent)
: QMainWindow(parent)
{
Init();
}
void ComponentPaletteWindow::Init()
{
layout()->setSizeConstraint(QLayout::SetMinimumSize);
QVBoxLayout* layout = new QVBoxLayout();
layout->setSizeConstraint(QLayout::SetMinimumSize);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
QHBoxLayout* gridLayout = new QHBoxLayout(nullptr);
gridLayout->setSizeConstraint(QLayout::SetMaximumSize);
gridLayout->setContentsMargins(0, 0, 0, 0);
gridLayout->setSpacing(0);
m_filterWidget = new AzToolsFramework::SearchCriteriaWidget(this);
QStringList tags;
tags << tr("name");
m_filterWidget->SetAcceptedTags(tags, tags[0]);
layout->addLayout(gridLayout, 1);
// Left Panel
QVBoxLayout* leftPaneLayout = new QVBoxLayout(this);
// Favorites
leftPaneLayout->addWidget(new QLabel(tr("Favorites")));
leftPaneLayout->addWidget(new QLabel(tr("Drag components here to add favorites.")));
FavoritesList* favorites = new FavoritesList();
favorites->Init();
leftPaneLayout->addWidget(favorites);
// Categories
m_categoryListWidget = new ComponentCategoryList();
m_categoryListWidget->Init();
leftPaneLayout->addWidget(m_categoryListWidget);
gridLayout->addLayout(leftPaneLayout);
// Right Panel
QVBoxLayout* rightPanelLayout = new QVBoxLayout(this);
gridLayout->addLayout(rightPanelLayout);
// Component list
m_componentListWidget = new FilteredComponentList(this);
m_componentListWidget->Init();
rightPanelLayout->addWidget(new QLabel(tr("Components")));
rightPanelLayout->addWidget(m_filterWidget, 0, Qt::AlignTop);
rightPanelLayout->addWidget(m_componentListWidget);
// The main window
QWidget* window = new QWidget();
window->setLayout(layout);
setCentralWidget(window);
connect(m_categoryListWidget, &ComponentCategoryList::OnCategoryChange, m_componentListWidget, &FilteredComponentList::SetCategory);
connect(m_filterWidget, &AzToolsFramework::SearchCriteriaWidget::SearchCriteriaChanged, m_componentListWidget, &FilteredComponentList::SearchCriteriaChanged);
}
void ComponentPaletteWindow::keyPressEvent(QKeyEvent* event)
{
if (event->modifiers().testFlag(Qt::ControlModifier) && event->key() == Qt::Key_F)
{
m_filterWidget->SelectTextEntryBox();
}
else
{
QMainWindow::keyPressEvent(event);
}
}
void ComponentPaletteWindow::RegisterViewClass()
{
using namespace AzToolsFramework;
ViewPaneOptions options;
options.canHaveMultipleInstances = true;
RegisterViewPane<ComponentPaletteWindow>("Component Palette", LyViewPane::CategoryOther, options);
}
#include <UI/ComponentPalette/moc_ComponentPaletteWindow.cpp>
@@ -1,59 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <AzCore/PlatformIncl.h>
#include <QMainWindow>
#include <AzCore/Math/Guid.h>
#endif
namespace AzToolsFramework
{
class SearchCriteriaWidget;
}
class ComponentCategoryList;
class FilteredComponentList;
class ComponentDataModel;
//! ComponentPaletteWindow
//! Provides a window with controls related to the Component Entity system. It provides an intuitive and organized
//! set of controls to display, sort, filter components. It provides mechanisms for creating entities by dragging
//! and dropping components into the viewport as well as from context menus.
class ComponentPaletteWindow
: public QMainWindow
{
Q_OBJECT
public:
explicit ComponentPaletteWindow(QWidget* parent = 0);
void Init();
static const GUID& GetClassID()
{
// {4236998F-1138-466D-9DF5-6533BFA1DFCA}
static const GUID guid =
{
0x4236998F, 0x1138, 0x466D, { 0x9D, 0xF5, 0x65, 0x33, 0xBF, 0xA1, 0xDF, 0xCA }
};
return guid;
}
static void RegisterViewClass();
protected:
ComponentCategoryList* m_categoryListWidget;
FilteredComponentList* m_componentListWidget;
AzToolsFramework::SearchCriteriaWidget* m_filterWidget;
void keyPressEvent(QKeyEvent* event) override;
};
@@ -1,392 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "FavoriteComponentList.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <Editor/CryEditDoc.h>
#include <Editor/ViewManager.h>
#include <QHeaderView>
#include <QMimeData>
// FavoritesList
//////////////////////////////////////////////////////////////////////////
FavoritesList::FavoritesList(QWidget* parent /*= nullptr*/)
: FilteredComponentList(parent)
{
}
FavoritesList::~FavoritesList()
{
FavoriteComponentListRequestBus::Handler::BusDisconnect();
}
void FavoritesList::Init()
{
FavoriteComponentListRequestBus::Handler::BusConnect();
FavoritesDataModel* favoritesDataModel = new FavoritesDataModel(this);
setModel(favoritesDataModel);
horizontalHeader()->setSectionResizeMode(ComponentDataModel::ColumnIndex::Name, QHeaderView::Stretch);
setShowGrid(false);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setSelectionMode(QAbstractItemView::SelectionMode::ExtendedSelection);
setStyleSheet("QTableView { selection-background-color: rgba(255,255,255,0.2); }");
setGridStyle(Qt::PenStyle::NoPen);
verticalHeader()->hide();
horizontalHeader()->hide();
setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
setShowGrid(false);
setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
setColumnWidth(ComponentDataModel::ColumnIndex::Icon, 32);
hideColumn(ComponentDataModel::ColumnIndex::Category);
setDragDropMode(QAbstractItemView::DragDrop);
setAcceptDrops(true);
horizontalHeader()->setSectionResizeMode(ComponentDataModel::ColumnIndex::Icon, QHeaderView::ResizeToContents);
setColumnWidth(ComponentDataModel::ColumnIndex::Icon, 32);
horizontalHeader()->setSectionResizeMode(ComponentDataModel::ColumnIndex::Category, QHeaderView::Stretch);
setColumnWidth(ComponentDataModel::ColumnIndex::Category, 90);
// Context menu
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &QWidget::customContextMenuRequested, this, &FavoritesList::ShowContextMenu);
}
void FavoritesList::ShowContextMenu(const QPoint& pos)
{
// Only show if a level is loaded
if (!GetIEditor() || GetIEditor()->IsInGameMode())
{
return;
}
if ( model()->rowCount() == 0)
{
return;
}
QMenu contextMenu(tr("Context menu"), this);
QAction actionNewEntity(tr("Make entity with selected favorites"), this);
QAction actionAddToSelection(this);
if (GetIEditor()->GetDocument()->IsDocumentReady())
{
QObject::connect(&actionNewEntity, &QAction::triggered, this, [&] { ContextMenu_NewEntity(); });
contextMenu.addAction(&actionNewEntity);
AzToolsFramework::EntityIdList selectedEntities;
EBUS_EVENT_RESULT(selectedEntities, AzToolsFramework::ToolsApplicationRequests::Bus, GetSelectedEntities);
if (!selectedEntities.empty())
{
QString addToSelection = selectedEntities.size() > 1 ? tr("Add to selected entities") : tr("Add to selected entity");
actionAddToSelection.setText(addToSelection);
QObject::connect(&actionAddToSelection, &QAction::triggered, this, [&] { ContextMenu_AddToSelectedEntities(); });
contextMenu.addAction(&actionAddToSelection);
}
contextMenu.addSeparator();
}
QAction action(tr("Remove"), this);
QObject::connect(&action, &QAction::triggered, this, [&] { ContextMenu_RemoveSelectedFavorites(); });
contextMenu.addAction(&action);
contextMenu.exec(mapToGlobal(pos));
}
void FavoritesList::ContextMenu_RemoveSelectedFavorites()
{
FavoritesDataModel* dataModel = qobject_cast<FavoritesDataModel*>(model());
if (!selectedIndexes().empty())
{
dataModel->Remove(selectedIndexes());
}
}
void FavoritesList::rowsInserted([[maybe_unused]] const QModelIndex& parent, [[maybe_unused]] int start, [[maybe_unused]] int end)
{
resizeRowToContents(0);
}
void FavoritesList::AddFavorites(const AZStd::vector<const AZ::SerializeContext::ClassData*>& classDataContainer)
{
for (const AZ::SerializeContext::ClassData* classData : classDataContainer)
{
if (classData)
{
FavoritesDataModel* dataModel = qobject_cast<FavoritesDataModel*>(model());
dataModel->AddFavorite(classData);
}
}
}
void FavoritesList::dragEnterEvent(QDragEnterEvent* event)
{
if (event->mimeData()->hasFormat(AzToolsFramework::ComponentTypeMimeData::GetMimeType()))
{
event->acceptProposedAction();
}
}
void FavoritesList::dragMoveEvent(QDragMoveEvent* event)
{
if (event->source() == this)
{
event->ignore();
}
else
{
event->accept();
}
}
// FavoritesDataModel
//////////////////////////////////////////////////////////////////////////
int FavoritesDataModel::rowCount([[maybe_unused]] const QModelIndex &parent /*= QModelIndex()*/) const
{
return m_favorites.size();
}
int FavoritesDataModel::columnCount([[maybe_unused]] const QModelIndex &parent /*= QModelIndex()*/) const
{
return ColumnIndex::Count;
}
void FavoritesDataModel::SaveState()
{
AZStd::vector<AZ::Uuid> favorites;
for (const AZ::SerializeContext::ClassData* classData : m_favorites)
{
favorites.push_back(classData->m_typeId);
}
m_settings->SetFavorites(AZStd::move(favorites));
// Write the settings to file...
AZ::SerializeContext* serializeContext = nullptr;
EBUS_EVENT_RESULT(serializeContext, AZ::ComponentApplicationBus, GetSerializeContext);
AZ_Assert(serializeContext, "Serialize Context is null!");
char settingsPath[AZ_MAX_PATH_LEN] = { 0 };
AZ::IO::FileIOBase::GetInstance()->ResolvePath(ComponentPaletteSettings::GetSettingsFile(), settingsPath, AZ_MAX_PATH_LEN);
bool result = m_provider.Save(settingsPath, serializeContext);
(void)result;
AZ_Warning("ComponentPaletteSettings", result, "Failed to Save the Component Palette Settings!");
}
void FavoritesDataModel::LoadState()
{
// It is necessary to Load the settings file *before* you call UserSettings::CreateFind!
AZ::SerializeContext* serializeContext = nullptr;
EBUS_EVENT_RESULT(serializeContext, AZ::ComponentApplicationBus, GetSerializeContext);
AZ_Assert(serializeContext, "Serialize Context is null!");
char settingsPath[AZ_MAX_PATH_LEN] = { 0 };
AZ::IO::FileIOBase::GetInstance()->ResolvePath(ComponentPaletteSettings::GetSettingsFile(), settingsPath, AZ_MAX_PATH_LEN);
bool result = m_provider.Load(settingsPath, serializeContext);
(void)result;
// Create (if no file was found) or find the settings, this will populate the m_settings->m_favorites list.
m_settings = AZ::UserSettings::CreateFind<ComponentPaletteSettings>(AZ_CRC("ComponentPaletteSettings", 0x481d355b), m_providerId);
// Add favorites to the data model from loaded settings
for (const AZ::Uuid& favorite : m_settings->m_favorites)
{
const AZ::SerializeContext::ClassData* classData = serializeContext->FindClassData(favorite);
if (classData)
{
AddFavorite(classData, false);
}
}
}
void FavoritesDataModel::Remove(const QModelIndexList& indices)
{
beginResetModel();
auto newFavorites = m_favorites;
// swap here
for (auto index : indices)
{
// we're only dealing with columns and they're the only thing with class data anyways
if (index.column() == 0)
{
QVariant classDataVariant = index.data(ComponentDataModel::ClassDataRole);
if (classDataVariant.isValid())
{
const AZ::SerializeContext::ClassData* classData = reinterpret_cast<const AZ::SerializeContext::ClassData*>(classDataVariant.value<void*>());
newFavorites.removeAll(classData);
AZ_TracePrintf("Debug", "Removing: %s\n", classData->m_editData->m_name);
}
}
}
m_favorites.swap(newFavorites);
endResetModel();
SaveState();
}
QModelIndex FavoritesDataModel::index(int row, int column, const QModelIndex &parent) const
{
if (!hasIndex(row, column, parent))
{
return QModelIndex();
}
if (row >= rowCount(parent) || column >= columnCount(parent))
{
return QModelIndex();
}
return createIndex(row, column, (void*)(m_favorites[row]));
}
QVariant FavoritesDataModel::data(const QModelIndex &index, int role /*= Qt::DisplayRole*/) const
{
if (!index.isValid())
{
return QVariant();
}
const AZ::SerializeContext::ClassData* classData = m_favorites[index.row()];
if (!classData)
{
return QVariant();
}
switch (role)
{
case Qt::DisplayRole:
{
if (index.column() == ComponentDataModel::ColumnIndex::Name)
{
if (m_favorites.empty())
{
return QVariant(tr("You have 0 favorites.\nDrag some components here."));
}
return QVariant(classData->m_editData->m_name);
}
}
break;
case Qt::DecorationRole:
{
if (index.column() == ColumnIndex::Icon)
{
const AZ::SerializeContext::ClassData* iconClassData = m_favorites[index.row()];
auto iconIterator = m_componentIcons.find(iconClassData->m_typeId);
if (iconIterator != m_componentIcons.end())
{
return iconIterator->second;
}
return QVariant();
}
}
break;
case ClassDataRole:
if (index.column() == 0) // Only get data for one column
{
return QVariant::fromValue<void*>(reinterpret_cast<void*>(const_cast<AZ::SerializeContext::ClassData*>(classData)));
}
break;
default:
break;
}
return ComponentDataModel::data(index, role);
}
void FavoritesDataModel::SetSavedStateKey([[maybe_unused]] AZ::u32 key)
{
}
FavoritesDataModel::FavoritesDataModel(QWidget* parent /*= nullptr*/)
: ComponentDataModel(parent)
, m_providerId(AZ_CRC("ComponentPaletteSettingsProviderId"))
{
m_provider.Activate(m_providerId);
LoadState();
}
FavoritesDataModel::~FavoritesDataModel()
{
m_provider.Deactivate();
}
void FavoritesDataModel::AddFavorite(const AZ::SerializeContext::ClassData* classData, bool updateSettings)
{
beginResetModel();
if (m_favorites.indexOf(classData) < 0)
{
m_favorites.push_back(classData);
}
endResetModel();
if (updateSettings)
{
SaveState();
}
}
bool FavoritesDataModel::dropMimeData(const QMimeData *data, Qt::DropAction action, [[maybe_unused]] int row, [[maybe_unused]] int column, [[maybe_unused]] const QModelIndex &parent)
{
if (action == Qt::IgnoreAction)
{
return true;
}
if (data && data->hasFormat(AzToolsFramework::ComponentTypeMimeData::GetMimeType()))
{
AzToolsFramework::ComponentTypeMimeData::ClassDataContainer classDataContainer;
AzToolsFramework::ComponentTypeMimeData::Get(data, classDataContainer);
for (const AZ::SerializeContext::ClassData* classData : classDataContainer)
{
if (classData)
{
AddFavorite(classData);
}
}
return true;
}
return false;
}
#include <UI/ComponentPalette/moc_FavoriteComponentList.cpp>
@@ -1,117 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include "ComponentDataModel.h"
#include "FilteredComponentList.h"
#include "ComponentPaletteSettings.h"
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/UserSettings/UserSettingsProvider.h>
#include <AzToolsFramework/ToolsComponents/ComponentMimeData.h>
#include <AzToolsFramework/ToolsComponents/ComponentAssetMimeDataContainer.h>
#endif
//! FavoriteComponentListRequest
//! Bus that provides a way for external features to record favorites
class FavoriteComponentListRequest : public AZ::EBusTraits
{
public:
virtual void AddFavorites(const AZStd::vector<const AZ::SerializeContext::ClassData*>&) = 0;
};
using FavoriteComponentListRequestBus = AZ::EBus<FavoriteComponentListRequest>;
//! FavoritesDataModel
//! Stores the list of component class data to display in the favorites control, offers persistence through user settings.
class FavoritesDataModel
: public ComponentDataModel
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(FavoritesDataModel, AZ::SystemAllocator, 0);
FavoritesDataModel(QWidget* parent = nullptr);
~FavoritesDataModel() override;
//! Add a favorite component
//! \param classData The ClassData information for the component to store as favorite
//! \param updateSettings Optional parameter used to determine if the persistent settings need to be updated.
void AddFavorite(const AZ::SerializeContext::ClassData* classData, bool updateSettings = true);
//! Remove all the specified items from the table
//! \param indices List of indices to remove from favorites
void Remove(const QModelIndexList& indices);
//! Save the list of favorite components to user settings
void SaveState();
//! Load the list of favorite components from user settings
void LoadState();
protected:
void SetSavedStateKey(AZ::u32 key);
// Qt handlers
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
// List of component class data
QList<const AZ::SerializeContext::ClassData*> m_favorites;
// The Palette settings and provider information for saving out the Favorites list
AZStd::intrusive_ptr<ComponentPaletteSettings> m_settings;
AZ::UserSettingsProvider m_provider;
AZ::u32 m_providerId;
};
//! FavoritesList
//! User customized list of favorite components, provides persistence.
class FavoritesList
: public FilteredComponentList
, FavoriteComponentListRequestBus::Handler
{
Q_OBJECT
public:
explicit FavoritesList(QWidget* parent = nullptr);
~FavoritesList() override;
void Init() override;
protected:
//////////////////////////////////////////////////////////////////////////
// FavoriteComponentListRequestBus
void AddFavorites(const AZStd::vector<const AZ::SerializeContext::ClassData*>& classDataContainer) override;
//////////////////////////////////////////////////////////////////////////
void rowsInserted(const QModelIndex& parent, int start, int end) override;
// Context menu handlers
void ShowContextMenu(const QPoint&);
void ContextMenu_RemoveSelectedFavorites();
// Validate data being dragged in
void dragEnterEvent(QDragEnterEvent * event) override;
void dragMoveEvent(QDragMoveEvent* event) override;
//! Handler used when dropping PaletteItems into the Viewport.
static void DragDropHandler(CViewport* viewport, int ptx, int pty, void* custom);
};
@@ -1,264 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "ComponentDataModel.h"
#include "FavoriteComponentList.h"
#include "FilteredComponentList.h"
#include "CryCommon/MathConversion.h"
#include "Editor/IEditor.h"
#include "Editor/ViewManager.h"
#include <Editor/CryEditDoc.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <QHeaderView>
void FilteredComponentList::Init()
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setDragDropMode(QAbstractItemView::DragDropMode::DragOnly);
setDragEnabled(true);
setSelectionMode(QAbstractItemView::SelectionMode::ExtendedSelection);
setStyleSheet("QTreeWidget { selection-background-color: rgba(255,255,255,0.2); }");
setGridStyle(Qt::PenStyle::NoPen);
verticalHeader()->hide();
horizontalHeader()->hide();
setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
setAcceptDrops(false);
m_componentDataModel = new ComponentDataModel(this);
ComponentDataProxyModel* componentDataProxyModel = new ComponentDataProxyModel(this);
componentDataProxyModel->setSourceModel(m_componentDataModel);
setModel(componentDataProxyModel);
QHeaderView* horizontalHeaderView = horizontalHeader();
horizontalHeaderView->setSectionResizeMode(ComponentDataModel::ColumnIndex::Icon, QHeaderView::ResizeToContents);
horizontalHeaderView->setSectionResizeMode(ComponentDataModel::ColumnIndex::Name, QHeaderView::Stretch);
setColumnWidth(ComponentDataModel::ColumnIndex::Icon, 32);
setShowGrid(false);
setColumnWidth(ComponentDataModel::ColumnIndex::Name, 90);
setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
sortByColumn(ComponentDataModel::ColumnIndex::Name, Qt::AscendingOrder);
hideColumn(ComponentDataModel::ColumnIndex::Category);
connect(model(), &QAbstractItemModel::rowsInserted, this, &FilteredComponentList::rowsInserted);
connect(model(), &QAbstractItemModel::rowsRemoved, this, &FilteredComponentList::rowsAboutToBeRemoved);
connect(model(), SIGNAL(modelReset()), SLOT(modelReset()));
// Context menu
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &QWidget::customContextMenuRequested, this, &FilteredComponentList::ShowContextMenu);
}
void FilteredComponentList::ContextMenu_NewEntity()
{
AZ::EntityId entityId;
auto proxyDataModel = qobject_cast<ComponentDataProxyModel*>(model());
if (proxyDataModel)
{
entityId = proxyDataModel->NewEntityFromSelection(selectedIndexes());
}
else
{
auto dataModel = qobject_cast<ComponentDataModel*>(model());
if (dataModel)
{
entityId = dataModel->NewEntityFromSelection(selectedIndexes());
}
}
}
void FilteredComponentList::ContextMenu_AddToFavorites()
{
AZStd::vector<const AZ::SerializeContext::ClassData*> componentsToAdd;
for (auto index : selectedIndexes())
{
QVariant classDataVariant = index.data(ComponentDataModel::ClassDataRole);
if (classDataVariant.isValid())
{
auto classData = reinterpret_cast<const AZ::SerializeContext::ClassData*>(classDataVariant.value<void*>());
componentsToAdd.push_back(classData);
}
}
if (!componentsToAdd.empty())
{
EBUS_EVENT(FavoriteComponentListRequestBus, AddFavorites, componentsToAdd);
}
}
void FilteredComponentList::ContextMenu_AddToSelectedEntities()
{
ComponentDataUtilities::AddComponentsToSelectedEntities(selectedIndexes(), model());
}
void FilteredComponentList::ShowContextMenu(const QPoint& pos)
{
QMenu contextMenu(tr("Context menu"), this);
QAction actionNewEntity(tr("Create new entity with selected components"), this);
if (GetIEditor()->GetDocument()->IsDocumentReady())
{
QObject::connect(&actionNewEntity, &QAction::triggered, this, [this] { ContextMenu_NewEntity(); });
contextMenu.addAction(&actionNewEntity);
}
QAction actionAddFavorite(tr("Add to favorites"), this);
QObject::connect(&actionAddFavorite, &QAction::triggered, this, [this] { ContextMenu_AddToFavorites(); });
contextMenu.addAction(&actionAddFavorite);
QAction actionAddToSelection(this);
if (GetIEditor()->GetDocument()->IsDocumentReady())
{
AzToolsFramework::EntityIdList selectedEntities;
EBUS_EVENT_RESULT(selectedEntities, AzToolsFramework::ToolsApplicationRequests::Bus, GetSelectedEntities);
if (!selectedEntities.empty())
{
QString addToSelection = selectedEntities.size() > 1 ? tr("Add to selected entities") : tr("Add to selected entity");
actionAddToSelection.setText(addToSelection);
QObject::connect(&actionAddToSelection, &QAction::triggered, this, [this] { ContextMenu_AddToSelectedEntities(); });
contextMenu.addAction(&actionAddToSelection);
}
}
// TODO: Requires information panel implementation LMBR-28174
//QAction actionHelp(tr("Help"), this);
//QObject::connect(&actionHelp, &QAction::triggered, this, [&] {});
//contextMenu.addAction(&actionHelp);
contextMenu.exec(mapToGlobal(pos));
}
void FilteredComponentList::modelReset()
{
// Ensure that the category column is hidden
hideColumn(ComponentDataModel::ColumnIndex::Category);
}
FilteredComponentList::FilteredComponentList(QWidget* parent /*= nullptr*/)
: QTableView(parent)
{
}
FilteredComponentList::~FilteredComponentList()
{
}
void FilteredComponentList::SearchCriteriaChanged(QStringList& criteriaList, AzToolsFramework::FilterOperatorType filterOperator)
{
setUpdatesEnabled(false);
auto dataModel = qobject_cast<ComponentDataProxyModel*>(model());
if (dataModel)
{
// Go through the list of items and show/hide as needed due to filter.
QString filter;
for (const auto& criteria : criteriaList)
{
QString tag, text;
AzToolsFramework::SearchCriteriaButton::SplitTagAndText(criteria, tag, text);
AppendFilter(filter, text, filterOperator);
}
dataModel->setFilterRegExp(QRegExp(filter, Qt::CaseSensitivity::CaseInsensitive));
}
setUpdatesEnabled(true);
}
void FilteredComponentList::SetCategory(const char* category)
{
auto dataModel = qobject_cast<ComponentDataProxyModel*>(model());
if (dataModel)
{
if (!category || category[0] == 0 || azstricmp(category, "All") == 0)
{
dataModel->ClearSelectedCategory();
}
else
{
dataModel->SetSelectedCategory(category);
}
}
// Note: this ensures the category column remains hidden
hideColumn(ComponentDataModel::ColumnIndex::Category);
}
void FilteredComponentList::BuildFilter(QStringList& criteriaList, AzToolsFramework::FilterOperatorType filterOperator)
{
ClearFilterRegExp();
for (const auto& criteria : criteriaList)
{
QString tag, text;
AzToolsFramework::SearchCriteriaButton::SplitTagAndText(criteria, tag, text);
if (tag.isEmpty())
{
tag = "null";
}
QString filter = m_filtersRegExp[tag.toStdString().c_str()].pattern();
AppendFilter(filter, text, filterOperator);
SetFilterRegExp(tag.toStdString().c_str(), QRegExp(filter, Qt::CaseInsensitive));
}
}
void FilteredComponentList::AppendFilter(QString& filter, const QString& text, AzToolsFramework::FilterOperatorType filterOperator)
{
if (filterOperator == AzToolsFramework::FilterOperatorType::Or)
{
if (filter.isEmpty())
{
filter = text;
}
else
{
filter += "|" + text;
}
}
else if (filterOperator == AzToolsFramework::FilterOperatorType::And)
{
//using lookaheads to produce an "and" effect.
filter += "(?=.*" + text + ")";
}
}
void FilteredComponentList::SetFilterRegExp(const AZStd::string& filterType, const QRegExp& regExp)
{
m_filtersRegExp[filterType] = regExp;
}
void FilteredComponentList::ClearFilterRegExp(const AZStd::string& filterType /*= AZStd::string()*/)
{
if (filterType.empty())
{
for (auto& it : m_filtersRegExp)
{
it.second = QRegExp();
}
}
else
{
m_filtersRegExp[filterType] = QRegExp();
}
}
#include <UI/ComponentPalette/moc_FilteredComponentList.cpp>
@@ -1,68 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <QTableView>
#include <QWidget>
#include <AzToolsFramework/UI/SearchWidget/SearchCriteriaWidget.hxx>
#include <AzToolsFramework/UI/SearchWidget/SearchWidgetTypes.hxx>
#include <AzCore/Serialization/SerializeContext.h>
#include "ComponentDataModel.h"
#endif
namespace AZ
{
class SerializeContext;
class ClassData;
}
class ComponentDataModel;
//! FilteredComponentList
//! Provides a list of components that can be filtered according to search criteria provided and/or from
//! a category selection control.
class FilteredComponentList
: public QTableView
{
Q_OBJECT
public:
explicit FilteredComponentList(QWidget* parent = nullptr);
~FilteredComponentList() override;
virtual void Init();
void SearchCriteriaChanged(QStringList& criteriaList, AzToolsFramework::FilterOperatorType filterOperator);
void SetCategory(const char* category);
protected:
// Filtering support
void BuildFilter(QStringList& criteriaList, AzToolsFramework::FilterOperatorType filterOperator);
void AppendFilter(QString& filter, const QString& text, AzToolsFramework::FilterOperatorType filterOperator);
void SetFilterRegExp(const AZStd::string& filterType, const QRegExp& regExp);
void ClearFilterRegExp(const AZStd::string& filterType = AZStd::string());
// Context menu handlers
void ShowContextMenu(const QPoint&);
void ContextMenu_NewEntity();
void ContextMenu_AddToFavorites();
void ContextMenu_AddToSelectedEntities();
void modelReset();
AzToolsFramework::FilterByCategoryMap m_filtersRegExp;
ComponentDataModel* m_componentDataModel;
};
@@ -20,19 +20,7 @@ set(FILES
UI/QComponentEntityEditorOutlinerWindow.cpp
UI/AssetCatalogModel.h
UI/AssetCatalogModel.cpp
UI/ComponentPalette/CategoriesList.h
UI/ComponentPalette/CategoriesList.cpp
UI/ComponentPalette/ComponentDataModel.h
UI/ComponentPalette/ComponentDataModel.cpp
UI/ComponentPalette/ComponentPaletteSettings.h
UI/ComponentPalette/ComponentPaletteWindow.h
UI/ComponentPalette/ComponentPaletteWindow.cpp
UI/ComponentPalette/FavoriteComponentList.h
UI/ComponentPalette/FavoriteComponentList.cpp
UI/ComponentPalette/FilteredComponentList.h
UI/ComponentPalette/FilteredComponentList.cpp
UI/ComponentPalette/InformationPanel.h
UI/ComponentPalette/InformationPanel.cpp
UI/Outliner/OutlinerDisplayOptionsMenu.h
UI/Outliner/OutlinerDisplayOptionsMenu.cpp
UI/Outliner/OutlinerTreeView.hxx
@@ -7,7 +7,6 @@
*/
#include <AssetImporterDocument.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <SceneAPI/SceneCore/Export/MtlMaterialExporter.h>
#include <Util/PathUtil.h>
#include <GFxFramework/MaterialIO/IMaterial.h>
@@ -1,700 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Copied utils functions from CryPhysics that are used by non-physics systems
// This functions will be eventually removed, DO *NOT* use these functions
// TO-DO: Re-implement users using new code
// LY-109806
#pragma once
#include "Cry_Math.h"
namespace LegacyCryPhysicsUtils
{
namespace polynomial_tpl_IMPL
{
template<class ftype, int degree>
class polynomial_tpl
{
public:
explicit polynomial_tpl() { denom = (ftype)1; };
explicit polynomial_tpl(ftype op) { zero(); data[degree] = op; }
AZ_FORCE_INLINE polynomial_tpl& zero()
{
for (int i = 0; i <= degree; i++)
{
data[i] = 0;
}
denom = (ftype)1;
return *this;
}
polynomial_tpl(const polynomial_tpl<ftype, degree>& src) { *this = src; }
polynomial_tpl& operator=(const polynomial_tpl<ftype, degree>& src)
{
denom = src.denom;
for (int i = 0; i <= degree; i++)
{
data[i] = src.data[i];
}
return *this;
}
template<int degree1>
AZ_FORCE_INLINE polynomial_tpl& operator=(const polynomial_tpl<ftype, degree1>& src)
{
int i;
denom = src.denom;
for (i = 0; i <= min(degree, degree1); i++)
{
data[i] = src.data[i];
}
for (; i < degree; i++)
{
data[i] = 0;
}
return *this;
}
AZ_FORCE_INLINE polynomial_tpl& set(ftype* pdata)
{
for (int i = 0; i <= degree; i++)
{
data[degree - i] = pdata[i];
}
return *this;
}
AZ_FORCE_INLINE ftype& operator[](int idx) { return data[idx]; }
void calc_deriviative(polynomial_tpl<ftype, degree>& deriv, int curdegree = degree) const;
AZ_FORCE_INLINE polynomial_tpl& fixsign()
{
ftype sg = sgnnz(denom);
denom *= sg;
for (int i = 0; i <= degree; i++)
{
data[i] *= sg;
}
return *this;
}
int findroots(ftype start, ftype end, ftype* proots, int nIters = 20, int curdegree = degree, bool noDegreeCheck = false) const;
int nroots(ftype start, ftype end) const;
AZ_FORCE_INLINE ftype eval(ftype x) const
{
ftype res = 0;
for (int i = degree; i >= 0; i--)
{
res = res * x + data[i];
}
return res;
}
AZ_FORCE_INLINE ftype eval(ftype x, int subdegree) const
{
ftype res = data[subdegree];
for (int i = subdegree - 1; i >= 0; i--)
{
res = res * x + data[i];
}
return res;
}
AZ_FORCE_INLINE polynomial_tpl& operator+=(ftype op) { data[0] += op * denom; return *this; }
AZ_FORCE_INLINE polynomial_tpl& operator-=(ftype op) { data[0] -= op * denom; return *this; }
AZ_FORCE_INLINE polynomial_tpl operator*(ftype op) const
{
polynomial_tpl<ftype, degree> res;
res.denom = denom;
for (int i = 0; i <= degree; i++)
{
res.data[i] = data[i] * op;
}
return res;
}
AZ_FORCE_INLINE polynomial_tpl& operator*=(ftype op)
{
for (int i = 0; i <= degree; i++)
{
data[i] *= op;
}
return *this;
}
AZ_FORCE_INLINE polynomial_tpl operator/(ftype op) const
{
polynomial_tpl<ftype, degree> res = *this;
res.denom = denom * op;
return res;
}
AZ_FORCE_INLINE polynomial_tpl& operator/=(ftype op) { denom *= op; return *this; }
AZ_FORCE_INLINE polynomial_tpl<ftype, degree * 2> sqr() const { return *this * *this; }
ftype denom;
ftype data[degree + 1];
};
template <class ftype>
struct tagPolyE
{
inline static ftype polye() { return (ftype)1E-10; }
};
template<>
inline float tagPolyE<float>::polye() { return 1e-6f; }
template <class ftype>
inline ftype polye() { return tagPolyE<ftype>::polye(); }
// Don't use this macro; use AZStd::max instead. This is only here to make the template const arguments below readable
// and because Visual Studio 2013 doesn't have a const_expr version of std::max
#define deprecated_degmax(degree1, degree2) (((degree1) > (degree2)) ? (degree1) : (degree2))
template<class ftype, int degree>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree> operator+(const polynomial_tpl<ftype, degree>& pn, ftype op)
{
polynomial_tpl<ftype, degree> res = pn;
res.data[0] += op * res.denom;
return res;
}
template<class ftype, int degree>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree> operator-(const polynomial_tpl<ftype, degree>& pn, ftype op)
{
polynomial_tpl<ftype, degree> res = pn;
res.data[0] -= op * res.denom;
return res;
}
template<class ftype, int degree>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree> operator+(ftype op, const polynomial_tpl<ftype, degree>& pn)
{
polynomial_tpl<ftype, degree> res = pn;
res.data[0] += op * res.denom;
return res;
}
template<class ftype, int degree>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree> operator-(ftype op, const polynomial_tpl<ftype, degree>& pn)
{
polynomial_tpl<ftype, degree> res = pn;
res.data[0] -= op * res.denom;
for (int i = 0; i <= degree; i++)
{
res.data[i] = -res.data[i];
}
return res;
}
template<class ftype, int degree>
polynomial_tpl<ftype, degree * 2> AZ_FORCE_INLINE psqr(const polynomial_tpl<ftype, degree>& op) { return op * op; }
template <class ftype, int degree1, int degree2>
AZ_FORCE_INLINE polynomial_tpl<ftype, deprecated_degmax(degree1, degree2)> operator+(const polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
{
polynomial_tpl<ftype, deprecated_degmax(degree1, degree2)> res;
int i;
for (i = 0; i <= min(degree1, degree2); i++)
{
res.data[i] = op1.data[i] * op2.denom + op2.data[i] * op1.denom;
}
for (; i <= degree1; i++)
{
res.data[i] = op1.data[i] * op2.denom;
}
for (; i <= degree2; i++)
{
res.data[i] = op2.data[i] * op1.denom;
}
res.denom = op1.denom * op2.denom;
return res;
}
template <class ftype, int degree1, int degree2>
AZ_FORCE_INLINE polynomial_tpl<ftype, deprecated_degmax(degree1, degree2)> operator-(const polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
{
polynomial_tpl<ftype, deprecated_degmax(degree1, degree2)> res;
int i;
for (i = 0; i <= min(degree1, degree2); i++)
{
res.data[i] = op1.data[i] * op2.denom - op2.data[i] * op1.denom;
}
for (; i <= degree1; i++)
{
res.data[i] = op1.data[i] * op2.denom;
}
for (; i <= degree2; i++)
{
res.data[i] = op2.data[i] * op1.denom;
}
res.denom = op1.denom * op2.denom;
return res;
}
template <class ftype, int degree1, int degree2>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree1>& operator+=(polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
{
for (int i = 0; i < min(degree1, degree2); i++)
{
op1.data[i] = op1.data[i] * op2.denom + op2.data[i] * op1.denom;
}
op1.denom *= op2.denom;
return op1;
}
template <class ftype, int degree1, int degree2>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree1>& operator-=(polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
{
for (int i = 0; i < min(degree1, degree2); i++)
{
op1.data[i] = op1.data[i] * op2.denom - op2.data[i] * op1.denom;
}
op1.denom *= op2.denom;
return op1;
}
template <class ftype, int degree1, int degree2>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree1 + degree2> operator*(const polynomial_tpl<ftype, degree1>& op1, const polynomial_tpl<ftype, degree2>& op2)
{
polynomial_tpl<ftype, degree1 + degree2> res;
res.zero();
int j;
switch (degree1)
{
case 8:
for (j = 0; j <= degree2; j++)
{
res.data[8 + j] += op1.data[8] * op2.data[j];
}
case 7:
for (j = 0; j <= degree2; j++)
{
res.data[7 + j] += op1.data[7] * op2.data[j];
}
case 6:
for (j = 0; j <= degree2; j++)
{
res.data[6 + j] += op1.data[6] * op2.data[j];
}
case 5:
for (j = 0; j <= degree2; j++)
{
res.data[5 + j] += op1.data[5] * op2.data[j];
}
case 4:
for (j = 0; j <= degree2; j++)
{
res.data[4 + j] += op1.data[4] * op2.data[j];
}
case 3:
for (j = 0; j <= degree2; j++)
{
res.data[3 + j] += op1.data[3] * op2.data[j];
}
case 2:
for (j = 0; j <= degree2; j++)
{
res.data[2 + j] += op1.data[2] * op2.data[j];
}
case 1:
for (j = 0; j <= degree2; j++)
{
res.data[1 + j] += op1.data[1] * op2.data[j];
}
case 0:
for (j = 0; j <= degree2; j++)
{
res.data[0 + j] += op1.data[0] * op2.data[j];
}
}
res.denom = op1.denom * op2.denom;
return res;
}
template <class ftype>
AZ_FORCE_INLINE void polynomial_divide(const polynomial_tpl<ftype, 8>& num, const polynomial_tpl<ftype, 8>& den, polynomial_tpl<ftype, 8>& quot,
polynomial_tpl<ftype, 8>& rem, int degree1, int degree2)
{
int i, j, k, l;
ftype maxel;
for (i = 0; i <= degree1; i++)
{
rem.data[i] = num.data[i];
}
for (i = 0; i <= degree1 - degree2; i++)
{
quot.data[i] = 0;
}
for (i = 1, maxel = fabs_tpl(num.data[0]); i <= degree1; i++)
{
maxel = max(maxel, num.data[i]);
}
for (maxel *= polye<ftype>(); degree1 >= 0 && fabs_tpl(num.data[degree1]) < maxel; degree1--)
{
;
}
for (i = 1, maxel = fabs_tpl(den.data[0]); i <= degree2; i++)
{
maxel = max(maxel, den.data[i]);
}
for (maxel *= polye<ftype>(); degree2 >= 0 && fabs_tpl(den.data[degree2]) < maxel; degree2--)
{
;
}
rem.denom = num.denom;
quot.denom = (ftype)1;
if (degree1 < 0 || degree2 < 0)
{
return;
}
for (k = degree1 - degree2, l = degree1; l >= degree2; l--, k--)
{
quot.data[k] = rem.data[l] * den.denom;
quot.denom *= den.data[degree2];
for (i = degree1 - degree2; i > k; i--)
{
quot.data[i] *= den.data[degree2];
}
for (i = degree2 - 1, j = l - 1; i >= 0; i--, j--)
{
rem.data[j] = rem.data[j] * den.data[degree2] - den.data[i] * rem.data[l];
}
for (; j >= 0; j--)
{
rem.data[j] *= den.data[degree2];
}
rem.denom *= den.data[degree2];
}
}
template <class ftype, int degree1, int degree2>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree1 - degree2> operator/(const polynomial_tpl<ftype, degree1>& num, const polynomial_tpl<ftype, degree2>& den)
{
polynomial_tpl<ftype, degree1 - degree2> quot;
polynomial_tpl<ftype, degree1> rem;
polynomial_divide((polynomial_tpl<ftype, 8>&)num, (polynomial_tpl<ftype, 8>&)den, (polynomial_tpl<ftype, 8>&)quot,
(polynomial_tpl<ftype, 8>&)rem, degree1, degree2);
return quot;
}
template <class ftype, int degree1, int degree2>
AZ_FORCE_INLINE polynomial_tpl<ftype, degree2 - 1> operator%(const polynomial_tpl<ftype, degree1>& num, const polynomial_tpl<ftype, degree2>& den)
{
polynomial_tpl<ftype, degree1 - degree2> quot;
polynomial_tpl<ftype, degree1> rem;
polynomial_divide((polynomial_tpl<ftype, 8>&)num, (polynomial_tpl<ftype, 8>&)den, (polynomial_tpl<ftype, 8>&)quot,
(polynomial_tpl<ftype, 8>&)rem, degree1, degree2);
return (polynomial_tpl<ftype, degree2 - 1>&)rem;
}
template <class ftype, int degree>
AZ_FORCE_INLINE void polynomial_tpl<ftype, degree>::calc_deriviative(polynomial_tpl<ftype, degree>& deriv, int curdegree) const
{
for (int i = 0; i < curdegree; i++)
{
deriv.data[i] = data[i + 1] * (i + 1);
}
deriv.denom = denom;
}
template<typename to_t, typename from_t>
to_t* convert_type(from_t* input)
{
typedef union
{
to_t* to;
from_t* from;
} convert_union;
convert_union u;
u.from = input;
return u.to;
}
template <class ftype, int degree>
AZ_FORCE_INLINE int polynomial_tpl<ftype, degree>::nroots(ftype start, ftype end) const
{
polynomial_tpl<ftype, degree> f[degree + 1];
int i, j, sg_a, sg_b;
ftype val, prevval;
calc_deriviative(f[0]);
polynomial_divide(*convert_type<polynomial_tpl<ftype, 8> >(this), *convert_type< polynomial_tpl<ftype, 8> >(&f[0]), *convert_type<polynomial_tpl<ftype, 8> >(&f[degree]),
*convert_type<polynomial_tpl<ftype, 8> >(&f[1]), degree, degree - 1);
f[1].denom = -f[1].denom;
for (i = 2; i < degree; i++)
{
polynomial_divide(*convert_type<polynomial_tpl<ftype, 8> >(&f[i - 2]), *convert_type<polynomial_tpl<ftype, 8> >(&f[i - 1]), *convert_type<polynomial_tpl<ftype, 8> >(&f[degree]),
*convert_type<polynomial_tpl<ftype, 8> >(&f[i]), degree + 1 - i, degree - i);
f[i].denom = -f[i].denom;
if (fabs_tpl(f[i].denom) > (ftype)1E10)
{
for (j = 0; j <= degree - 1 - i; j++)
{
f[i].data[j] *= (ftype)1E-10;
}
f[i].denom *= (ftype)1E-10;
}
}
prevval = eval(start) * denom;
for (i = sg_a = 0; i < degree; i++, prevval = val)
{
val = f[i].eval(start, degree - 1 - i) * f[i].denom;
sg_a += isneg(val * prevval);
}
prevval = eval(end) * denom;
for (i = sg_b = 0; i < degree; i++, prevval = val)
{
val = f[i].eval(end, degree - 1 - i) * f[i].denom;
sg_b += isneg(val * prevval);
}
return fabs_tpl(sg_a - sg_b);
}
template<class ftype>
AZ_FORCE_INLINE ftype cubert_tpl(ftype x) { return fabs_tpl(x) > (ftype)1E-20 ? exp_tpl(log_tpl(fabs_tpl(x)) * (ftype)(1.0 / 3)) * sgnnz(x) : x; }
template<class ftype>
AZ_FORCE_INLINE ftype pow_tpl(ftype x, ftype pow) { return fabs_tpl(x) > (ftype)1E-20 ? exp_tpl(log_tpl(fabs_tpl(x)) * pow) * sgnnz(x) : x; }
template<class ftype>
AZ_FORCE_INLINE void swap(ftype* ptr, int i, int j) { ftype t = ptr[i]; ptr[i] = ptr[j]; ptr[j] = t; }
template <class ftype, int maxdegree>
int polynomial_tpl<ftype, maxdegree>::findroots(ftype start, ftype end, ftype* proots, [[maybe_unused]] int nIters, int degree, bool noDegreeCheck) const
{
AZ_UNUSED(nIters);
int i, j, nRoots = 0;
ftype maxel;
if (!noDegreeCheck)
{
for (i = 1, maxel = fabs_tpl(data[0]); i <= degree; i++)
{
maxel = max(maxel, data[i]);
}
for (maxel *= polye<ftype>(); degree > 0 && fabs_tpl(data[degree]) <= maxel; degree--)
{
;
}
}
if constexpr (maxdegree >= 1)
{
if (degree == 1)
{
proots[0] = data[0] / data[1];
nRoots = 1;
}
}
if constexpr (maxdegree >= 2)
{
if (degree == 2)
{
ftype a, b, c, d, bound[2], sg;
a = data[2];
b = data[1];
c = data[0];
d = aznumeric_cast<ftype>(sgnnz(a));
a *= d;
b *= d;
c *= d;
d = b * b - a * c * 4;
bound[0] = start * a * 2 + b;
bound[1] = end * a * 2 + b;
sg = aznumeric_cast<ftype>((sgnnz(bound[0] * bound[1]) + 1) >> 1);
bound[0] *= bound[0];
bound[1] *= bound[1];
bound[isneg(fabs_tpl(bound[1]) - fabs_tpl(bound[0]))] *= sg;
if (isnonneg(d) & inrange(d, bound[0], bound[1]))
{
d = sqrt_tpl(d);
a = (ftype)0.5 / a;
proots[nRoots] = (-b - d) * a;
nRoots += inrange(proots[nRoots], start, end);
proots[nRoots] = (-b + d) * a;
nRoots += inrange(proots[nRoots], start, end);
}
}
}
if constexpr (maxdegree >= 3)
{
if (degree == 3)
{
ftype t, a, b, c, a3, p, q, Q, Qr, Ar, Ai, phi;
t = (ftype)1.0 / data[3];
a = data[2] * t;
b = data[1] * t;
c = data[0] * t;
a3 = a * (ftype)(1.0 / 3);
p = b - a * a3;
q = (a3 * b - c) * (ftype)0.5 - cube(a3);
Q = cube(p * (ftype)(1.0 / 3)) + q * q;
Qr = sqrt_tpl(fabs_tpl(Q));
if (Q > 0)
{
proots[0] = cubert_tpl(q + Qr) + cubert_tpl(q - Qr) - a3;
nRoots = 1;
}
else
{
phi = atan2_tpl(Qr, q) * (ftype)(1.0 / 3);
t = pow_tpl(Qr * Qr + q * q, (ftype)(1.0 / 6));
Ar = t * cos_tpl(phi);
Ai = t * sin_tpl(phi);
proots[0] = 2 * Ar - a3;
proots[1] = aznumeric_cast<ftype>(-Ar + Ai * sqrt3 - a3);
proots[2] = aznumeric_cast<ftype>(-Ar - Ai * sqrt3 - a3);
i = idxmax3(proots);
swap(proots, i, 2);
i = isneg(proots[0] - proots[1]);
swap(proots, i, 1);
nRoots = 3;
}
}
}
if constexpr (maxdegree >= 4)
{
if (degree == 4)
{
ftype t, a3, a2, a1, a0, y, R, D, E, subroots[3];
const ftype e = (ftype)1E-9;
t = (ftype)1.0 / data[4];
a3 = data[3] * t;
a2 = data[2] * t;
a1 = data[1] * t;
a0 = data[0] * t;
polynomial_tpl<ftype, 3> p3aux;
ftype kp3aux[] = { 1, -a2, a1 * a3 - 4 * a0, 4 * a2 * a0 - a1 * a1 - a3 * a3 * a0 };
p3aux.set(kp3aux);
if (!p3aux.findroots((ftype)-1E20, (ftype)1E20, subroots))
{
return 0;
}
R = a3 * a3 * (ftype)0.25 - a2 + (y = subroots[0]);
if (R > -e)
{
if (R < e)
{
D = E = a3 * a3 * (ftype)(3.0 / 4) - 2 * a2;
t = y * y - 4 * a0;
if (t < -e)
{
return 0;
}
t = 2 * sqrt_tpl(max((ftype)0, t));
}
else
{
R = sqrt_tpl(max((ftype)0, R));
D = E = a3 * a3 * (ftype)(3.0 / 4) - R * R - 2 * a2;
t = (4 * a3 * a2 - 8 * a1 - a3 * a3 * a3) / R * (ftype)0.25;
}
if (D + t > -e)
{
D = sqrt_tpl(max((ftype)0, D + t));
proots[nRoots++] = a3 * (ftype)-0.25 + (R - D) * (ftype)0.5;
proots[nRoots++] = a3 * (ftype)-0.25 + (R + D) * (ftype)0.5;
}
if (E - t > -e)
{
E = sqrt_tpl(max((ftype)0, E - t));
proots[nRoots++] = a3 * (ftype)-0.25 - (R + E) * (ftype)0.5;
proots[nRoots++] = a3 * (ftype)-0.25 - (R - E) * (ftype)0.5;
}
if (nRoots == 4)
{
i = idxmax3(proots);
if (proots[3] < proots[i])
{
swap(proots, i, 3);
}
i = idxmax3(proots);
swap(proots, i, 2);
i = isneg(proots[0] - proots[1]);
swap(proots, i, 1);
}
}
}
}
if constexpr (maxdegree > 4)
{
if (degree > 4)
{
ftype roots[maxdegree + 1], prevroot, val, prevval[2], curval, bound[2], middle;
polynomial_tpl<ftype, maxdegree> deriv;
int nExtremes, iter, iBound;
calc_deriviative(deriv);
// find a subset of deriviative extremes between start and end
for (nExtremes = deriv.findroots(start, end, roots + 1, nIters, degree - 1) + 1; nExtremes > 1 && roots[nExtremes - 1] > end; nExtremes--)
{
;
}
for (i = 1; i < nExtremes && roots[i] < start; i++)
{
;
}
roots[i - 1] = start;
PREFAST_ASSUME(nExtremes < maxdegree + 1);
roots[nExtremes++] = end;
for (prevroot = start, prevval[0] = eval(start, degree), nRoots = 0; i < nExtremes; prevval[0] = val, prevroot = roots[i++])
{
val = eval(roots[i], degree);
if (val * prevval[0] < 0)
{
// we have exactly one root between prevroot and roots[i]
bound[0] = prevroot;
bound[1] = roots[i];
iter = 0;
do
{
middle = (bound[0] + bound[1]) * (ftype)0.5;
curval = eval(middle, degree);
iBound = isneg(prevval[0] * curval);
bound[iBound] = middle;
prevval[iBound] = curval;
} while (++iter < nIters);
proots[nRoots++] = middle;
}
}
}
}
for (i = 0; i < nRoots && proots[i] < start; i++)
{
;
}
for (; nRoots > i&& proots[nRoots - 1] > end; nRoots--)
{
;
}
for (j = i; j < nRoots; j++)
{
proots[j - i] = proots[j];
}
return nRoots - i;
}
} // namespace polynomial_tpl_IMPL
template<class ftype, int degree>
using polynomial_tpl = polynomial_tpl_IMPL::polynomial_tpl<ftype, degree>;
typedef polynomial_tpl<real, 3> P3;
typedef polynomial_tpl<real, 2> P2;
typedef polynomial_tpl<real, 1> P1;
typedef polynomial_tpl<float, 3> P3f;
typedef polynomial_tpl<float, 2> P2f;
typedef polynomial_tpl<float, 1> P1f;
} // namespace LegacyCryPhysicsUtils
@@ -1,172 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "DeepFilterProxyModel.h"
#include <QPalette>
DeepFilterProxyModel::DeepFilterProxyModel(QObject* parent)
: QSortFilterProxyModel(parent)
{
}
void DeepFilterProxyModel::setFilterString(const QString& filter)
{
m_filter = filter;
m_filterParts = m_filter.split(' ', Qt::SkipEmptyParts);
m_acceptCache.clear();
}
void DeepFilterProxyModel::invalidate()
{
QSortFilterProxyModel::invalidate();
m_acceptCache.clear();
}
QVariant DeepFilterProxyModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::ForegroundRole)
{
QModelIndex sourceIndex = mapToSource(index);
if (matchFilter(sourceIndex.row(), sourceIndex.parent()))
{
return QSortFilterProxyModel::data(index, role);
}
else
{
return QPalette().color(QPalette::Disabled, QPalette::Text);
}
}
else
{
return QSortFilterProxyModel::data(index, role);
}
}
void DeepFilterProxyModel::setFilterWildcard(const QString& pattern)
{
m_acceptCache.clear();
QSortFilterProxyModel::setFilterWildcard(pattern);
}
bool DeepFilterProxyModel::matchFilter(int sourceRow, const QModelIndex& sourceParent) const
{
int columnCount = sourceModel()->columnCount(sourceParent);
for (int i = 0; i < m_filterParts.size(); ++i)
{
bool atLeastOneContains = false;
for (int j = 0; j < columnCount; ++j)
{
QModelIndex index = sourceModel()->index(sourceRow, j, sourceParent);
QVariant data = sourceModel()->data(index, Qt::DisplayRole);
QString str(data.toString());
if (str.isEmpty())
{
if (m_filterParts.empty())
{
atLeastOneContains = true;
}
}
else if (str.contains(m_filterParts[i], Qt::CaseInsensitive))
{
atLeastOneContains = true;
}
}
if (!atLeastOneContains)
{
return false;
}
}
return true;
}
bool DeepFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
{
if (matchFilter(sourceRow, sourceParent))
{
return true;
}
if (hasAcceptedChildrenCached(sourceRow, sourceParent))
{
return true;
}
return false;
}
bool DeepFilterProxyModel::hasAcceptedChildrenCached(int sourceRow, const QModelIndex& sourceParent) const
{
std::pair<QModelIndex, int> indexId = std::make_pair(sourceParent, sourceRow);
TAcceptCache::iterator it = m_acceptCache.find(indexId);
if (it == m_acceptCache.end())
{
bool result = hasAcceptedChildren(sourceRow, sourceParent);
m_acceptCache[indexId] = result;
return result;
}
else
{
return it->second;
}
}
bool DeepFilterProxyModel::hasAcceptedChildren(int sourceRow, const QModelIndex& sourceParent) const
{
QModelIndex item = sourceModel()->index(sourceRow, 0, sourceParent);
if (!item.isValid())
{
return false;
}
int childCount = item.model()->rowCount(item);
if (childCount == 0)
{
return false;
}
for (int i = 0; i < childCount; ++i)
{
if (filterAcceptsRow(i, item))
{
return true;
}
}
return false;
}
QModelIndex DeepFilterProxyModel::findFirstMatchingIndex(const QModelIndex& root)
{
int rowCount = this->rowCount(root);
for (int i = 0; i < rowCount; ++i)
{
QModelIndex index = this->index(i, 0, root);
if (!index.isValid())
{
continue;
}
QModelIndex sourceIndex = mapToSource(index);
if (!sourceIndex.isValid())
{
continue;
}
if (matchFilter(sourceIndex.row(), sourceIndex.parent()))
{
return index;
}
QModelIndex child = findFirstMatchingIndex(index);
if (child.isValid())
{
return child;
}
}
return QModelIndex();
}
@@ -1,48 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITORCOMMON_DEEPFILTERPROXYMODEL_H
#define CRYINCLUDE_EDITORCOMMON_DEEPFILTERPROXYMODEL_H
#pragma once
#include <QSortFilterProxyModel>
#include <QModelIndex>
#include <QStringList>
#include "EditorCommonAPI.h"
class EDITOR_COMMON_API DeepFilterProxyModel
: public QSortFilterProxyModel
{
public:
DeepFilterProxyModel(QObject* parent);
void setFilterString(const QString& filter);
void invalidate();
QVariant data(const QModelIndex& index, int role) const override;
void setFilterWildcard(const QString& pattern);
bool matchFilter(int source_row, const QModelIndex& source_parent) const;
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
bool hasAcceptedChildrenCached(int source_row, const QModelIndex& source_parent) const;
bool hasAcceptedChildren(int source_row, const QModelIndex& source_parent) const;
QModelIndex findFirstMatchingIndex(const QModelIndex& root);
private:
QString m_filter;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
QStringList m_filterParts;
typedef std::map<std::pair<QModelIndex, int>, bool> TAcceptCache;
mutable TAcceptCache m_acceptCache;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
#endif // CRYINCLUDE_EDITORCOMMON_DEEPFILTERPROXYMODEL_H
@@ -1,9 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "../../Editor/Objects/DisplayContextShared.inl"
@@ -1,192 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "Ruler.h"
#include <QPainter>
#include <QPalette>
#include <AzCore/Casting/numeric_cast.h>
#include <AzCore/std/algorithm.h>
namespace DrawingPrimitives
{
enum
{
RULER_MIN_PIXELS_PER_TICK = 3,
};
std::vector<STick> CalculateTicks(uint size, Range visibleRange, Range rulerRange, int* pRulerPrecision, Range* pScreenRulerRange)
{
std::vector<STick> ticks;
if (size == 0)
{
if (pRulerPrecision)
{
*pRulerPrecision = 0;
}
return ticks;
}
const float pixelsPerUnit = visibleRange.Length() > 0.0f ? (float)size / visibleRange.Length() : 1.0f;
const float startTime = rulerRange.start;
const float endTime = rulerRange.end;
const float totalDuration = endTime - startTime;
const float ticksMinPower = log10f(RULER_MIN_PIXELS_PER_TICK);
const float ticksPowerDelta = ticksMinPower - log10f(pixelsPerUnit);
const int digitsAfterPoint = AZStd::max(-int(ceil(ticksPowerDelta)) - 1, 0);
if (pRulerPrecision)
{
*pRulerPrecision = digitsAfterPoint;
}
const float scaleStep = powf(10.0f, ceil(ticksPowerDelta));
const float scaleStepPixels = scaleStep * pixelsPerUnit;
const int numMarkers = int(totalDuration / scaleStep) + 1;
const float startTimeRound = int(startTime / scaleStep) * scaleStep;
const int startOffsetMod = int(startTime / scaleStep) % 10;
const int scaleOffsetPixels = aznumeric_cast<int>((startTime - startTimeRound) * pixelsPerUnit);
const int startX = aznumeric_cast<int>((rulerRange.start - visibleRange.start) * pixelsPerUnit);
const int endX = aznumeric_cast<int>(startX + (numMarkers - 1) * scaleStepPixels - scaleOffsetPixels);
if (pScreenRulerRange)
{
*pScreenRulerRange = Range(aznumeric_cast<float>(startX), aznumeric_cast<float>(endX));
}
const int startLoop = std::max((int)((scaleOffsetPixels - startX) / scaleStepPixels) - 1, 0);
const int endLoop = std::min((int)((size + scaleOffsetPixels - startX) / scaleStepPixels) + 1, numMarkers);
for (int i = startLoop; i < endLoop; ++i)
{
STick tick;
const int x = aznumeric_cast<int>(startX + i * scaleStepPixels - scaleOffsetPixels);
const float value = startTimeRound + i * scaleStep;
tick.m_bTenth = (startOffsetMod + i) % 10 != 0;
tick.m_position = x;
tick.m_value = value;
ticks.push_back(tick);
}
return ticks;
}
QColor Interpolate(const QColor& a, const QColor& b, float k)
{
float mk = 1.0f - k;
return QColor(aznumeric_cast<int>(a.red() * mk + b.red() * k),
aznumeric_cast<int>(a.green() * mk + b.green() * k),
aznumeric_cast<int>(a.blue() * mk + b.blue() * k),
aznumeric_cast<int>(a.alpha() * mk + b.alpha() * k));
}
void DrawTicks(const std::vector<STick>& ticks, QPainter& painter, const QPalette& palette, const STickOptions& options)
{
QColor midDark = DrawingPrimitives::Interpolate(palette.color(QPalette::Dark), palette.color(QPalette::Button), 0.5f);
painter.setPen(QPen(midDark));
const int height = options.m_rect.height();
const int top = options.m_rect.top();
for (const STick& tick : ticks)
{
const int x = tick.m_position + options.m_rect.left();
if (tick.m_bTenth)
{
painter.drawLine(QPoint(x, top + height - options.m_markHeight / 2), QPoint(x, top + height));
}
else
{
painter.drawLine(QPoint(x, top + height - options.m_markHeight), QPoint(x, top + height));
}
}
}
void DrawTicks(QPainter& painter, const QPalette& palette, const SRulerOptions& options)
{
const std::vector<STick> ticks = CalculateTicks(options.m_rect.width(), options.m_visibleRange, options.m_rulerRange, nullptr, nullptr);
DrawTicks(ticks, painter, palette, options);
}
void DrawRuler(QPainter& painter, const QPalette& palette, const SRulerOptions& options, int* pRulerPrecision)
{
int rulerPrecision;
Range screenRulerRange;
const std::vector<STick> ticks = CalculateTicks(options.m_rect.width(), options.m_visibleRange, options.m_rulerRange, &rulerPrecision, &screenRulerRange);
if (pRulerPrecision)
{
*pRulerPrecision = rulerPrecision;
}
if (options.m_shadowSize > 0)
{
QRect shadowRect = QRect(options.m_rect.left(), options.m_rect.height(), options.m_rect.width(), options.m_shadowSize);
QLinearGradient upperGradient(shadowRect.left(), shadowRect.top(), shadowRect.left(), shadowRect.bottom());
upperGradient.setColorAt(0.0f, QColor(0, 0, 0, 128));
upperGradient.setColorAt(1.0f, QColor(0, 0, 0, 0));
QBrush upperBrush(upperGradient);
painter.fillRect(shadowRect, upperBrush);
}
painter.fillRect(options.m_rect, DrawingPrimitives::Interpolate(palette.color(QPalette::Button), palette.color(QPalette::Midlight), 0.25f));
if (options.m_drawBackgroundCallback)
{
options.m_drawBackgroundCallback();
}
QColor midDark = DrawingPrimitives::Interpolate(palette.color(QPalette::Dark), palette.color(QPalette::Button), 0.5f);
painter.setPen(QPen(midDark));
QFont font;
font.setPixelSize(10);
painter.setFont(font);
char format[16] = "";
azsprintf(format, "%%.%df", rulerPrecision);
const int height = options.m_rect.height();
const int top = options.m_rect.top();
QString str;
for (const STick& tick : ticks)
{
const int x = tick.m_position + options.m_rect.left();
const float value = tick.m_value;
if (tick.m_bTenth)
{
painter.drawLine(QPoint(x, top + height - options.m_markHeight / 2), QPoint(x, top + height));
}
else
{
painter.drawLine(QPoint(x, top + height - options.m_markHeight), QPoint(x, top + height));
painter.setPen(palette.color(QPalette::Disabled, QPalette::Text));
str.asprintf(format, value);
painter.drawText(QPoint(x + 2, top + height - options.m_markHeight + 1), str);
painter.setPen(midDark);
}
}
painter.setPen(QPen(palette.color(QPalette::Dark)));
painter.drawLine(QPoint(aznumeric_cast<int>(options.m_rect.left() + screenRulerRange.start), 0), QPoint(aznumeric_cast<int>(options.m_rect.left() + screenRulerRange.start), options.m_rect.top() + height));
painter.drawLine(QPoint(aznumeric_cast<int>(options.m_rect.left() + screenRulerRange.end), 0), QPoint(aznumeric_cast<int>(options.m_rect.left() + screenRulerRange.end), options.m_rect.top() + height));
}
}
@@ -1,52 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include "Range.h"
#include <functional>
#include <vector>
#include <QRect>
class QPainter;
class QPalette;
namespace DrawingPrimitives
{
struct SRulerOptions;
typedef std::function<void()> TDrawCallback;
struct SRulerOptions
{
QRect m_rect;
Range m_visibleRange;
Range m_rulerRange;
int m_textXOffset;
int m_textYOffset;
int m_markHeight;
int m_shadowSize;
TDrawCallback m_drawBackgroundCallback;
};
struct STick
{
bool m_bTenth;
int m_position;
float m_value;
};
typedef SRulerOptions STickOptions;
std::vector<STick> CalculateTicks(uint size, Range visibleRange, Range rulerRange, int* pRulerPrecision, Range* pScreenRulerRange);
void DrawTicks(const std::vector<STick>& ticks, QPainter& painter, const QPalette& palette, const STickOptions& options);
void DrawTicks(QPainter& painter, const QPalette& palette, const STickOptions& options);
void DrawRuler(QPainter& painter, const QPalette& palette, const SRulerOptions& options, int* pRulerPrecision);
}
@@ -1,48 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "TimeSlider.h"
#include <QPainter>
#include <QPalette>
#include <AzCore/Casting/numeric_cast.h>
namespace DrawingPrimitives
{
void DrawTimeSlider(QPainter& painter, const QPalette& palette, const STimeSliderOptions& options)
{
QString text = QString::number(options.m_time, 'f', options.m_precision + 1);
QFontMetrics fm(painter.font());
const int textWidth = fm.horizontalAdvance(text) + fm.height();
const int markerHeight = fm.height();
const int thumbX = options.m_position;
const bool fits = thumbX + textWidth < options.m_rect.right();
const QRect timeRect(fits ? thumbX : thumbX - textWidth, 3, textWidth, fm.height());
painter.fillRect(timeRect.adjusted(fits ? 0 : -1, 0, fits ? 1 : 0, 0), options.m_bHasFocus ? palette.highlight() : palette.shadow());
painter.setPen(palette.color(QPalette::HighlightedText));
painter.drawText(timeRect.adjusted(fits ? 0 : aznumeric_cast<int>(markerHeight * 0.2f), -1, fits ? aznumeric_cast<int>(-markerHeight * 0.2f) : 0, 0), text, QTextOption(fits ? Qt::AlignRight : Qt::AlignLeft));
painter.setPen(palette.color(QPalette::Text));
painter.drawLine(QPointF(thumbX, 0), QPointF(thumbX, options.m_rect.height()));
QPointF points[3] =
{
QPointF(thumbX, markerHeight),
QPointF(thumbX - markerHeight * 0.66f, 0),
QPointF(thumbX + markerHeight * 0.66f, 0)
};
painter.setBrush(palette.base());
painter.setPen(palette.color(QPalette::Text));
painter.drawPolygon(points, 3);
}
}
@@ -1,31 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include "Range.h"
#include <QRect>
class QPainter;
class QPalette;
namespace DrawingPrimitives
{
struct STimeSliderOptions
{
QRect m_rect;
int m_precision;
int m_position;
float m_time;
bool m_bHasFocus;
};
void DrawTimeSlider(QPainter& painter, const QPalette& palette, const STimeSliderOptions& options);
}
Binary file not shown.
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3e60156229cc8677e0294d297486f04bd78867ef4e0922b35444c8b45f78584d
size 1090
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fd29a16a1d1d9a363e4b154d51910c2cba2787fbbe1360cfd107b393053d2e49
size 1226
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:244005cde119238bbfc2815f36a343c6135c3233d0b72a5c97a6080604568e8f
size 1160
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:33176a8ea6b0798adf1114fdbea4b0f5c708f40c3d48a047b1cb0fa6ebcbbded
size 1181
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c122557745cc377768491ce59c5b5b17e54671aa59f7f87101766aa61758959e
size 939
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3c2a360a56a37bfae2bea16b495f5b6ee482caa28d0949e8eadea48fdaae654f
size 845
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:eb0f43228bdb5246ea3bfde0726f07e0df0468279610ba4c801b21e264b33123
size 765
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:97a2e879222323bc70787efbe2cbc1c47bbabb7b10df8465857e600a9084abb2
size 795

Some files were not shown because too many files have changed in this diff Show More