Skip to content

Commit 78947c5

Browse files
committed
Fix graphical glitches when moving between welcome panel, patch view and pluginmode view
1 parent 484f98c commit 78947c5

8 files changed

+34
-57
lines changed

Source/Dialogs/PatchStore.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ class PatchFullDisplay : public Component, public DownloadPool::DownloadListener
698698
public:
699699
enum Type
700700
{
701+
UpdateAvailable,
701702
AlreadyInstalled,
702703
Download,
703704
Store,
@@ -715,7 +716,7 @@ class PatchFullDisplay : public Component, public DownloadPool::DownloadListener
715716
String getIcon()
716717
{
717718
if(type == AlreadyInstalled) return isMouseOver() ? Icons::Reset : Icons::Checkmark;
718-
if(type == Download) return Icons::Download;
719+
if(type == Download || type == UpdateAvailable) return Icons::Download;
719720
if(type == Store) return Icons::Store;
720721
if(type == View) return Icons::Info;
721722
if(type == Cancel) return {};
@@ -724,6 +725,7 @@ class PatchFullDisplay : public Component, public DownloadPool::DownloadListener
724725

725726
String getText()
726727
{
728+
if(type == UpdateAvailable) return "Update";
727729
if(type == AlreadyInstalled) return isMouseOver() ? "Reinstall" : "Installed";
728730
if(type == Download) return "Download";
729731
if(type == Store) return "View in store";
@@ -866,7 +868,9 @@ class PatchFullDisplay : public Component, public DownloadPool::DownloadListener
866868

867869
auto fileName = URL(currentPatch.download).getFileName();
868870

869-
if (currentPatch.isPatchInstalled()) {
871+
if (currentPatch.updateAvailable()) {
872+
downloadButton.setType(LinkButton::UpdateAvailable);
873+
} else if (currentPatch.isPatchInstalled()) {
870874
downloadButton.setType(LinkButton::AlreadyInstalled);
871875
} else if (currentPatch.isPatchArchive()) {
872876
downloadButton.setType(LinkButton::Download);
@@ -894,10 +898,8 @@ class PatchFullDisplay : public Component, public DownloadPool::DownloadListener
894898
}
895899
}
896900

897-
if(result.size() <= 1)
901+
if(result.size() < 3)
898902
{
899-
result.clear();
900-
901903
for(auto& [patch, flags] : toFilter)
902904
{
903905
if(result.size() >= 3) break;

Source/NVGSurface.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ void NVGSurface::initialise()
130130

131131
lastRenderScale = calculateRenderScale();
132132
nvg = nvgCreateContext(view, NVG_ANTIALIAS | NVG_TRIPLE_BUFFER, getWidth() * lastRenderScale, getHeight() * lastRenderScale);
133-
resized();
134133
#else
135134
setVisible(true);
136135
glContext->attachTo(*this);
@@ -153,7 +152,6 @@ void NVGSurface::initialise()
153152
nvgCreateFontMem(nvg, "Inter-SemiBold", (unsigned char*)BinaryData::InterSemiBold_ttf, BinaryData::InterSemiBold_ttfSize, 0);
154153
nvgCreateFontMem(nvg, "Inter-Tabular", (unsigned char*)BinaryData::InterTabular_ttf, BinaryData::InterTabular_ttfSize, 0);
155154
nvgCreateFontMem(nvg, "icon_font-Regular", (unsigned char*)BinaryData::IconFont_ttf, BinaryData::IconFont_ttfSize, 0);
156-
invalidateAll();
157155
}
158156

159157
void NVGSurface::updateWindowContextVisibility()
@@ -227,11 +225,6 @@ void NVGSurface::lookAndFeelChanged()
227225
}
228226
}
229227

230-
void NVGSurface::triggerRepaint()
231-
{
232-
needsBufferSwap = true;
233-
}
234-
235228
bool NVGSurface::makeContextActive()
236229
{
237230
#ifdef NANOVG_METAL_IMPLEMENTATION
@@ -290,6 +283,8 @@ void NVGSurface::resized()
290283
}
291284
#endif
292285
backupImageComponent.setBounds(editor->getLocalArea(this, getLocalBounds()));
286+
invalidateAll();
287+
render();
293288
}
294289

295290
void NVGSurface::invalidateAll()

Source/NVGSurface.h

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class NVGSurface :
4141

4242
void render();
4343

44-
void triggerRepaint();
4544
bool makeContextActive();
4645

4746
void detachContext();

Source/PluginEditor.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -516,15 +516,6 @@ CallOutBox& PluginEditor::showCalloutBox(std::unique_ptr<Component> content, Rec
516516

517517
void PluginEditor::showWelcomePanel(bool shouldShow)
518518
{
519-
if(shouldShow)
520-
{
521-
welcomePanel->show();
522-
sidebar->showSidebar(true);
523-
}
524-
else {
525-
welcomePanel->hide();
526-
}
527-
528519
editButton.setVisible(!shouldShow);
529520
runButton.setVisible(!shouldShow);
530521
presentButton.setVisible(!shouldShow);
@@ -539,6 +530,15 @@ void PluginEditor::showWelcomePanel(bool shouldShow)
539530
welcomePanelSearchButton.setVisible(shouldShow);
540531
recentlyOpenedPanelSelector.setVisible(shouldShow);
541532
libraryPanelSelector.setVisible(shouldShow);
533+
534+
if(shouldShow)
535+
{
536+
welcomePanel->show();
537+
sidebar->showSidebar(true);
538+
}
539+
else {
540+
welcomePanel->hide();
541+
}
542542
}
543543

544544
DragAndDropTarget* PluginEditor::findNextDragAndDropTarget(Point<int> screenPos)

Source/PluginMode.h

+13-12
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,19 @@ class PluginMode : public Component
114114
titleBar.addAndMakeVisible(scaleComboBox);
115115

116116
addAndMakeVisible(titleBar);
117+
cnv->connectionLayer.setVisible(false);
118+
}
117119

120+
~PluginMode() override
121+
{
122+
if (pluginModeLnf) {
123+
editor->setLookAndFeel(editor->pd->lnf);
124+
editor->getTopLevelComponent()->sendLookAndFeelChange();
125+
}
126+
}
127+
128+
void updateSize()
129+
{
118130
// set scale to the last scale that was set for this patches plugin mode
119131
// if none was set, use 100% scale
120132
if (pluginModeScaleMap.contains(patchPtr->getPointer().get())) {
@@ -124,16 +136,6 @@ class PluginMode : public Component
124136
} else {
125137
setWidthAndHeight(1.0f);
126138
}
127-
128-
cnv->connectionLayer.setVisible(false);
129-
}
130-
131-
~PluginMode() override
132-
{
133-
if (pluginModeLnf) {
134-
editor->setLookAndFeel(editor->pd->lnf);
135-
editor->getTopLevelComponent()->sendLookAndFeelChange();
136-
}
137139
}
138140

139141
void setWidthAndHeight(float scale)
@@ -161,9 +163,8 @@ class PluginMode : public Component
161163
OSUtils::updateX11Constraints(getPeer()->getNativeHandle());
162164
}
163165
#endif
164-
editor->setSize(newWidth, newHeight);
165166
setBounds(0, 0, newWidth, newHeight);
166-
167+
editor->setSize(newWidth, newHeight);
167168
editor->nvgSurface.invalidateAll();
168169
}
169170

