Changed bookmark image view implementation so that it doesn't use tooltip events.

This commit is contained in:
mjbudd77 2021-12-11 20:54:19 -05:00
parent e0c3f2445f
commit 9633f081ca
7 changed files with 99 additions and 25 deletions

View File

@ -5272,7 +5272,7 @@ bool QAsmView::event(QEvent *event)
asmEntry[line]->addr, asmEntry[line]->bank, asmEntry[line]->rom ); asmEntry[line]->addr, asmEntry[line]->bank, asmEntry[line]->rom );
} }
//static_cast<asmLookAheadPopup*>(fceuCustomToolTipShow( helpEvent, new asmLookAheadPopup(asmEntry[line]->addr, this) )); //static_cast<asmLookAheadPopup*>(fceuCustomToolTipShow( helpEvent->globalPos(), new asmLookAheadPopup(asmEntry[line]->addr, this) ));
QToolTip::showText(helpEvent->globalPos(), tr(stmp), this ); QToolTip::showText(helpEvent->globalPos(), tr(stmp), this );
//QToolTip::hideText(); //QToolTip::hideText();
//event->ignore(); //event->ignore();
@ -5297,7 +5297,7 @@ bool QAsmView::event(QEvent *event)
addr, bank, romOfs ); addr, bank, romOfs );
} }
static_cast<asmLookAheadPopup*>(fceuCustomToolTipShow( helpEvent, new asmLookAheadPopup(addr, this) )); static_cast<asmLookAheadPopup*>(fceuCustomToolTipShow( helpEvent->globalPos(), new asmLookAheadPopup(addr, this) ));
//QToolTip::showText(helpEvent->globalPos(), tr(stmp), this ); //QToolTip::showText(helpEvent->globalPos(), tr(stmp), this );
QToolTip::hideText(); QToolTip::hideText();
event->ignore(); event->ignore();
@ -6866,7 +6866,7 @@ bool ppuCtrlRegDpy::event(QEvent *event)
//{ //{
// printf("Tool Tip Show\n"); // printf("Tool Tip Show\n");
//} //}
popup = static_cast<ppuRegPopup*>(fceuCustomToolTipShow( helpEvent, new ppuRegPopup(this) )); popup = static_cast<ppuRegPopup*>(fceuCustomToolTipShow( helpEvent->globalPos(), new ppuRegPopup(this) ));
QToolTip::hideText(); QToolTip::hideText();
event->ignore(); event->ignore();

View File

