diff --git a/src/audioCore/Utils.cpp b/src/audioCore/Utils.cpp index 4882c5ba..a316bf00 100644 --- a/src/audioCore/Utils.cpp +++ b/src/audioCore/Utils.cpp @@ -1055,6 +1055,10 @@ namespace utils { 88200, 96000, 176400, 192000, 352800, 384000 }; } + juce::Colour getDefaultColour() { + return juce::Colour::fromRGB(98, 111, 252); + } + void bufferOutputResampledFixed(juce::AudioSampleBuffer& dst, const juce::AudioSampleBuffer& src, juce::AudioSampleBuffer& temp1, juce::AudioSampleBuffer& temp2, double resampleRatio, int channels, double dstSampleRate, diff --git a/src/audioCore/Utils.h b/src/audioCore/Utils.h index f7357ee6..85201edc 100644 --- a/src/audioCore/Utils.h +++ b/src/audioCore/Utils.h @@ -124,6 +124,8 @@ namespace utils { const juce::StringArray getPluginFormatsSupported(); const juce::Array getSourceSampleRateSupported(); + juce::Colour getDefaultColour(); + using AudioConnection = std::tuple; using AudioConnectionList = juce::Array; diff --git a/src/audioCore/graph/MainGraph.cpp b/src/audioCore/graph/MainGraph.cpp index 0ef60171..bf6d91ab 100644 --- a/src/audioCore/graph/MainGraph.cpp +++ b/src/audioCore/graph/MainGraph.cpp @@ -4,6 +4,7 @@ #include "../misc/Renderer.h" #include "../misc/AudioLock.h" #include "../misc/VMath.h" +#include "../uiCallback/UICallback.h" #include "../source/CloneableSourceManager.h" #include "../AudioCore.h" #include "../Utils.h" @@ -205,6 +206,10 @@ void MainGraph::clearGraph() { this->removeNode(i->nodeID); } this->audioSourceNodeList.clear(); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::InstrChanged, -1); + UICallbackAPI::invoke(UICallbackType::TrackChanged, -1); } const juce::Array MainGraph::getOutputLevels() const { diff --git a/src/audioCore/graph/MixerGraph.cpp b/src/audioCore/graph/MixerGraph.cpp index dfea2665..c5a1bcd5 100644 --- a/src/audioCore/graph/MixerGraph.cpp +++ b/src/audioCore/graph/MixerGraph.cpp @@ -1,4 +1,5 @@ #include "MainGraph.h" +#include "../uiCallback/UICallback.h" void MainGraph::insertTrack(int index, const juce::AudioChannelSet& type) { /** Add Node To Graph */ @@ -19,6 +20,9 @@ void MainGraph::insertTrack(int index, const juce::AudioChannelSet& type) { /** Prepare To Play */ ptrNode->getProcessor()->setPlayHead(this->getPlayHead()); ptrNode->getProcessor()->prepareToPlay(this->getSampleRate(), this->getBlockSize()); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, index); } else { jassertfalse; @@ -102,6 +106,9 @@ void MainGraph::removeTrack(int index) { /** Remove Node From Graph */ this->removeNode(nodeID); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, index); } int MainGraph::getTrackNum() const { @@ -117,6 +124,9 @@ void MainGraph::setTrackBypass(int index, bool bypass) { if (index < 0 || index >= this->trackNodeList.size()) { return; } if (auto node = this->trackNodeList.getUnchecked(index)) { node->setBypassed(bypass); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, index); } } @@ -144,6 +154,9 @@ void MainGraph::setMIDII2TrkConnection(int trackIndex) { {nodeID, this->midiChannelIndex} }; this->addConnection(connection); this->midiI2TrkConnectionList.add(connection); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); } void MainGraph::removeMIDII2TrkConnection(int trackIndex) { @@ -162,6 +175,9 @@ void MainGraph::removeMIDII2TrkConnection(int trackIndex) { } return false; }); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); } void MainGraph::setAudioI2TrkConnection(int trackIndex, int srcChannel, int dstChannel) { @@ -183,6 +199,9 @@ void MainGraph::setAudioI2TrkConnection(int trackIndex, int srcChannel, int dstC this->addConnection(connection); this->audioI2TrkConnectionList.add(connection); } + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); } void MainGraph::removeAudioI2TrkConnection(int trackIndex, int srcChannel, int dstChannel) { @@ -194,6 +213,9 @@ void MainGraph::removeAudioI2TrkConnection(int trackIndex, int srcChannel, int d { {this->audioInputNode->nodeID, srcChannel}, {nodeID, dstChannel} }; this->removeConnection(connection); this->audioI2TrkConnectionList.removeAllInstancesOf(connection); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); } void MainGraph::setAudioTrk2OConnection(int trackIndex, int srcChannel, int dstChannel) { @@ -215,6 +237,9 @@ void MainGraph::setAudioTrk2OConnection(int trackIndex, int srcChannel, int dstC this->addConnection(connection); this->audioTrk2OConnectionList.add(connection); } + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); } void MainGraph::removeAudioTrk2OConnection(int trackIndex, int srcChannel, int dstChannel) { @@ -226,6 +251,9 @@ void MainGraph::removeAudioTrk2OConnection(int trackIndex, int srcChannel, int d { {nodeID, srcChannel}, {this->audioOutputNode->nodeID, dstChannel} }; this->removeConnection(connection); this->audioTrk2OConnectionList.removeAllInstancesOf(connection); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); } void MainGraph::setAudioTrk2TrkConnection(int trackIndex, int dstTrackIndex, int srcChannel, int dstChannel) { @@ -255,6 +283,10 @@ void MainGraph::setAudioTrk2TrkConnection(int trackIndex, int dstTrackIndex, int this->addConnection(connection); this->audioTrk2TrkConnectionList.add(connection); } + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); + UICallbackAPI::invoke(UICallbackType::TrackChanged, dstTrackIndex); } void MainGraph::removeAudioTrk2TrkConnection(int trackIndex, int dstTrackIndex, int srcChannel, int dstChannel) { @@ -274,6 +306,10 @@ void MainGraph::removeAudioTrk2TrkConnection(int trackIndex, int dstTrackIndex, { {nodeID, srcChannel}, {dstNodeID, dstChannel} }; this->removeConnection(connection); this->audioTrk2TrkConnectionList.removeAllInstancesOf(connection); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); + UICallbackAPI::invoke(UICallbackType::TrackChanged, dstTrackIndex); } void MainGraph::setMIDITrk2OConnection(int trackIndex) { @@ -292,6 +328,9 @@ void MainGraph::setMIDITrk2OConnection(int trackIndex) { {this->midiOutputNode->nodeID, this->midiChannelIndex} }; this->addConnection(connection); this->midiTrk2OConnectionList.add(connection); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); } void MainGraph::removeMIDITrk2OConnection(int trackIndex) { @@ -310,6 +349,9 @@ void MainGraph::removeMIDITrk2OConnection(int trackIndex) { } return false; }); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); } bool MainGraph::isMIDII2TrkConnected(int trackIndex) const { @@ -723,6 +765,9 @@ void MainGraph::removeIllegalAudioI2TrkConnections() { } return false; }); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, -1); } void MainGraph::removeIllegalAudioTrk2OConnections() { @@ -734,6 +779,9 @@ void MainGraph::removeIllegalAudioTrk2OConnections() { } return false; }); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, -1); } int MainGraph::findTrack(const Track* ptr) const { diff --git a/src/audioCore/graph/SendGraph.cpp b/src/audioCore/graph/SendGraph.cpp index 3be23858..ea74cfc7 100644 --- a/src/audioCore/graph/SendGraph.cpp +++ b/src/audioCore/graph/SendGraph.cpp @@ -19,6 +19,9 @@ void MainGraph::setMIDISrc2TrkConnection(int sourceIndex, int trackIndex) { {trkNodeID, this->midiChannelIndex} }; this->addConnection(connection); this->midiSrc2TrkConnectionList.add(connection); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); } void MainGraph::removeMIDISrc2TrkConnection(int sourceIndex, int trackIndex) { @@ -40,6 +43,9 @@ void MainGraph::removeMIDISrc2TrkConnection(int sourceIndex, int trackIndex) { } return false; }); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); } void MainGraph::setAudioSrc2TrkConnection(int sourceIndex, int trackIndex, int srcChannel, int dstChannel) { @@ -66,6 +72,9 @@ void MainGraph::setAudioSrc2TrkConnection(int sourceIndex, int trackIndex, int s this->addConnection(connection); this->audioSrc2TrkConnectionList.add(connection); } + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); } void MainGraph::removeAudioSrc2TrkConnection(int sourceIndex, int trackIndex, int srcChannel, int dstChannel) { @@ -82,6 +91,9 @@ void MainGraph::removeAudioSrc2TrkConnection(int sourceIndex, int trackIndex, in { {srcNodeID, srcChannel}, {trkNodeID, dstChannel} }; this->removeConnection(connection); this->audioSrc2TrkConnectionList.removeAllInstancesOf(connection); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); } void MainGraph::setAudioInstr2TrkConnection(int instrIndex, int trackIndex, int srcChannel, int dstChannel) { @@ -111,6 +123,7 @@ void MainGraph::setAudioInstr2TrkConnection(int instrIndex, int trackIndex, int /** Callback */ UICallbackAPI::invoke(UICallbackType::InstrChanged, instrIndex); + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); } void MainGraph::removeAudioInstr2TrkConnection(int instrIndex, int trackIndex, int srcChannel, int dstChannel) { @@ -130,6 +143,7 @@ void MainGraph::removeAudioInstr2TrkConnection(int instrIndex, int trackIndex, i /** Callback */ UICallbackAPI::invoke(UICallbackType::InstrChanged, instrIndex); + UICallbackAPI::invoke(UICallbackType::TrackChanged, trackIndex); } bool MainGraph::isMIDISrc2TrkConnected(int sourceIndex, int trackIndex) const { diff --git a/src/audioCore/graph/SeqSourceProcessor.cpp b/src/audioCore/graph/SeqSourceProcessor.cpp index 38dd4ef5..eeddbc12 100644 --- a/src/audioCore/graph/SeqSourceProcessor.cpp +++ b/src/audioCore/graph/SeqSourceProcessor.cpp @@ -12,6 +12,9 @@ SeqSourceProcessor::SeqSourceProcessor(const juce::AudioChannelSet& type) /** Set Channel Layout */ this->setChannelLayoutOfBus(true, 0, type); this->setChannelLayoutOfBus(false, 0, type); + + /** Default Color */ + this->trackColor = utils::getDefaultColour(); } int SeqSourceProcessor::addSeq(const SourceList::SeqBlock& block) { diff --git a/src/audioCore/graph/Track.cpp b/src/audioCore/graph/Track.cpp index 24fd5c58..492fc918 100644 --- a/src/audioCore/graph/Track.cpp +++ b/src/audioCore/graph/Track.cpp @@ -1,6 +1,7 @@ #include "Track.h" #include "../misc/Renderer.h" +#include "../uiCallback/UICallback.h" #include "../Utils.h" #include using namespace org::vocalsharp::vocalshaper; @@ -63,6 +64,9 @@ Track::Track(const juce::AudioChannelSet& type) /** Connect MIDI IO Node */ this->addConnection( { {this->midiInputNode->nodeID, this->midiChannelIndex}, {this->midiOutputNode->nodeID, this->midiChannelIndex} }); + + /** Default Color */ + this->trackColor = utils::getDefaultColour(); } bool Track::addAdditionalAudioBus() { @@ -101,6 +105,9 @@ bool Track::addAdditionalAudioBus() { {this->pluginDockNode->nodeID, i} }); } + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, -1); + return true; } @@ -136,6 +143,9 @@ bool Track::removeAdditionalAudioBus() { /** Auto Remove Connection */ this->removeIllegalConnections(); + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, -1); + return true; } @@ -145,6 +155,9 @@ int Track::getAdditionalAudioBusNum() const { void Track::setMute(bool mute) { this->isMute = mute; + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, -1); } bool Track::getMute() const { @@ -154,6 +167,9 @@ bool Track::getMute() const { void Track::setGain(float gain) { auto& gainDsp = this->gainAndPanner.get<0>(); gainDsp.setGainDecibels(gain); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, -1); } float Track::getGain() const { @@ -167,6 +183,9 @@ void Track::setPan(float pan) { auto& panDsp = this->gainAndPanner.get<1>(); panDsp.setPan(pan); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, -1); } float Track::getPan() const { @@ -176,6 +195,9 @@ float Track::getPan() const { void Track::setSlider(float slider) { auto& sliderDsp = this->slider.get<0>(); sliderDsp.setGainLinear(slider); + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, -1); } float Track::getSlider() const { @@ -185,6 +207,9 @@ float Track::getSlider() const { void Track::setTrackName(const juce::String& name) { this->trackName = name; + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, -1); } const juce::String Track::getTrackName() const { @@ -193,6 +218,9 @@ const juce::String Track::getTrackName() const { void Track::setTrackColor(const juce::Colour& color) { this->trackColor = color; + + /** Callback */ + UICallbackAPI::invoke(UICallbackType::TrackChanged, -1); } const juce::Colour Track::getTrackColor() const { diff --git a/src/audioCore/quickAPI/QuickGet.cpp b/src/audioCore/quickAPI/QuickGet.cpp index 48133d0a..2c294968 100644 --- a/src/audioCore/quickAPI/QuickGet.cpp +++ b/src/audioCore/quickAPI/QuickGet.cpp @@ -622,6 +622,15 @@ namespace quickAPI { return result; } + const juce::Colour getMixerTrackColor(int index) { + if (auto graph = AudioCore::getInstance()->getGraph()) { + if (auto track = graph->getTrackProcessor(index)) { + return track->getTrackColor(); + } + } + return utils::getDefaultColour(); + } + const juce::AudioChannelSet getMixerTrackChannelSet(int index) { if (auto graph = AudioCore::getInstance()->getGraph()) { if (auto track = graph->getTrackProcessor(index)) { diff --git a/src/audioCore/quickAPI/QuickGet.h b/src/audioCore/quickAPI/QuickGet.h index c61d8625..255110f5 100644 --- a/src/audioCore/quickAPI/QuickGet.h +++ b/src/audioCore/quickAPI/QuickGet.h @@ -125,6 +125,7 @@ namespace quickAPI { int getMixerTrackNum(); const juce::String getMixerTrackName(int index); const juce::StringArray getMixerTrackNameList(); + const juce::Colour getMixerTrackColor(int index); const juce::AudioChannelSet getMixerTrackChannelSet(int index); int getMixerTrackInputChannelNum(int index); int getMixerTrackOutputChannelNum(int index); diff --git a/src/audioCore/uiCallback/UICallbackType.h b/src/audioCore/uiCallback/UICallbackType.h index f2fbea8e..2819346c 100644 --- a/src/audioCore/uiCallback/UICallbackType.h +++ b/src/audioCore/uiCallback/UICallbackType.h @@ -8,6 +8,7 @@ enum class UICallbackType : int { PluginSearchStateChanged, SourceChanged, InstrChanged, + TrackChanged, TypeMaxNum }; diff --git a/src/ui/Utils.cpp b/src/ui/Utils.cpp index 2ae5f0c0..6fe85921 100644 --- a/src/ui/Utils.cpp +++ b/src/ui/Utils.cpp @@ -556,4 +556,8 @@ namespace utils { + juce::String{num[4]} + juce::String{ num[5] } + ":" + juce::String{num[6]} + juce::String{num[7]}; } + + bool isLightColor(const juce::Colour& color) { + return color.getLightness() > 0.6f; + } } diff --git a/src/ui/Utils.h b/src/ui/Utils.h index bba95ad3..8e66aab4 100644 --- a/src/ui/Utils.h +++ b/src/ui/Utils.h @@ -124,4 +124,6 @@ namespace utils { const std::array createBeatStringBase(const TimeInBeats& time); const juce::String createTimeString(const TimeInSeconds& time); const juce::String createBeatString(const TimeInBeats& time); + + bool isLightColor(const juce::Colour& color); } diff --git a/src/ui/component/MixerTrackComponent.cpp b/src/ui/component/MixerTrackComponent.cpp new file mode 100644 index 00000000..beb57c14 --- /dev/null +++ b/src/ui/component/MixerTrackComponent.cpp @@ -0,0 +1,69 @@ +#include "MixerTrackComponent.h" +#include "../Utils.h" +#include "../../audioCore/AC_API.h" + +MixerTrackComponent::MixerTrackComponent() {} + +void MixerTrackComponent::paint(juce::Graphics& g) { + /** Size */ + auto screenSize = utils::getScreenSize(this); + int colorHeight = screenSize.getHeight() * 0.015; + int titleBorderWidth = screenSize.getWidth() * 0.00125; + + float outlineThickness = screenSize.getHeight() * 0.00125; + + float titleFontHeight = screenSize.getHeight() * 0.0125; + + /** Color */ + auto& laf = this->getLookAndFeel(); + juce::Colour backgroundColor = laf.findColour( + juce::Label::ColourIds::backgroundColourId); + juce::Colour outlineColor = laf.findColour( + juce::Label::ColourIds::outlineColourId); + + /** Font */ + juce::Font titleFont(titleFontHeight); + + /** Background */ + g.setColour(backgroundColor); + g.fillAll(); + + /** Outline */ + auto totalRect = this->getLocalBounds(); + g.setColour(outlineColor); + g.drawRect(totalRect, outlineThickness); + + /** Track Color */ + auto colorRect = totalRect.withHeight(colorHeight); + g.setColour(this->trackColor); + g.fillRect(colorRect); + + /** Title */ + juce::String title = juce::String{ this->index }; + if (this->name.isNotEmpty()) { + title += (" - " + this->name); + } + g.setColour(this->nameColor); + g.setFont(titleFont); + g.drawFittedText(title, + colorRect.withTrimmedLeft(titleBorderWidth).withTrimmedRight(titleBorderWidth), + juce::Justification::centred, 1, 1.f); +} + +void MixerTrackComponent::update(int index) { + this->index = index; + if (index > -1) { + this->name = quickAPI::getMixerTrackName(index); + this->trackColor = quickAPI::getMixerTrackColor(index); + + auto& laf = this->getLookAndFeel(); + if (utils::isLightColor(this->trackColor)) { + this->nameColor = laf.findColour( + juce::Label::ColourIds::textWhenEditingColourId); + } + else { + this->nameColor = laf.findColour( + juce::Label::ColourIds::textColourId); + } + } +} diff --git a/src/ui/component/MixerTrackComponent.h b/src/ui/component/MixerTrackComponent.h new file mode 100644 index 00000000..dc10111d --- /dev/null +++ b/src/ui/component/MixerTrackComponent.h @@ -0,0 +1,19 @@ +#pragma once + +#include + +class MixerTrackComponent final : public juce::Component { +public: + MixerTrackComponent(); + + void paint(juce::Graphics& g) override; + + void update(int index); + +private: + int index = -1; + juce::Colour trackColor, nameColor; + juce::String name; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MixerTrackComponent) +}; diff --git a/src/ui/component/MixerView.cpp b/src/ui/component/MixerView.cpp index 19aaaae7..cd1cf9f0 100644 --- a/src/ui/component/MixerView.cpp +++ b/src/ui/component/MixerView.cpp @@ -1,6 +1,8 @@ #include "MixerView.h" #include "../lookAndFeel/LookAndFeelFactory.h" +#include "../misc/CoreCallbacks.h" #include "../Utils.h" +#include "../../audioCore/AC_API.h" MixerView::MixerView() : FlowComponent(TRANS("Mixer")) { @@ -19,6 +21,15 @@ MixerView::MixerView() int width, int height, bool vertical) { this->paintTrackPreview(g, itemIndex, width, height, vertical); }); this->addAndMakeVisible(this->hScroller.get()); + + /** Update Callback */ + CoreCallbacks::getInstance()->addTrackChanged( + [comp = MixerView::SafePointer(this)](int) { + if (comp) { + comp->update(); + } + } + ); } void MixerView::resized() { @@ -47,25 +58,78 @@ void MixerView::paint(juce::Graphics& g) { g.fillAll(); } +void MixerView::update() { + /** Create Or Remove Track */ + int currentSize = this->trackList.size(); + int newSize = quickAPI::getMixerTrackNum(); + if (currentSize > newSize) { + for (int i = currentSize - 1; i >= newSize; i--) { + this->trackList.remove(i, true); + } + } + else { + for (int i = currentSize; i < newSize; i++) { + auto track = std::make_unique(); + this->addAndMakeVisible(track.get()); + this->trackList.add(std::move(track)); + } + } + + /** Update Tracks */ + for (int i = 0; i < this->trackList.size(); i++) { + this->trackList[i]->update(i); + } + + /** Update Color Temp */ + this->colorTemp.clear(); + for (int i = 0; i < this->trackList.size(); i++) { + this->colorTemp.add(quickAPI::getMixerTrackColor(i)); + } + + /** Update View Pos */ + this->hScroller->update(); +} + int MixerView::getViewWidth() const { return this->getWidth(); } int MixerView::getTrackNum() const { - /** TODO */ - return 20; + return this->trackList.size(); } std::tuple MixerView::getTrackWidthLimit() const { - /** TODO */ - return { this->getWidth() / 8, this->getWidth() / 4 }; + auto screenSize = utils::getScreenSize(this); + return { (int)(screenSize.getWidth() * 0.04), + (int)(screenSize.getWidth() * 0.05) }; } void MixerView::updatePos(int pos, int itemSize) { - /** TODO */ + int height = this->getHeight() - this->hScroller->getHeight(); + for (int i = 0; i < this->trackList.size(); i++) { + juce::Rectangle trackRect( + i * itemSize - pos, 0, + itemSize, height); + this->trackList[i]->setBounds(trackRect); + } } void MixerView::paintTrackPreview(juce::Graphics& g, int itemIndex, - int width, int height, bool vertical) { - /** TODO */ + int width, int height, bool /*vertical*/) { + /** Limit Size */ + if (itemIndex < 0 || itemIndex >= this->colorTemp.size()) { return; } + + /** Size */ + auto screenSize = utils::getScreenSize(this); + int paddingHeight = screenSize.getHeight() * 0.005; + int colorHeight = screenSize.getHeight() * 0.005; + + /** Color */ + juce::Colour color = this->colorTemp[itemIndex]; + + /** Draw Color */ + juce::Rectangle colorRect( + 0, paddingHeight, width, colorHeight); + g.setColour(color); + g.fillRect(colorRect); } diff --git a/src/ui/component/MixerView.h b/src/ui/component/MixerView.h index 0bce0017..63982394 100644 --- a/src/ui/component/MixerView.h +++ b/src/ui/component/MixerView.h @@ -3,6 +3,7 @@ #include #include #include "Scroller.h" +#include "MixerTrackComponent.h" class MixerView final : public flowUI::FlowComponent { public: @@ -11,8 +12,12 @@ class MixerView final : public flowUI::FlowComponent { void resized() override; void paint(juce::Graphics& g) override; + void update(); + private: std::unique_ptr hScroller = nullptr; + juce::OwnedArray trackList; + juce::Array colorTemp; int getViewWidth() const; int getTrackNum() const; diff --git a/src/ui/component/ScrollerBase.cpp b/src/ui/component/ScrollerBase.cpp index e68c46ac..84f0b9f6 100644 --- a/src/ui/component/ScrollerBase.cpp +++ b/src/ui/component/ScrollerBase.cpp @@ -252,6 +252,7 @@ void ScrollerBase::setStart(int start) { /** Get Size */ double startPer = start / (double)this->getTrackLength(); double endPer = (this->viewPos + this->viewSize) / (double)this->getActualTotalSize(); + if (startPer < 0.0) { startPer = 0.0; } if (startPer > (endPer - DELTA)) { startPer = endPer - DELTA; } double viewNum = (endPer - startPer) * this->itemNum; int itemSize = this->limitItemSize(this->viewSize / viewNum); @@ -262,6 +263,7 @@ void ScrollerBase::setStart(int start) { /** Get Pos */ int endPos = endPer * this->getActualTotalSize(); int pos = endPos - this->viewSize; + if (pos < 0) { pos = 0; } /** Set Pos */ this->viewPos = pos; @@ -277,6 +279,7 @@ void ScrollerBase::setEnd(int end) { /** Get Size */ double startPer = this->viewPos / (double)this->getActualTotalSize(); double endPer = end / (double)this->getTrackLength(); + if (endPer > 1.0) { endPer = 1.0; } if (endPer < (startPer + DELTA)) { endPer = startPer + DELTA; } double viewNum = (endPer - startPer) * this->itemNum; int itemSize = this->limitItemSize(this->viewSize / viewNum); @@ -286,6 +289,7 @@ void ScrollerBase::setEnd(int end) { /** Get Pos */ int pos = startPer * this->getActualTotalSize(); + if (pos < 0) { pos = 0; } /** Set Pos */ this->viewPos = pos; diff --git a/src/ui/lookAndFeel/MixerLookAndFeel.cpp b/src/ui/lookAndFeel/MixerLookAndFeel.cpp index 77d93e5d..979f1d92 100644 --- a/src/ui/lookAndFeel/MixerLookAndFeel.cpp +++ b/src/ui/lookAndFeel/MixerLookAndFeel.cpp @@ -6,4 +6,18 @@ MixerLookAndFeel::MixerLookAndFeel() /** Background */ this->setColour(juce::ResizableWindow::ColourIds::backgroundColourId, ColorMap::getInstance()->get("ThemeColorB1")); + + /** Track */ + this->setColour(juce::Label::ColourIds::backgroundColourId, + ColorMap::getInstance()->get("ThemeColorB2"));/** Track Background */ + this->setColour(juce::Label::ColourIds::textColourId, + ColorMap::getInstance()->get("ThemeColorB10"));/** Item Name Light */ + this->setColour(juce::Label::ColourIds::outlineColourId, + ColorMap::getInstance()->get("ThemeColorB1"));/** Track Outline */ + this->setColour(juce::Label::ColourIds::backgroundWhenEditingColourId, + ColorMap::getInstance()->get("ThemeColorB2")); + this->setColour(juce::Label::ColourIds::textWhenEditingColourId, + ColorMap::getInstance()->get("ThemeColorB0"));/** Item Name Dark */ + this->setColour(juce::Label::ColourIds::outlineWhenEditingColourId, + ColorMap::getInstance()->get("ThemeColorB4")); } diff --git a/src/ui/lookAndFeel/ScrollerLookAndFeel.cpp b/src/ui/lookAndFeel/ScrollerLookAndFeel.cpp index 882f3a71..42b888e0 100644 --- a/src/ui/lookAndFeel/ScrollerLookAndFeel.cpp +++ b/src/ui/lookAndFeel/ScrollerLookAndFeel.cpp @@ -11,7 +11,7 @@ ScrollerLookAndFeel::ScrollerLookAndFeel() this->setColour(juce::ScrollBar::ColourIds::backgroundColourId, ColorMap::getInstance()->get("ThemeColorB1")); this->setColour(juce::ScrollBar::ColourIds::thumbColourId, - ColorMap::getInstance()->get("ThemeColorB4").withAlpha(0.9f)); + ColorMap::getInstance()->get("ThemeColorB4").withAlpha(0.7f)); this->setColour(juce::ScrollBar::ColourIds::trackColourId, ColorMap::getInstance()->get("ThemeColorB3"));/** Outline */ } diff --git a/src/ui/misc/CoreCallbacks.cpp b/src/ui/misc/CoreCallbacks.cpp index 4b54fc71..34268ad4 100644 --- a/src/ui/misc/CoreCallbacks.cpp +++ b/src/ui/misc/CoreCallbacks.cpp @@ -30,6 +30,10 @@ CoreCallbacks::CoreCallbacks() { [](int index) { CoreCallbacks::getInstance()->invokeInstrChanged(index); }); + UICallbackAPI::set(UICallbackType::TrackChanged, + [](int index) { + CoreCallbacks::getInstance()->invokeTrackChanged(index); + }); } void CoreCallbacks::addError(const ErrorCallback& callback) { @@ -60,6 +64,10 @@ void CoreCallbacks::addInstrChanged(const InstrChangedCallback& callback) { this->instrChanged.add(callback); } +void CoreCallbacks::addTrackChanged(const TrackChangedCallback& callback) { + this->trackChanged.add(callback); +} + void CoreCallbacks::invokeError( const juce::String& title, const juce::String& mes) const { for (auto& i : this->error) { @@ -103,6 +111,12 @@ void CoreCallbacks::invokeInstrChanged(int index) const { } } +void CoreCallbacks::invokeTrackChanged(int index) const { + for (auto& i : this->trackChanged) { + i(index); + } +} + CoreCallbacks* CoreCallbacks::getInstance() { return CoreCallbacks::instance ? CoreCallbacks::instance : (CoreCallbacks::instance = new CoreCallbacks{}); diff --git a/src/ui/misc/CoreCallbacks.h b/src/ui/misc/CoreCallbacks.h index 15ff673e..9b31be9f 100644 --- a/src/ui/misc/CoreCallbacks.h +++ b/src/ui/misc/CoreCallbacks.h @@ -20,6 +20,8 @@ class CoreCallbacks final : private juce::DeletedAtShutdown { void addSourceChanged(const SourceChangedCallback& callback); using InstrChangedCallback = std::function; void addInstrChanged(const InstrChangedCallback& callback); + using TrackChangedCallback = std::function; + void addTrackChanged(const TrackChangedCallback& callback); void invokeError(const juce::String& title, const juce::String& mes) const; void invokePlayingStatus(bool status) const; @@ -28,6 +30,7 @@ class CoreCallbacks final : private juce::DeletedAtShutdown { void invokeSearchPlugin(bool status) const; void invokeSourceChanged(int index) const; void invokeInstrChanged(int index) const; + void invokeTrackChanged(int index) const; private: juce::Array error; @@ -37,6 +40,7 @@ class CoreCallbacks final : private juce::DeletedAtShutdown { juce::Array searchPlugin; juce::Array sourceChanged; juce::Array instrChanged; + juce::Array trackChanged; public: static CoreCallbacks* getInstance();