Source/PluginProcessor.cpp

-19
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,6 @@ void PluginProcessor::processBlock(AudioBuffer<float>& buffer, MidiBuffer& midiB
635635

636636
setThis();
637637
sendPlayhead();
638-
sendParameters();
639638

640639
midiDeviceManager.dequeueMidiInput(buffer.getNumSamples(), [this](int port, int blockSize, MidiBuffer& buffer) {
641640
midiInputHistory.addEvents(buffer, 0, blockSize, 0);
@@ -915,24 +914,6 @@ void PluginProcessor::sendPlayhead()
915914
unlockAudioThread();
916915
}
917916

918-
void PluginProcessor::sendParameters()
919-
{
920-
for (auto* param : getParameters()) {
921-
// We used to do dynamic_cast here, but since it gets called very often and param is always PlugDataParameter, we use reinterpret_cast now
922-
// this is probably UB...
923-
auto* pldParam = reinterpret_cast<PlugDataParameter*>(param);
924-
if (!pldParam->isEnabled())
925-
continue;
926-
927-
auto newvalue = pldParam->getUnscaledValue();
928-
if (!approximatelyEqual(pldParam->getLastValue(), newvalue)) {
929-
auto title = pldParam->getTitle();
930-
sendFloat(title.data(), pldParam->getUnscaledValue());
931-
pldParam->setLastValue(newvalue);
932-
}
933-
}
934-
}
935-
936917
MidiDeviceManager& PluginProcessor::getMidiDeviceManager()
937918
{
938919
return midiDeviceManager;

Source/PluginProcessor.h

-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ class PluginProcessor final : public AudioProcessor
126126

127127
void sendMidiBuffer(int device, MidiBuffer& buffer);
128128
void sendPlayhead();
129-
void sendParameters();
130129

131130
SmallArray<PluginEditor*> getEditors() const;
132131

Source/TabComponent.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ void TabComponent::handleAsyncUpdate()
381381
clearCanvases();
382382
if (!editor->isInPluginMode() || editor->pluginMode->getPatch()->getPointer().get() != patchInPluginMode->getUncheckedPointer()) {
383383
editor->pluginMode = std::make_unique<PluginMode>(editor, patchInPluginMode);
384-
editor->resized();
384+
editor->pluginMode->updateSize();
385385
// hack to force the window title buttons to hide
386386
editor->parentSizeChanged();
387387
}
@@ -772,12 +772,12 @@ void TabComponent::closeTab(Canvas* cnv)
772772
showTab(tabbars[1][tabbars[1].indexOf(tab) - 1]->cnv, 1);
773773
}
774774
}
775-
775+
776776
canvases.removeObject(cnv);
777777
pd->patches.remove_one(patch);
778778

779779
pd->updateObjectImplementations();
780-
780+
781781
triggerAsyncUpdate();
782782
}
783783

0 commit comments

Comments
 (0)