Add option to clear all notes in SlicerT (#7850)

This commit is contained in:
Petar Katić
2025-05-06 01:03:53 +02:00
committed by GitHub
parent 61736a97b6
commit e50f312818
4 changed files with 26 additions and 3 deletions

View File

@@ -71,6 +71,12 @@ SlicerTView::SlicerTView(SlicerT* instrument, QWidget* parent)
m_syncToggle->setToolTip(tr("Enable BPM sync"));
m_syncToggle->setModel(&m_slicerTParent->m_enableSync);
m_clearButton = new PixmapButton(this, tr("Clear all slices"));
m_clearButton->setActiveGraphic(PLUGIN_NAME::getIconPixmap("clear_slices_active"));
m_clearButton->setInactiveGraphic(PLUGIN_NAME::getIconPixmap("clear_slices_inactive"));
m_clearButton->setToolTip(tr("Clear all slices"));
connect(m_clearButton, &PixmapButton::clicked, this, &SlicerTView::clearSlices);
m_bpmBox = new LcdSpinBox(3, "19purple", this);
m_bpmBox->setToolTip(tr("Original sample BPM"));
m_bpmBox->setModel(&m_slicerTParent->m_originalBPM);
@@ -111,6 +117,19 @@ Knob* SlicerTView::createStyledKnob()
return newKnob;
}
// Clear all notes
void SlicerTView::clearSlices()
{
m_slicerTParent->m_slicePoints.clear();
// Points are added to the start (0) and end (1) of the sample,
// so the whole sample can still be copied using MIDI.
m_slicerTParent->m_slicePoints.emplace_back(0);
m_slicerTParent->m_slicePoints.emplace_back(1);
emit m_slicerTParent->dataChanged();
}
// copied from piano roll
void SlicerTView::exportMidi()
{
@@ -261,7 +280,7 @@ void SlicerTView::resizeEvent(QResizeEvent* re)
{
m_y1 = height() - s_bottomBoxOffset;
// left box
// Left box
m_noteThresholdKnob->move(s_x1 - 25, m_y1);
m_fadeOutKnob->move(s_x2 - 25, m_y1);
@@ -271,8 +290,10 @@ void SlicerTView::resizeEvent(QResizeEvent* re)
m_bpmBox->move(s_x5 - 13, m_y1 + 4);
m_snapSetting->move(s_x6 - 8, m_y1 + 3);
// right box
m_syncToggle->move((width() - 100), m_y1 + 5);
// Right box
// For explanation on the choice of constants, look at #7850
m_syncToggle->move((width() - 100), m_y1 - 7);
m_clearButton->move((width() - 100), m_y1 + 17);
m_folderButton->move(width() - 20, height() - s_bottomBoxHeight - s_sampleBoxHeight + 1);

View File

@@ -49,6 +49,7 @@ class SlicerTView : public InstrumentView
public slots:
void exportMidi();
void openFiles();
void clearSlices();
public:
SlicerTView(SlicerT* instrument, QWidget* parent);
@@ -87,6 +88,7 @@ private:
LcdSpinBox* m_bpmBox;
ComboBox* m_snapSetting;
PixmapButton* m_syncToggle;
PixmapButton* m_clearButton;
PixmapButton* m_folderButton;
QPushButton* m_resetButton;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB