Reduce plugin width by 102px and fix bottom panel layout to scale proportionally

This commit is contained in:
Armin 2026-07-22 23:10:55 +02:00
commit f035e89ba9
9 changed files with 305 additions and 106 deletions

View file

@ -171,19 +171,18 @@ int WaveformDisplay::sampleToX(int sample) const
int WaveformDisplay::keyRowToMidiNote(int row) const
{
const int numRows = 12;
const int numRows = 25;
const int baseMidiNote = 60;
return baseMidiNote + (numRows - 1 - row);
}
int WaveformDisplay::midiNoteToSliceIndex(int note) const
{
int pitchClass = note % 12;
const auto& slices = sliceManager.getSlices();
int numSlices = sliceManager.getNumSlices();
for (int i = 0; i < numSlices; ++i)
{
if (slices[static_cast<size_t>(i)].midiNote == pitchClass)
if (slices[static_cast<size_t>(i)].midiNote == note)
return i;
}
return -1;
@ -223,12 +222,12 @@ void WaveformDisplay::paint(juce::Graphics& g)
auto waveBounds = bounds.withTrimmedBottom(scrollbarHeight);
// Ruler across full width (drawn first so keys can overlap)
drawRuler(g, waveBounds.removeFromTop(20.0f));
// Left key area (matches piano roll)
drawKeys(g, waveBounds.withWidth(keyWidth));
// Ruler across full width
drawRuler(g, waveBounds.removeFromTop(20.0f));
// Waveform and markers in the area to the right of keys
auto waveArea = waveBounds.withTrimmedLeft(keyWidth);
drawWaveform(g, waveArea);
@ -240,7 +239,7 @@ void WaveformDisplay::drawKeys(juce::Graphics& g, juce::Rectangle<float> bounds)
g.setColour(juce::Colour(0xff222233));
g.fillRect(bounds);
const int numRows = 12;
const int numRows = 25;
float rowHeight = bounds.getHeight() / static_cast<float>(numRows);
juce::Colour markerColours[] = {
@ -545,14 +544,15 @@ void WaveformDisplay::mouseDown(const juce::MouseEvent& e)
}
auto bounds = getLocalBounds().toFloat();
auto keyArea = bounds.withWidth(keyWidth).withTrimmedBottom(scrollbarHeight);
auto keyArea = bounds.withWidth(keyWidth).withTrimmedBottom(scrollbarHeight).withTrimmedTop(20.0f);
// Check if click is in the key area
if (e.getPosition().getX() < static_cast<int>(keyArea.getWidth()))
{
float rowHeight = keyArea.getHeight() / 12.0f;
const int numRows = 25;
float rowHeight = keyArea.getHeight() / static_cast<float>(numRows);
int row = static_cast<int>((static_cast<float>(e.getPosition().getY()) - keyArea.getY()) / rowHeight);
row = juce::jlimit(0, 11, row);
row = juce::jlimit(0, numRows - 1, row);
int midiNote = keyRowToMidiNote(row);
if (onKeyClick)