diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp index 7123489f..c058a9d7 100644 --- a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp +++ b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -42,6 +43,7 @@ #include "movie.h" #include "driver.h" +#include "common/vidblit.h" #include "Qt/config.h" #include "Qt/keyscan.h" #include "Qt/throttle.h" @@ -4333,3 +4335,100 @@ void QPianoRoll::paintEvent(QPaintEvent *event) } //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +//---- Bookmark Preview Popup +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +bookmarkPreviewPopup::bookmarkPreviewPopup( int index, QWidget *parent ) + : fceuCustomToolTip( parent ) +{ + int p; + QVBoxLayout *vbox; + QLabel *imgLbl, *descLbl; + uint32_t *pixBuf; + uint32_t pixel; + QPixmap pixmap; + + fceuWrapperLock(); + + // retrieve info from the pointed bookmark's Markers + int frame = bookmarks->bookmarksArray[index].snapshot.keyFrame; + int markerID = markersManager->getMarkerAboveFrame(bookmarks->bookmarksArray[index].snapshot.markers, frame); + + screenShotRaster = (unsigned char *)malloc( SCREENSHOT_SIZE ); + + if ( screenShotRaster == NULL ) + { + printf("Error: Failed to allocate screenshot image memory\n"); + } + // bookmarks.itemUnderMouse + + pixBuf = (uint32_t *)malloc( SCREENSHOT_SIZE * sizeof(uint32_t) ); + + loadImage(index); + + p=0; + for (int h=0; h> 16; + pixBuf[p] |= (pixel & 0x0000FF00); + p++; + } + } + QImage img( (unsigned char*)pixBuf, SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT, SCREENSHOT_WIDTH*4, QImage::Format_RGBA8888 ); + pixmap.convertFromImage( img ); + + vbox = new QVBoxLayout(); + + setLayout( vbox ); + + imgLbl = new QLabel(); + descLbl = new QLabel(); + + imgLbl->setPixmap( pixmap ); + + vbox->addWidget( imgLbl , 100 ); + vbox->addWidget( descLbl, 1 ); + + descLbl->setText( tr(markersManager->getNoteCopy(bookmarks->bookmarksArray[index].snapshot.markers, markerID).c_str()) ); + + resize( 256, 256 ); + + if ( pixBuf ) + { + free( pixBuf ); pixBuf = NULL; + } + fceuWrapperUnLock(); +} +//---------------------------------------------------------------------------- +bookmarkPreviewPopup::~bookmarkPreviewPopup( void ) +{ + if ( screenShotRaster != NULL ) + { + free( screenShotRaster ); screenShotRaster = NULL; + } + //printf("Popup Deleted\n"); +} +//---------------------------------------------------------------------------- +int bookmarkPreviewPopup::loadImage(int index) +{ + // uncompress + int ret = 0; + uLongf destlen = SCREENSHOT_SIZE; + int e = uncompress(screenShotRaster, &destlen, &bookmarks->bookmarksArray[index].savedScreenshot[0], bookmarks->bookmarksArray[index].savedScreenshot.size()); + if (e != Z_OK && e != Z_BUF_ERROR) + { + // error decompressing + FCEU_printf("Error decompressing screenshot %d\n", index); + // at least fill bitmap with zeros + memset(screenShotRaster, 0, SCREENSHOT_SIZE); + ret = -1; + } + return ret; +} +//---------------------------------------------------------------------------- diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.h b/src/drivers/Qt/TasEditor/TasEditorWindow.h index c65940cd..ec863f80 100644 --- a/src/drivers/Qt/TasEditor/TasEditorWindow.h +++ b/src/drivers/Qt/TasEditor/TasEditorWindow.h @@ -36,6 +36,7 @@ #include #include +#include "Qt/ConsoleUtilities.h" #include "Qt/TasEditor/taseditor_config.h" #include "Qt/TasEditor/taseditor_project.h" #include "Qt/TasEditor/greenzone.h" @@ -63,6 +64,19 @@ struct NewProjectParameters std::wstring authorName; }; +class bookmarkPreviewPopup : public fceuCustomToolTip +{ + Q_OBJECT + public: + bookmarkPreviewPopup( int index, QWidget *parent = nullptr ); + ~bookmarkPreviewPopup(void); + + private: + int loadImage(int index); + + unsigned char *screenShotRaster; +}; + class QPianoRoll : public QWidget { Q_OBJECT diff --git a/src/drivers/Qt/TasEditor/bookmarks.cpp b/src/drivers/Qt/TasEditor/bookmarks.cpp index 5a274c58..72fbfa7c 100644 --- a/src/drivers/Qt/TasEditor/bookmarks.cpp +++ b/src/drivers/Qt/TasEditor/bookmarks.cpp @@ -19,6 +19,8 @@ Bookmarks/Branches - Manager of Bookmarks * stores resources: save id, ids of commands, captions for panel, gradients for flashings, id of default slot ------------------------------------------------------------------------------------ */ +#include + #include #include "utils/xstring.h" #include "Qt/fceuWrapper.h" @@ -957,6 +959,34 @@ void BOOKMARKS::mouseMoveEvent(QMouseEvent * event) //printf("Mouse Move: 0x%x (%i,%i)\n", event->button(), c.x(), c.y() ); } +bool BOOKMARKS::event(QEvent *event) +{ + if (event->type() == QEvent::ToolTip) + { + int item, row_under_mouse, item_valid, column; + QHelpEvent *helpEvent = static_cast(event); + + QPoint c = convPixToCursor( helpEvent->pos() ); + + row_under_mouse = c.y(); + column = calcColumn( helpEvent->pos().x() ); + + item = (row_under_mouse + 1) % TOTAL_BOOKMARKS; + item_valid = (item >= 0) && (item < TOTAL_BOOKMARKS); + + if ( item_valid ) + { + static_cast(fceuCustomToolTipShow( helpEvent, new bookmarkPreviewPopup(item, this) )); + //QToolTip::showText(helpEvent->globalPos(), tr(stmp), this ); + QToolTip::hideText(); + event->ignore(); + } + + return true; + } + return QWidget::event(event); +} + void BOOKMARKS::handleMouseMove(int newX, int newY) { mouseX = newX; diff --git a/src/drivers/Qt/TasEditor/bookmarks.h b/src/drivers/Qt/TasEditor/bookmarks.h index 46e5df19..dbda038b 100644 --- a/src/drivers/Qt/TasEditor/bookmarks.h +++ b/src/drivers/Qt/TasEditor/bookmarks.h @@ -112,6 +112,7 @@ protected: void mousePressEvent(QMouseEvent * event); void mouseReleaseEvent(QMouseEvent * event); void mouseMoveEvent(QMouseEvent * event); + bool event(QEvent *event); int calcColumn( int px ); QPoint convPixToCursor( QPoint p );