Skip to content

Commit

Permalink
Fix more TODOs, reimplement patch validity test when pasting into pal…
Browse files Browse the repository at this point in the history
…ettes
  • Loading branch information
timothyschoen committed Feb 21, 2025
1 parent d1dec3c commit 1161128
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
1 change: 0 additions & 1 deletion Source/Components/WelcomePanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ class WelcomePanel final : public Component
}
tileMenu.addSeparator();

// TODO: we may want to be clearer about this - that it doesn't delete the file on disk
// Put this at he bottom, so it's not accidentally clicked on
tileMenu.addItem("Remove from recently opened", onRemove);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/NoteObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class NoteObject final : public ObjectBase {
needsRepaint = true;

noteEditor.setInterceptsMouseClicks(!isLocked, !isLocked);
object->updateIolets(); // TODO: why?
object->updateIolets();
}

void resized() override
Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/ScalarObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DrawableTemplate : public pd::MessageListener
bool mouseWasDown = false;

DrawableTemplate(t_scalar* object, t_word* scalarData, t_template* scalarTemplate, t_template* parentTemplate, Canvas* cnv, t_float const x, t_float const y)
: NVGComponent(reinterpret_cast<Component*>(this)) // TODO: clean this up
: NVGComponent(cnv)
, pd(cnv->pd)
, canvas(cnv)
, baseX(x)
Expand Down
7 changes: 1 addition & 6 deletions Source/Sidebar/Palettes.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,8 @@ class PaletteDraggableList final : public Component

pasteButton.onClick = [this] {
auto const clipboardText = SystemClipboard::getTextFromClipboard();
// TODO: reimplement patch validity check
if (!OfflineObjectRenderer::checkIfPatchIsValid(clipboardText)) {
/*
juce::AlertWindow::showMessageBoxAsync(juce::AlertWindow::AlertIconType::NoIcon,
"Clipboard contents not valid PD objects",
"Pasted text: " + clipboardText.substring(0, 200).quoted());
*/
Dialogs::showMultiChoiceDialog(&editor->openedDialog, editor, "Clipboard contents not valid PD patch", [](int){}, {"Dismiss"});
return;
}
ValueTree itemTree("Item");
Expand Down
12 changes: 11 additions & 1 deletion Source/Utility/OfflineObjectRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,17 @@ ImageWithOffset OfflineObjectRenderer::patchToTempImage(String const& patch, flo

bool OfflineObjectRenderer::checkIfPatchIsValid(String const& patch)
{
// TODO: fix this!
// Split the patch into lines
auto lines = StringArray::fromLines(patch);

for (const auto& line : lines)
{
if (line.startsWith("#X") || line.startsWith("#N") || line.startsWith("#A") || !line.containsNonWhitespaceChars())
continue;

return false;
}

return true;
}

Expand Down

0 comments on commit 1161128

Please sign in to comment.