Skip to content

Commit 290205a

Browse files
committed
More code cleanup
1 parent 2787433 commit 290205a

38 files changed

+517
-498
lines changed

Source/Canvas.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ void Canvas::renderAllConnections(NVGcontext* nvg, Rectangle<int> const area)
866866
}
867867

868868
if (connectionsToDraw.not_empty()) {
869-
for (auto* connection : connectionsToDraw) {
869+
for (auto const* connection : connectionsToDraw) {
870870
NVGScopedState scopedState(nvg);
871871
connection->renderConnectionOrder(nvg);
872872
}

Source/CanvasViewport.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class Minimap final : public Component
128128
nvgFillColor(nvg, NVGComponent::convertColour(mapBackground.withAlpha(0.8f)));
129129

130130
// draw objects
131-
for (auto* object : cnv->objects) {
131+
for (auto const* object : cnv->objects) {
132132
auto b = (object->getBounds().reduced(Object::margin).translated(map.offsetX, map.offsetY) - cnv->canvasOrigin).toFloat() * map.scale;
133133
nvgFillRoundedRect(nvg, x + b.getX(), y + b.getY(), b.getWidth(), b.getHeight(), Corners::objectCornerRadius * map.scale);
134134
}
@@ -488,7 +488,7 @@ class CanvasViewport final : public Viewport
488488
addAndMakeVisible(vbar);
489489
addAndMakeVisible(hbar);
490490

491-
setCachedComponentImage(new NVGSurface::InvalidationListener(editor->nvgSurface, this, [this] {
491+
setCachedComponentImage(new NVGSurface::InvalidationListener(editor->nvgSurface, this, [this]{
492492
return editor->getTabComponent().getVisibleCanvases().contains(this->cnv);
493493
}));
494494

@@ -547,8 +547,7 @@ class CanvasViewport final : public Viewport
547547
lerpAnimation += animationSpeed;
548548
break;
549549
}
550-
default:
551-
break;
550+
default: break;
552551
}
553552
}
554553

@@ -686,7 +685,7 @@ class CanvasViewport final : public Viewport
686685
{
687686
if (editor->isInPluginMode())
688687
return;
689-
688+
690689
Viewport::componentMovedOrResized(c, moved, resized);
691690
adjustScrollbarBounds();
692691
}
@@ -701,7 +700,7 @@ class CanvasViewport final : public Viewport
701700
onScroll();
702701
adjustScrollbarBounds();
703702
minimap.updateMinimap(r);
704-
703+
705704
cnv->getParentComponent()->setSize(getWidth(), getHeight());
706705
}
707706

@@ -739,10 +738,10 @@ class CanvasViewport final : public Viewport
739738

740739
auto const offset = currentCentre - newCentre;
741740
setViewPosition(getViewPosition() + offset);
742-
741+
743742
// This fixes some graphical glitches on macOS, but causes terrible glitches anywhere else
744743
#if JUCE_MAC
745-
if (!scaleChanged) {
744+
if(!scaleChanged) {
746745
editor->nvgSurface.renderAll();
747746
}
748747
#endif
@@ -774,5 +773,5 @@ class CanvasViewport final : public Viewport
774773
MousePanner panner = MousePanner(this);
775774
ViewportScrollBar vbar = ViewportScrollBar(true, this);
776775
ViewportScrollBar hbar = ViewportScrollBar(false, this);
777-
bool scaleChanged : 1 = false;
776+
bool scaleChanged:1 = false;
778777
};

Source/Components/ColourPicker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ class ColourPicker final : public Component {
375375
}
376376
}
377377

378-
auto getHS()
378+
auto getHS() const
379379
{
380380
struct HS {
381381
float hue, sat;

Source/Components/MarkupDisplay.h

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ class TableBlock final : public Block {
584584
table.cells.clear();
585585
for (auto line : lines) {
586586
// find all cells in this line
587-
auto row = new OwnedArray<Cell>();
587+
auto const row = new OwnedArray<Cell>();
588588
while (line.containsAnyOf("^|")) {
589589
bool const isHeader = line.startsWith("^");
590590
line = line.substring(1); // remove left delimiter
@@ -676,7 +676,7 @@ class TableBlock final : public Block {
676676
// Override the mouse event methods to forward them to the parent Viewport
677677
void mouseDown(MouseEvent const& e) override
678678
{
679-
if (auto parent = findParentComponentOfClass<Viewport>()) {
679+
if (auto const parent = findParentComponentOfClass<Viewport>()) {
680680
MouseEvent const ep = MouseEvent(e.source, e.position, e.mods, e.pressure, e.orientation, e.rotation, e.tiltX, e.tiltY, parent, e.originalComponent, e.eventTime, e.mouseDownPosition, e.mouseDownTime, e.getNumberOfClicks(), e.mouseWasDraggedSinceMouseDown());
681681
parent->mouseDown(ep);
682682
}
@@ -1126,18 +1126,18 @@ class MarkupDisplayComponent final : public Component {
11261126
b->parseMarkup(clines, font);
11271127
content.addAndMakeVisible(b);
11281128
blocks.add(b);
1129-
} else if (ListItem::isListItem(line)) { // if we find a list item...
1130-
auto* b = new ListItem(urlHandler); // ...create a new object...
1131-
b->setColours(&colours); // ...set its colour palette...
1132-
if (Block::containsLink(line)) { // ...and, if there's a link...
1133-
line = b->consumeLink(line); // ...preprocess line...
1129+
} else if (ListItem::isListItem(line)) { // if we find a list item...
1130+
auto* b = new ListItem(urlHandler); // ...create a new object...
1131+
b->setColours(&colours); // ...set its colour palette...
1132+
if (Block::containsLink(line)) { // ...and, if there's a link...
1133+
line = b->consumeLink(line); // ...preprocess line...
11341134
}
11351135
b->parseItemMarkup(line, font, indentPerSpace, labelGap); // ...parse it...
11361136
content.addAndMakeVisible(b); // ...add the object to content component...
11371137
blocks.add(b); // ...and the block list...
11381138
li++; // ...and go to next line.
11391139
} else if (AdmonitionBlock::isAdmonitionLine(line)) { // if we find an admonition...
1140-
auto* b = new AdmonitionBlock(urlHandler); // ...create a new object...
1140+
auto* b = new AdmonitionBlock(urlHandler); // ...create a new object...
11411141
b->setColours(&colours); // ...set its colour palette...
11421142
if (Block::containsLink(line)) { // ...and, if there's a link...
11431143
line = b->consumeLink(line); // ...preprocess line...
@@ -1147,7 +1147,7 @@ class MarkupDisplayComponent final : public Component {
11471147
blocks.add(b); // ...and the block list...
11481148
li++; // ...and go to next line.
11491149
} else if (ImageBlock::isImageLine(line)) { // if we find an image...
1150-
auto* b = new ImageBlock(urlHandler); // ...create a new object...
1150+
auto* b = new ImageBlock(urlHandler); // ...create a new object...
11511151
if (Block::containsLink(line)) { // ...and, if there's a link...
11521152
line = b->consumeLink(line); // ...preprocess line...
11531153
}
@@ -1156,7 +1156,7 @@ class MarkupDisplayComponent final : public Component {
11561156
blocks.add(b); // ...and the block list...
11571157
li++; // ...and go to next line.
11581158
} else if (ImageBlock::isHTMLImageLine(line)) { // if we find an image...
1159-
auto* b = new ImageBlock(urlHandler); // ...create a new object...
1159+
auto* b = new ImageBlock(urlHandler); // ...create a new object...
11601160
if (Block::containsLink(line)) { // ...and, if there's a link...
11611161
line = b->consumeLink(line); // ...preprocess line...
11621162
}
@@ -1165,7 +1165,7 @@ class MarkupDisplayComponent final : public Component {
11651165
blocks.add(b); // ...and the block list...
11661166
li++; // ...and go to next line.
11671167
} else if (TableBlock::isTableLine(line)) { // if we find a table...
1168-
auto* b = new TableBlock(urlHandler); // ...create a new object...
1168+
auto* b = new TableBlock(urlHandler); // ...create a new object...
11691169
b->setColours(&colours); // ...set its colour palette...
11701170
b->setBGColours(tableBG, tableBGHeader); // ...its background colours...
11711171
b->setMargins(tableMargin, tableGap, margin); // ...and its margins.
@@ -1174,19 +1174,19 @@ class MarkupDisplayComponent final : public Component {
11741174
tlines.add(line); // ...add it to table lines...
11751175
line = lines[++li]; // ...and read next line.
11761176
}
1177-
b->parseMarkup(tlines, font); // ...parse the collected lines...
1178-
content.addAndMakeVisible(b); // ...add the object to content component...
1179-
blocks.add(b); // ...and the block list.
1180-
} else if (Block::containsLink(line)) { // ...if we got here and there's a link...
1177+
b->parseMarkup(tlines, font); // ...parse the collected lines...
1178+
content.addAndMakeVisible(b); // ...add the object to content component...
1179+
blocks.add(b); // ...and the block list.
1180+
} else if (Block::containsLink(line)) { // ...if we got here and there's a link...
11811181
auto* b = new TextBlock(urlHandler); // ...set up a new text block object...
1182-
b->setColours(&colours); // ...set its colours...
1183-
line = b->consumeLink(line); // ...preprocess line...
1184-
b->parseMarkup(line, font); // ...parse markup...
1185-
content.addAndMakeVisible(b); // ...add the object to content component...
1186-
blocks.add(b); // ...and the block list...
1187-
li++; // ...and go to next line.
1188-
} else { // otherwise we assume that we have a text block
1189-
StringArray blines; // set up text block lines
1182+
b->setColours(&colours); // ...set its colours...
1183+
line = b->consumeLink(line); // ...preprocess line...
1184+
b->parseMarkup(line, font); // ...parse markup...
1185+
content.addAndMakeVisible(b); // ...add the object to content component...
1186+
blocks.add(b); // ...and the block list...
1187+
li++; // ...and go to next line.
1188+
} else { // otherwise we assume that we have a text block
1189+
StringArray blines; // set up text block lines
11901190
bool blockEnd = false;
11911191
while (!ListItem::isListItem(line) && // while line is not part of a list...
11921192
!TableBlock::isTableLine(line) && // ...nor a table...
@@ -1200,10 +1200,10 @@ class MarkupDisplayComponent final : public Component {
12001200
blockEnd &= line.isNotEmpty(); // ...and finish shouldEndBloc...
12011201
}
12021202
auto* b = new TextBlock(urlHandler); // set up a new text block object...
1203-
b->setColours(&colours); // ...set its colours...
1204-
b->parseMarkup(blines, font); // ...parse markup...
1205-
content.addAndMakeVisible(b); // ...add the object to content component...
1206-
blocks.add(b); // ...and the block list.
1203+
b->setColours(&colours); // ...set its colours...
1204+
b->parseMarkup(blines, font); // ...parse markup...
1205+
content.addAndMakeVisible(b); // ...add the object to content component...
1206+
blocks.add(b); // ...and the block list.
12071207
}
12081208
}
12091209

0 commit comments

Comments
 (0)