-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a340c3c
commit cd0b9e7
Showing
4 changed files
with
124 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "InstrIOComponent.h" | ||
#include "../Utils.h" | ||
|
||
InstrIOComponent::InstrIOComponent(bool isInput) | ||
: isInput(isInput) { | ||
this->setMouseCursor(juce::MouseCursor::PointingHandCursor); | ||
} | ||
|
||
void InstrIOComponent::paint(juce::Graphics& g) { | ||
/** Size */ | ||
auto screenSize = utils::getScreenSize(this); | ||
float pointHeight = screenSize.getHeight() * 0.01; | ||
|
||
/** Color */ | ||
juce::Colour colorOn = this->isInput | ||
? juce::Colours::blue | ||
:juce::Colours::lightgreen; | ||
juce::Colour colorOff = this->isInput | ||
? juce::Colours::indianred | ||
: juce::Colours::yellow; | ||
|
||
/** Center */ | ||
auto centerPoint = this->getLocalBounds().getCentre(); | ||
|
||
/** Draw Point */ | ||
if (this->linked) { | ||
juce::Path path; | ||
path.startNewSubPath(centerPoint.getX(), centerPoint.getY() - pointHeight / 2); | ||
path.lineTo(centerPoint.getX() + pointHeight / 2, centerPoint.getY()); | ||
path.lineTo(centerPoint.getX(), centerPoint.getY() + pointHeight / 2); | ||
path.lineTo(centerPoint.getX() - pointHeight / 2, centerPoint.getY()); | ||
path.closeSubPath(); | ||
|
||
g.setColour(colorOn); | ||
g.fillPath(path); | ||
} | ||
else { | ||
juce::Rectangle<float> pointRect( | ||
centerPoint.getX() - pointHeight / 2, centerPoint.getY() - pointHeight / 2, | ||
pointHeight, pointHeight); | ||
|
||
g.setColour(colorOff); | ||
g.fillEllipse(pointRect); | ||
} | ||
} | ||
|
||
void InstrIOComponent::update(int index) { | ||
this->index = index; | ||
if (index > -1) { | ||
/** TODO */ | ||
this->repaint(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <JuceHeader.h> | ||
|
||
class InstrIOComponent final : public juce::Component { | ||
public: | ||
InstrIOComponent() = delete; | ||
InstrIOComponent(bool isInput); | ||
|
||
void paint(juce::Graphics& g) override; | ||
|
||
void update(int index); | ||
|
||
private: | ||
const bool isInput; | ||
int index = -1; | ||
bool linked = false; | ||
|
||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(InstrIOComponent) | ||
}; |