@ -312,7 +312,7 @@ int fceuLoadConfigColor( const char *confName, QColor *color )
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// FCEU Custom Tool Tip Helper Functions // FCEU Custom Tool Tip Helper Functions
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
QDialog *fceuCustomToolTipShow( QHelpEvent *helpEvent, QDialog *popup ) QDialog *fceuCustomToolTipShow( const QPoint &globalPos, QDialog *popup )
{ {
int xo = 32, yo = 32; int xo = 32, yo = 32;
QPoint pos; QPoint pos;
@ -332,19 +332,19 @@ QDialog *fceuCustomToolTipShow( QHelpEvent *helpEvent, QDialog *popup )
popup->show(); popup->show();
pos.setX( helpEvent->globalPos().x() + xo ); pos.setX( globalPos.x() + xo );
pos.setY( helpEvent->globalPos().y() + yo ); pos.setY( globalPos.y() + yo );
if ( scr ) if ( scr )
{ {
if ( ( (pos.x() + popup->width()) > scr->virtualSize().width() ) ) if ( ( (pos.x() + popup->width()) > scr->virtualSize().width() ) )
{ {
pos.setX( helpEvent->globalPos().x() - popup->width() - xo ); pos.setX( globalPos.x() - popup->width() - xo );
} }
if ( ( (pos.y() + popup->height()) > scr->virtualSize().height() ) ) if ( ( (pos.y() + popup->height()) > scr->virtualSize().height() ) )
{ {
pos.setY( helpEvent->globalPos().y() - popup->height() - yo ); pos.setY( globalPos.y() - popup->height() - yo );
} }
popup->move( pos ); popup->move( pos );
} }

View File

@ -90,4 +90,4 @@ class QCheckBoxRO : public QCheckBox
QString fceuGetOpcodeToolTip( uint8_t *opcode, int size ); QString fceuGetOpcodeToolTip( uint8_t *opcode, int size );
QDialog *fceuCustomToolTipShow( QHelpEvent *helpEvent, QDialog *popup ); QDialog *fceuCustomToolTipShow( const QPoint &globalPos, QDialog *popup );

View File

@ -47,9 +47,9 @@ Bookmarks/Branches - Manager of Bookmarks
//extern BRANCHES branches; //extern BRANCHES branches;
// resources // resources
char bookmarks_save_id[BOOKMARKS_ID_LEN] = "BOOKMARKS"; static char bookmarks_save_id[BOOKMARKS_ID_LEN] = "BOOKMARKS";
char bookmarks_skipsave_id[BOOKMARKS_ID_LEN] = "BOOKMARKX"; static char bookmarks_skipsave_id[BOOKMARKS_ID_LEN] = "BOOKMARKX";
char bookmarksCaption[3][23] = { " Bookmarks ", " Bookmarks / Branches ", " Branches " }; //char bookmarksCaption[3][23] = { " Bookmarks ", " Bookmarks / Branches ", " Branches " };
// color tables for flashing when saving/loading bookmarks // color tables for flashing when saving/loading bookmarks
//COLORREF bookmark_flash_colors[TOTAL_BOOKMARK_COMMANDS][FLASH_PHASE_MAX+1] = { //COLORREF bookmark_flash_colors[TOTAL_BOOKMARK_COMMANDS][FLASH_PHASE_MAX+1] = {
// // set // // set
@ -68,6 +68,12 @@ BOOKMARKS::BOOKMARKS(QWidget *parent)
viewWidth = 256; viewWidth = 256;
viewHeight = 256; viewHeight = 256;
imageItem = 0;
imageTimer = new QTimer(this);
imageTimer->setSingleShot(true);
imageTimer->setInterval(100);
connect( imageTimer, SIGNAL(timeout(void)), this, SLOT(showImage(void)) );
g_config->getOption("SDL.TasBookmarksFont", &fontString); g_config->getOption("SDL.TasBookmarksFont", &fontString);
if ( fontString.size() > 0 ) if ( fontString.size() > 0 )
@ -97,6 +103,7 @@ void BOOKMARKS::init()
reset(); reset();
selectedSlot = DEFAULT_SLOT; selectedSlot = DEFAULT_SLOT;
imageItem = 0;
redrawBookmarksSectionCaption(); redrawBookmarksSectionCaption();
} }
@ -125,6 +132,7 @@ void BOOKMARKS::reset_vars()
mustCheckItemUnderMouse = true; mustCheckItemUnderMouse = true;
bookmarkLeftclicked = bookmarkRightclicked = ITEM_UNDER_MOUSE_NONE; bookmarkLeftclicked = bookmarkRightclicked = ITEM_UNDER_MOUSE_NONE;
nextFlashUpdateTime = clock() + BOOKMARKS_FLASH_TICK; nextFlashUpdateTime = clock() + BOOKMARKS_FLASH_TICK;
imageItem = 0;
} }
void BOOKMARKS::setFont( QFont &newFont ) void BOOKMARKS::setFont( QFont &newFont )
@ -727,6 +735,7 @@ int BOOKMARKS::calcColumn( int px )
void BOOKMARKS::mousePressEvent(QMouseEvent * event) void BOOKMARKS::mousePressEvent(QMouseEvent * event)
{ {
fceuCriticalSection emuLock;
int item, row_under_mouse, item_valid; int item, row_under_mouse, item_valid;
QPoint c = convPixToCursor( event->pos() ); QPoint c = convPixToCursor( event->pos() );
@ -765,6 +774,7 @@ void BOOKMARKS::mousePressEvent(QMouseEvent * event)
void BOOKMARKS::mouseReleaseEvent(QMouseEvent * event) void BOOKMARKS::mouseReleaseEvent(QMouseEvent * event)
{ {
fceuCriticalSection emuLock;
//QPoint c = convPixToCursor( event->pos() ); //QPoint c = convPixToCursor( event->pos() );
//printf("Mouse Button Released: 0x%x (%i,%i)\n", event->button(), c.x(), c.y() ); //printf("Mouse Button Released: 0x%x (%i,%i)\n", event->button(), c.x(), c.y() );
@ -787,11 +797,37 @@ void BOOKMARKS::mouseReleaseEvent(QMouseEvent * event)
} }
} }
void BOOKMARKS::showImage(void)
{
static_cast<bookmarkPreviewPopup*>(fceuCustomToolTipShow( imagePos, new bookmarkPreviewPopup(imageItem, this) ));
}
void BOOKMARKS::mouseMoveEvent(QMouseEvent * event) void BOOKMARKS::mouseMoveEvent(QMouseEvent * event)
{ {
//QPoint c = convPixToCursor( event->pos() ); fceuCriticalSection emuLock;
int item, row_under_mouse, item_valid, column;
QPoint c = convPixToCursor( event->pos() );
//printf("Mouse Move: 0x%x (%i,%i)\n", event->button(), c.x(), c.y() ); //printf("Mouse Move: 0x%x (%i,%i)\n", event->button(), c.x(), c.y() );
row_under_mouse = c.y();
column = calcColumn( event->pos().x() );
item = (row_under_mouse + 1) % TOTAL_BOOKMARKS;
item_valid = (item >= 0) && (item < TOTAL_BOOKMARKS);
if ( item_valid && (column == BOOKMARKSLIST_COLUMN_TIME) && bookmarks->bookmarksArray[item].notEmpty)
{
imageItem = item;
imagePos = event->globalPos();
imageTimer->start();
QToolTip::hideText();
}
else
{
imageTimer->stop();
}
} }
bool BOOKMARKS::event(QEvent *event) bool BOOKMARKS::event(QEvent *event)
@ -811,7 +847,7 @@ bool BOOKMARKS::event(QEvent *event)
if ( item_valid && (column == BOOKMARKSLIST_COLUMN_TIME) && bookmarks->bookmarksArray[item].notEmpty) if ( item_valid && (column == BOOKMARKSLIST_COLUMN_TIME) && bookmarks->bookmarksArray[item].notEmpty)
{ {
static_cast<bookmarkPreviewPopup*>(fceuCustomToolTipShow( helpEvent, new bookmarkPreviewPopup(item, this) )); //static_cast<bookmarkPreviewPopup*>(fceuCustomToolTipShow( helpEvent, new bookmarkPreviewPopup(item, this) ));
//QToolTip::showText(helpEvent->globalPos(), tr(stmp), this ); //QToolTip::showText(helpEvent->globalPos(), tr(stmp), this );
QToolTip::hideText(); QToolTip::hideText();
event->ignore(); event->ignore();
@ -820,7 +856,10 @@ bool BOOKMARKS::event(QEvent *event)
{ {
QToolTip::showText(helpEvent->globalPos(), tr("Right click = set Bookmark, Left click = jump to Bookmark or load Branch"), this ); QToolTip::showText(helpEvent->globalPos(), tr("Right click = set Bookmark, Left click = jump to Bookmark or load Branch"), this );
} }
else
{
QToolTip::hideText();
}
return true; return true;
} }
return QWidget::event(event); return QWidget::event(event);

