Qt TAS editor bookmark list paint code implemented.

This commit is contained in:
mjbudd77 2021-11-14 20:34:55 -05:00
parent 96f6a28cc6
commit 06ea1bf29a
4 changed files with 288 additions and 101 deletions

View File

@ -0,0 +1,88 @@
// TasColors.h
#pragma once
// Piano Roll Colors
#define NORMAL_TEXT_COLOR 0x0
#define NORMAL_BACKGROUND_COLOR 0xFFFFFF
//#define NORMAL_FRAMENUM_COLOR 0xFFFFFF
//#define NORMAL_INPUT_COLOR1 0xEDEDED
//#define NORMAL_INPUT_COLOR2 0xE2E2E2
#define NORMAL_FRAMENUM_COLOR 0xFF, 0xFF, 0xFF
#define NORMAL_INPUT_COLOR1 0xED, 0xED, 0xED
#define NORMAL_INPUT_COLOR2 0xE2, 0xE2, 0xE2
//#define GREENZONE_FRAMENUM_COLOR 0xDDFFDD
//#define GREENZONE_INPUT_COLOR1 0xC8F7C4
//#define GREENZONE_INPUT_COLOR2 0xADE7AD
#define GREENZONE_FRAMENUM_COLOR 0xDD, 0xFF, 0xDD
#define GREENZONE_INPUT_COLOR1 0xC4, 0xF7, 0xC8
#define GREENZONE_INPUT_COLOR2 0xAD, 0xE7, 0xAD
//#define PALE_GREENZONE_FRAMENUM_COLOR 0xE4FFE4
//#define PALE_GREENZONE_INPUT_COLOR1 0xD3F9D2
//#define PALE_GREENZONE_INPUT_COLOR2 0xBAEBBA
#define PALE_GREENZONE_FRAMENUM_COLOR 0xE4, 0xFF, 0xE4
#define PALE_GREENZONE_INPUT_COLOR1 0xD2, 0xF9, 0xD3
#define PALE_GREENZONE_INPUT_COLOR2 0xBA, 0xEB, 0xBA
//#define VERY_PALE_GREENZONE_FRAMENUM_COLOR 0xF9FFF9
//#define VERY_PALE_GREENZONE_INPUT_COLOR1 0xE0FBE0
//#define VERY_PALE_GREENZONE_INPUT_COLOR2 0xD2F2D2
#define VERY_PALE_GREENZONE_FRAMENUM_COLOR 0xF9, 0xFF, 0xF9
#define VERY_PALE_GREENZONE_INPUT_COLOR1 0xE0, 0xFB, 0xE0
#define VERY_PALE_GREENZONE_INPUT_COLOR2 0xD2, 0xF2, 0xD2
//#define LAG_FRAMENUM_COLOR 0xDDDCFF
//#define LAG_INPUT_COLOR1 0xD2D0F0
//#define LAG_INPUT_COLOR2 0xC9C6E8
#define LAG_FRAMENUM_COLOR 0xFF, 0xDC, 0xDD
#define LAG_INPUT_COLOR1 0xF0, 0xD0, 0xD2
#define LAG_INPUT_COLOR2 0xE8, 0xC6, 0xC9
//#define PALE_LAG_FRAMENUM_COLOR 0xE3E3FF
//#define PALE_LAG_INPUT_COLOR1 0xDADAF4
//#define PALE_LAG_INPUT_COLOR2 0xCFCEEA
#define PALE_LAG_FRAMENUM_COLOR 0xFF, 0xE3, 0xE3
#define PALE_LAG_INPUT_COLOR1 0xF4, 0xDA, 0xDA
#define PALE_LAG_INPUT_COLOR2 0xEA, 0xCE, 0xCF
//#define VERY_PALE_LAG_FRAMENUM_COLOR 0xE9E9FF
//#define VERY_PALE_LAG_INPUT_COLOR1 0xE5E5F7
//#define VERY_PALE_LAG_INPUT_COLOR2 0xE0E0F1
#define VERY_PALE_LAG_FRAMENUM_COLOR 0xFF, 0xE9, 0xE9
#define VERY_PALE_LAG_INPUT_COLOR1 0xF7, 0xE5, 0xE5
#define VERY_PALE_LAG_INPUT_COLOR2 0xF1, 0xE0, 0xE0
//#define CUR_FRAMENUM_COLOR 0xFCEDCF
//#define CUR_INPUT_COLOR1 0xF7E7B5
//#define CUR_INPUT_COLOR2 0xE5DBA5
#define CUR_FRAMENUM_COLOR 0xCF, 0xED, 0xFC
#define CUR_INPUT_COLOR1 0xB5, 0xE7, 0xF7
#define CUR_INPUT_COLOR2 0xA5, 0xDB, 0xE5
//#define UNDOHINT_FRAMENUM_COLOR 0xF9DDE6
//#define UNDOHINT_INPUT_COLOR1 0xF7D2E1
//#define UNDOHINT_INPUT_COLOR2 0xE9BED1
#define UNDOHINT_FRAMENUM_COLOR 0xE6, 0xDD, 0xF9
#define UNDOHINT_INPUT_COLOR1 0xE1, 0xD2, 0xF7
#define UNDOHINT_INPUT_COLOR2 0xD1, 0xBE, 0xE9
#define MARKED_FRAMENUM_COLOR 0xAEF0FF
#define CUR_MARKED_FRAMENUM_COLOR 0xCAEDEA
#define MARKED_UNDOHINT_FRAMENUM_COLOR 0xDDE5E9
#define BINDMARKED_FRAMENUM_COLOR 0xC9FFF7
#define CUR_BINDMARKED_FRAMENUM_COLOR 0xD5F2EC
#define BINDMARKED_UNDOHINT_FRAMENUM_COLOR 0xE1EBED
#define PLAYBACK_MARKER_COLOR 0xC9AF00

