diff --git a/plugins/SlicerT/SlicerTView.cpp b/plugins/SlicerT/SlicerTView.cpp index 7af2db143..1fc3effe7 100644 --- a/plugins/SlicerT/SlicerTView.cpp +++ b/plugins/SlicerT/SlicerTView.cpp @@ -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); diff --git a/plugins/SlicerT/SlicerTView.h b/plugins/SlicerT/SlicerTView.h index f24246621..c4d0da959 100644 --- a/plugins/SlicerT/SlicerTView.h +++ b/plugins/SlicerT/SlicerTView.h @@ -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; diff --git a/plugins/SlicerT/clear_slices_active.png b/plugins/SlicerT/clear_slices_active.png new file mode 100644 index 000000000..36b7f0f7e Binary files /dev/null and b/plugins/SlicerT/clear_slices_active.png differ diff --git a/plugins/SlicerT/clear_slices_inactive.png b/plugins/SlicerT/clear_slices_inactive.png new file mode 100644 index 000000000..b39fb4974 Binary files /dev/null and b/plugins/SlicerT/clear_slices_inactive.png differ