Skip to content

Commit 1014fdb

Browse files
committed
More message listener improvements, fix 32-bit support, increase message debugging for lists up to 15 elements
1 parent 1ea6232 commit 1014fdb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+186
-221
lines changed

Libraries/pure-data

Resources/Scripts/package_resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def generate_binary_data(output_dir, file_list):
182182
for i in range(0, len(data['binary']), chunk_size):
183183
chunk = data['binary'][i:i + chunk_size]
184184
# Format and write each chunk without a trailing comma
185-
hex_values = ', '.join(str(byte) for byte in chunk) + ', '
185+
hex_values = ','.join(str(byte) for byte in chunk) + ','
186186
cpp_file.write(f" {hex_values}\n")
187187

188188
cpp_file.write("};\n\n")

Source/Canvas.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,7 +2478,7 @@ bool Canvas::panningModifierDown()
24782478
return isPanDragKeysActive || ModifierKeys::getCurrentModifiers().isMiddleButtonDown();
24792479
}
24802480

2481-
void Canvas::receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms)
2481+
void Canvas::receiveMessage(t_symbol* symbol, SmallArray<pd::Atom> const& atoms)
24822482
{
24832483
switch (hash(symbol->s_name)) {
24842484
case hash("sync"):
@@ -2510,7 +2510,7 @@ void Canvas::receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 7> const& ato
25102510
break;
25112511
}
25122512
case hash("editmode"): {
2513-
if (numAtoms >= 1) {
2513+
if (atoms.size() >= 1) {
25142514
int flag = atoms[0].getFloat();
25152515
if (flag % 2 == 0) {
25162516
locked = true;
@@ -2522,7 +2522,7 @@ void Canvas::receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 7> const& ato
25222522
break;
25232523
}
25242524
case hash("setbounds"): {
2525-
if (numAtoms >= 4) {
2525+
if (atoms.size() >= 4) {
25262526
auto width = atoms[2].getFloat() - atoms[0].getFloat();
25272527
auto height = atoms[3].getFloat() - atoms[1].getFloat();
25282528
setValueExcludingListener(patchWidth, width, this);

Source/Canvas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class Canvas : public Component
177177

178178
ObjectParameters& getInspectorParameters();
179179

180-
void receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override;
180+
void receiveMessage(t_symbol* symbol, SmallArray<pd::Atom> const& atoms) override;
181181

182182
void activateCanvasSearchHighlight(Object* obj);
183183
void removeCanvasSearchHighlight();

Source/Connection.cpp

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -369,28 +369,14 @@ void Connection::popPathState()
369369
updatePath();
370370
}
371371

372-
t_pd* Connection::getTargetObject(t_outconnect* oc)
373-
{
374-
struct _outconnect
375-
{
376-
struct _outconnect *oc_next;
377-
t_pd *oc_to;
378-
t_symbol* oc_path_data;
379-
t_signal* oc_signal;
380-
void* oc_signal_reference;
381-
};
382-
383-
return reinterpret_cast<_outconnect*>(oc)->oc_to;
384-
}
385-
386372
void Connection::setPointer(t_outconnect* newPtr)
387373
{
388374
auto originalPointer = ptr.getRawUnchecked<t_outconnect>();
389375
if (originalPointer != newPtr) {
390376
ptr = pd::WeakReference(newPtr, cnv->pd);
391377

392378
cnv->pd->unregisterMessageListener(this);
393-
cnv->pd->registerMessageListener(getTargetObject(newPtr), this);
379+
cnv->pd->registerMessageListener(newPtr, this);
394380
}
395381
}
396382

@@ -571,36 +557,37 @@ void Connection::animate()
571557

572558
StringArray Connection::getMessageFormated()
573559
{
574-
auto args = lastValue;
560+
auto const& args = lastValue;
561+
auto numArgs = args.size();
575562
auto name = lastSelector ? String::fromUTF8(lastSelector->s_name) : "";
576563

577564
StringArray formatedMessage;
578565

579-
if (name == "float" && lastNumArgs > 0) {
566+
if (name == "float" && numArgs > 0) {
580567
formatedMessage.add("float:");
581568
formatedMessage.add(args[0].toString());
582-
} else if (name == "symbol" && lastNumArgs > 0) {
569+
} else if (name == "symbol" && numArgs > 0) {
583570
formatedMessage.add("symbol:");
584571
formatedMessage.add(args[0].toString());
585572
} else if (name == "list") {
586-
if (lastNumArgs >= 7) {
587-
formatedMessage.add("list (6+):");
573+
if (numArgs >= 15) {
574+
formatedMessage.add("list (14+):");
588575
} else {
589-
formatedMessage.add("list (" + String(lastNumArgs) + "):");
576+
formatedMessage.add("list (" + String(numArgs) + "):");
590577
}
591-
for (int arg = 0; arg < lastNumArgs; arg++) {
578+
for (int arg = 0; arg < numArgs; arg++) {
592579
if (args[arg].isFloat()) {
593580
formatedMessage.add(String(args[arg].getFloat()));
594581
} else if (args[arg].isSymbol()) {
595582
formatedMessage.add(args[arg].toString());
596583
}
597584
}
598-
if (lastNumArgs >= 7) {
585+
if (numArgs >= 15) {
599586
formatedMessage.add("...");
600587
}
601588
} else {
602589
formatedMessage.add(name);
603-
for (int arg = 0; arg < lastNumArgs; arg++) {
590+
for (int arg = 0; arg < numArgs; arg++) {
604591
if (args[arg].isFloat()) {
605592
formatedMessage.add(String(args[arg].getFloat()));
606593
} else if (args[arg].isSymbol()) {
@@ -1380,7 +1367,7 @@ void ConnectionPathUpdater::timerCallback()
13801367
canvas->patch.endUndoSequence("SetConnectionPaths");
13811368
}
13821369

1383-
void Connection::receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms)
1370+
void Connection::receiveMessage(t_symbol* symbol, SmallArray<pd::Atom> const& atoms)
13841371
{
13851372
if (cnv->shouldShowConnectionActivity()) {
13861373
startTimer(StopAnimation, 1000 / 8.0f);
@@ -1392,6 +1379,5 @@ void Connection::receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 7> const&
13921379

13931380
outobj->triggerOverlayActiveState();
13941381
lastValue = atoms;
1395-
lastNumArgs = numAtoms;
13961382
lastSelector = symbol;
13971383
}

Source/Connection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Connection : public DrawablePath
9797

9898
bool straightLineIntersectsObject(Line<float> toCheck, SmallArray<Object*>& objects);
9999

100-
void receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override;
100+
void receiveMessage(t_symbol* symbol, SmallArray<pd::Atom> const& atoms) override;
101101

102102
bool isSelected() const;
103103

@@ -160,7 +160,7 @@ class Connection : public DrawablePath
160160
NVGCachedPath cachedPath;
161161
pd::WeakReference ptr;
162162

163-
StackArray<pd::Atom, 7> lastValue;
163+
SmallArray<pd::Atom> lastValue;
164164
int lastNumArgs = 0;
165165
t_symbol* lastSelector = nullptr;
166166

Source/Dialogs/AboutPanel.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,27 @@ class AboutPanel : public Component {
152152
class LicensePanel : public Component {
153153
TextEditor license;
154154

155-
String licenseText = "Copyright Timothy Schoen\n\n"
155+
static inline const String licenseText = "Copyright Timothy Schoen\n\n"
156156
"This app is licensed under the GNU General Public License version 3 (GPL-3.0). You are free to use, modify, and distribute the software, provided that any derivative works also carry the same license and the source code remains accessible.\n"
157157
"This application comes with absolutely no warranty.";
158158

159159
public:
160160
LicensePanel()
161161
{
162-
license.setColour(TextEditor::outlineColourId, Colours::transparentBlack);
163-
license.setColour(TextEditor::backgroundColourId, Colours::transparentBlack);
164-
license.setReadOnly(true);
165-
license.setMultiLine(true);
166-
license.setText(licenseText);
167-
license.setFont(Font(15));
168-
license.setLineSpacing(1.1f);
169-
addAndMakeVisible(license);
162+
}
163+
164+
void visibilityChanged() override
165+
{
166+
if(!license.isVisible()) {
167+
license.setColour(TextEditor::outlineColourId, Colours::transparentBlack);
168+
license.setColour(TextEditor::backgroundColourId, Colours::transparentBlack);
169+
license.setReadOnly(true);
170+
license.setMultiLine(true);
171+
license.setText(licenseText);
172+
license.setFont(Font(15));
173+
license.setLineSpacing(1.1f);
174+
addAndMakeVisible(license);
175+
}
170176
}
171177

172178
void resized() override

Source/Objects/ArrayObject.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,11 @@ class GraphicalArray : public Component
222222
}
223223
}
224224

225-
void receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override
225+
void receiveMessage(t_symbol* symbol, SmallArray<pd::Atom> const& atoms) override
226226
{
227227
switch (hash(symbol->s_name)) {
228228
case hash("edit"): {
229-
if (numAtoms <= 0)
229+
if (atoms.size() <= 0)
230230
break;
231231
MessageManager::callAsync([_this = SafePointer(this), shouldBeEditable = static_cast<bool>(atoms[0].getFloat())]() {
232232
if (_this) {
@@ -237,7 +237,7 @@ class GraphicalArray : public Component
237237
break;
238238
}
239239
case hash("rename"): {
240-
if (numAtoms <= 0)
240+
if (atoms.size() <= 0)
241241
break;
242242
MessageManager::callAsync([_this = SafePointer(this), newName = atoms[0].toString()]() {
243243
if (_this) {
@@ -1316,7 +1316,7 @@ class ArrayObject final : public ObjectBase {
13161316
});
13171317
}
13181318

1319-
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override
1319+
void receiveObjectMessage(hash32 symbol, SmallArray<pd::Atom> const& atoms) override
13201320
{
13211321
switch (symbol) {
13221322
case hash("redraw"): {
@@ -1409,7 +1409,7 @@ class ArrayDefineObject final : public TextBase {
14091409
}
14101410
}
14111411

1412-
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override
1412+
void receiveObjectMessage(hash32 symbol, SmallArray<pd::Atom> const& atoms) override
14131413
{
14141414
}
14151415
};

Source/Objects/BangObject.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class BangObject final : public ObjectBase
206206
}
207207
}
208208

209-
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override
209+
void receiveObjectMessage(hash32 symbol, SmallArray<pd::Atom> const& atoms) override
210210
{
211211
switch (symbol) {
212212
case hash("float"):
@@ -215,9 +215,9 @@ class BangObject final : public ObjectBase
215215
trigger();
216216
break;
217217
case hash("flashtime"): {
218-
if (numAtoms > 0)
218+
if (atoms.size() > 0)
219219
setParameterExcludingListener(bangInterrupt, atoms[0].getFloat());
220-
if (numAtoms > 1)
220+
if (atoms.size() > 1)
221221
setParameterExcludingListener(bangHold, atoms[1].getFloat());
222222
break;
223223
}
@@ -226,7 +226,7 @@ class BangObject final : public ObjectBase
226226
case hash("loadbang"):
227227
break;
228228
default: {
229-
bool wasIemMessage = iemHelper.receiveObjectMessage(symbol, atoms, numAtoms);
229+
bool wasIemMessage = iemHelper.receiveObjectMessage(symbol, atoms);
230230
if (!wasIemMessage) {
231231
trigger();
232232
}

Source/Objects/BicoeffObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ class BicoeffObject final : public ObjectBase {
624624
graph.saveProperties();
625625
}
626626

627-
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override
627+
void receiveObjectMessage(hash32 symbol, SmallArray<pd::Atom> const& atoms) override
628628
{
629629
switch (symbol) {
630630
case hash("allpass"): {

0 commit comments

Comments
 (0)