Added initial placeholder widget for Qt TAS piano roll.
This commit is contained in:
parent
b7ad6cab38
commit
1db99e21d8
|
@ -26,14 +26,17 @@
|
||||||
|
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QFontMetrics>
|
||||||
|
|
||||||
#include "Qt/config.h"
|
#include "Qt/config.h"
|
||||||
#include "Qt/fceuWrapper.h"
|
#include "Qt/fceuWrapper.h"
|
||||||
#include "Qt/TasEditor/TasEditorWindow.h"
|
#include "Qt/TasEditor/TasEditorWindow.h"
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
//---- Main TAS Editor Window
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
TasEditorWindow::TasEditorWindow(QWidget *parent)
|
TasEditorWindow::TasEditorWindow(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog( parent, Qt::Window )
|
||||||
{
|
{
|
||||||
QVBoxLayout *mainLayout;
|
QVBoxLayout *mainLayout;
|
||||||
//QHBoxLayout *hbox;
|
//QHBoxLayout *hbox;
|
||||||
|
@ -44,8 +47,12 @@ TasEditorWindow::TasEditorWindow(QWidget *parent)
|
||||||
resize(512, 512);
|
resize(512, 512);
|
||||||
|
|
||||||
mainLayout = new QVBoxLayout();
|
mainLayout = new QVBoxLayout();
|
||||||
|
mainHBox = new QSplitter( Qt::Horizontal );
|
||||||
|
|
||||||
//mainLayout->addWidget(tree);
|
buildPianoRollDisplay();
|
||||||
|
|
||||||
|
mainHBox->addWidget( pianoRollContainerWidget );
|
||||||
|
mainLayout->addWidget(mainHBox);
|
||||||
|
|
||||||
menuBar = buildMenuBar();
|
menuBar = buildMenuBar();
|
||||||
|
|
||||||
|
@ -177,3 +184,109 @@ QMenuBar *TasEditorWindow::buildMenuBar(void)
|
||||||
return menuBar;
|
return menuBar;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
void TasEditorWindow::buildPianoRollDisplay(void)
|
||||||
|
{
|
||||||
|
QVBoxLayout *vbox;
|
||||||
|
QHBoxLayout *hbox;
|
||||||
|
QGridLayout *grid;
|
||||||
|
|
||||||
|
grid = new QGridLayout();
|
||||||
|
pianoRoll = new QPianoRoll(this);
|
||||||
|
pianoRollVBar = new QScrollBar( Qt::Vertical, this );
|
||||||
|
pianoRollHBar = new QScrollBar( Qt::Horizontal, this );
|
||||||
|
upperMarkerLabel = new QLabel( tr("Marker 0") );
|
||||||
|
lowerMarkerLabel = new QLabel( tr("Marker 1") );
|
||||||
|
upperMarkerName = new QLineEdit();
|
||||||
|
lowerMarkerName = new QLineEdit();
|
||||||
|
|
||||||
|
pianoRoll->setScrollBars( pianoRollHBar, pianoRollVBar );
|
||||||
|
|
||||||
|
grid->addWidget( pianoRoll , 0, 0 );
|
||||||
|
grid->addWidget( pianoRollVBar, 0, 1 );
|
||||||
|
grid->addWidget( pianoRollHBar, 1, 0 );
|
||||||
|
|
||||||
|
vbox = new QVBoxLayout();
|
||||||
|
|
||||||
|
pianoRollHBar->setMinimum(0);
|
||||||
|
pianoRollHBar->setMaximum(100);
|
||||||
|
pianoRollVBar->setMinimum(0);
|
||||||
|
pianoRollVBar->setMaximum(100);
|
||||||
|
|
||||||
|
hbox = new QHBoxLayout();
|
||||||
|
hbox->addWidget( upperMarkerLabel, 1 );
|
||||||
|
hbox->addWidget( upperMarkerName, 10 );
|
||||||
|
|
||||||
|
vbox->addLayout( hbox, 1 );
|
||||||
|
vbox->addLayout( grid, 100 );
|
||||||
|
|
||||||
|
hbox = new QHBoxLayout();
|
||||||
|
hbox->addWidget( lowerMarkerLabel, 1 );
|
||||||
|
hbox->addWidget( lowerMarkerName, 10 );
|
||||||
|
|
||||||
|
vbox->addLayout( hbox, 1 );
|
||||||
|
|
||||||
|
pianoRollContainerWidget = new QWidget();
|
||||||
|
pianoRollContainerWidget->setLayout( vbox );
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
//---- TAS Piano Roll Widget
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
QPianoRoll::QPianoRoll(QWidget *parent)
|
||||||
|
: QWidget( parent )
|
||||||
|
{
|
||||||
|
std::string fontString;
|
||||||
|
|
||||||
|
viewWidth = 512;
|
||||||
|
viewHeight = 512;
|
||||||
|
|
||||||
|
g_config->getOption("SDL.TasPianoRollFont", &fontString);
|
||||||
|
|
||||||
|
if ( fontString.size() > 0 )
|
||||||
|
{
|
||||||
|
font.fromString( QString::fromStdString( fontString ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
font.setFamily("Courier New");
|
||||||
|
font.setStyle( QFont::StyleNormal );
|
||||||
|
font.setStyleHint( QFont::Monospace );
|
||||||
|
}
|
||||||
|
|
||||||
|
this->parent = qobject_cast <TasEditorWindow*>( parent );
|
||||||
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
|
calcFontData();
|
||||||
|
|
||||||
|
vbar = NULL;
|
||||||
|
hbar = NULL;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
QPianoRoll::~QPianoRoll(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void QPianoRoll::setScrollBars( QScrollBar *h, QScrollBar *v )
|
||||||
|
{
|
||||||
|
hbar = h; vbar = v;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void QPianoRoll::calcFontData(void)
|
||||||
|
{
|
||||||
|
QWidget::setFont(font);
|
||||||
|
QFontMetrics metrics(font);
|
||||||
|
#if QT_VERSION > QT_VERSION_CHECK(5, 11, 0)
|
||||||
|
pxCharWidth = metrics.horizontalAdvance(QLatin1Char('2'));
|
||||||
|
#else
|
||||||
|
pxCharWidth = metrics.width(QLatin1Char('2'));
|
||||||
|
#endif
|
||||||
|
pxCharHeight = metrics.capHeight();
|
||||||
|
pxLineSpacing = metrics.lineSpacing() * 1.25;
|
||||||
|
pxLineLead = pxLineSpacing - metrics.height();
|
||||||
|
pxCursorHeight = metrics.height();
|
||||||
|
|
||||||
|
//printf("W:%i H:%i LS:%i \n", pxCharWidth, pxCharHeight, pxLineSpacing );
|
||||||
|
|
||||||
|
viewLines = (viewHeight / pxLineSpacing) + 1;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
#include <QSplitter>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
@ -22,9 +23,44 @@
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
#include <QTreeWidgetItem>
|
#include <QTreeWidgetItem>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
|
#include <QScrollBar>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QFont>
|
||||||
|
|
||||||
|
class TasEditorWindow;
|
||||||
|
|
||||||
|
class QPianoRoll : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QPianoRoll(QWidget *parent = 0);
|
||||||
|
~QPianoRoll(void);
|
||||||
|
|
||||||
|
void setScrollBars( QScrollBar *h, QScrollBar *v );
|
||||||
|
|
||||||
|
QFont getFont(void){ return font; };
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void calcFontData(void);
|
||||||
|
|
||||||
|
private:
|
||||||
|
TasEditorWindow *parent;
|
||||||
|
QFont font;
|
||||||
|
QScrollBar *hbar;
|
||||||
|
QScrollBar *vbar;
|
||||||
|
|
||||||
|
int pxCharWidth;
|
||||||
|
int pxCharHeight;
|
||||||
|
int pxCursorHeight;
|
||||||
|
int pxLineSpacing;
|
||||||
|
int pxLineLead;
|
||||||
|
int viewLines;
|
||||||
|
int viewWidth;
|
||||||
|
int viewHeight;
|
||||||
|
};
|
||||||
|
|
||||||
class TasEditorWindow : public QDialog
|
class TasEditorWindow : public QDialog
|
||||||
{
|
{
|
||||||
|
@ -34,11 +70,24 @@ class TasEditorWindow : public QDialog
|
||||||
TasEditorWindow(QWidget *parent = 0);
|
TasEditorWindow(QWidget *parent = 0);
|
||||||
~TasEditorWindow(void);
|
~TasEditorWindow(void);
|
||||||
|
|
||||||
|
QPianoRoll *pianoRoll;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
QMenuBar *buildMenuBar(void);
|
QMenuBar *buildMenuBar(void);
|
||||||
|
void buildPianoRollDisplay(void);
|
||||||
|
|
||||||
QMenu *recentMenu;
|
QMenu *recentMenu;
|
||||||
|
|
||||||
|
QSplitter *mainHBox;
|
||||||
|
QWidget *pianoRollContainerWidget;
|
||||||
|
QScrollBar *pianoRollHBar;
|
||||||
|
QScrollBar *pianoRollVBar;
|
||||||
|
QLabel *upperMarkerLabel;
|
||||||
|
QLabel *lowerMarkerLabel;
|
||||||
|
QLineEdit *upperMarkerName;
|
||||||
|
QLineEdit *lowerMarkerName;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
Loading…
Reference in New Issue