Skip to content

Commit

Permalink
Update SeqTrackContentViewer mouse cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
FangCunWuChang committed May 25, 2024
1 parent d2fda86 commit ae3d1dd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/ui/component/sequencer/SeqTrackContentViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "../../lookAndFeel/LookAndFeelFactory.h"
#include "../../misc/AudioExtractor.h"
#include "../../misc/MainThreadPool.h"
#include "../../misc/Tools.h"
#include "../../Utils.h"
#include "../../../audioCore/AC_API.h"

Expand Down Expand Up @@ -363,6 +364,40 @@ void SeqTrackContentViewer::paint(juce::Graphics& g) {
}
}

void SeqTrackContentViewer::mouseMove(const juce::MouseEvent& event) {
/** Size */
auto screenSize = utils::getScreenSize(this);
int blockJudgeWidth = screenSize.getWidth() * 0.005;

/** Move */
if (Tools::getInstance()->getType() == Tools::Type::Hand) {
this->setMouseCursor(juce::MouseCursor::DraggingHandCursor);
return;
}

/** Block */
float posX = event.position.getX();
for (auto block : this->blockTemp) {
float startX = (block->startTime - this->secStart) / (this->secEnd - this->secStart) * this->getWidth();
float endX = (block->endTime - this->secStart) / (this->secEnd - this->secStart) * this->getWidth();

if (std::abs(posX - startX) < blockJudgeWidth) {
this->setMouseCursor(juce::MouseCursor::LeftEdgeResizeCursor);
return;
}
else if (std::abs(posX - endX) < blockJudgeWidth) {
this->setMouseCursor(juce::MouseCursor::RightEdgeResizeCursor);
return;
}
else if (posX > startX && posX < endX) {
this->setMouseCursor(juce::MouseCursor::PointingHandCursor);
return;
}
}

this->setMouseCursor(juce::MouseCursor::NormalCursor);
}

void SeqTrackContentViewer::updateBlockInternal(int blockIndex) {
if (auto temp = this->blockTemp[blockIndex]) {
std::tie(temp->startTime, temp->endTime, temp->offset)
Expand Down
2 changes: 2 additions & 0 deletions src/ui/component/sequencer/SeqTrackContentViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class SeqTrackContentViewer final : public juce::Component {

void paint(juce::Graphics& g) override;

void mouseMove(const juce::MouseEvent& event) override;

private:
bool compressed = false;
int index = -1;
Expand Down

0 comments on commit ae3d1dd

Please sign in to comment.