From 2ac66f79beed4557dab3f2820669f445c0721f2f Mon Sep 17 00:00:00 2001 From: Timothy Schoen Date: Wed, 8 Jan 2025 01:59:27 +0100 Subject: [PATCH] Applied formatting --- Source/Canvas.cpp | 16 +- Source/CanvasViewport.h | 106 +++++++------- Source/Components/Buttons.h | 4 +- Source/Components/CanvasBorderResizer.h | 18 ++- Source/Components/ConnectionMessageDisplay.h | 5 +- Source/Components/WelcomePanel.h | 60 ++++---- Source/Connection.cpp | 5 +- Source/Connection.h | 5 +- Source/Dialogs/PatchStore.h | 3 +- Source/Object.cpp | 10 +- Source/Objects/AllGuis.h | 106 +++++++------- Source/Objects/KnobObject.h | 39 +++-- Source/Objects/MessboxObject.h | 3 +- Source/Objects/NoteObject.h | 2 +- Source/Objects/PopMenu.h | 145 +++++++++---------- Source/Pd/Instance.cpp | 6 +- Source/Pd/Patch.cpp | 5 +- Source/Pd/Setup.cpp | 1 - Source/PluginMode.h | 2 +- Source/PluginProcessor.cpp | 12 +- Source/Sidebar/Sidebar.cpp | 3 +- Source/Standalone/PlugDataApp.cpp | 7 +- Source/TabComponent.cpp | 2 +- Source/Utility/CachedTextRender.h | 7 +- Source/Utility/Containers.h | 27 ++-- Source/Utility/MidiDeviceManager.h | 11 +- Source/Utility/PatchInfo.h | 13 +- Source/Utility/PluginParameter.h | 4 +- 28 files changed, 307 insertions(+), 320 deletions(-) diff --git a/Source/Canvas.cpp b/Source/Canvas.cpp index 1b88863cf..850183f31 100644 --- a/Source/Canvas.cpp +++ b/Source/Canvas.cpp @@ -1126,9 +1126,10 @@ void Canvas::performSynchronise() { static bool alreadyFlushed = false; // By flushing twice, we can make sure that any message sent before this point will be dequeued - if(!alreadyFlushed) pd->doubleFlushMessageQueue(); + if (!alreadyFlushed) + pd->doubleFlushMessageQueue(); ScopedValueSetter flushGuard(alreadyFlushed, true); - + // Remove deleted connections for (int n = connections.size() - 1; n >= 0; n--) { if (!connections[n]->getPointer()) { @@ -2540,9 +2541,9 @@ void Canvas::valueChanged(Value& v) auto y1 = static_cast(cnv->gl_screeny1); auto x2 = static_cast(getValue(patchWidth) + x1); auto y2 = static_cast(cnv->gl_screeny2); - + char buf[MAXPDSTRING]; - snprintf(buf, MAXPDSTRING-1, ".x%lx", (unsigned long)cnv.get()); + snprintf(buf, MAXPDSTRING - 1, ".x%lx", (unsigned long)cnv.get()); pd->sendMessage(buf, "setbounds", { x1, y1, x2, y2 }); } repaint(); @@ -2555,7 +2556,7 @@ void Canvas::valueChanged(Value& v) auto y2 = static_cast(getValue(patchHeight) + y1); char buf[MAXPDSTRING]; - snprintf(buf, MAXPDSTRING-1, ".x%lx", (unsigned long)cnv.get()); + snprintf(buf, MAXPDSTRING - 1, ".x%lx", (unsigned long)cnv.get()); pd->sendMessage(buf, "setbounds", { x1, y1, x2, y2 }); } repaint(); @@ -2806,8 +2807,9 @@ void Canvas::receiveMessage(t_symbol* symbol, SmallArray const& atoms) break; } case hash("editmode"): { - if(::getValue(commandLocked)) return; - + if (::getValue(commandLocked)) + return; + if (atoms.size() >= 1) { int const flag = atoms[0].getFloat(); if (flag % 2 == 0) { diff --git a/Source/CanvasViewport.h b/Source/CanvasViewport.h index 3c7b55fac..d9c020e34 100644 --- a/Source/CanvasViewport.h +++ b/Source/CanvasViewport.h @@ -22,49 +22,48 @@ using namespace gl; #include "Utility/SettingsFile.h" -class Minimap : public Component, public Timer, public AsyncUpdater -{ +class Minimap : public Component + , public Timer + , public AsyncUpdater { public: - Minimap(Canvas* canvas) : cnv(canvas) + Minimap(Canvas* canvas) + : cnv(canvas) { } - + void handleAsyncUpdate() override { auto area = visibleArea / getValue(cnv->zoomScale); bool renderMinimap = cnv->objects.not_empty(); - for(auto* obj : cnv->objects) - { - if(obj->getBounds().intersects(area)) - { + for (auto* obj : cnv->objects) { + if (obj->getBounds().intersects(area)) { renderMinimap = false; break; } } - - if(renderMinimap && minimapAlpha != 1.0f) - { + + if (renderMinimap && minimapAlpha != 1.0f) { setVisible(true); minimapTargetAlpha = 1.0f; - if(!isTimerRunning()) startTimer(11); - } - else if(!renderMinimap && minimapAlpha != 0.0f) - { + if (!isTimerRunning()) + startTimer(11); + } else if (!renderMinimap && minimapAlpha != 0.0f) { setVisible(false); minimapTargetAlpha = 0.0f; - if(!isTimerRunning()) startTimer(11); + if (!isTimerRunning()) + startTimer(11); } } - + void updateMinimap(Rectangle area) { - if(isMouseDown || area.isEmpty()) + if (isMouseDown || area.isEmpty()) return; - + visibleArea = area; triggerAsyncUpdate(); } - + auto getMapBounds() { struct @@ -73,66 +72,65 @@ class Minimap : public Component, public Timer, public AsyncUpdater int offsetX, offsetY; float scale; } b; - + auto const zoom = getValue(cnv->zoomScale); b.viewBounds = cnv->viewport->getViewArea() / zoom; Rectangle allObjectBounds = Rectangle(cnv->canvasOrigin.x, cnv->canvasOrigin.y, b.viewBounds.getWidth(), b.viewBounds.getHeight()); - for(auto* object : cnv->objects) - { + for (auto* object : cnv->objects) { allObjectBounds = allObjectBounds.getUnion(object->getBounds()); } - + b.fullBounds = isMouseDown ? boundsBeforeDrag : allObjectBounds.getUnion(b.viewBounds); b.offsetX = -std::min(0, b.fullBounds.getX() - cnv->canvasOrigin.x); b.offsetY = -std::min(0, b.fullBounds.getY() - cnv->canvasOrigin.y); b.scale = std::min(width / (b.fullBounds.getWidth() + b.offsetX), height / (b.fullBounds.getHeight() + b.offsetY)); boundsBeforeDrag = b.fullBounds; - + return b; } - + void render(NVGcontext* nvg) { - if(approximatelyEqual(minimapAlpha, 0.0f)) return; - + if (approximatelyEqual(minimapAlpha, 0.0f)) + return; + nvgGlobalAlpha(nvg, minimapAlpha); - + auto map = getMapBounds(); - + float const x = cnv->viewport->getViewWidth() - (width + 10); float const y = cnv->viewport->getViewHeight() - (height + 10); - + auto canvasBackground = cnv->findColour(PlugDataColour::canvasBackgroundColourId); auto mapBackground = canvasBackground.contrasting(0.5f); - + // draw background nvgFillColor(nvg, NVGComponent::convertColour(mapBackground.withAlpha(0.4f))); nvgFillRoundedRect(nvg, x - 4, y - 4, width + 8, height + 8, Corners::largeCornerRadius); - + nvgFillColor(nvg, NVGComponent::convertColour(mapBackground.withAlpha(0.8f))); - + // draw objects - for(auto* object : cnv->objects) - { + for (auto* object : cnv->objects) { auto b = (object->getBounds().reduced(Object::margin).translated(map.offsetX, map.offsetY) - cnv->canvasOrigin).toFloat() * map.scale; nvgFillRoundedRect(nvg, x + b.getX(), y + b.getY(), b.getWidth(), b.getHeight(), Corners::objectCornerRadius * map.scale); } - + // draw visible area - nvgDrawRoundedRect(nvg, x + (map.offsetX + map.viewBounds.getX() - cnv->canvasOrigin.x) * map.scale, y + (map.offsetY + map.viewBounds.getY() - cnv->canvasOrigin.y) * map.scale, map.viewBounds.getWidth() * map.scale, map.viewBounds.getHeight() * map.scale, NVGComponent::convertColour(canvasBackground.withAlpha(0.6f)), NVGComponent::convertColour(canvasBackground.contrasting(0.4f)), 0.0f); + nvgDrawRoundedRect(nvg, x + (map.offsetX + map.viewBounds.getX() - cnv->canvasOrigin.x) * map.scale, y + (map.offsetY + map.viewBounds.getY() - cnv->canvasOrigin.y) * map.scale, map.viewBounds.getWidth() * map.scale, map.viewBounds.getHeight() * map.scale, NVGComponent::convertColour(canvasBackground.withAlpha(0.6f)), NVGComponent::convertColour(canvasBackground.contrasting(0.4f)), 0.0f); nvgGlobalAlpha(nvg, 1.0f); } - + void mouseDown(MouseEvent const& e) override { downPosition = cnv->viewport->getViewPosition(); - + auto map = getMapBounds(); auto realViewBounds = Rectangle((map.offsetX + map.viewBounds.getX() - cnv->canvasOrigin.x) * map.scale, (map.offsetY + map.viewBounds.getY() - cnv->canvasOrigin.y) * map.scale, map.viewBounds.getWidth() * map.scale, map.viewBounds.getHeight() * map.scale); isMouseDown = realViewBounds.contains(e.getMouseDownPosition()); } - + void mouseUp(MouseEvent const& e) override { auto viewBounds = cnv->viewport->getViewArea(); @@ -140,29 +138,26 @@ class Minimap : public Component, public Timer, public AsyncUpdater isMouseDown = false; updateMinimap(viewBounds); } - + void mouseDrag(MouseEvent const& e) override { auto map = getMapBounds(); - - if(isMouseDown) - { + + if (isMouseDown) { cnv->viewport->setViewPosition(downPosition + (e.getOffsetFromDragStart() / map.scale)); } } - + void timerCallback() override { minimapAlpha = jmap(0.2f, minimapAlpha, minimapTargetAlpha); - if(approximatelyEqual(minimapAlpha, minimapTargetAlpha, Tolerance{} - .withAbsolute(0.01f))) - { + if (approximatelyEqual(minimapAlpha, minimapTargetAlpha, Tolerance {}.withAbsolute(0.01f))) { minimapAlpha = minimapTargetAlpha; stopTimer(); } cnv->editor->nvgSurface.invalidateAll(); } - + private: Canvas* cnv; float minimapAlpha = 0.0f; @@ -462,7 +457,7 @@ class CanvasViewport final : public Viewport addChildComponent(minimap); addAndMakeVisible(vbar); addAndMakeVisible(hbar); - + setCachedComponentImage(new NVGSurface::InvalidationListener(editor->nvgSurface, this)); lookAndFeelChanged(); @@ -475,7 +470,7 @@ class CanvasViewport final : public Viewport void render(NVGcontext* nvg, Rectangle const area) { minimap.render(nvg); - + if (area.intersects(vbar.getBounds())) { NVGScopedState scopedState(nvg); nvgTranslate(nvg, vbar.getX(), vbar.getY()); @@ -681,7 +676,7 @@ class CanvasViewport final : public Viewport vbar.setVisible(isVerticalScrollBarShown()); hbar.setVisible(isHorizontalScrollBarShown()); minimap.setBounds(Rectangle(getWidth() - 200, getHeight() - 150, 190, 140)); - + if (editor->isInPluginMode()) return; @@ -721,12 +716,13 @@ class CanvasViewport final : public Viewport std::function onScroll = [] { }; private: - enum Timers { ResizeTimer, AnimationTimer }; + enum Timers { ResizeTimer, + AnimationTimer }; Point startPos; Point targetPos; float lerpAnimation; float animationSpeed; - + Minimap minimap; Time lastScrollTime; Time lastZoomTime; diff --git a/Source/Components/Buttons.h b/Source/Components/Buttons.h index ef4c1326d..4b6f6e281 100644 --- a/Source/Components/Buttons.h +++ b/Source/Components/Buttons.h @@ -44,8 +44,8 @@ class MainToolbarButton final : public TextButton { } } } - - void mouseEnter(const MouseEvent& e) override + + void mouseEnter(MouseEvent const& e) override { if (auto const* topLevel = getTopLevelComponent()) { if (auto const* peer = topLevel->getPeer()) { diff --git a/Source/Components/CanvasBorderResizer.h b/Source/Components/CanvasBorderResizer.h index 407db8ac5..d4012f63b 100644 --- a/Source/Components/CanvasBorderResizer.h +++ b/Source/Components/CanvasBorderResizer.h @@ -33,8 +33,9 @@ class BorderResizer final : public Component void mouseDown(MouseEvent const& e) override { - if(getValue(cnv->locked)) return; - + if (getValue(cnv->locked)) + return; + if (cnv->showBorder) { dragger.startDraggingComponent(this, e); } @@ -42,8 +43,9 @@ class BorderResizer final : public Component void mouseDrag(MouseEvent const& e) override { - if(getValue(cnv->locked)) return; - + if (getValue(cnv->locked)) + return; + if (cnv->showBorder) { auto const constrainedPoint = getLocalPoint(cnv, Rectangle(cnv->canvasOrigin.x + 11, cnv->canvasOrigin.y + 11, cnv->canvasOrigin.x, cnv->canvasOrigin.y).getConstrainedPoint(e.getEventRelativeTo(cnv).getPosition())); dragger.dragComponent(this, e.withNewPosition(constrainedPoint), nullptr); @@ -56,15 +58,17 @@ class BorderResizer final : public Component void mouseUp(MouseEvent const& e) override { - if(getValue(cnv->locked)) return; - + if (getValue(cnv->locked)) + return; + cnv->patchHeight.addListener(this); cnv->patchWidth.addListener(this); } void render(NVGcontext* nvg) override { - if(getValue(cnv->locked)) return; + if (getValue(cnv->locked)) + return; NVGScopedState state(nvg); nvgSave(nvg); nvgTranslate(nvg, getX(), getY()); diff --git a/Source/Components/ConnectionMessageDisplay.h b/Source/Components/ConnectionMessageDisplay.h index bf544201e..41741001f 100644 --- a/Source/Components/ConnectionMessageDisplay.h +++ b/Source/Components/ConnectionMessageDisplay.h @@ -106,8 +106,9 @@ class ConnectionMessageDisplay final messageItemsWithFormat.clear(); auto* connection = activeConnection.load(); - if(!connection) return; - + if (!connection) + return; + auto haveMessage = true; auto textString = connection->getMessageFormated(); diff --git a/Source/Components/WelcomePanel.h b/Source/Components/WelcomePanel.h index 014fa5acd..c0c2e61c3 100644 --- a/Source/Components/WelcomePanel.h +++ b/Source/Components/WelcomePanel.h @@ -247,7 +247,7 @@ class WelcomePanel final : public Component String modifiedTimeDescription = String(); String accessedTimeDescription = String(); String fileSizeDescription = String(); - + UnorderedMap previousVersions; File patchFile; @@ -355,20 +355,18 @@ class WelcomePanel final : public Component resized(); } - + void setPreviousVersions(Array> versions) { previousVersions.clear(); - - for(auto& [time, file] : versions) - { + + for (auto& [time, file] : versions) { auto metaFile = file.getParentDirectory().getChildFile("meta.json"); if (metaFile.existsAsFile()) { auto const json = JSON::fromString(metaFile.loadFileAsString()); - if(json.hasProperty("Version")) { + if (json.hasProperty("Version")) { previousVersions[json["Version"].toString()] = file; - } - else { + } else { previousVersions["Added " + Time(time).toString(true, false)] = file; } } @@ -407,19 +405,18 @@ class WelcomePanel final : public Component patchInfoSubMenu.addItem("Author: " + patchInfo.author, false, false, nullptr); patchInfoSubMenu.addItem("Released: " + patchInfo.releaseDate, false, false, nullptr); patchInfoSubMenu.addItem("About: " + patchInfo.description, false, false, nullptr); - if(patchInfo.version.isNotEmpty()) { + if (patchInfo.version.isNotEmpty()) { patchInfoSubMenu.addItem("Version: " + patchInfo.version, false, false, nullptr); } - + tileMenu.addSubMenu(String(tileName + " info"), patchInfoSubMenu, true); } else { tileMenu.addItem("Patch info not provided", false, false, nullptr); } - - if(previousVersions.size()) { + + if (previousVersions.size()) { PopupMenu versionsSubMenu; - for(auto& [name, file] : previousVersions) - { + for (auto& [name, file] : previousVersions) { versionsSubMenu.addItem(name, [this, file] { parent.editor->getTabComponent().openPatch(URL(file)); }); @@ -938,12 +935,12 @@ class WelcomePanel final : public Component auto const pName = patchFile.getFileNameWithoutExtension(); auto foundThumbs = patchFile.getParentDirectory().findChildFiles(File::findFiles, true, pName + "_thumb.png;" + pName + "_thumb.jpg;" + pName + "_thumb.jpeg;" + pName + "_thumb.gif"); - std::ranges::sort(patches, [](std::pair const& first, std::pair const& second){ + std::ranges::sort(patches, [](std::pair const& first, std::pair const& second) { return first.first > second.first; }); - + patches.remove(0); - + constexpr float scale = 1.0f; Image thumbImage; for (auto& thumb : foundThumbs) { @@ -972,9 +969,9 @@ class WelcomePanel final : public Component tile->setPreviousVersions(patches); contentComponent.addAndMakeVisible(tile); }; - + Array> allPatches; - + auto const patchesFolder = ProjectInfo::appDataDir.getChildFile("Patches"); for (auto& file : OSUtils::iterateDirectory(patchesFolder, false, false)) { if (OSUtils::isDirectoryFast(file.getFullPathName())) { @@ -988,38 +985,33 @@ class WelcomePanel final : public Component auto const json = JSON::fromString(metaFile.loadFileAsString()); author = json["Author"].toString(); title = json["Title"].toString(); - if(json.hasProperty("InstallTime")) - { + if (json.hasProperty("InstallTime")) { installTime = static_cast(json["InstallTime"]); - } - else { + } else { installTime = metaFile.getCreationTime().toMilliseconds(); } - } - else { + } else { title = subfile.getFileNameWithoutExtension(); installTime = 0; } - - allPatches.add({subfile, hash(title + author), installTime}); + + allPatches.add({ subfile, hash(title + author), installTime }); break; } } } else { if (file.hasFileExtension("pd")) { - allPatches.add({file, 0, 0}); + allPatches.add({ file, 0, 0 }); } } } - + // Combine different versions of the same patch into one tile UnorderedMap>> versions; - for(auto& [file, hash, time] : allPatches) - { - versions[hash].add({time, file}); + for (auto& [file, hash, time] : allPatches) { + versions[hash].add({ time, file }); } - for(auto& [hash, patches] : versions) - { + for (auto& [hash, patches] : versions) { addTile(patches); } } diff --git a/Source/Connection.cpp b/Source/Connection.cpp index db372cae3..944bb0c9d 100644 --- a/Source/Connection.cpp +++ b/Source/Connection.cpp @@ -332,7 +332,8 @@ void Connection::pushPathState(bool force) } cnv->pathUpdater->pushPathState(this, newPathState); - if(force) cnv->pathUpdater->timerCallback(); + if (force) + cnv->pathUpdater->timerCallback(); } void Connection::popPathState() @@ -837,7 +838,7 @@ void Connection::componentMovedOrResized(Component& component, bool wasMoved, bo auto offsetPath = getPath(); offsetPath.applyTransform(translation); setPath(offsetPath); - + updateReconnectHandle(); clipRegion.transformAll(translation); diff --git a/Source/Connection.h b/Source/Connection.h index 85273f0a6..89168488f 100644 --- a/Source/Connection.h +++ b/Source/Connection.h @@ -329,9 +329,8 @@ class ConnectionPathUpdater final : public Timer { Canvas* canvas; moodycamel::ReaderWriterQueue, t_symbol*>> connectionUpdateQueue = moodycamel::ReaderWriterQueue, t_symbol*>>(4096); - + public: - explicit ConnectionPathUpdater(Canvas* cnv) : canvas(cnv) { @@ -342,6 +341,6 @@ class ConnectionPathUpdater final : public Timer { connectionUpdateQueue.enqueue({ connection, newPathState }); startTimer(50); } - + void timerCallback() override; }; diff --git a/Source/Dialogs/PatchStore.h b/Source/Dialogs/PatchStore.h index ffc064b60..39c0a1eb0 100644 --- a/Source/Dialogs/PatchStore.h +++ b/Source/Dialogs/PatchStore.h @@ -183,8 +183,7 @@ class DownloadPool final : public DeletedAtShutdown { info.setInstallTime(Time::currentTimeMillis()); auto json = info.json; metaFile.replaceWithText(info.json); - } - else { + } else { info = PatchInfo(JSON::fromString(metaFile.loadFileAsString())); info.setInstallTime(Time::currentTimeMillis()); auto json = info.json; diff --git a/Source/Object.cpp b/Source/Object.cpp index 716925066..61b73c0bc 100644 --- a/Source/Object.cpp +++ b/Source/Object.cpp @@ -846,7 +846,7 @@ void Object::mouseUp(MouseEvent const& e) if (ds.wasResized) { cnv->objectGrid.clearIndicators(false); - for(auto* connection : getConnections()) + for (auto* connection : getConnections()) connection->pushPathState(true); applyBounds(); @@ -873,9 +873,9 @@ void Object::mouseUp(MouseEvent const& e) } if (ds.didStartDragging) { - for(auto* connection : getConnections()) + for (auto* connection : getConnections()) connection->pushPathState(true); - + applyBounds(); cnv->patch.endUndoSequence("Drag"); cnv->objectGrid.clearIndicators(false); @@ -1190,13 +1190,13 @@ void Object::render(NVGcontext* nvg) { auto const lb = getLocalBounds(); auto const b = lb.reduced(margin); - + if (cnv->shouldShowObjectActivity() && !approximatelyEqual(activeStateAlpha, 0.0f)) { auto glowColour = cnv->dataCol; glowColour.a = static_cast(activeStateAlpha * 255); nvgSmoothGlow(nvg, lb.getX(), lb.getY(), lb.getWidth(), lb.getHeight(), glowColour, nvgRGBA(0, 0, 0, 0), Corners::objectCornerRadius, 1.1f); } - + if (selectedFlag && showHandles) { auto& resizeHandleImage = cnv->resizeHandleImage; int angle = 360; diff --git a/Source/Objects/AllGuis.h b/Source/Objects/AllGuis.h index 3ffcc0e69..694501eb8 100644 --- a/Source/Objects/AllGuis.h +++ b/Source/Objects/AllGuis.h @@ -648,57 +648,57 @@ struct t_fake_keycode { // else/popmenu struct t_fake_menu { - t_object x_obj; - void *x_proxy; - t_canvas *x_cv; - t_glist *x_glist; - int x_width, x_height; // Graphical Object's dimensions - int x_fontsize; // Font Size - int x_idx; // selected item's index - int x_n_items; // number of items in the popmenu - int x_maxitems; - int x_disabled; - int x_zoom; - t_symbol *x_label; - t_symbol **x_items; - t_symbol *x_sym; - t_symbol *x_param; - t_symbol *x_var; - t_symbol *x_var_raw; - int x_var_set; - int x_savestate; - int x_keep; // keep/save contents - int x_load; // value when loading patch - int x_lb; - int x_outline; - int x_outmode; - int x_flag; - int x_pos; - t_symbol *x_dir; - t_symbol *x_rcv; - t_symbol *x_rcv_raw; - int x_rcv_set; - int x_r_flag; - t_symbol *x_snd; - t_symbol *x_snd_raw; - int x_snd_set; - int x_s_flag; - int x_v_flag; - char x_tag_obj[32]; - char x_tag_outline[32]; - char x_tag_in[32]; - char x_tag_out[32]; - char x_tag_sel[32]; - char x_tag_mb[32]; - char x_tag_popmenu[32]; - char x_tag_menu[64]; - char x_tag_menu_sel[64]; - char x_callback_proc[64]; - char *x_cvId; - int x_edit; - t_symbol *x_bg; - t_symbol *x_fg; - t_symbol *x_ignore; - t_atom *x_options; - int x_itemcount; + t_object x_obj; + void* x_proxy; + t_canvas* x_cv; + t_glist* x_glist; + int x_width, x_height; // Graphical Object's dimensions + int x_fontsize; // Font Size + int x_idx; // selected item's index + int x_n_items; // number of items in the popmenu + int x_maxitems; + int x_disabled; + int x_zoom; + t_symbol* x_label; + t_symbol** x_items; + t_symbol* x_sym; + t_symbol* x_param; + t_symbol* x_var; + t_symbol* x_var_raw; + int x_var_set; + int x_savestate; + int x_keep; // keep/save contents + int x_load; // value when loading patch + int x_lb; + int x_outline; + int x_outmode; + int x_flag; + int x_pos; + t_symbol* x_dir; + t_symbol* x_rcv; + t_symbol* x_rcv_raw; + int x_rcv_set; + int x_r_flag; + t_symbol* x_snd; + t_symbol* x_snd_raw; + int x_snd_set; + int x_s_flag; + int x_v_flag; + char x_tag_obj[32]; + char x_tag_outline[32]; + char x_tag_in[32]; + char x_tag_out[32]; + char x_tag_sel[32]; + char x_tag_mb[32]; + char x_tag_popmenu[32]; + char x_tag_menu[64]; + char x_tag_menu_sel[64]; + char x_callback_proc[64]; + char* x_cvId; + int x_edit; + t_symbol* x_bg; + t_symbol* x_fg; + t_symbol* x_ignore; + t_atom* x_options; + int x_itemcount; }; diff --git a/Source/Objects/KnobObject.h b/Source/Objects/KnobObject.h index 9137517ee..ee38a6eda 100644 --- a/Source/Objects/KnobObject.h +++ b/Source/Objects/KnobObject.h @@ -238,7 +238,7 @@ class Knob final : public Component numberOfTicks = steps; repaint(); } - + void doubleClicked() { setValue(std::clamp(doubleClickValue, minValue, maxValue)); @@ -348,7 +348,7 @@ class KnobObject final : public ObjectBase { knob.onDragEnd = [this] { stopEdition(); }; - + knob.addMouseListener(this, false); locked = ::getValue(object->locked); @@ -360,10 +360,10 @@ class KnobObject final : public ObjectBase { objectParameters.addParamInt("Angular range", cGeneral, &angularRange, 270); objectParameters.addParamInt("Angular offset", cGeneral, &angularOffset, 0); objectParameters.addParamFloat("Arc start", cGeneral, &arcStart, 0.0f); - objectParameters.addParamCombo("Log mode", cGeneral, &logMode, { "Linear", "Logarithmic", "Exponential"}, 0); + objectParameters.addParamCombo("Log mode", cGeneral, &logMode, { "Linear", "Logarithmic", "Exponential" }, 0); objectParameters.addParamFloat("Exp factor", cGeneral, &exponential, 0.0f); objectParameters.addParamBool("Discrete", cGeneral, &discrete, { "No", "Yes" }, 0); - objectParameters.addParamBool("Show ticks", cGeneral, &showTicks, {"No", "Yes"}, 0); + objectParameters.addParamBool("Show ticks", cGeneral, &showTicks, { "No", "Yes" }, 0); objectParameters.addParamInt("Steps", cGeneral, &steps, 0); objectParameters.addParamBool("Circular drag", cGeneral, &circular, { "No", "Yes" }, 0); objectParameters.addParamBool("Read only", cGeneral, &readOnly, { "No", "Yes" }, 0); @@ -772,7 +772,8 @@ class KnobObject final : public ObjectBase { } break; } - default:break; + default: + break; } } @@ -784,18 +785,17 @@ class KnobObject final : public ObjectBase { bool const selected = object->isSelected() && !cnv->isGraph; auto const outlineColour = selected ? cnv->selectedOutlineCol : cnv->objectOutlineCol; auto const lineThickness = std::max(b.getWidth() * 0.03f, 1.0f); - + nvgDrawRoundedRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), bgCol, outlineColour, Corners::objectCornerRadius); - - if(!::getValue(showArc)) - { + + if (!::getValue(showArc)) { nvgBeginPath(nvg); nvgStrokeWidth(nvg, lineThickness); nvgStrokeColor(nvg, convertColour(::getValue(arcColour))); nvgCircle(nvg, b.getCentreX(), b.getCentreY(), b.getWidth() / 2.7f); nvgStroke(nvg); } - + knob.render(nvg); } else { auto circleBounds = getLocalBounds().toFloat().reduced(getWidth() * 0.13f); @@ -819,7 +819,7 @@ class KnobObject final : public ObjectBase { nvgStrokeColor(nvg, convertColour(cnv->editor->getLookAndFeel().findColour(objectOutlineColourId))); nvgStrokeWidth(nvg, 1.0f); nvgStroke(nvg); - + knob.render(nvg); } } @@ -920,18 +920,17 @@ class KnobObject final : public ObjectBase { } } } - + void mouseUp(MouseEvent const& e) override { - if(e.mods.isCommandDown()) - { + if (e.mods.isCommandDown()) { if (auto knob = ptr.get()) { auto message = e.mods.isShiftDown() ? SmallString("forget") : SmallString("learn"); pd->sendDirectMessage(knob.cast(), message, {}); } } } - + Colour getBackgroundColour() const { if (auto knob = ptr.get()) { @@ -942,7 +941,6 @@ class KnobObject final : public ObjectBase { return Colour(); } - Colour getForegroundColour() const { if (auto knob = ptr.get()) { @@ -1021,7 +1019,7 @@ class KnobObject final : public ObjectBase { knb->x_max = value; } } - + void mouseDoubleClick(MouseEvent const& e) override { knob.doubleClicked(); @@ -1069,7 +1067,7 @@ class KnobObject final : public ObjectBase { } else { return; } - + // TODO: this is probably a bit broken right now? // if exponential mode, map current position factor into exponential @@ -1161,8 +1159,7 @@ class KnobObject final : public ObjectBase { knb->x_ticks = ::getValue(showTicks); } updateRotaryParameters(); - } - else if (value.refersToSameSourceAs(steps)) { + } else if (value.refersToSameSourceAs(steps)) { steps = jmax(::getValue(steps), 0); if (auto knb = ptr.get()) { knb->x_steps = ::getValue(steps); @@ -1242,7 +1239,7 @@ class KnobObject final : public ObjectBase { } else if (value.refersToSameSourceAs(variableName)) { if (auto knb = ptr.get()) { auto* s = pd->generateSymbol(variableName.toString()); - + if (s == gensym("")) s = gensym("empty"); t_symbol* var = s == gensym("empty") ? gensym("") : canvas_realizedollar(knb->x_glist, s); diff --git a/Source/Objects/MessboxObject.h b/Source/Objects/MessboxObject.h index c032ac903..d8a76ccd8 100644 --- a/Source/Objects/MessboxObject.h +++ b/Source/Objects/MessboxObject.h @@ -216,8 +216,7 @@ class MessboxObject final : public ObjectBase for (auto& atom : atoms) { if (atom.isFloat()) { newText += String(atom.getFloat()) + " "; - } - else { + } else { auto symbol = atom.toString(); auto const* sym = symbol.toRawUTF8(); int pos; diff --git a/Source/Objects/NoteObject.h b/Source/Objects/NoteObject.h index 684590c32..3b43fe819 100644 --- a/Source/Objects/NoteObject.h +++ b/Source/Objects/NoteObject.h @@ -429,7 +429,7 @@ class NoteObject final : public ObjectBase { } auto currentFile = cnv->patch.getCurrentFile(); - if(currentFile.exists() && !currentFile.isRoot()) { + if (currentFile.exists() && !currentFile.isRoot()) { // Check if there is a patch font loaded via the patch loading if (auto const patchFont = Fonts::findFont(currentFile, typefaceName); patchFont.has_value()) return patchFont->withStyle(style).withHeight(fontHeight); diff --git a/Source/Objects/PopMenu.h b/Source/Objects/PopMenu.h index 67b6bf343..8606cd2a9 100644 --- a/Source/Objects/PopMenu.h +++ b/Source/Objects/PopMenu.h @@ -15,14 +15,14 @@ class PopMenu final : public ObjectBase { Value receiveSymbol = SynchronousValue(); Value parameterName = SynchronousValue(); Value variableName = SynchronousValue(); - + Value outline = SynchronousValue(); Value savestate = SynchronousValue(); Value loadbang = SynchronousValue(); - + NVGcolor fgCol; NVGcolor bgCol; - + StringArray items; int currentItem = 0; @@ -37,13 +37,13 @@ class PopMenu final : public ObjectBase { objectParameters.addParamReceiveSymbol(&receiveSymbol); objectParameters.addParamString("Parameter", cGeneral, ¶meterName); objectParameters.addParamString("Variable", cGeneral, &variableName); - objectParameters.addParamBool("Outline", cGeneral, &outline, {"No", "Yes"}); - objectParameters.addParamBool("Save state", cGeneral, &savestate, {"No", "Yes"}); - objectParameters.addParamBool("Loadbang", cGeneral, &loadbang, {"No", "Yes"}); - + objectParameters.addParamBool("Outline", cGeneral, &outline, { "No", "Yes" }); + objectParameters.addParamBool("Save state", cGeneral, &savestate, { "No", "Yes" }); + objectParameters.addParamBool("Loadbang", cGeneral, &loadbang, { "No", "Yes" }); + updateColours(); } - + static Colour convertTclColour(String const& colourStr) { if (tclColours.count(colourStr)) { @@ -51,41 +51,39 @@ class PopMenu final : public ObjectBase { } return Colour::fromString(colourStr.replace("#", "ff")); } - + void updateColours() { bgCol = convertColour(Colour::fromString(secondaryColour.toString())); fgCol = convertColour(Colour::fromString(primaryColour.toString())); repaint(); } - + void showMenu() { auto menu = PopupMenu(); - for(int i = 0; i < items.size(); i++) - { + for (int i = 0; i < items.size(); i++) { menu.addItem(i + 1, items[i], true, i == currentItem); } - if(items.size() == 0) - { - menu.addItem (1, "(No options)", false, false); + if (items.size() == 0) { + menu.addItem(1, "(No options)", false, false); } - menu.setLookAndFeel (&object->getLookAndFeel()); - menu.showMenuAsync(PopupMenu::Options().withTargetComponent(this), [_this = SafePointer(this)](int item){ - if(item && _this) { + menu.setLookAndFeel(&object->getLookAndFeel()); + menu.showMenuAsync(PopupMenu::Options().withTargetComponent(this), [_this = SafePointer(this)](int item) { + if (item && _this) { _this->currentItem = item - 1; _this->repaint(); } }); } - + void mouseDown(MouseEvent const& e) override { showMenu(); } - + String getSendSymbol() const { if (auto menu = ptr.get()) { @@ -115,7 +113,7 @@ class PopMenu final : public ObjectBase { return ""; } - + void setSendSymbol(String const& symbol) const { if (auto menu = ptr.get()) { @@ -129,24 +127,24 @@ class PopMenu final : public ObjectBase { pd->sendDirectMessage(menu.get(), "receive", { pd::Atom(pd->generateSymbol(symbol)) }); } } - + void update() override { items.clear(); if (auto menu = ptr.get()) { - for(int i = 0; i < menu->x_n_items; i++) // Loop for menu items + for (int i = 0; i < menu->x_n_items; i++) // Loop for menu items items.add(String::fromUTF8(menu->x_items[i]->s_name)); - + primaryColour = convertTclColour(String::fromUTF8(menu->x_fg->s_name)).toString(); secondaryColour = convertTclColour(String::fromUTF8(menu->x_bg->s_name)).toString(); sizeProperty = VarArray(menu->x_width, menu->x_height); savestate = menu->x_savestate; loadbang = menu->x_lb; outline = menu->x_outline; - + sendSymbol = getSendSymbol(); receiveSymbol = getReceiveSymbol(); - + auto varName = menu->x_var_raw ? String::fromUTF8(menu->x_var_raw->s_name) : String(""); if (varName == "empty") varName = ""; @@ -160,7 +158,7 @@ class PopMenu final : public ObjectBase { updateColours(); } - + Rectangle getPdBounds() override { if (auto gobj = ptr.get()) { @@ -191,27 +189,27 @@ class PopMenu final : public ObjectBase { setParameterExcludingListener(sizeProperty, VarArray(var(menu->x_width), var(menu->x_height))); } } - + void render(NVGcontext* nvg) override { auto b = getLocalBounds().toFloat(); nvgDrawRoundedRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), bgCol, object->isSelected() ? cnv->selectedOutlineCol : cnv->objectOutlineCol, Corners::objectCornerRadius); - + nvgFillColor(nvg, fgCol); nvgTextAlign(nvg, NVG_ALIGN_MIDDLE | NVG_ALIGN_LEFT); - if(items.size()) { + if (items.size()) { nvgText(nvg, 4, getHeight() / 2, items[currentItem].toRawUTF8(), nullptr); } - + auto triangleBounds = b.removeFromRight(getHeight() * 0.8f).reduced(getHeight() / 3.75f); - + nvgBeginPath(nvg); nvgMoveTo(nvg, triangleBounds.getCentreX() - 3, triangleBounds.getY() + 3); nvgLineTo(nvg, triangleBounds.getCentreX(), triangleBounds.getY()); nvgLineTo(nvg, triangleBounds.getCentreX() + 3, triangleBounds.getY() + 3); nvgStroke(nvg); - + nvgBeginPath(nvg); nvgMoveTo(nvg, triangleBounds.getCentreX() - 3, triangleBounds.getBottom() - 3); nvgLineTo(nvg, triangleBounds.getCentreX(), triangleBounds.getBottom()); @@ -258,7 +256,7 @@ class PopMenu final : public ObjectBase { } else if (value.refersToSameSourceAs(variableName)) { if (auto knb = ptr.get()) { auto* s = pd->generateSymbol(variableName.toString()); - + if (s == gensym("")) s = gensym("empty"); t_symbol* var = s == gensym("empty") ? gensym("") : canvas_realizedollar(knb->x_glist, s); @@ -268,13 +266,13 @@ class PopMenu final : public ObjectBase { knb->x_var = var; } } - } else if(value.refersToSameSourceAs(outline)) { + } else if (value.refersToSameSourceAs(outline)) { if (auto menu = ptr.get()) menu->x_outline = getValue(outline); - } else if(value.refersToSameSourceAs(savestate)) { + } else if (value.refersToSameSourceAs(savestate)) { if (auto menu = ptr.get()) menu->x_savestate = getValue(savestate); - } else if(value.refersToSameSourceAs(loadbang)) { + } else if (value.refersToSameSourceAs(loadbang)) { if (auto menu = ptr.get()) menu->x_lb = getValue(loadbang); } @@ -282,45 +280,46 @@ class PopMenu final : public ObjectBase { void receiveObjectMessage(hash32 const symbol, SmallArray const& atoms) override { - switch(symbol) { - case hash("float"): - case hash("set"): { - if(atoms.size() >= 1) { - currentItem = static_cast(atoms[0].getFloat()); - repaint(); - } - break; - } - case hash("clear"): - case hash("add"): { - update(); - break; + switch (symbol) { + case hash("float"): + case hash("set"): { + if (atoms.size() >= 1) { + currentItem = static_cast(atoms[0].getFloat()); + repaint(); } - case hash("send"): { - if (atoms.size() >= 1) - setParameterExcludingListener(sendSymbol, atoms[0].toString()); - object->updateIolets(); - break; - } - case hash("receive"): { - if (atoms.size() >= 1) - setParameterExcludingListener(receiveSymbol, atoms[0].toString()); - object->updateIolets(); - break; - } - case hash("fgcolor"): { - if(atoms.size() >= 1) { - primaryColour = convertTclColour(atoms[0].toString()).toString(); - } - break; + break; + } + case hash("clear"): + case hash("add"): { + update(); + break; + } + case hash("send"): { + if (atoms.size() >= 1) + setParameterExcludingListener(sendSymbol, atoms[0].toString()); + object->updateIolets(); + break; + } + case hash("receive"): { + if (atoms.size() >= 1) + setParameterExcludingListener(receiveSymbol, atoms[0].toString()); + object->updateIolets(); + break; + } + case hash("fgcolor"): { + if (atoms.size() >= 1) { + primaryColour = convertTclColour(atoms[0].toString()).toString(); } - case hash("bgcolor"): { - if(atoms.size() >= 1) { - secondaryColour = convertTclColour(atoms[0].toString()).toString(); - } - break; + break; + } + case hash("bgcolor"): { + if (atoms.size() >= 1) { + secondaryColour = convertTclColour(atoms[0].toString()).toString(); } - default: break; + break; + } + default: + break; } } }; diff --git a/Source/Pd/Instance.cpp b/Source/Pd/Instance.cpp index db44961e2..1be7b7690 100644 --- a/Source/Pd/Instance.cpp +++ b/Source/Pd/Instance.cpp @@ -220,7 +220,7 @@ void Instance::initialisePd(String& pdlua_version) auto* pd = static_cast(inst); t_canvas* glist = reinterpret_cast(argv->a_w.w_gpointer); - + if (auto const vis = atom_getfloat(argv + 1)) { pd::Patch::Ptr subpatch = new pd::Patch(pd::WeakReference(glist, pd), pd, false); if (canvas_isabstraction(glist)) { @@ -229,10 +229,10 @@ void Instance::initialisePd(String& pdlua_version) } MessageManager::callAsync([pd, subpatch] { - if(pd->patches.contains(subpatch, [](auto const& ptr1, auto const& ptr2){ return *ptr1 == *ptr2; })) { + if (pd->patches.contains(subpatch, [](auto const& ptr1, auto const& ptr2) { return *ptr1 == *ptr2; })) { return; } - + for (auto* editor : pd->getEditors()) { if (!editor->isActiveWindow()) continue; diff --git a/Source/Pd/Patch.cpp b/Source/Pd/Patch.cpp index d3563c5ea..e17193630 100644 --- a/Source/Pd/Patch.cpp +++ b/Source/Pd/Patch.cpp @@ -625,10 +625,9 @@ String Patch::getTitle() const void Patch::setTitle(String const& newTitle) { - if(newTitle.isEmpty()) { + if (newTitle.isEmpty()) { title = "Untitled Patcher"; - } - else { + } else { title = newTitle; } diff --git a/Source/Pd/Setup.cpp b/Source/Pd/Setup.cpp index 728fb8732..b8ef7a6c9 100644 --- a/Source/Pd/Setup.cpp +++ b/Source/Pd/Setup.cpp @@ -1276,7 +1276,6 @@ void setup_mpe0x2ein(); void velvet_tilde_setup(); void popmenu_setup(); - #ifdef ENABLE_FFMPEG void setup_play0x2efile_tilde(); void sfload_setup(); diff --git a/Source/PluginMode.h b/Source/PluginMode.h index 2fd2b6e61..4285a1407 100644 --- a/Source/PluginMode.h +++ b/Source/PluginMode.h @@ -445,7 +445,7 @@ class PluginMode final : public Component float const height = static_cast(cnv->patchHeight.getValue()) + 1.0f; float pluginModeScale = 1.0f; int pluginPreviousScale = 100; - + String lastTheme; std::unique_ptr pluginModeLnf; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index dfb0889c1..5398a859d 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -630,7 +630,7 @@ void PluginProcessor::processBlock(AudioBuffer& buffer, MidiBuffer& midiB auto const totalNumInputChannels = getTotalNumInputChannels(); auto const totalNumOutputChannels = getTotalNumOutputChannels(); auto midiInputHistory = midiBuffer; - + setThis(); sendPlayhead(); @@ -647,7 +647,7 @@ void PluginProcessor::processBlock(AudioBuffer& buffer, MidiBuffer& midiB midiBuffer.clear(); processConstant(blockOut); } - + if (oversampling > 0) { oversampler->processSamplesDown(targetBlock); } @@ -682,7 +682,7 @@ void PluginProcessor::processBlock(AudioBuffer& buffer, MidiBuffer& midiB // apply smoothing to the main volume control smoothedGain.setTargetValue(mappedTargetGain); smoothedGain.applyGain(buffer, buffer.getNumSamples()); - + midiDeviceManager.sendAndCollectMidiOutput(midiBuffer); auto const internalSynthPort = midiDeviceManager.getInternalSynthPort(); @@ -701,7 +701,7 @@ void PluginProcessor::processBlock(AudioBuffer& buffer, MidiBuffer& midiB midiInputHistory.addEvents(midiDeviceManager.getInputHistory(), 0, buffer.getNumSamples(), 0); statusbarSource->process(midiInputHistory, midiDeviceManager.getOutputHistory(), totalNumOutputChannels); midiDeviceManager.clearMidiOutputBuffers(blockOut.getNumSamples()); - + statusbarSource->setCPUUsage(cpuLoadMeasurer.getLoadAsPercentage()); statusbarSource->peakBuffer.write(buffer); @@ -777,7 +777,7 @@ void PluginProcessor::processVariable(dsp::AudioBlock buffer, MidiBuffer& auto const numChannels = buffer.getNumChannels(); inputFifo->writeAudioAndMidi(buffer, midiBuffer); - + audioAdvancement = 0; // Always has to be 0 if we use the AudioMidiFifo! while (outputFifo->getNumSamplesAvailable() < buffer.getNumSamples()) { @@ -1498,7 +1498,7 @@ void PluginProcessor::receiveSysMessage(SmallString const& selector, SmallArray< auto themeFile = patches[0]->getPatchFile().getParentDirectory().getChildFile(pluginModeThemeOrPath); if (themeFile.existsAsFile()) { auto themeTree = ValueTree::fromXml(themeFile.loadFileAsString()); - if(themeTree.isValid()) { + if (themeTree.isValid()) { pluginModeTheme = themeTree; } } diff --git a/Source/Sidebar/Sidebar.cpp b/Source/Sidebar/Sidebar.cpp index 9dc82b330..91c28e5ae 100644 --- a/Source/Sidebar/Sidebar.cpp +++ b/Source/Sidebar/Sidebar.cpp @@ -116,7 +116,8 @@ void Sidebar::paint(Graphics& g) if (inspectorButton.isInspectorPinned()) { auto inpectorPos = Point(0, dividerFactor * getHeight()); - if (inspector->isEmpty()) inpectorPos.setY(getHeight() - 30); + if (inspector->isEmpty()) + inpectorPos.setY(getHeight() - 30); g.setColour(findColour(PlugDataColour::sidebarActiveBackgroundColourId)); g.fillRect(inpectorPos.x, inpectorPos.y, getWidth() - 30, 30); auto inspectorTitle = inspector->getTitle(); diff --git a/Source/Standalone/PlugDataApp.cpp b/Source/Standalone/PlugDataApp.cpp index d318f539e..43c244e7b 100644 --- a/Source/Standalone/PlugDataApp.cpp +++ b/Source/Standalone/PlugDataApp.cpp @@ -105,7 +105,7 @@ class PlugDataApp final : public JUCEApplication { if (macOSTrash.isDirectory()) { macOSTrash.deleteRecursively(); } - + auto extractedLocation = patchesDir.getChildFile(zip.getEntry(0)->filename); auto const metaFile = extractedLocation.getChildFile("meta.json"); if (!metaFile.existsAsFile()) { @@ -114,14 +114,13 @@ class PlugDataApp final : public JUCEApplication { info.setInstallTime(Time::currentTimeMillis()); auto json = info.json; metaFile.replaceWithText(info.json); - } - else { + } else { auto info = PatchInfo(JSON::fromString(metaFile.loadFileAsString())); info.setInstallTime(Time::currentTimeMillis()); auto json = info.json; metaFile.replaceWithText(info.json); } - + Dialogs::showMultiChoiceDialog(&editor->openedDialog, editor, "Successfully installed " + file.getFileNameWithoutExtension(), [](int) { }, { "Dismiss" }, Icons::Checkmark); } else { Dialogs::showMultiChoiceDialog(&editor->openedDialog, editor, "Failed to install " + file.getFileNameWithoutExtension(), [](int) { }, { "Dismiss" }); diff --git a/Source/TabComponent.cpp b/Source/TabComponent.cpp index 69303bae1..7d624021e 100644 --- a/Source/TabComponent.cpp +++ b/Source/TabComponent.cpp @@ -92,7 +92,7 @@ Canvas* TabComponent::openPatch(pd::Patch::Ptr existingPatch, bool const warnIfA } } - pd->patches.add_unique(existingPatch, [](auto const& ptr1, auto const& ptr2){ + pd->patches.add_unique(existingPatch, [](auto const& ptr1, auto const& ptr2) { return *ptr1 == *ptr2; }); diff --git a/Source/Utility/CachedTextRender.h b/Source/Utility/CachedTextRender.h index 11ea20c2d..ec917fcc1 100644 --- a/Source/Utility/CachedTextRender.h +++ b/Source/Utility/CachedTextRender.h @@ -28,7 +28,7 @@ class CachedTextRender { auto const flagColour = colour.interpolatedWith(LookAndFeel::getDefaultLookAndFeel().findColour(PlugDataColour::signalColourId), 0.7f); auto const mathColour = colour.interpolatedWith(Colours::purple, 0.5f); - + bool firstToken = true; bool hadFlag = false; bool mathExpression = false; @@ -37,12 +37,11 @@ class CachedTextRender { token += " "; if (firstToken) { attributedText.append(token, font, nameColour); - if(token == "expr " || token == "expr~ " || token == "fexpr~ " || token == "op " || token == "op~ ") - { + if (token == "expr " || token == "expr~ " || token == "fexpr~ " || token == "op " || token == "op~ ") { mathExpression = true; } firstToken = false; - } else if(mathExpression) { + } else if (mathExpression) { attributedText.append(token, font, mathColour); } else if (token.startsWith("-") && !token.containsOnly("e.-0123456789 ")) { attributedText.append(token, font, flagColour); diff --git a/Source/Utility/Containers.h b/Source/Utility/Containers.h index 37643970a..f4db94c4c 100644 --- a/Source/Utility/Containers.h +++ b/Source/Utility/Containers.h @@ -703,14 +703,15 @@ class SmallArrayImpl : public SmallArrayTemplateBase { { return std::find(this->begin(), this->end(), to_find) != this->end(); } - - template - [[nodiscard]] bool contains(T const& to_find, Predicate pred) { - for(auto const& elt : *this) - { - if(pred(elt, to_find)) return true; + + template + [[nodiscard]] bool contains(T const& to_find, Predicate pred) + { + for (auto const& elt : *this) { + if (pred(elt, to_find)) + return true; } - + return false; } @@ -773,17 +774,19 @@ class SmallArrayImpl : public SmallArrayTemplateBase { return false; // Element already exists } - template - bool add_unique(T const& to_add, Predicate pred) { + template + bool add_unique(T const& to_add, Predicate pred) + { if (std::find_if(this->begin(), this->end(), [&](T const& element) { return pred(element, to_add); - }) == this->end()) { + }) + == this->end()) { this->push_back(to_add); return true; } return false; // Element already exists } - + void add(T const& to_add) { this->push_back(to_add); @@ -1898,7 +1901,7 @@ class HeapArray { { return std::find(data_.begin(), data_.end(), to_find) != end(); } - + template [[nodiscard]] int index_of(U const& to_find) const { diff --git a/Source/Utility/MidiDeviceManager.h b/Source/Utility/MidiDeviceManager.h index 0cef927b6..f31fc8b82 100644 --- a/Source/Utility/MidiDeviceManager.h +++ b/Source/Utility/MidiDeviceManager.h @@ -281,7 +281,8 @@ class MidiDeviceManager final : public ChangeListener auto& [midiMessage, samplePosition] = message; outputPort.buffer.addEvent(midiMessage, samplePosition); midiOutputHistory.addEvent(midiMessage, samplePosition); - if(i == 1) dawOutput.addEvent(midiMessage, samplePosition); + if (i == 1) + dawOutput.addEvent(midiMessage, samplePosition); } if (!outputPort.buffer.isEmpty()) { @@ -300,16 +301,16 @@ class MidiDeviceManager final : public ChangeListener outputPort.buffer.clear(0, numSamples); } } - + midiOutputHistory.clear(); midiInputHistory.clear(); } - + MidiBuffer getInputHistory() { return midiInputHistory; } - + MidiBuffer getOutputHistory() { return midiOutputHistory; @@ -447,7 +448,7 @@ class MidiDeviceManager final : public ChangeListener MidiBuffer midiBufferOut; MidiBuffer midiInputHistory, midiOutputHistory; - + MidiInput* toPlugdata = nullptr; MidiOutput* fromPlugdata = nullptr; diff --git a/Source/Utility/PatchInfo.h b/Source/Utility/PatchInfo.h index 5f25a39a3..0eba4c3b6 100644 --- a/Source/Utility/PatchInfo.h +++ b/Source/Utility/PatchInfo.h @@ -21,7 +21,7 @@ class PatchInfo { int64 installTime; PatchInfo() = default; - + PatchInfo(var const& jsonData) { title = jsonData["Title"]; @@ -32,21 +32,18 @@ class PatchInfo { price = jsonData["Price"]; thumbnailUrl = jsonData["StoreThumb"]; version = jsonData["Version"]; - if(jsonData.hasProperty("InstallTime")) - { + if (jsonData.hasProperty("InstallTime")) { installTime = static_cast(jsonData["InstallTime"]); - } - else { + } else { installTime = 0; } json = JSON::toString(jsonData, false); } - + void setInstallTime(int64 millisSinceEpoch) { auto jsonData = JSON::fromString(json); - if (auto* obj = jsonData.getDynamicObject()) - { + if (auto* obj = jsonData.getDynamicObject()) { obj->setProperty("InstallTime", millisSinceEpoch); json = JSON::toString(jsonData, false); } diff --git a/Source/Utility/PluginParameter.h b/Source/Utility/PluginParameter.h index bb07771a9..2dcd1ae69 100644 --- a/Source/Utility/PluginParameter.h +++ b/Source/Utility/PluginParameter.h @@ -292,12 +292,12 @@ class PlugDataParameter final : public RangedAudioParameter { { valueChanged = false; } - + void setChanged() { valueChanged = true; } - + float getGestureState() const { return gestureState;