diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp index 55052b25..4d2cd760 100644 --- a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp +++ b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp @@ -6468,17 +6468,31 @@ void QPianoRoll::paintEvent(QPaintEvent *event) //---- Bookmark Preview Popup //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- +bookmarkPreviewPopup *bookmarkPreviewPopup::instance = 0; +//---------------------------------------------------------------------------- bookmarkPreviewPopup::bookmarkPreviewPopup( int index, QWidget *parent ) - : fceuCustomToolTip( parent ) + : QDialog( parent, Qt::ToolTip ) { int p; + QPoint pos; QVBoxLayout *vbox; QLabel *imgLbl, *descLbl; uint32_t *pixBuf; uint32_t pixel; QPixmap pixmap; - setHideOnMouseMove(true); + if ( instance ) + { + //instance->done(0); + //instance->deleteLater(); + instance->actv = false; + instance = 0; + } + instance = this; + + imageIndex = index; + + //qApp->installEventFilter(this); fceuWrapperLock(); @@ -6534,11 +6548,32 @@ bookmarkPreviewPopup::bookmarkPreviewPopup( int index, QWidget *parent ) { free( pixBuf ); pixBuf = NULL; } + + pos = parent->mapToGlobal(QPoint(0,0)); + + pos.setX( pos.x() - 300 ); + + move(pos); + fceuWrapperUnLock(); + + alpha = 0; + actv = true; + + setWindowOpacity(0.0f); + + timer = new QTimer(this); + + connect( timer, &QTimer::timeout, this, &bookmarkPreviewPopup::periodicUpdate ); + + timer->start(33); + } //---------------------------------------------------------------------------- bookmarkPreviewPopup::~bookmarkPreviewPopup( void ) { + timer->stop(); + if ( screenShotRaster != NULL ) { free( screenShotRaster ); screenShotRaster = NULL; @@ -6546,6 +6581,70 @@ bookmarkPreviewPopup::~bookmarkPreviewPopup( void ) //printf("Popup Deleted\n"); } //---------------------------------------------------------------------------- +void bookmarkPreviewPopup::periodicUpdate(void) +{ + if ( actv ) + { + if ( alpha < 255 ) + { + alpha += 10; + + if ( alpha > 255 ) + { + alpha = 255; + } + setWindowOpacity( alpha / 255.0f ); + + update(); + } + } + else + { + if ( alpha > 0 ) + { + alpha -= 10; + + if ( alpha < 0 ) + { + alpha = 0; + } + setWindowOpacity( alpha / 255.0f ); + + update(); + } + else + { + if ( instance == this ) + { + instance = NULL; + } + done(0); + deleteLater(); + } + } +} +//---------------------------------------------------------------------------- +int bookmarkPreviewPopup::currentIndex(void) +{ + if ( instance ) + { + return instance->imageIndex; + } + return -1; +} +//---------------------------------------------------------------------------- +void bookmarkPreviewPopup::imageIndexChanged(int newIndex) +{ + //printf("newIndex:%i\n", newIndex ); + + actv = false; + + if ( instance == this ) + { + instance = NULL; + } +} +//---------------------------------------------------------------------------- int bookmarkPreviewPopup::loadImage(int index) { // uncompress diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.h b/src/drivers/Qt/TasEditor/TasEditorWindow.h index 7a9f04b3..df186446 100644 --- a/src/drivers/Qt/TasEditor/TasEditorWindow.h +++ b/src/drivers/Qt/TasEditor/TasEditorWindow.h @@ -114,17 +114,29 @@ struct NewProjectParameters std::wstring authorName; }; -class bookmarkPreviewPopup : public fceuCustomToolTip +class bookmarkPreviewPopup : public QDialog { Q_OBJECT public: bookmarkPreviewPopup( int index, QWidget *parent = nullptr ); ~bookmarkPreviewPopup(void); - private: - int loadImage(int index); + static int currentIndex(void); - unsigned char *screenShotRaster; + private: + int loadImage(int index); + + int alpha; + int imageIndex; + bool actv; + unsigned char *screenShotRaster; + QTimer *timer; + + static bookmarkPreviewPopup *instance; + + public slots: + void periodicUpdate(void); + void imageIndexChanged(int); }; class markerDragPopup : public QDialog diff --git a/src/drivers/Qt/TasEditor/bookmarks.cpp b/src/drivers/Qt/TasEditor/bookmarks.cpp index efad29b2..7e22ba6b 100644 --- a/src/drivers/Qt/TasEditor/bookmarks.cpp +++ b/src/drivers/Qt/TasEditor/bookmarks.cpp @@ -788,7 +788,17 @@ void BOOKMARKS::mouseReleaseEvent(QMouseEvent * event) void BOOKMARKS::showImage(void) { fceuCriticalSection emuLock; - static_cast(fceuCustomToolTipShow( imagePos, new bookmarkPreviewPopup(imageItem, this) )); + //static_cast(fceuCustomToolTipShow( imagePos, new bookmarkPreviewPopup(imageItem, this) )); + bool item_valid = (imageItem >= 0) && (imageItem < TOTAL_BOOKMARKS); + + if ( item_valid && (imageItem != bookmarkPreviewPopup::currentIndex()) ) + { + bookmarkPreviewPopup *popup = new bookmarkPreviewPopup(imageItem, this); + + connect( this, SIGNAL(imageIndexChanged(int)), popup, SLOT(imageIndexChanged(int)) ); + + popup->show(); + } } void BOOKMARKS::mouseMoveEvent(QMouseEvent * event) @@ -808,6 +818,10 @@ void BOOKMARKS::mouseMoveEvent(QMouseEvent * event) if ( item_valid && (column == BOOKMARKSLIST_COLUMN_TIME) && bookmarks->bookmarksArray[item].notEmpty) { + if ( item != imageItem ) + { + emit imageIndexChanged(item); + } imageItem = item; imagePos = event->globalPos(); imageTimer->start(); @@ -815,10 +829,36 @@ void BOOKMARKS::mouseMoveEvent(QMouseEvent * event) } else { + item = -1; + if ( item != imageItem ) + { + emit imageIndexChanged(item); + } + imageItem = item; imageTimer->stop(); } } +void BOOKMARKS::focusOutEvent(QFocusEvent *event) +{ + int item = -1; + if ( item != imageItem ) + { + emit imageIndexChanged(item); + } + imageItem = item; +} + +void BOOKMARKS::leaveEvent(QEvent *event) +{ + int item = -1; + if ( item != imageItem ) + { + emit imageIndexChanged(item); + } + imageItem = item; +} + bool BOOKMARKS::event(QEvent *event) { if (event->type() == QEvent::ToolTip) diff --git a/src/drivers/Qt/TasEditor/bookmarks.h b/src/drivers/Qt/TasEditor/bookmarks.h index 25b659bc..70ed2b7f 100644 --- a/src/drivers/Qt/TasEditor/bookmarks.h +++ b/src/drivers/Qt/TasEditor/bookmarks.h @@ -110,6 +110,8 @@ protected: void mousePressEvent(QMouseEvent * event); void mouseReleaseEvent(QMouseEvent * event); void mouseMoveEvent(QMouseEvent * event); + void focusOutEvent(QFocusEvent *event); + void leaveEvent(QEvent *event); bool event(QEvent *event); int calcColumn( int px ); @@ -157,4 +159,7 @@ private: private slots: void showImage(void); + + signals: + void imageIndexChanged(int); }; diff --git a/src/drivers/Qt/TasEditor/branches.cpp b/src/drivers/Qt/TasEditor/branches.cpp index e6788afb..e02ef1d3 100644 --- a/src/drivers/Qt/TasEditor/branches.cpp +++ b/src/drivers/Qt/TasEditor/branches.cpp @@ -586,7 +586,18 @@ void BRANCHES::mouseReleaseEvent(QMouseEvent * event) void BRANCHES::showImage(void) { fceuCriticalSection emuLock; - static_cast(fceuCustomToolTipShow( imagePos, new bookmarkPreviewPopup(imageItem, this) )); + //static_cast(fceuCustomToolTipShow( imagePos, new bookmarkPreviewPopup(imageItem, this) )); + + bool item_valid = (imageItem >= 0) && (imageItem < TOTAL_BOOKMARKS); + + if ( item_valid && (imageItem != bookmarkPreviewPopup::currentIndex()) ) + { + bookmarkPreviewPopup *popup = new bookmarkPreviewPopup(imageItem, this); + + connect( this, SIGNAL(imageIndexChanged(int)), popup, SLOT(imageIndexChanged(int)) ); + + popup->show(); + } } void BRANCHES::mouseMoveEvent(QMouseEvent * event) @@ -602,6 +613,10 @@ void BRANCHES::mouseMoveEvent(QMouseEvent * event) if ( item_valid && bookmarks->bookmarksArray[item].notEmpty) { + if ( item != imageItem ) + { + emit imageIndexChanged(item); + } imageItem = item; imagePos = event->globalPos(); imageTimer->start(); @@ -609,6 +624,12 @@ void BRANCHES::mouseMoveEvent(QMouseEvent * event) } else { + item = -1; + if ( item != imageItem ) + { + emit imageIndexChanged(item); + } + imageItem = item; imageTimer->stop(); } @@ -623,6 +644,30 @@ void BRANCHES::mouseMoveEvent(QMouseEvent * event) } +void BRANCHES::focusOutEvent(QFocusEvent *event) +{ + int item = -1; + if ( item != imageItem ) + { + emit imageIndexChanged(item); + } + imageItem = item; + + bookmarks->itemUnderMouse = ITEM_UNDER_MOUSE_NONE; +} + +void BRANCHES::leaveEvent(QEvent *event) +{ + int item = -1; + if ( item != imageItem ) + { + emit imageIndexChanged(item); + } + imageItem = item; + + bookmarks->itemUnderMouse = ITEM_UNDER_MOUSE_NONE; +} + bool BRANCHES::event(QEvent *event) { if (event->type() == QEvent::ToolTip) diff --git a/src/drivers/Qt/TasEditor/branches.h b/src/drivers/Qt/TasEditor/branches.h index 45c7cdc5..a7d18e82 100644 --- a/src/drivers/Qt/TasEditor/branches.h +++ b/src/drivers/Qt/TasEditor/branches.h @@ -151,6 +151,8 @@ protected: void mouseReleaseEvent(QMouseEvent * event); void mouseMoveEvent(QMouseEvent * event); void mouseDoubleClickEvent(QMouseEvent * event); + void focusOutEvent(QFocusEvent *event); + void leaveEvent(QEvent *event); bool event(QEvent *event); private: @@ -214,4 +216,7 @@ private: private slots: void showImage(void); + + signals: + void imageIndexChanged(int); };