diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp index 66593400..bda01610 100644 --- a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp +++ b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -644,6 +645,35 @@ QMenuBar *TasEditorWindow::buildMenuBar(void) viewMenu->addAction(act); + viewMenu->addSeparator(); + + // View -> Piano Roll Font + act = new QAction(tr("Piano Roll Font..."), this); + //act->setShortcut(QKeySequence(tr("Ctrl+F"))); + act->setStatusTip(tr("Select Piano Roll Font")); + //act->setIcon( style()->standardIcon( QStyle::SP_FileDialogStart ) ); + connect(act, SIGNAL(triggered(void)), this, SLOT(changePianoRollFontCB(void)) ); + + viewMenu->addAction(act); + + // View -> Bookmarks Font + act = new QAction(tr("Bookmarks View Font..."), this); + //act->setShortcut(QKeySequence(tr("Ctrl+F"))); + act->setStatusTip(tr("Select Bookmarks View Font")); + //act->setIcon( style()->standardIcon( QStyle::SP_FileDialogStart ) ); + connect(act, SIGNAL(triggered(void)), this, SLOT(changeBookmarksFontCB(void)) ); + + viewMenu->addAction(act); + + // View -> Branches Font + act = new QAction(tr("Branches View Font..."), this); + //act->setShortcut(QKeySequence(tr("Ctrl+F"))); + act->setStatusTip(tr("Select Branches View Font")); + //act->setIcon( style()->standardIcon( QStyle::SP_FileDialogStart ) ); + connect(act, SIGNAL(triggered(void)), this, SLOT(changeBranchesFontCB(void)) ); + + viewMenu->addAction(act); + // Config confMenu = menuBar->addMenu(tr("&Config")); @@ -2685,6 +2715,54 @@ void TasEditorWindow::updateToolTips(void) } } //---------------------------------------------------------------------------- +void TasEditorWindow::changePianoRollFontCB(void) +{ + bool ok = false; + + QFont selFont = QFontDialog::getFont( &ok, pianoRoll->QWidget::font(), this, tr("Select Font"), QFontDialog::MonospacedFonts ); + + if ( ok ) + { + pianoRoll->setFont( selFont ); + + //printf("Font Changed to: '%s'\n", selFont.toString().toStdString().c_str() ); + + g_config->setOption("SDL.TasPianoRollFont", selFont.toString().toStdString().c_str() ); + } +} +//---------------------------------------------------------------------------- +void TasEditorWindow::changeBookmarksFontCB(void) +{ + bool ok = false; + + QFont selFont = QFontDialog::getFont( &ok, bookmarks.QWidget::font(), this, tr("Select Font"), QFontDialog::MonospacedFonts ); + + if ( ok ) + { + bookmarks.setFont( selFont ); + + //printf("Font Changed to: '%s'\n", selFont.toString().toStdString().c_str() ); + + g_config->setOption("SDL.TasBookmarksFont", selFont.toString().toStdString().c_str() ); + } +} +//---------------------------------------------------------------------------- +void TasEditorWindow::changeBranchesFontCB(void) +{ + bool ok = false; + + QFont selFont = QFontDialog::getFont( &ok, branches.QWidget::font(), this, tr("Select Font"), QFontDialog::MonospacedFonts ); + + if ( ok ) + { + branches.setFont( selFont ); + + //printf("Font Changed to: '%s'\n", selFont.toString().toStdString().c_str() ); + + g_config->setOption("SDL.TasBranchesFont", selFont.toString().toStdString().c_str() ); + } +} +//---------------------------------------------------------------------------- void TasEditorWindow::playbackPauseCB(void) { fceuWrapperLock(); @@ -3459,6 +3537,7 @@ QPianoRoll::QPianoRoll(QWidget *parent) if ( fontString.size() > 0 ) { + //printf("Font String: '%s'\n", fontString.c_str() ); font.fromString( QString::fromStdString( fontString ) ); } else @@ -3672,6 +3751,13 @@ void QPianoRoll::vbarChanged(int val) update(); } //---------------------------------------------------------------------------- +void QPianoRoll::setFont( QFont &newFont ) +{ + font = newFont; + QWidget::setFont( newFont ); + calcFontData(); +} +//---------------------------------------------------------------------------- void QPianoRoll::calcFontData(void) { QWidget::setFont(font); diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.h b/src/drivers/Qt/TasEditor/TasEditorWindow.h index a4750f04..917eb6e4 100644 --- a/src/drivers/Qt/TasEditor/TasEditorWindow.h +++ b/src/drivers/Qt/TasEditor/TasEditorWindow.h @@ -159,6 +159,7 @@ class QPianoRoll : public QWidget void setLightInHeaderColumn(int column, int level); void periodicUpdate(void); + void setFont( QFont &font ); protected: void calcFontData(void); void resizeEvent(QResizeEvent *event); @@ -513,6 +514,9 @@ class TasEditorWindow : public QDialog void removeMarkers(void); void ungreenzoneSelectedFrames(void); void activateHotkey( int hkIdx, QShortcut *shortcut ); + void changePianoRollFontCB(void); + void changeBookmarksFontCB(void); + void changeBranchesFontCB(void); friend class RECORDER; friend class SPLICER; diff --git a/src/drivers/Qt/TasEditor/bookmarks.cpp b/src/drivers/Qt/TasEditor/bookmarks.cpp index 7ee16364..c5fdeca6 100644 --- a/src/drivers/Qt/TasEditor/bookmarks.cpp +++ b/src/drivers/Qt/TasEditor/bookmarks.cpp @@ -68,7 +68,7 @@ BOOKMARKS::BOOKMARKS(QWidget *parent) viewWidth = 256; viewHeight = 256; - g_config->getOption("SDL.TasPianoRollFont", &fontString); + g_config->getOption("SDL.TasBookmarksFont", &fontString); if ( fontString.size() > 0 ) { @@ -94,191 +94,15 @@ BOOKMARKS::~BOOKMARKS(void) void BOOKMARKS::init() { free(); -// hwndBookmarksList = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_BOOKMARKSLIST); -// hwndBranchesBitmap = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_BRANCHES_BITMAP); -// hwndBookmarks = GetDlgItem(taseditorWindow.hwndTASEditor, IDC_BOOKMARKS_BOX); -// -// // set a font which is overridden elsewhere and so really only used to calculate the row size -// SendMessage(hwndBookmarksList, WM_SETFONT, (WPARAM)pianoRoll.hItemMeasurementFont, 0); -// // prepare bookmarks listview -// ListView_SetExtendedListViewStyleEx(hwndBookmarksList, LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES, LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES); -// // subclass the listview -// hwndBookmarksList_oldWndProc = (WNDPROC)SetWindowLongPtr(hwndBookmarksList, GWLP_WNDPROC, (LONG_PTR)BookmarksListWndProc); -// // setup images for the listview -// hImgList = ImageList_Create(11, 13, ILC_COLOR8 | ILC_MASK, 1, 1); -// HBITMAP bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP0)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP1)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP2)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP3)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP4)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP5)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP6)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP7)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP8)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP9)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP10)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP11)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP12)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP13)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP14)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP15)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP16)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP17)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP18)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP19)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED0)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED1)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED2)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED3)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED4)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED5)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED6)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED7)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED8)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED9)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED10)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED11)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED12)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED13)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED14)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED15)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED16)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED17)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED18)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// bmp = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BITMAP_SELECTED19)); -// ImageList_AddMasked(hImgList, bmp, 0xFFFFFF); -// DeleteObject(bmp); -// ListView_SetImageList(hwndBookmarksList, hImgList, LVSIL_SMALL); -// // setup columns -// LVCOLUMN lvc; -// // icons column -// lvc.mask = LVCF_WIDTH; -// lvc.cx = BOOKMARKSLIST_COLUMN_ICONS_WIDTH; -// ListView_InsertColumn(hwndBookmarksList, 0, &lvc); -// // keyframe column -// lvc.mask = LVCF_WIDTH | LVCF_FMT; -// lvc.fmt = LVCFMT_CENTER; -// lvc.cx = BOOKMARKSLIST_COLUMN_FRAMENUM_WIDTH; -// ListView_InsertColumn(hwndBookmarksList, 1, &lvc); -// // time column -// lvc.cx = BOOKMARKSLIST_COLUMN_TIMESTAMP_WIDTH; -// ListView_InsertColumn(hwndBookmarksList, 2, &lvc); -// // create 10 rows -// ListView_SetItemCountEx(hwndBookmarksList, TOTAL_BOOKMARKS, LVSICF_NOSCROLL | LVSICF_NOINVALIDATEALL); reset(); selectedSlot = DEFAULT_SLOT; - // find the top/height of the "Time" cell of the 1st row (for mouseover hittest calculations) - //RECT temp_rect, wrect; - //if (ListView_GetSubItemRect(hwndBookmarksList, 0, 2, LVIR_BOUNDS, &temp_rect) && temp_rect.bottom != temp_rect.top) - //{ - // listTopMargin = temp_rect.top; - // listRowLeft = temp_rect.left; - // listRowHeight = temp_rect.bottom - temp_rect.top; - //} else - //{ - // // couldn't get rect, set default values - // listTopMargin = 0; - // listRowLeft = BOOKMARKSLIST_COLUMN_ICONS_WIDTH + BOOKMARKSLIST_COLUMN_FRAMENUM_WIDTH; - // listRowHeight = 14; - //} - // calculate the needed height of client area (so that all 10 rows fir the screen) - //int total_list_height = listTopMargin + listRowHeight * TOTAL_BOOKMARKS; - // find the difference between Bookmarks List window and Bookmarks List client area - //GetWindowRect(hwndBookmarksList, &wrect); - //GetClientRect(hwndBookmarksList, &temp_rect); - //total_list_height += (wrect.bottom - wrect.top) - (temp_rect.bottom - temp_rect.top); - // change the height - //taseditorWindow.changeBookmarksListHeight(total_list_height); redrawBookmarksSectionCaption(); } void BOOKMARKS::free() { bookmarksArray.resize(0); - //if (hImgList) - //{ - // ImageList_Destroy(hImgList); - // hImgList = 0; - //} } void BOOKMARKS::reset() { @@ -303,6 +127,13 @@ void BOOKMARKS::reset_vars() nextFlashUpdateTime = clock() + BOOKMARKS_FLASH_TICK; } +void BOOKMARKS::setFont( QFont &newFont ) +{ + font = newFont; + QWidget::setFont( newFont ); + calcFontData(); +} + void BOOKMARKS::calcFontData(void) { QWidget::setFont(font); diff --git a/src/drivers/Qt/TasEditor/bookmarks.h b/src/drivers/Qt/TasEditor/bookmarks.h index dbda038b..8e8d393c 100644 --- a/src/drivers/Qt/TasEditor/bookmarks.h +++ b/src/drivers/Qt/TasEditor/bookmarks.h @@ -2,6 +2,7 @@ #pragma once #include +#include #include #include @@ -67,6 +68,7 @@ public: void reset_vars(); void update(); + void setFont( QFont &font ); void save(EMUFILE *os, bool really_save = true); bool load(EMUFILE *is, unsigned int offset); diff --git a/src/drivers/Qt/TasEditor/branches.cpp b/src/drivers/Qt/TasEditor/branches.cpp index b7b675b1..b39b0b54 100644 --- a/src/drivers/Qt/TasEditor/branches.cpp +++ b/src/drivers/Qt/TasEditor/branches.cpp @@ -63,7 +63,7 @@ BRANCHES::BRANCHES(QWidget *parent) this->setMinimumWidth(BRANCHES_BITMAP_WIDTH); this->setMinimumHeight(BRANCHES_BITMAP_HEIGHT); - g_config->getOption("SDL.TasBranchFont", &fontString); + g_config->getOption("SDL.TasBranchesFont", &fontString); if ( fontString.size() > 0 ) { @@ -84,6 +84,16 @@ BRANCHES::~BRANCHES(void) } //---------------------------------------------------------------------------- +void BRANCHES::setFont( QFont &newFont ) +{ + font = newFont; + QWidget::setFont( newFont ); + calcFontData(); + reset(); + recalculateParents(); + recalculateBranchesTree(); +} + void BRANCHES::calcFontData(void) { QWidget::setFont(font); diff --git a/src/drivers/Qt/TasEditor/branches.h b/src/drivers/Qt/TasEditor/branches.h index b62306cf..86397757 100644 --- a/src/drivers/Qt/TasEditor/branches.h +++ b/src/drivers/Qt/TasEditor/branches.h @@ -113,6 +113,7 @@ public: void resetVars(); void update(); + void setFont( QFont &font ); void save(EMUFILE *os); bool load(EMUFILE *is); diff --git a/src/drivers/Qt/config.cpp b/src/drivers/Qt/config.cpp index 257e5f9e..5b2bdfc5 100644 --- a/src/drivers/Qt/config.cpp +++ b/src/drivers/Qt/config.cpp @@ -754,6 +754,9 @@ InitConfig() config->addOption( buf, ""); } + config->addOption("SDL.TasPianoRollFont", ""); + config->addOption("SDL.TasBookmarksFont", ""); + config->addOption("SDL.TasBranchesFont" , ""); config->addOption("_useNativeFileDialog", "SDL.UseNativeFileDialog", false); config->addOption("_useNativeMenuBar" , "SDL.UseNativeMenuBar", false);