View File

@ -3,6 +3,7 @@
#include <vector> #include <vector>
#include <QFont> #include <QFont>
#include <QTimer>
#include <QWidget> #include <QWidget>
#include <QScrollBar> #include <QScrollBar>
@ -74,8 +75,6 @@ public:
void command(int command_id, int slot = -1); void command(int command_id, int slot = -1);
//void getDispInfo(NMLVDISPINFO* nmlvDispInfo);
//LONG handleCustomDraw(NMLVCUSTOMDRAW* msg);
void handleLeftClick(); void handleLeftClick();
void handleRightClick(); void handleRightClick();
@ -100,14 +99,11 @@ public:
bool mustCheckItemUnderMouse; bool mustCheckItemUnderMouse;
bool mouseOverBranchesBitmap, mouseOverBookmarksList; bool mouseOverBranchesBitmap, mouseOverBookmarksList;
int itemUnderMouse; int itemUnderMouse;
//TRACKMOUSEEVENT tme, tmeList;
int bookmarkLeftclicked, bookmarkRightclicked, columnClicked; int bookmarkLeftclicked, bookmarkRightclicked, columnClicked;
int listTopMargin; int listTopMargin;
int listRowLeft; int listRowLeft;
int listRowHeight; int listRowHeight;
//HWND hwndBookmarksList, hwndBranchesBitmap, hwndBookmarks;
protected: protected:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
@ -131,13 +127,15 @@ private:
int nextFlashUpdateTime; int nextFlashUpdateTime;
int mouseX, mouseY; int mouseX, mouseY;
// GDI stuff // GUI stuff
//HFONT hBookmarksFont;
//HIMAGELIST hImgList;
QFont font; QFont font;
QScrollBar *hbar; QScrollBar *hbar;
QScrollBar *vbar; QScrollBar *vbar;
QTimer *imageTimer;
QPoint imagePos;
int imageItem;
int viewWidth; int viewWidth;
int viewHeight; int viewHeight;
int viewLines; int viewLines;
@ -156,4 +154,7 @@ private:
int pxStartCol1; int pxStartCol1;
int pxStartCol2; int pxStartCol2;
int pxStartCol3; int pxStartCol3;
private slots:
void showImage(void);
}; };

