@ -7,75 +7,117 @@
*/
*/
# include <AzToolsFramework/Debug/TraceContext.h>
# include <AzToolsFramework/Debug/TraceContext.h>
AZ_PUSH_DISABLE_WARNING ( 4251 4800 , " -Wunknown-warning-option " ) // 4251: 'QRawFont::d': class 'QExplicitlySharedDataPointer<QRawFontPrivate>' needs to have dll-interface to be used by clients of class 'QRawFont'
// 4800: 'QTextEngine *const ': forcing value to bool 'true' or 'false' (performance warning)
// 4251: 'QRawFont::d': class 'QExplicitlySharedDataPointer<QRawFontPrivate>' needs to have dll-interface to be used by clients of class
# include <QLabel>
// 'QRawFont' 4800: 'QTextEngine *const ': forcing value to bool 'true' or 'false' (performance warning)
# include <QHBoxLayout>
AZ_PUSH_DISABLE_WARNING ( 4251 4800 , " -Wunknown-warning-option " )
# include <QApplication>
# include <QEvent>
# include <QEvent>
# include <QHBoxLayout>
# include <QLabel>
# include <QPainter>
# include <QPainter>
# include <UI/UICore/AspectRatioAwarePixmapWidget.hxx>
# include <Thumbnails/ThumbnailWidget.h>
# include <Thumbnails/ThumbnailWidget.h>
# include < QApplication >
# include < UI/UICore/AspectRatioAwarePixmapWidget.hxx >
AZ_POP_DISABLE_WARNING
AZ_POP_DISABLE_WARNING
# include "ThumbnailPropertyCtrl.h"
# include "ThumbnailPropertyCtrl.h"
namespace AzToolsFramework
namespace AzToolsFramework
{
{
ThumbnailPropertyCtrl : : ThumbnailPropertyCtrl ( QWidget * parent )
ThumbnailPropertyCtrl : : ThumbnailPropertyCtrl ( QWidget * parent )
: QWidget ( parent )
: QWidget ( parent )
{
{
QHBoxLayout * pLayout = new QHBoxLayout ( ) ;
pLayout - > setContentsMargins ( 0 , 0 , 0 , 0 ) ;
pLayout - > setSpacing ( 0 ) ;
m_thumbnail = new Thumbnailer : : ThumbnailWidget ( this ) ;
m_thumbnail = new Thumbnailer : : ThumbnailWidget ( this ) ;
m_thumbnail - > setFixedSize ( QSize ( 24 , 24 ) ) ;
m_thumbnail - > setFixedSize ( QSize ( 24 , 24 ) ) ;
m_thumbnailEnlarged = new Thumbnailer : : ThumbnailWidget ( this ) ;
m_thumbnailEnlarged - > setFixedSize ( QSize ( 180 , 180 ) ) ;
m_thumbnailEnlarged - > setWindowFlags ( Qt : : Window | Qt : : FramelessWindowHint ) ;
m_customThumbnail = new QLabel ( this ) ;
m_customThumbnail - > setFixedSize ( QSize ( 24 , 24 ) ) ;
m_customThumbnail - > setScaledContents ( true ) ;
m_customThumbnailEnlarged = new QLabel ( this ) ;
m_customThumbnailEnlarged - > setFixedSize ( QSize ( 180 , 180 ) ) ;
m_customThumbnailEnlarged - > setWindowFlags ( Qt : : Window | Qt : : FramelessWindowHint ) ;
m_customThumbnailEnlarged - > setScaledContents ( true ) ;
m_dropDownArrow = new AspectRatioAwarePixmapWidget ( this ) ;
m_dropDownArrow = new AspectRatioAwarePixmapWidget ( this ) ;
m_dropDownArrow - > setPixmap ( QPixmap ( " :/stylesheet/img/triangle0.png " ) ) ;
m_dropDownArrow - > setPixmap ( QPixmap ( " :/stylesheet/img/triangle0.png " ) ) ;
m_dropDownArrow - > setFixedSize ( QSize ( 8 , 24 ) ) ;
m_dropDownArrow - > setFixedSize ( QSize ( 8 , 24 ) ) ;
ShowDropDownArrow ( false ) ;
m_emptyThumbnail = new QLabel ( this ) ;
m_emptyThumbnail = new QLabel ( this ) ;
m_emptyThumbnail - > setPixmap ( QPixmap ( " :/stylesheet/img/line.png " ) ) ;
m_emptyThumbnail - > setPixmap ( QPixmap ( " :/stylesheet/img/line.png " ) ) ;
m_emptyThumbnail - > setFixedSize ( QSize ( 24 , 24 ) ) ;
m_emptyThumbnail - > setFixedSize ( QSize ( 24 , 24 ) ) ;
pLayout - > addWidget ( m_emptyThumbnail ) ;
QHBoxLayout * pLayout = new QHBoxLayout ( ) ;
pLayout - > setContentsMargins ( 0 , 0 , 0 , 0 ) ;
pLayout - > setSpacing ( 0 ) ;
pLayout - > addWidget ( m_thumbnail ) ;
pLayout - > addWidget ( m_thumbnail ) ;
pLayout - > addWidget ( m_customThumbnail ) ;
pLayout - > addWidget ( m_emptyThumbnail ) ;
pLayout - > addSpacing ( 4 ) ;
pLayout - > addSpacing ( 4 ) ;
pLayout - > addWidget ( m_dropDownArrow ) ;
pLayout - > addWidget ( m_dropDownArrow ) ;
pLayout - > addSpacing ( 4 ) ;
pLayout - > addSpacing ( 4 ) ;
setLayout ( pLayout ) ;
setLayout ( pLayout ) ;
ShowDropDownArrow ( false ) ;
UpdateVisibility ( ) ;
}
}
void ThumbnailPropertyCtrl : : SetThumbnailKey ( Thumbnailer : : SharedThumbnailKey key , const char * contextName )
void ThumbnailPropertyCtrl : : SetThumbnailKey ( Thumbnailer : : SharedThumbnailKey key , const char * contextName )
{
{
m_key = key ;
if ( m_customThumbnailEnabled )
m_emptyThumbnail - > setVisible ( false ) ;
{
m_thumbnail - > SetThumbnailKey ( key , contextName ) ;
ClearThumbnail ( ) ;
}
else
{
m_key = key ;
m_thumbnail - > SetThumbnailKey ( m_key , contextName ) ;
m_thumbnailEnlarged - > SetThumbnailKey ( m_key , contextName ) ;
}
UpdateVisibility ( ) ;
}
}
void ThumbnailPropertyCtrl : : ClearThumbnail ( )
void ThumbnailPropertyCtrl : : ClearThumbnail ( )
{
{
m_emptyThumbnail - > setVisible ( true ) ;
m_ key. clear ( ) ;
m_thumbnail - > ClearThumbnail ( ) ;
m_thumbnail - > ClearThumbnail ( ) ;
m_thumbnailEnlarged - > ClearThumbnail ( ) ;
UpdateVisibility ( ) ;
}
}
void ThumbnailPropertyCtrl : : ShowDropDownArrow ( bool visible )
void ThumbnailPropertyCtrl : : ShowDropDownArrow ( bool visible )
{
{
if ( visible )
setFixedSize ( QSize ( visible ? 40 : 24 , 24 ) ) ;
{
setFixedSize ( QSize ( 40 , 24 ) ) ;
}
else
{
setFixedSize ( QSize ( 24 , 24 ) ) ;
}
m_dropDownArrow - > setVisible ( visible ) ;
m_dropDownArrow - > setVisible ( visible ) ;
}
}
void ThumbnailPropertyCtrl : : SetCustomThumbnailEnabled ( bool enabled )
{
m_customThumbnailEnabled = enabled ;
UpdateVisibility ( ) ;
}
void ThumbnailPropertyCtrl : : SetCustomThumbnailPixmap ( const QPixmap & pixmap )
{
m_customThumbnail - > setPixmap ( pixmap ) ;
m_customThumbnailEnlarged - > setPixmap ( pixmap ) ;
UpdateVisibility ( ) ;
}
void ThumbnailPropertyCtrl : : UpdateVisibility ( )
{
m_thumbnail - > setVisible ( m_key & & ! m_customThumbnailEnabled ) ;
m_thumbnailEnlarged - > setVisible ( false ) ;
m_customThumbnail - > setVisible ( m_customThumbnailEnabled ) ;
m_customThumbnailEnlarged - > setVisible ( false ) ;
m_emptyThumbnail - > setVisible ( ! m_key & & ! m_customThumbnailEnabled ) ;
}
bool ThumbnailPropertyCtrl : : event ( QEvent * e )
bool ThumbnailPropertyCtrl : : event ( QEvent * e )
{
{
if ( isEnabled ( ) )
if ( isEnabled ( ) )
@ -83,7 +125,7 @@ namespace AzToolsFramework
if ( e - > type ( ) = = QEvent : : MouseButtonPress )
if ( e - > type ( ) = = QEvent : : MouseButtonPress )
{
{
emit clicked ( ) ;
emit clicked ( ) ;
return true ; // ignore
return true ; // ignore
}
}
}
}
@ -94,37 +136,32 @@ namespace AzToolsFramework
{
{
QPainter p ( this ) ;
QPainter p ( this ) ;
QRect targetRect ( QPoint ( ) , QSize ( 40 , 24 ) ) ;
QRect targetRect ( QPoint ( ) , QSize ( 40 , 24 ) ) ;
p . fillRect ( targetRect , QColor ( 17 , 17 , 17 ) ) ; // #111111
p . fillRect ( targetRect , QColor ( " #111111 " ) ) ;
QWidget : : paintEvent ( e ) ;
QWidget : : paintEvent ( e ) ;
}
}
void ThumbnailPropertyCtrl : : enterEvent ( QEvent * e )
void ThumbnailPropertyCtrl : : enterEvent ( QEvent * e )
{
{
m_dropDownArrow - > setPixmap ( QPixmap ( " :/stylesheet/img/triangle0_highlighted.png " ) ) ;
m_dropDownArrow - > setPixmap ( QPixmap ( " :/stylesheet/img/triangle0_highlighted.png " ) ) ;
if ( ! m_thumbnailEnlarged & & m_key )
const QPoint offset ( - m_thumbnailEnlarged - > width ( ) - 5 , - m_thumbnailEnlarged - > height ( ) / 2 + m_thumbnail - > height ( ) / 2 ) ;
{
QPoint position = mapToGlobal ( pos ( ) - QPoint ( 185 , 0 ) ) ;
m_thumbnailEnlarged - > move ( mapToGlobal ( pos ( ) ) + offset ) ;
QSize size ( 180 , 180 ) ;
m_thumbnailEnlarged - > raise ( ) ;
m_thumbnailEnlarged . reset ( new Thumbnailer : : ThumbnailWidget ( ) ) ;
m_thumbnailEnlarged - > setVisible ( m_key & & ! m_customThumbnailEnabled ) ;
m_thumbnailEnlarged - > setFixedSize ( size ) ;
m_thumbnailEnlarged - > move ( position ) ;
m_customThumbnailEnlarged - > move ( mapToGlobal ( pos ( ) ) + offset ) ;
m_thumbnailEnlarged - > setWindowFlags ( Qt : : Window | Qt : : FramelessWindowHint ) ;
m_customThumbnailEnlarged - > raise ( ) ;
m_thumbnailEnlarged - > SetThumbnailKey ( m_key ) ;
m_customThumbnailEnlarged - > setVisible ( m_customThumbnailEnabled ) ;
m_thumbnailEnlarged - > raise ( ) ;
m_thumbnailEnlarged - > show ( ) ;
}
QWidget : : enterEvent ( e ) ;
QWidget : : enterEvent ( e ) ;
}
}
void ThumbnailPropertyCtrl : : leaveEvent ( QEvent * e )
void ThumbnailPropertyCtrl : : leaveEvent ( QEvent * e )
{
{
m_dropDownArrow - > setPixmap ( QPixmap ( " :/stylesheet/img/triangle0.png " ) ) ;
m_dropDownArrow - > setPixmap ( QPixmap ( " :/stylesheet/img/triangle0.png " ) ) ;
if ( m_thumbnailEnlarged )
m_thumbnailEnlarged - > setVisible ( false ) ;
{
m_customThumbnailEnlarged - > setVisible ( false ) ;
m_thumbnailEnlarged . reset ( ) ;
}
QWidget : : leaveEvent ( e ) ;
QWidget : : leaveEvent ( e ) ;
}
}
}
} // namespace AzToolsFramework
# include "UI/PropertyEditor/moc_ThumbnailPropertyCtrl.cpp"
# include "UI/PropertyEditor/moc_ThumbnailPropertyCtrl.cpp"