View File

@ -45,6 +45,7 @@
#include "Qt/throttle.h"
#include "Qt/fceuWrapper.h"
#include "Qt/ConsoleUtilities.h"
#include "Qt/TasEditor/TasColors.h"
#include "Qt/TasEditor/TasEditorWindow.h"
TasEditorWindow *tasWin = NULL;
@ -120,92 +121,6 @@ enum DRAG_MODES
#define GREEN_ARROW_IMAGE_ID 61
#define GREEN_BLUE_ARROW_IMAGE_ID 62
// Piano Roll Colors
#define NORMAL_TEXT_COLOR 0x0
#define NORMAL_BACKGROUND_COLOR 0xFFFFFF
//#define NORMAL_FRAMENUM_COLOR 0xFFFFFF
//#define NORMAL_INPUT_COLOR1 0xEDEDED
//#define NORMAL_INPUT_COLOR2 0xE2E2E2
#define NORMAL_FRAMENUM_COLOR 0xFF, 0xFF, 0xFF
#define NORMAL_INPUT_COLOR1 0xED, 0xED, 0xED
#define NORMAL_INPUT_COLOR2 0xE2, 0xE2, 0xE2
//#define GREENZONE_FRAMENUM_COLOR 0xDDFFDD
//#define GREENZONE_INPUT_COLOR1 0xC8F7C4
//#define GREENZONE_INPUT_COLOR2 0xADE7AD
#define GREENZONE_FRAMENUM_COLOR 0xDD, 0xFF, 0xDD
#define GREENZONE_INPUT_COLOR1 0xC4, 0xF7, 0xC8
#define GREENZONE_INPUT_COLOR2 0xAD, 0xE7, 0xAD
//#define PALE_GREENZONE_FRAMENUM_COLOR 0xE4FFE4
//#define PALE_GREENZONE_INPUT_COLOR1 0xD3F9D2
//#define PALE_GREENZONE_INPUT_COLOR2 0xBAEBBA
#define PALE_GREENZONE_FRAMENUM_COLOR 0xE4, 0xFF, 0xE4
#define PALE_GREENZONE_INPUT_COLOR1 0xD2, 0xF9, 0xD3
#define PALE_GREENZONE_INPUT_COLOR2 0xBA, 0xEB, 0xBA
//#define VERY_PALE_GREENZONE_FRAMENUM_COLOR 0xF9FFF9
//#define VERY_PALE_GREENZONE_INPUT_COLOR1 0xE0FBE0
//#define VERY_PALE_GREENZONE_INPUT_COLOR2 0xD2F2D2
#define VERY_PALE_GREENZONE_FRAMENUM_COLOR 0xF9, 0xFF, 0xF9
#define VERY_PALE_GREENZONE_INPUT_COLOR1 0xE0, 0xFB, 0xE0
#define VERY_PALE_GREENZONE_INPUT_COLOR2 0xD2, 0xF2, 0xD2
//#define LAG_FRAMENUM_COLOR 0xDDDCFF
//#define LAG_INPUT_COLOR1 0xD2D0F0
//#define LAG_INPUT_COLOR2 0xC9C6E8
#define LAG_FRAMENUM_COLOR 0xFF, 0xDC, 0xDD
#define LAG_INPUT_COLOR1 0xF0, 0xD0, 0xD2
#define LAG_INPUT_COLOR2 0xE8, 0xC6, 0xC9
//#define PALE_LAG_FRAMENUM_COLOR 0xE3E3FF
//#define PALE_LAG_INPUT_COLOR1 0xDADAF4
//#define PALE_LAG_INPUT_COLOR2 0xCFCEEA
#define PALE_LAG_FRAMENUM_COLOR 0xFF, 0xE3, 0xE3
#define PALE_LAG_INPUT_COLOR1 0xF4, 0xDA, 0xDA
#define PALE_LAG_INPUT_COLOR2 0xEA, 0xCE, 0xCF
//#define VERY_PALE_LAG_FRAMENUM_COLOR 0xE9E9FF
//#define VERY_PALE_LAG_INPUT_COLOR1 0xE5E5F7
//#define VERY_PALE_LAG_INPUT_COLOR2 0xE0E0F1
#define VERY_PALE_LAG_FRAMENUM_COLOR 0xFF, 0xE9, 0xE9
#define VERY_PALE_LAG_INPUT_COLOR1 0xF7, 0xE5, 0xE5
#define VERY_PALE_LAG_INPUT_COLOR2 0xF1, 0xE0, 0xE0
//#define CUR_FRAMENUM_COLOR 0xFCEDCF
//#define CUR_INPUT_COLOR1 0xF7E7B5
//#define CUR_INPUT_COLOR2 0xE5DBA5
#define CUR_FRAMENUM_COLOR 0xCF, 0xED, 0xFC
#define CUR_INPUT_COLOR1 0xB5, 0xE7, 0xF7
#define CUR_INPUT_COLOR2 0xA5, 0xDB, 0xE5
//#define UNDOHINT_FRAMENUM_COLOR 0xF9DDE6
//#define UNDOHINT_INPUT_COLOR1 0xF7D2E1
//#define UNDOHINT_INPUT_COLOR2 0xE9BED1
#define UNDOHINT_FRAMENUM_COLOR 0xE6, 0xDD, 0xF9
#define UNDOHINT_INPUT_COLOR1 0xE1, 0xD2, 0xF7
#define UNDOHINT_INPUT_COLOR2 0xD1, 0xBE, 0xE9
#define MARKED_FRAMENUM_COLOR 0xAEF0FF
#define CUR_MARKED_FRAMENUM_COLOR 0xCAEDEA
#define MARKED_UNDOHINT_FRAMENUM_COLOR 0xDDE5E9
#define BINDMARKED_FRAMENUM_COLOR 0xC9FFF7
#define CUR_BINDMARKED_FRAMENUM_COLOR 0xD5F2EC
#define BINDMARKED_UNDOHINT_FRAMENUM_COLOR 0xE1EBED
#define PLAYBACK_MARKER_COLOR 0xC9AF00
#define MARKER_DRAG_COUNTDOWN_MAX 14
//----------------------------------------------------------------------------
@ -1071,6 +986,7 @@ void TasEditorWindow::buildSideControlPanel(void)
QVBoxLayout *vbox;
QHBoxLayout *hbox;
QGridLayout *grid;
QScrollArea *scrollArea;
QTreeWidgetItem *item;
ctlPanelMainVbox = new QVBoxLayout();
@ -1176,9 +1092,17 @@ void TasEditorWindow::buildSideControlPanel(void)
//hbox->addWidget( runLuaBtn );
//hbox->addWidget( autoLuaCBox );
//luaGBox->setLayout( hbox );
scrollArea = new QScrollArea();
scrollArea->setWidgetResizable(false);
scrollArea->setSizeAdjustPolicy( QAbstractScrollArea::AdjustToContents );
scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
scrollArea->setMinimumSize( QSize( 128, 128 ) );
scrollArea->setWidget( &bookmarks );
bkmkBrnchStack = new QTabWidget();
bkmkBrnchStack->addTab( &bookmarks, tr("Bookmarks") );
bkmkBrnchStack->addTab( scrollArea, tr("Bookmarks") );
bkmkBrnchStack->addTab( &branches , tr("Branches") );
vbox = new QVBoxLayout();