View File

@ -57,6 +57,12 @@ BRANCHES::BRANCHES(QWidget *parent)
{ {
std::string fontString; std::string fontString;
imageItem = 0;
imageTimer = new QTimer(this);
imageTimer->setSingleShot(true);
imageTimer->setInterval(100);
connect( imageTimer, SIGNAL(timeout(void)), this, SLOT(showImage(void)) );
//this->parent = qobject_cast <TasEditorWindow*>( parent ); //this->parent = qobject_cast <TasEditorWindow*>( parent );
this->setFocusPolicy(Qt::StrongFocus); this->setFocusPolicy(Qt::StrongFocus);
this->setMouseTracking(true); this->setMouseTracking(true);
@ -559,12 +565,33 @@ void BRANCHES::mouseReleaseEvent(QMouseEvent * event)
} }
} }
void BRANCHES::showImage(void)
{
static_cast<bookmarkPreviewPopup*>(fceuCustomToolTipShow( imagePos, new bookmarkPreviewPopup(imageItem, this) ));
}
void BRANCHES::mouseMoveEvent(QMouseEvent * event) void BRANCHES::mouseMoveEvent(QMouseEvent * event)
{ {
int item = findItemUnderMouse( event->pos().x(), event->pos().y() ); int item, item_valid;
item = findItemUnderMouse( event->pos().x(), event->pos().y() );
item_valid = (item >= 0) && (item < TOTAL_BOOKMARKS);
bookmarks->itemUnderMouse = item; bookmarks->itemUnderMouse = item;
if ( item_valid && bookmarks->bookmarksArray[item].notEmpty)
{
imageItem = item;
imagePos = event->globalPos();
imageTimer->start();
QToolTip::hideText();
}
else
{
imageTimer->stop();
}
//if (event->button() & Qt::LeftButton) //if (event->button() & Qt::LeftButton)
//{ //{
@ -589,7 +616,7 @@ bool BRANCHES::event(QEvent *event)
if ( item_valid && bookmarks->bookmarksArray[item].notEmpty) if ( item_valid && bookmarks->bookmarksArray[item].notEmpty)
{ {
static_cast<bookmarkPreviewPopup*>(fceuCustomToolTipShow( helpEvent, new bookmarkPreviewPopup(item, this) )); //static_cast<bookmarkPreviewPopup*>(fceuCustomToolTipShow( helpEvent->globalPos(), new bookmarkPreviewPopup(item, this) ));
//QToolTip::showText(helpEvent->globalPos(), tr(stmp), this ); //QToolTip::showText(helpEvent->globalPos(), tr(stmp), this );
QToolTip::hideText(); QToolTip::hideText();
event->ignore(); event->ignore();

View File

@ -5,6 +5,7 @@
#include <vector> #include <vector>
#include <QFont> #include <QFont>
#include <QTimer>
#include <QWidget> #include <QWidget>
#define BRANCHES_ANIMATION_TICK (40 * CLOCKS_PER_SEC / 1000) // animate at 25FPS #define BRANCHES_ANIMATION_TICK (40 * CLOCKS_PER_SEC / 1000) // animate at 25FPS
@ -189,7 +190,10 @@ private:
int lastItemUnderMouse; int lastItemUnderMouse;
QFont font; QFont font;
QPoint imagePos;
QTimer *imageTimer;
int imageItem;
int viewWidth; int viewWidth;
int viewHeight; int viewHeight;
int pxCharWidth; int pxCharWidth;
@ -207,4 +211,7 @@ private:
std::vector<int> gridY; std::vector<int> gridY;
std::vector<int> gridHeight; std::vector<int> gridHeight;
std::vector<std::vector<uint8_t>> children; std::vector<std::vector<uint8_t>> children;
private slots:
void showImage(void);
}; };