Enhanced quantize in PianoRoll (#5946)
* Button with menu has split highlight * Add menu with more action to quantize button * Style changes * Fix CSS length-zero-no-unit warning * Add combo button to classic theme
This commit is contained in:
@@ -484,7 +484,7 @@ QToolButton#stopButton {
|
||||
|
||||
/* all tool buttons */
|
||||
|
||||
QToolButton {
|
||||
QToolButton, QToolButton::menu-button {
|
||||
padding: 1px 1px 1px 1px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid rgba(63, 63, 63, 128);
|
||||
@@ -510,6 +510,22 @@ QToolButton:checked {
|
||||
color: black;
|
||||
}
|
||||
|
||||
/* buttons with combined menu */
|
||||
|
||||
QToolButton[popupMode="1"] {
|
||||
margin-right: 11px;
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
QToolButton::menu-button {
|
||||
subcontrol-origin: margin;
|
||||
width: 11px;
|
||||
padding: 0;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
/* track label buttons - the part that contains the icon and track title */
|
||||
|
||||
TrackLabelButton {
|
||||
|
||||
@@ -490,7 +490,7 @@ QToolBar::separator {
|
||||
|
||||
/* all tool buttons */
|
||||
|
||||
QToolButton {
|
||||
QToolButton, QToolButton::menu-button {
|
||||
margin: 1px;
|
||||
padding: 2px 2px 2px 2px;
|
||||
border-top: 1px solid #778394;
|
||||
@@ -522,6 +522,22 @@ QToolButton:checked {
|
||||
background-image: url(resources:shadow_p.png);
|
||||
}
|
||||
|
||||
/* buttons with combined menu */
|
||||
|
||||
QToolButton[popupMode="1"] {
|
||||
margin-right: 13px;
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
QToolButton::menu-button {
|
||||
subcontrol-origin: margin;
|
||||
width: 13px;
|
||||
padding: 0;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
/* track label buttons - the part that contains the icon and track title */
|
||||
|
||||
TrackLabelButton {
|
||||
|
||||
@@ -142,6 +142,13 @@ public:
|
||||
int quantization() const;
|
||||
|
||||
protected:
|
||||
enum QuantizeActions
|
||||
{
|
||||
QuantizeBoth,
|
||||
QuantizePos,
|
||||
QuantizeLength
|
||||
};
|
||||
|
||||
void keyPressEvent( QKeyEvent * ke ) override;
|
||||
void keyReleaseEvent( QKeyEvent * ke ) override;
|
||||
void leaveEvent( QEvent * e ) override;
|
||||
@@ -198,7 +205,7 @@ protected slots:
|
||||
void quantizeChanged();
|
||||
void noteLengthChanged();
|
||||
void keyChanged();
|
||||
void quantizeNotes();
|
||||
void quantizeNotes(QuantizeActions mode = QuantizeBoth);
|
||||
|
||||
void updateSemiToneMarkerMenu();
|
||||
|
||||
|
||||
@@ -4554,7 +4554,7 @@ int PianoRoll::quantization() const
|
||||
}
|
||||
|
||||
|
||||
void PianoRoll::quantizeNotes()
|
||||
void PianoRoll::quantizeNotes(QuantizeActions mode)
|
||||
{
|
||||
if( ! hasValidPattern() )
|
||||
{
|
||||
@@ -4582,8 +4582,15 @@ void PianoRoll::quantizeNotes()
|
||||
|
||||
Note copy(*n);
|
||||
m_pattern->removeNote( n );
|
||||
copy.quantizePos( quantization() );
|
||||
m_pattern->addNote( copy );
|
||||
if (mode == QuantizeBoth || mode == QuantizePos)
|
||||
{
|
||||
copy.quantizePos(quantization());
|
||||
}
|
||||
if (mode == QuantizeBoth || mode == QuantizeLength)
|
||||
{
|
||||
copy.quantizeLength(quantization());
|
||||
}
|
||||
m_pattern->addNote(copy, false);
|
||||
}
|
||||
|
||||
update();
|
||||
@@ -4704,15 +4711,30 @@ PianoRollWindow::PianoRollWindow() :
|
||||
|
||||
connect( editModeGroup, SIGNAL( triggered( int ) ), m_editor, SLOT( setEditMode( int ) ) );
|
||||
|
||||
QAction* quantizeAction = new QAction(embed::getIconPixmap( "quantize" ), tr( "Quantize" ), this );
|
||||
connect( quantizeAction, SIGNAL( triggered() ), m_editor, SLOT( quantizeNotes() ) );
|
||||
// Quantize combo button
|
||||
QToolButton* quantizeButton = new QToolButton(notesActionsToolBar);
|
||||
QMenu* quantizeButtonMenu = new QMenu(quantizeButton);
|
||||
|
||||
QAction* quantizeAction = new QAction(embed::getIconPixmap("quantize"), tr("Quantize"), this);
|
||||
QAction* quantizePosAction = new QAction(tr("Quantize positions"), this);
|
||||
QAction* quantizeLengthAction = new QAction(tr("Quantize lengths"), this);
|
||||
|
||||
connect(quantizeAction, &QAction::triggered, [this](){ m_editor->quantizeNotes(); });
|
||||
connect(quantizePosAction, &QAction::triggered, [this](){ m_editor->quantizeNotes(PianoRoll::QuantizePos); });
|
||||
connect(quantizeLengthAction, &QAction::triggered, [this](){ m_editor->quantizeNotes(PianoRoll::QuantizeLength); });
|
||||
|
||||
quantizeButton->setPopupMode(QToolButton::MenuButtonPopup);
|
||||
quantizeButton->setDefaultAction(quantizeAction);
|
||||
quantizeButton->setMenu(quantizeButtonMenu);
|
||||
quantizeButtonMenu->addAction(quantizePosAction);
|
||||
quantizeButtonMenu->addAction(quantizeLengthAction);
|
||||
|
||||
notesActionsToolBar->addAction( drawAction );
|
||||
notesActionsToolBar->addAction( eraseAction );
|
||||
notesActionsToolBar->addAction( selectAction );
|
||||
notesActionsToolBar->addAction( pitchBendAction );
|
||||
notesActionsToolBar->addSeparator();
|
||||
notesActionsToolBar->addAction( quantizeAction );
|
||||
notesActionsToolBar->addWidget(quantizeButton);
|
||||
|
||||
// Copy + paste actions
|
||||
DropToolBar *copyPasteActionsToolBar = addDropToolBarToTop( tr( "Copy paste controls" ) );
|
||||
|
||||
Reference in New Issue
Block a user