fix sample info overwrite; show loop points on preview
parent
39f5966c0f
commit
72b5eb3b53
|
@ -25,6 +25,7 @@ namespace Xybrid::Config {
|
|||
QColor waveformBg = {23, 23, 23};
|
||||
QColor waveformBgHighlight = {31, 31, 47};
|
||||
QColor waveformFgPrimary = {191, 163, 255};
|
||||
QColor waveformLoopPoints = {255, 127, 127};
|
||||
};
|
||||
extern ColorScheme colorScheme;
|
||||
}
|
||||
|
|
|
@ -382,16 +382,19 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
editingSample->loopStart = -1;
|
||||
editingSample->loopEnd = -1;
|
||||
}
|
||||
ui->waveformPreview->update();
|
||||
}
|
||||
});
|
||||
connect(ui->spinSampleLoopStart, qOverload<int>(&QSpinBox::valueChanged), this, [this](int v) {
|
||||
if (editingSample && ui->groupSampleLoop->isChecked()) {
|
||||
editingSample->loopStart = v;
|
||||
ui->waveformPreview->update();
|
||||
}
|
||||
});
|
||||
connect(ui->spinSampleLoopEnd, qOverload<int>(&QSpinBox::valueChanged), this, [this](int v) {
|
||||
if (editingSample && ui->groupSampleLoop->isChecked()) {
|
||||
editingSample->loopEnd = v;
|
||||
ui->waveformPreview->update();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -657,7 +660,7 @@ void MainWindow::selectSampleForEditing(std::shared_ptr<Xybrid::Data::Sample> sm
|
|||
ui->spinSampleLoopStart->setValue(0);
|
||||
ui->spinSampleLoopEnd->setValue(0);
|
||||
} else {
|
||||
editingSample = smp;
|
||||
editingSample = nullptr;
|
||||
ui->sampleViewPane->setEnabled(true);
|
||||
ui->sampleInfo->setText(
|
||||
qs("%1 // %2\n%3 %4Hz, %5 frames (%6)")
|
||||
|
@ -681,6 +684,8 @@ void MainWindow::selectSampleForEditing(std::shared_ptr<Xybrid::Data::Sample> sm
|
|||
ui->spinSampleLoopStart->setValue(smp->loopStart);
|
||||
ui->spinSampleLoopEnd->setValue(smp->loopEnd);
|
||||
}
|
||||
|
||||
editingSample = smp;
|
||||
}
|
||||
|
||||
ui->waveformPreview->setSample(smp);
|
||||
|
|
|
@ -117,6 +117,7 @@ void SampleSelectorGadget::buildSubmenu(DirectoryNode* dir, QMenu* menu) {
|
|||
wa->setDefaultWidget(wfp);
|
||||
wfp->showName = true;
|
||||
wfp->highlightable = true;
|
||||
wfp->showLoopPoints = false;
|
||||
wfp->setSample(s);
|
||||
wfp->setMinimumSize(192, 48);
|
||||
menu->addAction(wa);
|
||||
|
|
|
@ -76,6 +76,17 @@ void WaveformPreviewWidget::paintEvent(QPaintEvent* event [[maybe_unused]]) {
|
|||
paintChannel(p, smp, 0, r);
|
||||
paintChannel(p, smp, 1, r.translated(0, cs));
|
||||
}
|
||||
if (showLoopPoints && smp->loopStart >= 0) { // draw loop points if able
|
||||
double scale = static_cast<double>(smp->length()) / static_cast<double>(rect.width());
|
||||
p.setPen(Config::colorScheme.waveformLoopPoints);
|
||||
auto x = rect.x();
|
||||
auto y = rect.y();
|
||||
auto h = rect.height();
|
||||
auto xs = x + static_cast<int>(static_cast<double>(smp->loopStart)/scale);
|
||||
auto xe = x + static_cast<int>(static_cast<double>(smp->loopEnd)/scale);
|
||||
p.drawLine(QPoint(xs, y), QPoint(xs, y+h));
|
||||
p.drawLine(QPoint(xe, y), QPoint(xe, y+h));
|
||||
}
|
||||
}
|
||||
|
||||
if (showName) {
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Xybrid::UI {
|
|||
public:
|
||||
bool showName = false;
|
||||
bool highlightable = false;
|
||||
bool showLoopPoints = true;
|
||||
|
||||
explicit WaveformPreviewWidget(QWidget* parent = nullptr);
|
||||
|
||||
|
|
Loading…
Reference in New Issue