diff --git a/src/audioCore/source/CloneableSource.cpp b/src/audioCore/source/CloneableSource.cpp index 95f9659c..f14b9e10 100644 --- a/src/audioCore/source/CloneableSource.cpp +++ b/src/audioCore/source/CloneableSource.cpp @@ -1,5 +1,6 @@ #include "CloneableSource.h" #include "../misc/AudioLock.h" +#include "../uiCallback/UICallback.h" std::atomic_int CloneableSource::globalCounter = 0; @@ -83,6 +84,11 @@ int CloneableSource::getId() const { void CloneableSource::setName(const juce::String& name) { this->name = name; + + /** Callback */ + juce::MessageManager::callAsync([] { + UICallbackAPI::invoke(UICallbackType::SourceChanged, -1); + }); } const juce::String CloneableSource::getName() const { diff --git a/src/audioCore/source/CloneableSynthSource.cpp b/src/audioCore/source/CloneableSynthSource.cpp index 3a4f0cc4..470ab6bf 100644 --- a/src/audioCore/source/CloneableSynthSource.cpp +++ b/src/audioCore/source/CloneableSynthSource.cpp @@ -69,6 +69,11 @@ void CloneableSynthSource::setSynthesizer( DMDA::PluginHandler handShakeHandler( [](DMDA::Context* context) { context->handShake(); }); this->synthesizer->getExtensions(handShakeHandler); + + /** Callback */ + juce::MessageManager::callAsync([] { + UICallbackAPI::invoke(UICallbackType::SourceChanged, -1); + }); } const juce::String CloneableSynthSource::getSynthesizerName() const { diff --git a/src/ui/component/SourceComponent.cpp b/src/ui/component/SourceComponent.cpp index 6db21311..5abb0271 100644 --- a/src/ui/component/SourceComponent.cpp +++ b/src/ui/component/SourceComponent.cpp @@ -135,6 +135,8 @@ void SourceComponent::update(int index, bool selected) { this->sampleRate = quickAPI::getSourceSampleRate(index); this->isIOTask = quickAPI::checkSourceIOTask(index); this->isSynthing = quickAPI::checkSourceSynthing(index); + + this->setTooltip(this->createTooltip()); } this->repaint(); @@ -330,3 +332,28 @@ juce::var SourceComponent::getDragSourceDescription() const { return juce::var{ object.release() }; } + +juce::String SourceComponent::createTooltip() const { + juce::String result = + "#" + juce::String{ this->id } + " " + this->nameEditor->getText() + "\n" + + TRANS("Type:") + " " + this->typeName + "\n" + + TRANS("Length:") + " " + juce::String{ this->length } + "s\n"; + + if (this->type == quickAPI::SourceType::AudioSource || this->type == quickAPI::SourceType::SynthSource) { + result += (TRANS("Channels:") + " " + juce::String{ this->channels } + "\n"); + } + if (this->type == quickAPI::SourceType::MIDISource || this->type == quickAPI::SourceType::SynthSource) { + result += (TRANS("Tracks:") + " " + juce::String{ this->tracks } + "\n"); + } + if (this->type == quickAPI::SourceType::MIDISource || this->type == quickAPI::SourceType::SynthSource) { + result += (TRANS("Events:") + " " + juce::String{ this->events } + "\n"); + } + if (this->type == quickAPI::SourceType::SynthSource) { + result += (TRANS("Synthesizer:") + " " + this->synthesizer + "\n"); + } + if (this->type == quickAPI::SourceType::AudioSource || this->type == quickAPI::SourceType::SynthSource) { + result += (TRANS("Sample Rate:") + " " + juce::String{ this->sampleRate } + "Hz\n"); + } + + return result; +} diff --git a/src/ui/component/SourceComponent.h b/src/ui/component/SourceComponent.h index db36e7de..d34721b8 100644 --- a/src/ui/component/SourceComponent.h +++ b/src/ui/component/SourceComponent.h @@ -4,7 +4,8 @@ class SourceComponent final : public juce::Component, - public juce::DragAndDropTarget { + public juce::DragAndDropTarget, + public juce::SettableTooltipClient { public: SourceComponent(const std::function& selectCallback); @@ -51,6 +52,7 @@ class SourceComponent final juce::PopupMenu createNewMenu() const; juce::var getDragSourceDescription() const; + juce::String createTooltip() const; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SourceComponent) }; diff --git a/src/ui/dataModel/SourceListModel.cpp b/src/ui/dataModel/SourceListModel.cpp index dc716c21..2297a997 100644 --- a/src/ui/dataModel/SourceListModel.cpp +++ b/src/ui/dataModel/SourceListModel.cpp @@ -14,7 +14,7 @@ int SourceListModel::getNumRows() { void SourceListModel::paintListBoxItem(int rowNumber, juce::Graphics& g, int width, int height, bool rowIsSelected) { - /** TODO */ + /** Nothing To Do */ } juce::Component* SourceListModel::refreshComponentForRow( @@ -42,37 +42,6 @@ void SourceListModel::backgroundClicked(const juce::MouseEvent& event) { } } -juce::String SourceListModel::getTooltipForRow(int row) { - auto type = quickAPI::getSourceType(row); - - juce::String result = - "#" + juce::String{ quickAPI::getSourceId(row) } + " " + quickAPI::getSourceName(row) + "\n" - + TRANS("Type:") + " " + quickAPI::getSourceTypeName(row) + "\n" - + TRANS("Length:") + " " + juce::String{ quickAPI::getSourceLength(row) } + "s\n"; - - if (type == quickAPI::SourceType::AudioSource || type == quickAPI::SourceType::SynthSource) { - result += (TRANS("Channels:") + " " + juce::String{ quickAPI::getSourceChannelNum(row) } + "\n"); - } - if (type == quickAPI::SourceType::MIDISource || type == quickAPI::SourceType::SynthSource) { - result += (TRANS("Tracks:") + " " + juce::String{ quickAPI::getSourceTrackNum(row) } + "\n"); - } - if (type == quickAPI::SourceType::MIDISource || type == quickAPI::SourceType::SynthSource) { - result += (TRANS("Events:") + " " + juce::String{ quickAPI::getSourceEventNum(row) } + "\n"); - } - if (type == quickAPI::SourceType::SynthSource) { - result += (TRANS("Synthesizer:") + " " + juce::String{ quickAPI::getSourceSynthesizerName(row) } + "\n"); - } - if (type == quickAPI::SourceType::AudioSource || type == quickAPI::SourceType::SynthSource) { - result += (TRANS("Sample Rate:") + " " + juce::String{ quickAPI::getSourceSampleRate(row) } + "\n"); - } - - return result; -} - -juce::MouseCursor SourceListModel::getMouseCursorForRow(int row) { - return juce::MouseCursor::PointingHandCursor; -} - enum SourceListActionType { NewAudio = 1, NewMIDI, diff --git a/src/ui/dataModel/SourceListModel.h b/src/ui/dataModel/SourceListModel.h index 053b95ad..90738242 100644 --- a/src/ui/dataModel/SourceListModel.h +++ b/src/ui/dataModel/SourceListModel.h @@ -14,8 +14,6 @@ class SourceListModel final : public juce::ListBoxModel { juce::Component* existingComponentToUpdate) override; juce::String getNameForRow(int rowNumber) override; void backgroundClicked(const juce::MouseEvent&) override; - juce::String getTooltipForRow(int row) override; - juce::MouseCursor getMouseCursorForRow(int row) override; private: const std::function selectCallback;