Enlarged thumbnails on hover
This commit is contained in:
+6
-35
@@ -63,7 +63,7 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
#include <UI/PropertyEditor/Model/AssetCompleterModel.h>
|
||||
#include <UI/PropertyEditor/View/AssetCompleterListView.h>
|
||||
#include <UI/PropertyEditor/ThumbnailDropDown.h>
|
||||
#include <UI/PropertyEditor/ThumbnailPropertyCtrl.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -93,15 +93,11 @@ namespace AzToolsFramework
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
m_thumbnail = new Thumbnailer::ThumbnailWidget(this);
|
||||
m_thumbnail->setFixedSize(QSize(24, 24));
|
||||
m_thumbnail = new ThumbnailPropertyCtrl(this);
|
||||
m_thumbnail->setFixedSize(QSize(40, 24));
|
||||
m_thumbnail->setVisible(false);
|
||||
|
||||
m_thumbnailDropDown = new ThumbnailDropDown(this);
|
||||
m_thumbnailDropDown->setFixedSize(QSize(40, 24));
|
||||
m_thumbnailDropDown->setVisible(false);
|
||||
|
||||
connect(m_thumbnailDropDown, &ThumbnailDropDown::clicked, this, &PropertyAssetCtrl::OnEditButtonClicked);
|
||||
connect(m_thumbnail, &ThumbnailPropertyCtrl::clicked, this, &PropertyAssetCtrl::OnEditButtonClicked);
|
||||
|
||||
m_editButton = new QToolButton(this);
|
||||
m_editButton->setAutoRaise(true);
|
||||
@@ -112,7 +108,6 @@ namespace AzToolsFramework
|
||||
connect(m_editButton, &QToolButton::clicked, this, &PropertyAssetCtrl::OnEditButtonClicked);
|
||||
|
||||
pLayout->addWidget(m_thumbnail);
|
||||
pLayout->addWidget(m_thumbnailDropDown);
|
||||
pLayout->addWidget(m_browseEdit);
|
||||
pLayout->addWidget(m_editButton);
|
||||
|
||||
@@ -1091,9 +1086,8 @@ namespace AzToolsFramework
|
||||
void PropertyAssetCtrl::UpdateThumbnail()
|
||||
{
|
||||
m_thumbnail->setVisible(m_showThumbnail);
|
||||
m_thumbnailDropDown->setVisible(m_showThumbnailDropDown);
|
||||
|
||||
if (m_showThumbnail || m_showThumbnailDropDown)
|
||||
if (m_showThumbnail)
|
||||
{
|
||||
const AZ::Data::AssetId assetID = GetCurrentAssetID();
|
||||
if (assetID.IsValid())
|
||||
@@ -1112,17 +1106,12 @@ namespace AzToolsFramework
|
||||
{
|
||||
m_thumbnail->SetThumbnailKey(thumbnailKey, Thumbnailer::ThumbnailContext::DefaultContext);
|
||||
}
|
||||
if (m_showThumbnailDropDown)
|
||||
{
|
||||
m_thumbnailDropDown->SetThumbnailKey(thumbnailKey, Thumbnailer::ThumbnailContext::DefaultContext);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_thumbnail->ClearThumbnail();
|
||||
m_thumbnailDropDown->ClearThumbnail();
|
||||
}
|
||||
|
||||
void PropertyAssetCtrl::SetClearButtonEnabled(bool enable)
|
||||
@@ -1156,16 +1145,6 @@ namespace AzToolsFramework
|
||||
return m_showThumbnail;
|
||||
}
|
||||
|
||||
void PropertyAssetCtrl::SetShowThumbnailDropDown(bool enable)
|
||||
{
|
||||
m_showThumbnailDropDown = enable;
|
||||
}
|
||||
|
||||
bool PropertyAssetCtrl::GetShowThumbnailDropDown() const
|
||||
{
|
||||
return m_showThumbnailDropDown;
|
||||
}
|
||||
|
||||
const AZ::Uuid& AssetPropertyHandlerDefault::GetHandledType() const
|
||||
{
|
||||
return AZ::GetAssetClassId();
|
||||
@@ -1276,19 +1255,11 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
else if (attrib == AZ_CRC_CE("Thumbnail"))
|
||||
{
|
||||
bool showThumbnail = false;
|
||||
if (attrValue->Read<bool>(showThumbnail))
|
||||
{
|
||||
GUI->SetShowThumbnail(showThumbnail);
|
||||
}
|
||||
}
|
||||
else if (attrib == AZ_CRC_CE("ThumbnailWithDropDown"))
|
||||
{
|
||||
PropertyAssetCtrl::EditCallbackType* func = azdynamic_cast<PropertyAssetCtrl::EditCallbackType*>(attrValue->GetAttribute());
|
||||
if (func)
|
||||
{
|
||||
GUI->SetShowThumbnailDropDown(true);
|
||||
GUI->SetShowThumbnail(true);
|
||||
GUI->SetEditNotifyCallback(func);
|
||||
}
|
||||
else
|
||||
|
||||
+2
-7
@@ -45,7 +45,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
class AssetCompleterModel;
|
||||
class AssetCompleterListView;
|
||||
class ThumbnailDropDown;
|
||||
class ThumbnailPropertyCtrl;
|
||||
|
||||
namespace Thumbnailer
|
||||
{
|
||||
@@ -95,8 +95,7 @@ namespace AzToolsFramework
|
||||
void OnAssetIDChanged(AZ::Data::AssetId newAssetID);
|
||||
|
||||
protected:
|
||||
ThumbnailDropDown* m_thumbnailDropDown = nullptr;
|
||||
Thumbnailer::ThumbnailWidget* m_thumbnail = nullptr;
|
||||
ThumbnailPropertyCtrl* m_thumbnail = nullptr;
|
||||
QPushButton* m_errorButton = nullptr;
|
||||
QToolButton* m_editButton = nullptr;
|
||||
|
||||
@@ -158,8 +157,6 @@ namespace AzToolsFramework
|
||||
|
||||
bool m_showThumbnail = false;
|
||||
|
||||
bool m_showThumbnailDropDown = false;
|
||||
|
||||
// ! Default suffix used in the field's placeholder text when a default value is set.
|
||||
const char* m_DefaultSuffix = " (default)";
|
||||
|
||||
@@ -209,8 +206,6 @@ namespace AzToolsFramework
|
||||
|
||||
void SetShowThumbnail(bool enable);
|
||||
bool GetShowThumbnail() const;
|
||||
void SetShowThumbnailDropDown(bool enable);
|
||||
bool GetShowThumbnailDropDown() const;
|
||||
|
||||
void SetSelectedAssetID(const AZ::Data::AssetId& newID);
|
||||
void SetCurrentAssetType(const AZ::Data::AssetType& newType);
|
||||
|
||||
+36
-9
@@ -19,12 +19,14 @@ AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // 4251: 'QRawFon
|
||||
#include <QPainter>
|
||||
#include <UI/UICore/AspectRatioAwarePixmapWidget.hxx>
|
||||
#include <Thumbnails/ThumbnailWidget.h>
|
||||
#include <QApplication>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
#include "ThumbnailDropDown.h"
|
||||
#include "ThumbnailPropertyCtrl.h"
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
ThumbnailDropDown::ThumbnailDropDown(QWidget* parent)
|
||||
|
||||
ThumbnailPropertyCtrl::ThumbnailPropertyCtrl(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QHBoxLayout* pLayout = new QHBoxLayout();
|
||||
@@ -51,19 +53,20 @@ namespace AzToolsFramework
|
||||
setLayout(pLayout);
|
||||
}
|
||||
|
||||
void ThumbnailDropDown::SetThumbnailKey(Thumbnailer::SharedThumbnailKey key, const char* contextName)
|
||||
void ThumbnailPropertyCtrl::SetThumbnailKey(Thumbnailer::SharedThumbnailKey key, const char* contextName)
|
||||
{
|
||||
m_key = key;
|
||||
m_emptyThumbnail->setVisible(false);
|
||||
m_thumbnail->SetThumbnailKey(key, contextName);
|
||||
}
|
||||
|
||||
void ThumbnailDropDown::ClearThumbnail()
|
||||
void ThumbnailPropertyCtrl::ClearThumbnail()
|
||||
{
|
||||
m_emptyThumbnail->setVisible(true);
|
||||
m_thumbnail->ClearThumbnail();
|
||||
}
|
||||
|
||||
bool ThumbnailDropDown::event(QEvent* e)
|
||||
bool ThumbnailPropertyCtrl::event(QEvent* e)
|
||||
{
|
||||
if (isEnabled())
|
||||
{
|
||||
@@ -77,7 +80,7 @@ namespace AzToolsFramework
|
||||
return QWidget::event(e);
|
||||
}
|
||||
|
||||
void ThumbnailDropDown::paintEvent(QPaintEvent* e)
|
||||
void ThumbnailPropertyCtrl::paintEvent(QPaintEvent* e)
|
||||
{
|
||||
QPainter p(this);
|
||||
QRect targetRect(QPoint(), QSize(40, 24));
|
||||
@@ -85,17 +88,41 @@ namespace AzToolsFramework
|
||||
QWidget::paintEvent(e);
|
||||
}
|
||||
|
||||
void ThumbnailDropDown::enterEvent(QEvent* e)
|
||||
#pragma optimize("", off)
|
||||
void ThumbnailPropertyCtrl::enterEvent(QEvent* e)
|
||||
{
|
||||
m_dropDownArrow->setPixmap(QPixmap(":/stylesheet/img/triangle0_highlighted.png"));
|
||||
if (!m_thumbnailEnlarged && m_key)
|
||||
{
|
||||
QWidget* rootWidget = QApplication::activeWindow();
|
||||
if (!rootWidget)
|
||||
return;
|
||||
QPoint rootPosition = rootWidget->pos();
|
||||
QPoint myPosition = pos();
|
||||
QPoint position = mapToGlobal(myPosition - QPoint(185, 0));
|
||||
QSize size(180, 180);
|
||||
m_thumbnailEnlarged = new Thumbnailer::ThumbnailWidget();
|
||||
m_thumbnailEnlarged->setFixedSize(size);
|
||||
m_thumbnailEnlarged->move(position);
|
||||
m_thumbnailEnlarged->setWindowTitle("test");
|
||||
m_thumbnailEnlarged->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
|
||||
m_thumbnailEnlarged->SetThumbnailKey(m_key);
|
||||
m_thumbnailEnlarged->show();
|
||||
}
|
||||
QWidget::enterEvent(e);
|
||||
}
|
||||
#pragma optimize("", on)
|
||||
|
||||
void ThumbnailDropDown::leaveEvent(QEvent* e)
|
||||
void ThumbnailPropertyCtrl::leaveEvent(QEvent* e)
|
||||
{
|
||||
m_dropDownArrow->setPixmap(QPixmap(":/stylesheet/img/triangle0.png"));
|
||||
if (m_thumbnailEnlarged)
|
||||
{
|
||||
delete m_thumbnailEnlarged;
|
||||
m_thumbnailEnlarged = nullptr;
|
||||
}
|
||||
QWidget::leaveEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
#include "UI/PropertyEditor/moc_ThumbnailDropDown.cpp"
|
||||
#include "UI/PropertyEditor/moc_ThumbnailPropertyCtrl.cpp"
|
||||
+5
-2
@@ -30,11 +30,12 @@ namespace AzToolsFramework
|
||||
class ThumbnailWidget;
|
||||
}
|
||||
|
||||
class ThumbnailDropDown : public QWidget
|
||||
//! Used by PropertyAssetCtrl to display thumbnail preview of the asset as well as additional drop-down actions
|
||||
class ThumbnailPropertyCtrl : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ThumbnailDropDown(QWidget* parent = nullptr);
|
||||
explicit ThumbnailPropertyCtrl(QWidget* parent = nullptr);
|
||||
|
||||
//! Call this to set what thumbnail widget will display
|
||||
void SetThumbnailKey(Thumbnailer::SharedThumbnailKey key, const char* contextName = "Default");
|
||||
@@ -52,7 +53,9 @@ namespace AzToolsFramework
|
||||
void leaveEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
Thumbnailer::SharedThumbnailKey m_key;
|
||||
Thumbnailer::ThumbnailWidget* m_thumbnail = nullptr;
|
||||
Thumbnailer::ThumbnailWidget* m_thumbnailEnlarged = nullptr;
|
||||
QLabel* m_emptyThumbnail = nullptr;
|
||||
AspectRatioAwarePixmapWidget* m_dropDownArrow = nullptr;
|
||||
};
|
||||
@@ -417,8 +417,8 @@ set(FILES
|
||||
UI/PropertyEditor/GrowTextEdit.cpp
|
||||
UI/PropertyEditor/MultiLineTextEditHandler.h
|
||||
UI/PropertyEditor/MultiLineTextEditHandler.cpp
|
||||
UI/PropertyEditor/ThumbnailDropDown.h
|
||||
UI/PropertyEditor/ThumbnailDropDown.cpp
|
||||
UI/PropertyEditor/ThumbnailPropertyCtrl.h
|
||||
UI/PropertyEditor/ThumbnailPropertyCtrl.cpp
|
||||
UI/Slice/SlicePushWidget.cpp
|
||||
UI/Slice/SlicePushWidget.hxx
|
||||
UI/Slice/SliceOverridesNotificationWindow.cpp
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ namespace AZ
|
||||
->Attribute(AZ::Edit::Attributes::DefaultAsset, &EditorMaterialComponentSlot::GetDefaultAssetId)
|
||||
->Attribute(AZ::Edit::Attributes::NameLabelOverride, &EditorMaterialComponentSlot::GetLabel)
|
||||
->Attribute(AZ::Edit::Attributes::ShowProductAssetFileName, true)
|
||||
->Attribute("ThumbnailWithDropDown", &EditorMaterialComponentSlot::OpenPopupMenu)
|
||||
->Attribute("Thumbnail", &EditorMaterialComponentSlot::OpenPopupMenu)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user