@@ -92,9 +92,9 @@ class ObjectsResizer final : public Component
9292 addAndMakeVisible (border);
9393
9494 setBounds (selectedObjectBounds.expanded (tabMargin));
95- };
95+ }
9696
97- ~ObjectsResizer ()
97+ ~ObjectsResizer () override
9898 {
9999 for (auto * obj : cnv->getSelectionOfType <Object>()) {
100100 obj->hideHandles (false );
@@ -567,6 +567,7 @@ void Canvas::updateFramebuffers(NVGcontext* nvg)
567567 if (zoom < 0 .5f )
568568 decim = 12 ;
569569 break ;
570+ default : break ;
570571 }
571572
572573 auto const majorDotColour = canvasMarkingsColJuce.withAlpha (std::min (zoom * 0 .8f , 1 .0f ));
@@ -892,6 +893,7 @@ void Canvas::settingsChanged(String const& name, var const& value)
892893 updateOverlays ();
893894 break ;
894895 }
896+ default : break ;
895897 }
896898}
897899
@@ -1111,7 +1113,7 @@ void Canvas::synchroniseSplitCanvas()
11111113void Canvas::performSynchronise ()
11121114{
11131115 static bool alreadyFlushed = false ;
1114- bool needsFlush = !alreadyFlushed;
1116+ bool const needsFlush = !alreadyFlushed;
11151117 ScopedValueSetter<bool > flushGuard (alreadyFlushed, true );
11161118 // By flushing twice, we can make sure that any message sent before this point will be dequeued
11171119 if (needsFlush && !isGraph)
@@ -1126,10 +1128,8 @@ void Canvas::performSynchronise()
11261128
11271129 // Remove deleted objects
11281130 for (int n = objects.size () - 1 ; n >= 0 ; n--) {
1129- auto * object = objects[n];
1130-
11311131 // If the object is showing it's initial editor, meaning no object was assigned yet, allow it to exist without pointing to an object
1132- if (!object->getPointer () && !object->isInitialEditorShown ()) {
1132+ if (auto * object = objects[n]; !object->getPointer () && !object->isInitialEditorShown ()) {
11331133 setSelected (object, false , false );
11341134 objects.remove_at (n);
11351135 }
@@ -1173,7 +1173,7 @@ void Canvas::performSynchronise()
11731173
11741174 // Make sure objects have the same order
11751175 std::ranges::sort (objects,
1176- [&pdObjects](Object* first, Object* second) mutable {
1176+ [&pdObjects](Object const * first, Object const * second) mutable {
11771177 return pdObjects.index_of (first->getPointer ()) < pdObjects.index_of (second->getPointer ());
11781178 });
11791179
@@ -1221,11 +1221,9 @@ void Canvas::performSynchronise()
12211221 if (it == connections.end ()) {
12221222 connections.add (this , inlet, outlet, ptr);
12231223 } else {
1224- auto & c = **it;
1225-
12261224 // This is necessary to make resorting a subpatchers iolets work
12271225 // And it can't hurt to check if the connection is valid anyway
1228- if (c.inlet != inlet || c.outlet != outlet) {
1226+ if (auto & c = **it; c.inlet != inlet || c.outlet != outlet) {
12291227 int const idx = connections.index_of (*it);
12301228 connections.remove_one (*it);
12311229 connections.insert (idx, this , inlet, outlet, ptr);
@@ -1306,8 +1304,7 @@ void Canvas::shiftKeyChanged(bool const isHeld)
13061304 return ;
13071305
13081306 t_outconnect* connection = nullptr ;
1309- auto selectedConnections = getSelectionOfType<Connection>();
1310- if (selectedConnections.size () == 1 ) {
1307+ if (auto selectedConnections = getSelectionOfType<Connection>(); selectedConnections.size () == 1 ) {
13111308 connection = selectedConnections[0 ]->getPointer ();
13121309 }
13131310
@@ -1428,10 +1425,8 @@ void Canvas::mouseDrag(MouseEvent const& e)
14281425 }
14291426 }
14301427
1431- bool const objectIsBeingEdited = ObjectBase::isBeingEdited ();
1432-
14331428 // Ignore on graphs or when locked
1434- if ((isGraph || locked == var (true ) || commandLocked == var (true )) && !objectIsBeingEdited ) {
1429+ if ((isGraph || locked == var (true ) || commandLocked == var (true )) && !ObjectBase::isBeingEdited () ) {
14351430 bool hasToggled = false ;
14361431
14371432 // Behaviour for dragging over toggles, bang and radiogroup to toggle them
@@ -1733,7 +1728,7 @@ void Canvas::focusLost(FocusChangeType cause)
17331728 });
17341729}
17351730
1736- void Canvas::dragAndDropPaste (String const & patchString, Point<int > mousePos, int const patchWidth, int const patchHeight, String const & name)
1731+ void Canvas::dragAndDropPaste (String const & patchString, Point<int > const mousePos, int const patchWidth, int const patchHeight, String const & name)
17371732{
17381733 locked = false ;
17391734 presentationMode = false ;
@@ -2017,9 +2012,7 @@ void Canvas::cycleSelection()
20172012 return ;
20182013 }
20192014 // Get the selected objects
2020- auto selectedObjects = getSelectionOfType<Object>();
2021-
2022- if (selectedObjects.size () == 1 ) {
2015+ if (auto selectedObjects = getSelectionOfType<Object>(); selectedObjects.size () == 1 ) {
20232016 // Find the index of the currently selected object
20242017 auto const currentIdx = objects.index_of (selectedObjects[0 ]);
20252018 setSelected (selectedObjects[0 ], false );
@@ -2032,9 +2025,7 @@ void Canvas::cycleSelection()
20322025 }
20332026
20342027 // Get the selected connections if no objects are selected
2035- auto selectedConnections = getSelectionOfType<Connection>();
2036-
2037- if (selectedConnections.size () == 1 ) {
2028+ if (auto selectedConnections = getSelectionOfType<Connection>(); selectedConnections.size () == 1 ) {
20382029 // Find the index of the currently selected connection
20392030 auto const currentIdx = connections.index_of (selectedConnections[0 ]);
20402031 setSelected (selectedConnections[0 ], false );
@@ -2237,8 +2228,7 @@ void Canvas::connectSelection()
22372228 }
22382229
22392230 t_outconnect* connection = nullptr ;
2240- auto selectedConnections = getSelectionOfType<Connection>();
2241- if (selectedConnections.size () == 1 ) {
2231+ if (auto selectedConnections = getSelectionOfType<Connection>(); selectedConnections.size () == 1 ) {
22422232 connection = selectedConnections[0 ]->getPointer ();
22432233 }
22442234
@@ -2316,7 +2306,7 @@ void Canvas::alignObjects(Align const alignment)
23162306 // get the bounding box of all selected objects
23172307 auto const selectedBounds = getBoundingBox (selectedObjects);
23182308
2319- auto onMove = [this , selectedObjects](Point<int > position) {
2309+ auto onMove = [this , selectedObjects](Point<int > const position) {
23202310 // Calculate the bounding box of all selected objects
23212311 Rectangle<int > totalSize;
23222312
@@ -2389,7 +2379,7 @@ void Canvas::alignObjects(Align const alignment)
23892379 case Align::HDistribute: {
23902380 sortByXPos (selectedObjects);
23912381
2392- auto onResize = [this , selectedObjects](Rectangle<int > newBounds) {
2382+ auto onResize = [this , selectedObjects](Rectangle<int > const newBounds) {
23932383 int totalObjectsWidth = 0 ;
23942384 for (auto const * obj : selectedObjects) {
23952385 totalObjectsWidth += obj->getBounds ().getWidth () - Object::doubleMargin;
@@ -2419,7 +2409,7 @@ void Canvas::alignObjects(Align const alignment)
24192409 case Align::VDistribute: {
24202410 sortByYPos (selectedObjects);
24212411
2422- auto onResize = [this , selectedObjects](Rectangle<int > newBounds) {
2412+ auto onResize = [this , selectedObjects](Rectangle<int > const newBounds) {
24232413 int totalObjectsHeight = 0 ;
24242414 for (auto const * obj : selectedObjects) {
24252415 totalObjectsHeight += obj->getBounds ().getHeight () - Object::doubleMargin;
@@ -2516,7 +2506,7 @@ void Canvas::valueChanged(Value& v)
25162506 auto y2 = static_cast <float >(cnv->gl_screeny2 );
25172507
25182508 char buf[MAXPDSTRING];
2519- snprintf (buf, MAXPDSTRING - 1 , " .x%lx" , ( unsigned long ) cnv.get ());
2509+ snprintf (buf, MAXPDSTRING - 1 , " .x%lx" , reinterpret_cast < unsigned long >( cnv.get () ));
25202510 pd->sendMessage (buf, " setbounds" , { x1, y1, x2, y2 });
25212511 }
25222512 repaint ();
@@ -2529,7 +2519,7 @@ void Canvas::valueChanged(Value& v)
25292519 auto y2 = static_cast <float >(getValue<int >(patchHeight) + y1);
25302520
25312521 char buf[MAXPDSTRING];
2532- snprintf (buf, MAXPDSTRING - 1 , " .x%lx" , ( unsigned long ) cnv.get ());
2522+ snprintf (buf, MAXPDSTRING - 1 , " .x%lx" , reinterpret_cast < unsigned long >( cnv.get () ));
25332523 pd->sendMessage (buf, " setbounds" , { x1, y1, x2, y2 });
25342524 }
25352525 repaint ();
@@ -2676,7 +2666,7 @@ bool Canvas::setPanDragMode(bool const shouldPan)
26762666 return false ;
26772667}
26782668
2679- bool Canvas::isPointOutsidePluginArea (Point<int > point) const
2669+ bool Canvas::isPointOutsidePluginArea (Point<int > const point) const
26802670{
26812671 auto const borderWidth = getValue<float >(patchWidth);
26822672 auto const borderHeight = getValue<float >(patchHeight);
@@ -2786,8 +2776,7 @@ void Canvas::receiveMessage(t_symbol* symbol, SmallArray<pd::Atom> const& atoms)
27862776 return ;
27872777
27882778 if (atoms.size () >= 1 ) {
2789- int const flag = atoms[0 ].getFloat ();
2790- if (flag % 2 == 0 ) {
2779+ if (int const flag = atoms[0 ].getFloat (); flag % 2 == 0 ) {
27912780 locked = true ;
27922781 } else {
27932782 locked = false ;
@@ -2812,6 +2801,7 @@ void Canvas::receiveMessage(t_symbol* symbol, SmallArray<pd::Atom> const& atoms)
28122801 synchroniseSplitCanvas ();
28132802 break ;
28142803 }
2804+ default : break ;
28152805 }
28162806}
28172807
0 commit comments