View File

@ -25,6 +25,7 @@
#include <QTreeWidgetItem>
#include <QCloseEvent>
#include <QScrollBar>
#include <QScrollArea>
#include <QMenu>
#include <QMenuBar>
#include <QAction>

View File

@ -24,6 +24,7 @@ Bookmarks/Branches - Manager of Bookmarks
#include "Qt/fceuWrapper.h"
#include "Qt/TasEditor/taseditor_project.h"
#include "Qt/TasEditor/TasEditorWindow.h"
#include "Qt/TasEditor/TasColors.h"
//#pragma comment(lib, "msimg32.lib")
@ -329,8 +330,11 @@ void BOOKMARKS::calcFontData(void)
pxStartCol2 = pxWidthCol1;
pxStartCol3 = pxWidthCol1 + pxWidthFrameCol;
setMinimumWidth( pxLineWidth );
setMinimumHeight( pxLineSpacing * TOTAL_BOOKMARKS );
viewWidth = pxLineWidth;
viewHeight = pxLineSpacing * TOTAL_BOOKMARKS;
setMinimumWidth( viewWidth );
setMinimumHeight( viewHeight );
}
void BOOKMARKS::update()
@ -409,7 +413,9 @@ void BOOKMARKS::update()
void BOOKMARKS::command(int command_id, int slot)
{
if (slot < 0)
{
slot = selectedSlot;
}
if (slot >= 0 && slot < TOTAL_BOOKMARKS)
{
commands.push_back(command_id);
@ -660,13 +666,14 @@ void BOOKMARKS::paintEvent(QPaintEvent *event)
{
fceuCriticalSection emuLock;
QPainter painter(this);
int x, y, item;
int x, y, item, cell_y;
QColor white(255,255,255), black(0,0,0), blkColor;
char txt[256];
bool timeColBgDone = false;
painter.setFont(font);
viewWidth = event->rect().width();
viewHeight = event->rect().height();
//viewWidth = event->rect().width();
//viewHeight = event->rect().height();
// Draw Background
painter.fillRect( 0, 0, viewWidth, viewHeight, white );
@ -675,7 +682,122 @@ void BOOKMARKS::paintEvent(QPaintEvent *event)
y = 0;
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
{
item = (i+1) % TOTAL_BOOKMARKS;
cell_y = item = (i+1) % TOTAL_BOOKMARKS;
timeColBgDone = taseditorConfig->oldControlSchemeForBranching && movie_readonly;
if (bookmarksArray[cell_y].notEmpty)
{
// frame number
//SelectObject(msg->nmcd.hdc, pianoRoll.hMainListFont);
int frame = bookmarksArray[cell_y].snapshot.keyFrame;
if (frame == currFrameCounter || frame == (playback->getFlashingPauseFrame() - 1))
{
// current frame
blkColor = QColor( CUR_FRAMENUM_COLOR );
}
else if (frame < greenzone->getSize())
{
if (!greenzone->isSavestateEmpty(frame))
{
if (greenzone->lagLog.getLagInfoAtFrame(frame) == LAGGED_YES)
{
blkColor = QColor( LAG_FRAMENUM_COLOR );
}
else
{
blkColor = QColor( GREENZONE_FRAMENUM_COLOR );
}
}
else if (!greenzone->isSavestateEmpty(cell_y & EVERY16TH)
|| !greenzone->isSavestateEmpty(cell_y & EVERY8TH)
|| !greenzone->isSavestateEmpty(cell_y & EVERY4TH)
|| !greenzone->isSavestateEmpty(cell_y & EVERY2ND))
{
if (greenzone->lagLog.getLagInfoAtFrame(frame) == LAGGED_YES)
{
blkColor = QColor( PALE_LAG_FRAMENUM_COLOR );
}
else
{
blkColor = QColor( PALE_GREENZONE_FRAMENUM_COLOR );
}
}
else
{
blkColor = QColor( NORMAL_FRAMENUM_COLOR );
}
}
else
{
blkColor = QColor( NORMAL_FRAMENUM_COLOR );
}
}
else
{
blkColor = QColor( NORMAL_BACKGROUND_COLOR ); // empty bookmark
}
painter.fillRect( pxStartCol2, y, pxWidthFrameCol, pxLineSpacing, blkColor );
if (timeColBgDone)
{
painter.fillRect( pxStartCol3, y, pxWidthTimeCol, pxLineSpacing, blkColor );
}
else
{
if (bookmarksArray[cell_y].notEmpty)
{
// frame number
//SelectObject(msg->nmcd.hdc, pianoRoll.hMainListFont);
int frame = bookmarksArray[cell_y].snapshot.keyFrame;
if (frame == currFrameCounter || frame == (playback->getFlashingPauseFrame() - 1))
{
// current frame
blkColor = QColor( CUR_INPUT_COLOR1 );
}
else if (frame < greenzone->getSize())
{
if (!greenzone->isSavestateEmpty(frame))
{
if (greenzone->lagLog.getLagInfoAtFrame(frame) == LAGGED_YES)
{
blkColor = QColor( LAG_INPUT_COLOR1 );
}
else
{
blkColor = QColor( GREENZONE_INPUT_COLOR1 );
}
}
else if (!greenzone->isSavestateEmpty(cell_y & EVERY16TH)
|| !greenzone->isSavestateEmpty(cell_y & EVERY8TH)
|| !greenzone->isSavestateEmpty(cell_y & EVERY4TH)
|| !greenzone->isSavestateEmpty(cell_y & EVERY2ND))
{
if (greenzone->lagLog.getLagInfoAtFrame(frame) == LAGGED_YES)
{
blkColor = QColor( PALE_LAG_INPUT_COLOR1 );
}
else
{
blkColor = QColor( PALE_GREENZONE_INPUT_COLOR1 );
}
}
else
{
blkColor = QColor( NORMAL_INPUT_COLOR1 );
}
}
else
{
blkColor = QColor( NORMAL_INPUT_COLOR1 );
}
}
else
{
blkColor = QColor( NORMAL_BACKGROUND_COLOR ); // empty bookmark
}
painter.fillRect( pxStartCol3, y, pxWidthTimeCol, pxLineSpacing, blkColor );
}
x = pxStartCol1 + pxCharWidth;
sprintf( txt, "%i", item );
@ -703,7 +825,8 @@ void BOOKMARKS::paintEvent(QPaintEvent *event)
painter.drawLine( pxStartCol1, 0, pxStartCol1, viewHeight );
painter.drawLine( pxStartCol2, 0, pxStartCol2, viewHeight );
painter.drawLine( pxStartCol3, 0, pxStartCol3, viewHeight );
painter.drawLine( pxLineWidth, 0, pxLineWidth, viewHeight );
painter.drawLine( pxLineWidth-1, 0, pxLineWidth-1, viewHeight );
y = 0;
for (int i = 0; i < TOTAL_BOOKMARKS; ++i)
@ -712,6 +835,7 @@ void BOOKMARKS::paintEvent(QPaintEvent *event)
y += pxLineSpacing;
}
painter.drawLine( 0, viewHeight-1, viewWidth, viewHeight-1);
}
//----------------------------------------------------------------------------
@ -764,23 +888,67 @@ int BOOKMARKS::calcColumn( int px )
void BOOKMARKS::mousePressEvent(QMouseEvent * event)
{
int item, row_under_mouse, item_valid;
QPoint c = convPixToCursor( event->pos() );
printf("Mouse Button Pressed: 0x%x (%i,%i)\n", event->button(), c.x(), c.y() );
row_under_mouse = c.y();
columnClicked = calcColumn( event->pos().x() );
item = (row_under_mouse + 1) % TOTAL_BOOKMARKS;
item_valid = (item >= 0) && (item < TOTAL_BOOKMARKS);
if ( item_valid && (event->button() & Qt::LeftButton) )
{
bookmarkLeftclicked = item;
if ( (columnClicked <= BOOKMARKSLIST_COLUMN_FRAME) || (taseditorConfig->oldControlSchemeForBranching && movie_readonly))
{
bookmarksArray[bookmarkLeftclicked].flashType = FLASH_TYPE_JUMP;
}
else if ( (columnClicked == BOOKMARKSLIST_COLUMN_TIME) && (!taseditorConfig->oldControlSchemeForBranching || !movie_readonly))
{
bookmarksArray[bookmarkLeftclicked].flashType = FLASH_TYPE_DEPLOY;
}
}
if ( item_valid && (event->button() & Qt::RightButton) )
{
bookmarkRightclicked = item;
bookmarksArray[bookmarkRightclicked].flashType = FLASH_TYPE_SET;
}
//printf("Mouse Button Pressed: 0x%x (%i,%i)\n", event->button(), c.x(), c.y() );
}
void BOOKMARKS::mouseReleaseEvent(QMouseEvent * event)
{
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() );
if ( event->button() & Qt::LeftButton )
{
if (bookmarkLeftclicked >= 0)
{
handleLeftClick();
}
bookmarkLeftclicked = ITEM_UNDER_MOUSE_NONE;
}
if ( event->button() & Qt::RightButton )
{
if (bookmarkRightclicked >= 0)
{
handleRightClick();
}
bookmarkRightclicked = ITEM_UNDER_MOUSE_NONE;
}
}
void BOOKMARKS::mouseMoveEvent(QMouseEvent * event)
{
QPoint c = convPixToCursor( event->pos() );
//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() );
}
void BOOKMARKS::handleMouseMove(int newX, int newY)
@ -929,17 +1097,23 @@ int BOOKMARKS::getSelectedSlot()
// }
//}
void BOOKMARKS::handleLeftClick()
void BOOKMARKS::handleLeftClick(void)
{
if (columnClicked <= BOOKMARKSLIST_COLUMN_FRAME || (taseditorConfig->oldControlSchemeForBranching && movie_readonly))
{
command(COMMAND_JUMP, bookmarkLeftclicked);
}
else if (columnClicked == BOOKMARKSLIST_COLUMN_TIME && (!taseditorConfig->oldControlSchemeForBranching || !movie_readonly))
{
command(COMMAND_DEPLOY, bookmarkLeftclicked);
}
}
void BOOKMARKS::handleRightClick()
void BOOKMARKS::handleRightClick(void)
{
if (bookmarkRightclicked >= 0)
{
command(COMMAND_SET, bookmarkRightclicked);
}
}
int BOOKMARKS::findBookmarkAtFrame(int frame)