Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added data/themes/default/grid_snap_size.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/themes/default/quantize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,18 @@ QToolButton:checked {
background-image: url(resources:shadow_p.png);
}

/* buttons with menu */

QToolButton[popupMode="1"] {
padding-right: 15px;
}

QToolButton::menu-button {
border-top-right-radius: 1px;
border-bottom-right-radius: 1px;
width: 15px;
}

/* track label buttons - the part that contains the icon and track title */

TrackLabelButton {
Expand Down
9 changes: 8 additions & 1 deletion include/PianoRoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ class PianoRoll : public QWidget
int quantization() const;

protected:
enum QuantizeActions
{
QuantizeBoth,
QuantizePos,
QuantizeLength
};

void keyPressEvent( QKeyEvent * ke ) override;
void keyReleaseEvent( QKeyEvent * ke ) override;
void leaveEvent( QEvent * e ) override;
Expand Down Expand Up @@ -196,7 +203,7 @@ protected slots:
void quantizeChanged();
void noteLengthChanged();
void keyChanged();
void quantizeNotes();
void quantizeNotes(QuantizeActions mode = QuantizeBoth);

void updateSemiToneMarkerMenu();

Expand Down
37 changes: 30 additions & 7 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <QScrollBar>
#include <QStyleOption>
#include <QtMath>
#include <QToolButton>

#ifndef __USE_XOPEN
#define __USE_XOPEN
Expand Down Expand Up @@ -340,7 +341,7 @@ PianoRoll::PianoRoll() :
this, SLOT(zoomingYChanged()));

// Set up quantization model
m_quantizeModel.addItem( tr( "Note lock" ) );
m_quantizeModel.addItem(tr("Same as note"));
for (auto q : Quantizations) {
m_quantizeModel.addItem(QString("1/%1").arg(q));
}
Expand Down Expand Up @@ -4178,7 +4179,7 @@ int PianoRoll::quantization() const
}


void PianoRoll::quantizeNotes()
void PianoRoll::quantizeNotes(QuantizeActions mode)
{
if( ! hasValidPattern() )
{
Expand Down Expand Up @@ -4206,8 +4207,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();
Expand Down Expand Up @@ -4322,15 +4330,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" ) );
Expand Down
3 changes: 2 additions & 1 deletion src/gui/editors/SongEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ SongEditorWindow::SongEditorWindow(Song* song) :

DropToolBar *snapToolBar = addDropToolBarToTop(tr("Snap controls"));
QLabel * snap_lbl = new QLabel( m_toolBar );
snap_lbl->setPixmap( embed::getIconPixmap( "quantize" ) );
snap_lbl->setPixmap(embed::getIconPixmap("grid_snap_size"));

//Set up quantization/snapping selector
m_snappingComboBox = new ComboBox( m_toolBar );
Expand All @@ -998,6 +998,7 @@ SongEditorWindow::SongEditorWindow(Song* song) :
connect(m_setProportionalSnapAction, SIGNAL(triggered()), this, SLOT(updateSnapLabel()) );

snapToolBar->addWidget( snap_lbl );
snapToolBar->addSeparator();
snapToolBar->addWidget( m_snappingComboBox );
snapToolBar->addSeparator();
snapToolBar->addAction( m_setProportionalSnapAction );
Expand Down