-
-
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
6a611fd
commit 99e31ed
Showing
14 changed files
with
184 additions
and
60 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
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,103 @@ | ||
#include "SeqTrackSoloComponent.h" | ||
#include "../../lookAndFeel/LookAndFeelFactory.h" | ||
#include "../../misc/CoreActions.h" | ||
#include "../../Utils.h" | ||
#include "../../../audioCore/AC_API.h" | ||
|
||
SeqTrackSoloComponent::SeqTrackSoloComponent() { | ||
this->setLookAndFeel( | ||
LookAndFeelFactory::getInstance()->getLAFFor(LookAndFeelFactory::SoloButton)); | ||
} | ||
|
||
void SeqTrackSoloComponent::paint(juce::Graphics& g) { | ||
/** Size */ | ||
auto screenSize = utils::getScreenSize(this); | ||
float lineThickness = screenSize.getHeight() * 0.001; | ||
|
||
int buttonWidth = std::min(this->getWidth(), this->getHeight()) - lineThickness; | ||
int buttonHeight = buttonWidth; | ||
|
||
float textFontHeight = buttonWidth * 0.7; | ||
|
||
/** Color */ | ||
auto& laf = this->getLookAndFeel(); | ||
juce::Colour backgroundColor = laf.findColour(this->solo | ||
? juce::TextButton::ColourIds::buttonOnColourId | ||
: juce::TextButton::ColourIds::buttonColourId); | ||
juce::Colour textColor = laf.findColour(this->solo | ||
? juce::TextButton::ColourIds::textColourOnId | ||
: juce::TextButton::ColourIds::textColourOffId); | ||
|
||
/** Font */ | ||
juce::Font textFont(juce::FontOptions{ textFontHeight }); | ||
|
||
/** Button */ | ||
juce::Rectangle<float> buttonRect( | ||
this->getWidth() / 2.f - buttonWidth / 2.f, | ||
this->getHeight() / 2.f - buttonHeight / 2.f, | ||
buttonWidth, buttonHeight); | ||
g.setColour(backgroundColor); | ||
g.fillRect(buttonRect); | ||
|
||
g.setColour(textColor); | ||
g.drawRect(buttonRect, lineThickness); | ||
|
||
g.setFont(textFont); | ||
g.drawFittedText("S", buttonRect.toNearestInt(), | ||
juce::Justification::centred, 1, 0.f); | ||
} | ||
|
||
void SeqTrackSoloComponent::mouseDrag(const juce::MouseEvent& event) { | ||
this->mouseMove(event); | ||
} | ||
|
||
void SeqTrackSoloComponent::mouseMove(const juce::MouseEvent& event) { | ||
/** Size */ | ||
auto screenSize = utils::getScreenSize(this); | ||
float lineThickness = screenSize.getHeight() * 0.001; | ||
int buttonWidth = std::min(this->getWidth(), this->getHeight()) - lineThickness; | ||
int buttonHeight = buttonWidth; | ||
juce::Rectangle<float> buttonRect( | ||
this->getWidth() / 2.f - buttonWidth / 2.f, | ||
this->getHeight() / 2.f - buttonHeight / 2.f, | ||
buttonWidth, buttonHeight); | ||
|
||
/** Cursor */ | ||
this->setMouseCursor(buttonRect.contains(event.position) | ||
? juce::MouseCursor::PointingHandCursor | ||
: juce::MouseCursor::NormalCursor); | ||
} | ||
|
||
void SeqTrackSoloComponent::mouseUp(const juce::MouseEvent& event) { | ||
/** Size */ | ||
auto screenSize = utils::getScreenSize(this); | ||
float lineThickness = screenSize.getHeight() * 0.001; | ||
int buttonWidth = std::min(this->getWidth(), this->getHeight()) - lineThickness; | ||
int buttonHeight = buttonWidth; | ||
juce::Rectangle<float> buttonRect( | ||
this->getWidth() / 2.f - buttonWidth / 2.f, | ||
this->getHeight() / 2.f - buttonHeight / 2.f, | ||
buttonWidth, buttonHeight); | ||
|
||
if (buttonRect.contains(event.position)) { | ||
if (event.mods.isLeftButtonDown()) { | ||
this->changeSolo(); | ||
} | ||
else if (event.mods.isRightButtonDown()) { | ||
this->changeSolo(); | ||
} | ||
} | ||
} | ||
|
||
void SeqTrackSoloComponent::update(int index) { | ||
this->index = index; | ||
if (index > -1) { | ||
this->solo = quickAPI::getSeqTrackSolo(index); | ||
|
||
this->repaint(); | ||
} | ||
} | ||
|
||
void SeqTrackSoloComponent::changeSolo() { | ||
CoreActions::setSeqSolo(this->index, !(this->solo)); | ||
} |
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,26 @@ | ||
#pragma once | ||
|
||
#include <JuceHeader.h> | ||
|
||
class SeqTrackSoloComponent final | ||
: public juce::Component, | ||
public juce::SettableTooltipClient { | ||
public: | ||
SeqTrackSoloComponent(); | ||
|
||
void paint(juce::Graphics& g) override; | ||
|
||
void mouseDrag(const juce::MouseEvent& event) override; | ||
void mouseMove(const juce::MouseEvent& event) override; | ||
void mouseUp(const juce::MouseEvent& event) override; | ||
|
||
void update(int index); | ||
|
||
private: | ||
int index = -1; | ||
bool solo = false; | ||
|
||
void changeSolo(); | ||
|
||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SeqTrackSoloComponent) | ||
}; |
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
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,15 @@ | ||
#include "SoloButtonLookAndFeel.h" | ||
#include "../../misc/ColorMap.h" | ||
|
||
SoloButtonLookAndFeel::SoloButtonLookAndFeel() | ||
: MainLookAndFeel() { | ||
/** Button */ | ||
this->setColour(juce::TextButton::ColourIds::buttonColourId, | ||
ColorMap::getInstance()->get("ThemeColorB2")); | ||
this->setColour(juce::TextButton::ColourIds::buttonOnColourId, | ||
juce::Colours::red.withAlpha(0.6f)); | ||
this->setColour(juce::TextButton::ColourIds::textColourOffId, | ||
ColorMap::getInstance()->get("ThemeColorB8")); | ||
this->setColour(juce::TextButton::ColourIds::textColourOnId, | ||
ColorMap::getInstance()->get("ThemeColorB10")); | ||
} |
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,12 @@ | ||
#pragma once | ||
|
||
#include <JuceHeader.h> | ||
#include "../MainLookAndFeel.h" | ||
|
||
class SoloButtonLookAndFeel : public MainLookAndFeel { | ||
public: | ||
SoloButtonLookAndFeel(); | ||
|
||
private: | ||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SoloButtonLookAndFeel) | ||
}; |
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