Skip to content

Commit

Permalink
Fixed seq audio preview time
Browse files Browse the repository at this point in the history
  • Loading branch information
FangCunWuChang committed May 18, 2024
1 parent d05c532 commit 92efb27
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/ui/component/sequencer/SeqTrackContentViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,24 @@ void SeqTrackContentViewer::paint(juce::Graphics& g) {

int startPixel = startSec * dstPointPerSec / imgScaleRatio;
int endPixel = endSec * dstPointPerSec / imgScaleRatio;
int realStartPixel = std::min(startPixel, this->audioImageTemp->getWidth());
int realEndPixel = std::min(endPixel, this->audioImageTemp->getWidth());
realStartPixel = std::max(0, realStartPixel);
realEndPixel = std::max(0, realEndPixel);

double startLimitPercent = (realStartPixel - startPixel) / (double)(endPixel - startPixel);
double endLimitPercent = (realEndPixel - startPixel) / (double)(endPixel - startPixel);
float blockStartPosX = blockRect.getX() + blockRect.getWidth() * startLimitPercent;
float blockEndPosX = blockRect.getX() + blockRect.getWidth() * endLimitPercent;

/** Draw Content */
float nameAreaHeight = blockPaddingHeight + blockNameFontHeight + blockPaddingHeight;
juce::Rectangle<float> contentRect =
blockRect.withTrimmedTop(nameAreaHeight - paddingHeight)
.withTrimmedBottom(blockPaddingHeight);
juce::Rectangle<float> contentRect(
blockStartPosX, nameAreaHeight,
blockEndPosX - blockStartPosX,
this->getHeight() - blockPaddingHeight - nameAreaHeight);
juce::Rectangle<int> imageRect(
startPixel, 0, endPixel - startPixel, this->audioImageTemp->getHeight());
realStartPixel, 0, realEndPixel - realStartPixel, this->audioImageTemp->getHeight());
g.drawImage(this->audioImageTemp->getClippedImage(imageRect), contentRect,
juce::RectanglePlacement::stretchToFit, false);
}
Expand Down

0 comments on commit 92efb27

Please sign in to comment.